mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Horgan <ben.horgan@arm.com>
To: Jinjie Ruan <ruanjinjie@huawei.com>,
	james.morse@arm.com, reinette.chatre@intel.com,
	fenghuay@nvidia.com, jic23@kernel.org,
	tan.shaopeng@jp.fujitsu.com, zengheng4@huawei.com,
	gshan@redhat.com, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm_mpam: resctrl: Annotate domain list walks as RCU under cpus lock
Date: Mon, 16 Nov 2026 12:12:50 +0000	[thread overview]
Message-ID: <f89e485b-33b0-465a-984f-fdddd60a35d4@arm.com> (raw)
In-Reply-To: <20261116024834.275512-1-ruanjinjie@huawei.com>

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;
>  	}


      reply	other threads:[~2026-11-16 12:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  2:48 Jinjie Ruan
2026-11-16 12:12 ` Ben Horgan [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=f89e485b-33b0-465a-984f-fdddd60a35d4@arm.com \
    --to=ben.horgan@arm.com \
    --cc=fenghuay@nvidia.com \
    --cc=gshan@redhat.com \
    --cc=james.morse@arm.com \
    --cc=jic23@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reinette.chatre@intel.com \
    --cc=ruanjinjie@huawei.com \
    --cc=tan.shaopeng@jp.fujitsu.com \
    --cc=zengheng4@huawei.com \
    /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®