mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jinjie Ruan <ruanjinjie@huawei.com>
To: Reinette Chatre <reinette.chatre@intel.com>,
	<tony.luck@intel.com>, <Dave.Martin@arm.com>,
	<james.morse@arm.com>, <babu.moger@amd.com>, <bp@alien8.de>,
	<tan.shaopeng@fujitsu.com>, <x86@kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs
Date: Sat, 31 Oct 2026 11:20:22 +0800	[thread overview]
Message-ID: <3374b30b-eb3b-4794-949f-313ef32a5ce2@huawei.com> (raw)
In-Reply-To: <5c2c561e-b970-4ca0-a66d-b1043608d847@intel.com>



在 2026/10/31 2:15, Reinette Chatre 写道:
> Hi Jinjie,
> 
> On 10/30/26 2:21 AM, Jinjie Ruan wrote:
>> Busy RMIDs of a monitor domain are normally released by the limbo
>> handler once their cache occupancy drops below the threshold. When a
>> domain goes offline, its busy RMIDs are released without checking
>> occupancy, since the domain is going away and the RMIDs must not be
>> left behind.
> 
> nit: "left behind" is vague. How about changing "RMIDs must not be
> left behind" to "RMIDs would otherwise never return to the free list."

That indeed sounds more clear.

> 
>>
>> On the monitor domain offline path, __check_limbo() allocates
>> the monitor context that an occupancy check needs before it scans
>> the busy RMIDs, but without using it, and returns early when that
>> allocation fails. Then the caller destroys the domain's monitoring state,
>> including the bitmap that records which RMIDs are busy, so nothing can
>> clear those bits afterwards and the busy counts never reach zero. Those
>> RMIDs never return to the free list and, where the RMID depends on
>> the CLOSID, the dirty count of their CLOSID never decreases. The allocation
>> can also wait for a monitor to become free, which stalls the CPU offline
>> path on a context that is not going to be used.
>>
>> Only MPAM systems are affected. An architecture that can always read an
>> RMID allocates nothing for the monitor context, so the allocation can
>> neither fail nor wait there.
>>
>> So move the release of busy RMIDs into a separate function that does
> 
> nit: Please drop "So" to stick with imperative. Just start with "Move the release ..."

Thank you! Will drop it.

> 
>> not take a monitor context and leave the occupancy check to
>> __check_limbo().
>>
>> This is not a revert of the fixed commit. It preserves the original fix's
>> intent of not reading a counter in the offline path.
> 
> More on this below but after reconsidering the fallout I think above paragraph
> needs to be dropped.
> 
> For entire changelog, could you please adjust the line wraps after edit to not
> jump around as much?
> 
>>
>> Fixes: fc16126cc11d ("x86,fs/resctrl: Prevent out-of-bounds access while offlining CPU when SNC enabled")
> 
> Taking a closer look, the issue as described is present before fc16126cc11d. 
> At fc16126cc11d^, __check_limbo() already returns early on allocation failure,

Indeed it is.

> and the force-release caller already falls through to domain_destroy_l3_mon_state(d),
> so the RMIDs leak there too. 

I agree.

> 
> The issue seems to originate from feature that added the allocation and early
> release, which is:
> e557999f80a5 ("x86/resctrl: Allow arch to allocate memory needed in resctrl_arch_rmid_read()")
> 
> Even so, as with patch #1, since the impact is only on MPAM this need not
> be backported as far. I thus think the tags should be:
> 	Fixes: e557999f80a5 ("x86/resctrl: Allow arch to allocate memory needed in resctrl_arch_rmid_read()")

Yes, I also find this patch add alloc code.

> and
> 	Cc: <stable@vger.kernel.org> # 7.1.x
> 
> This fix does depend on fc16126cc11d to apply cleanly but fortunately it has been
> backported to 7.1.

Since commit 4aab135bda16 ("arm64: mpam: Select ARCH_HAS_CPU_RESCTR")
arm64 can use resctrl fs, which is v7.1-rc1.

> 
>> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
>> Cc: James Morse <james.morse@arm.com>
>> Cc: Reinette Chatre <reinette.chatre@intel.com>
>> Cc: <stable@vger.kernel.org>
>> ---
> 
> ...
> 
>>  /*
>>   * Check the RMIDs that are marked as busy for this domain. If the
>>   * reported LLC occupancy is below the threshold clear the busy bit and
>>   * decrement the count. If the busy count gets to zero on an RMID, we
>>   * free the RMID
>>   */
>> -void __check_limbo(struct rdt_l3_mon_domain *d, bool force_free)
>> +static void __check_limbo(struct rdt_l3_mon_domain *d)
>>  {
>>  	struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
>>  	u32 idx_limit = resctrl_arch_system_num_rmid_idx();
>>  	struct rmid_entry *entry;
>> -	bool rmid_dirty = true;
>> +	bool rmid_dirty;
>>  	u32 idx, cur_idx = 1;
>>  	void *arch_mon_ctx;
>>  	void *arch_priv;
> 
> Another difference between MPAM and tip style is that tip prefers variable
> declarations to be in reverse fir order. For reference, see "Variable declarations" in 
> Documentation/process/maintainer-tip.rst.

I also prefer the reverse Christmas tree style for local variable
declarations, and it seems other modules have similar requirements.

> 
> Please re-order the declarations to maintain reverse fir.
> 
> Everything else looks good.
> 
> Thank you very much.
> 
> Reinette

-- 
Best regards,
Jinjie


      reply	other threads:[~2026-10-31  3:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30  9:21 [PATCH v2 0/2] fs/resctrl: Fix RMID limbo handling Jinjie Ruan
2026-10-30  9:21 ` [PATCH] fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs Jinjie Ruan
2026-10-30  9:23   ` Jinjie Ruan
2026-10-30  9:21 ` [PATCH v2 1/2] fs/resctrl: Report a temporary RMID shortage per CLOSID Jinjie Ruan
2026-10-30 18:14   ` Reinette Chatre
2026-10-30  9:21 ` [PATCH v2 2/2] fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs Jinjie Ruan
2026-10-30 18:15   ` Reinette Chatre
2026-10-31  3:20     ` Jinjie Ruan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3374b30b-eb3b-4794-949f-313ef32a5ce2@huawei.com \
    --to=ruanjinjie@huawei.com \
    --cc=Dave.Martin@arm.com \
    --cc=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reinette.chatre@intel.com \
    --cc=tan.shaopeng@fujitsu.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®