Re: [PATCH] arm_mpam: resctrl: Annotate domain list walks as RCU under cpus lock
From: Jinjie Ruan
Date: Mon Nov 16 2026 - 07:54:11 EST
在 2026/11/16 20:12, Ben Horgan 写道:
> Hi Jinjie,
Hi Ben,
>
> On 16/11/2026 02:48, Jinjie Ruan wrote:
>> The resctrl domain lists are RCU lists which are only modified while the
>> CPU hotplug write lock is held, so traversing them is protected by
>> cpus_read_lock(). That is the convention the generic resctrl code
>> follows.
>>
>> The MPAM implementation omits the condition at three places, so lockdep
>> reports a spurious violation with CONFIG_PROVE_RCU_LIST on whenever
>> they run:
>>
>> WARNING: suspicious RCU usage
>> drivers/resctrl/mpam_resctrl.c:1762 RCU-list traversed in non-reader section!!
>> mpam_resctrl_get_domain_from_cpu+0x200/0x298
>> mpam_resctrl_online_cpu+0xa4/0x160
>> mpam_cpu_online+0x2b4/0x300
>> cpuhp_invoke_callback+0x304/0x700
>>
>> Likewise for mpam_resctrl_get_mon_domain_from_cpu() and
>> resctrl_arch_update_domains().
>>
>> The lock really is held: lockdep_assert_cpus_held() is the first thing
>> each of these functions does, and the warning's own lock list shows
>> cpu_hotplug_lock and cpuhp_state-up taken. Only the annotation is
>> missing, so add lockdep_is_cpus_held() to all three walks.
>>
>> Fixes: 9cd2b522be2c ("arm_mpam: resctrl: Implement helpers to update configuration")
>> Fixes: 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")
>> Fixes: 09e61daf8e96 ("arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation")
>> Cc: stable@xxxxxxxxxxxxxxx
>
> The patch looks good to me but the Fixes and stable Cc can be dropped. This is just providing extra
Thank you for the review.
Will delete the Fixes and stable Cc and resend.
> debug information to allow a debug feature under RCU_EXPERT to be used. The equivalent commit in
That is true.
> fs/resctrl, 11b57be8e406 ("x86,fs/resctrl: Document safe RCU list traversal"), which is needed to
> make this useful was only added after MPAM support was merged and has no Fixes tag.
Yes, the fix is wrong and not nessary.
Best regards,
Jinjie
>
> Thanks,
>
> Ben
>
>> Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
>> ---
>> drivers/resctrl/mpam_resctrl.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
>> index 5468367776e2..d25c2bac9678 100644
>> --- a/drivers/resctrl/mpam_resctrl.c
>> +++ b/drivers/resctrl/mpam_resctrl.c
>> @@ -1516,7 +1516,7 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
>> if (!mpam_is_enabled())
>> return -EINVAL;
>>
>> - list_for_each_entry_rcu(d, &r->ctrl_domains, hdr.list) {
>> + list_for_each_entry_rcu(d, &r->ctrl_domains, hdr.list, lockdep_is_cpus_held()) {
>> for (enum resctrl_conf_type t = 0; t < CDP_NUM_TYPES; t++) {
>> struct resctrl_staged_config *cfg = &d->staged_config[t];
>>
>> @@ -1743,7 +1743,8 @@ static struct mpam_resctrl_dom *mpam_resctrl_get_mon_domain_from_cpu(int cpu)
>> if (cache_id < 0)
>> return NULL;
>>
>> - list_for_each_entry_rcu(dom, &l3->resctrl_res.mon_domains, resctrl_mon_dom.hdr.list) {
>> + list_for_each_entry_rcu(dom, &l3->resctrl_res.mon_domains, resctrl_mon_dom.hdr.list,
>> + lockdep_is_cpus_held()) {
>> if (dom->resctrl_mon_dom.hdr.id == cache_id)
>> return dom;
>> }
>> @@ -1759,7 +1760,8 @@ mpam_resctrl_get_domain_from_cpu(int cpu, struct mpam_resctrl_res *res)
>>
>> lockdep_assert_cpus_held();
>>
>> - list_for_each_entry_rcu(dom, &r->ctrl_domains, resctrl_ctrl_dom.hdr.list) {
>> + list_for_each_entry_rcu(dom, &r->ctrl_domains, resctrl_ctrl_dom.hdr.list,
>> + lockdep_is_cpus_held()) {
>> if (cpumask_test_cpu(cpu, &dom->ctrl_comp->affinity))
>> return dom;
>> }
>