mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <llong@redhat.com>
To: Chen Ridong <chenridong@huaweicloud.com>,
	tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com,
	mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	vschneid@redhat.com, frederic@kernel.org
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	lujialin4@huawei.com
Subject: Re: [PATCH -next] sched/isolation: Use static_branch_enable_cpuslocked() on housekeeping_update
Date: Thu, 22 Jan 2026 21:37:09 -0500	[thread overview]
Message-ID: <5a6bd6f6-7dda-4665-9308-4ae8b0d64c9f@redhat.com> (raw)
In-Reply-To: <20260122080902.2312721-1-chenridong@huaweicloud.com>

On 1/22/26 3:09 AM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> The warning is observed:
>
>   WARNING: possible recursive locking detected
>   6.19.0-rc6-next-20260121 #1046 Not tainted
>   --------------------------------------------
>   test_cpuset_prs/686 is trying to acquire lock:
>   (cpu_hotplug_lock){++++}-{0:0}, at: static_key_enable+0xd/0x20
>
>   but task is already holding lock:
>   (cpu_hotplug_lock){++++}-{0:0}, at: cpuset_partition_write+0x72/0x10
>
>   other info that might help us debug this:
>    Possible unsafe locking scenario:
>
>          CPU0
>          ----
>     lock(cpu_hotplug_lock);
>     lock(cpu_hotplug_lock);
>
>    *** DEADLOCK ***
>
>    May be due to missing lock nesting notation
>
>   stack backtrace:
>   CPU: 11 UID: 0 PID: 686 Comm: test_cpuset_prs  6.19.0-rc6-next-20260121 #1
>   Call Trace:
>    <TASK>
>    dump_stack_lvl+0x82/0xd0
>    print_deadlock_bug+0x288/0x3c0
>    __lock_acquire+0x1506/0x27f0
>    lock_acquire+0xc8/0x2d0
>    ? static_key_enable+0xd/0x20
>    cpus_read_lock+0x3b/0xd0
>    ? static_key_enable+0xd/0x20
>    static_key_enable+0xd/0x20
>    housekeeping_update+0xe7/0x1b0
>    update_prstate+0x3f2/0x580
>    cpuset_partition_write+0x98/0x100
>    kernfs_fop_write_iter+0x14e/0x200
>    vfs_write+0x367/0x510
>    ksys_write+0x66/0xe0
>    do_syscall_64+0x6b/0x390
>    entry_SYSCALL_64_after_hwframe+0x76/0x7e
>   RIP: 0033:0x7f824cf8c887
>
> The commit 7109b22e6581 ("cpuset: Update HK_TYPE_DOMAIN cpumask from
> cpuset") introduced housekeeping_update, which calls static_branch_enable
> while cpu_read_lock() is held. Since static_key_enable itself also acquires
> cpu_read_lock, this leads to a lockdep warning. To resolve this issue,
> replace the call to static_key_enable with static_branch_enable_cpuslocked.
>
> Fixes: 7109b22e6581 ("cpuset: Update HK_TYPE_DOMAIN cpumask from cpuset")
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
>   kernel/cgroup/cpuset.c   | 2 --
>   kernel/sched/isolation.c | 4 +++-
>   2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 392ce795656d..a26ccff55bb7 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1308,8 +1308,6 @@ static void update_isolation_cpumasks(void)
>   	if (!isolated_cpus_updating)
>   		return;
>   
> -	lockdep_assert_cpus_held();
> -
>   	ret = housekeeping_update(isolated_cpus);
>   	WARN_ON_ONCE(ret < 0);
>   
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index ef152d401fe2..3b725d39c06e 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -123,6 +123,8 @@ int housekeeping_update(struct cpumask *isol_mask)
>   	struct cpumask *trial, *old = NULL;
>   	int err;
>   
> +	lockdep_assert_cpus_held();
> +
>   	trial = kmalloc(cpumask_size(), GFP_KERNEL);
>   	if (!trial)
>   		return -ENOMEM;
> @@ -134,7 +136,7 @@ int housekeeping_update(struct cpumask *isol_mask)
>   	}
>   
>   	if (!housekeeping.flags)
> -		static_branch_enable(&housekeeping_overridden);
> +		static_branch_enable_cpuslocked(&housekeeping_overridden);
>   
>   	if (housekeeping.flags & HK_FLAG_DOMAIN)
>   		old = housekeeping_cpumask_dereference(HK_TYPE_DOMAIN);

Good catch.

Thanks,
Longman


      parent reply	other threads:[~2026-01-23  2:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22  8:09 Chen Ridong
2026-01-22 11:45 ` Frederic Weisbecker
2026-01-22 12:03   ` Chen Ridong
2026-01-22 16:57     ` Frederic Weisbecker
2026-01-23  0:57       ` Chen Ridong
2026-01-23  2:37 ` Waiman Long [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=5a6bd6f6-7dda-4665-9308-4ae8b0d64c9f@redhat.com \
    --to=llong@redhat.com \
    --cc=bsegall@google.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chenridong@huaweicloud.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=frederic@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lujialin4@huawei.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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®