* [PATCH] arm_mpam: resctrl: Annotate domain list walks as RCU under cpus lock
@ 2026-11-16 2:48 Jinjie Ruan
2026-11-16 12:12 ` Ben Horgan
0 siblings, 1 reply; 3+ messages in thread
From: Jinjie Ruan @ 2026-11-16 2:48 UTC (permalink / raw)
To: james.morse, ben.horgan, reinette.chatre, fenghuay, jic23,
tan.shaopeng, zengheng4, gshan, linux-arm-kernel, linux-kernel
Cc: ruanjinjie
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@vger.kernel.org
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
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;
}
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] arm_mpam: resctrl: Annotate domain list walks as RCU under cpus lock
2026-11-16 2:48 [PATCH] arm_mpam: resctrl: Annotate domain list walks as RCU under cpus lock Jinjie Ruan
@ 2026-11-16 12:12 ` Ben Horgan
2026-11-16 12:54 ` Jinjie Ruan
0 siblings, 1 reply; 3+ messages in thread
From: Ben Horgan @ 2026-11-16 12:12 UTC (permalink / raw)
To: Jinjie Ruan, james.morse, reinette.chatre, fenghuay, jic23,
tan.shaopeng, zengheng4, gshan, linux-arm-kernel, linux-kernel
Hi Jinjie,
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@vger.kernel.org
The patch looks good to me but the Fixes and stable Cc can be dropped. This is just providing extra
debug information to allow a debug feature under RCU_EXPERT to be used. The equivalent commit in
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.
Thanks,
Ben
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> 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;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] arm_mpam: resctrl: Annotate domain list walks as RCU under cpus lock
2026-11-16 12:12 ` Ben Horgan
@ 2026-11-16 12:54 ` Jinjie Ruan
0 siblings, 0 replies; 3+ messages in thread
From: Jinjie Ruan @ 2026-11-16 12:54 UTC (permalink / raw)
To: linux-kernel
在 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@vger.kernel.org
>
> 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@huawei.com>
>> ---
>> 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;
>> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-16 12:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 2:48 [PATCH] arm_mpam: resctrl: Annotate domain list walks as RCU under cpus lock Jinjie Ruan
2026-11-16 12:12 ` Ben Horgan
2026-11-16 12:54 ` Jinjie Ruan
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®