mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Juri Lelli <juri.lelli@redhat.com>
To: Waiman Long <longman@redhat.com>
Cc: "Tejun Heo" <tj@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Ingo Molnar" <mingo@kernel.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>
Subject: Re: [PATCH 1/3] cgroup/cpuset: Use static_branch_enable_cpuslocked() on cpusets_insane_config_key
Date: Thu, 7 Aug 2025 14:15:06 +0100	[thread overview]
Message-ID: <aJSm2sG1G_mk_1P-@jlelli-thinkpadt14gen4.remote.csb> (raw)
In-Reply-To: <20250806172430.1155133-2-longman@redhat.com>

Hi,

On 06/08/25 13:24, Waiman Long wrote:
> The following lockdep splat was observed.
> 
> [  812.359086] ============================================
> [  812.359089] WARNING: possible recursive locking detected
> [  812.359097] --------------------------------------------
> [  812.359100] runtest.sh/30042 is trying to acquire lock:
> [  812.359105] ffffffffa7f27420 (cpu_hotplug_lock){++++}-{0:0}, at: static_key_enable+0xe/0x20
> [  812.359131]
> [  812.359131] but task is already holding lock:
> [  812.359134] ffffffffa7f27420 (cpu_hotplug_lock){++++}-{0:0}, at: cpuset_write_resmask+0x98/0xa70
>      :
> [  812.359267] Call Trace:
> [  812.359272]  <TASK>
> [  812.359367]  cpus_read_lock+0x3c/0xe0
> [  812.359382]  static_key_enable+0xe/0x20
> [  812.359389]  check_insane_mems_config.part.0+0x11/0x30
> [  812.359398]  cpuset_write_resmask+0x9f2/0xa70
> [  812.359411]  cgroup_file_write+0x1c7/0x660
> [  812.359467]  kernfs_fop_write_iter+0x358/0x530
> [  812.359479]  vfs_write+0xabe/0x1250
> [  812.359529]  ksys_write+0xf9/0x1d0
> [  812.359558]  do_syscall_64+0x5f/0xe0
> 
> Since commit d74b27d63a8b ("cgroup/cpuset: Change cpuset_rwsem
> and hotplug lock order"), the ordering of cpu hotplug lock
> and cpuset_mutex had been reversed. That patch correctly
> used the cpuslocked version of the static branch API to enable
> cpusets_pre_enable_key and cpusets_enabled_key, but it didn't do the
> same for cpusets_insane_config_key.
> 
> The cpusets_insane_config_key can be enabled in the
> check_insane_mems_config() which is called from update_nodemask()
> or cpuset_hotplug_update_tasks() with both cpu hotplug lock and
> cpuset_mutex held. Deadlock can happen with a pending hotplug event that
> tries to acquire the cpu hotplug write lock which will block further
> cpus_read_lock() attempt from check_insane_mems_config(). Fix that by
> switching to use static_branch_enable_cpuslocked().
> 
> Fixes: d74b27d63a8b ("cgroup/cpuset: Change cpuset_rwsem and hotplug lock order")
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---

Looks good to me. Thanks for spotting and fixing this.

Reviewed-by: Juri Lelli <juri.lelli@redhat.com>

Best,
Juri


  reply	other threads:[~2025-08-07 13:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 17:24 [PATCH 0/3] cgroup/cpuset: Miscellaneous fixes and cleanup Waiman Long
2025-08-06 17:24 ` [PATCH 1/3] cgroup/cpuset: Use static_branch_enable_cpuslocked() on cpusets_insane_config_key Waiman Long
2025-08-07 13:15   ` Juri Lelli [this message]
2025-08-07 13:47     ` Waiman Long
2025-08-06 17:24 ` [PATCH 2/3] cgroup/cpuset.c: Fix a partition error with CPU hotplug Waiman Long
2025-08-06 17:30   ` Waiman Long
2025-08-07  2:44   ` Chen Ridong
2025-08-07 13:54     ` Waiman Long
2025-08-06 17:24 ` [PATCH 3/3] cgroup/cpuset: Remove the unnecessary css_get/put() in cpuset_partition_write() Waiman Long
2025-08-07 11:25   ` Michal Koutný
2025-08-09 18:44 ` [PATCH 0/3] cgroup/cpuset: Miscellaneous fixes and cleanup Tejun Heo

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=aJSm2sG1G_mk_1P-@jlelli-thinkpadt14gen4.remote.csb \
    --to=juri.lelli@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=peterz@infradead.org \
    --cc=tj@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®