From: Waiman Long <llong@redhat.com>
To: Pingfan Liu <piliu@redhat.com>, Waiman Long <llong@redhat.com>
Cc: Juri Lelli <juri.lelli@redhat.com>,
linux-kernel@vger.kernel.org,
Chen Ridong <chenridong@huaweicloud.com>,
Peter Zijlstra <peterz@infradead.org>,
Pierre Gondois <pierre.gondois@arm.com>,
Ingo Molnar <mingo@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
Tejun Heo <tj@kernel.org>, Johannes Weiner <hannes@cmpxchg.org>,
mkoutny@suse.com
Subject: Re: [PATCHv7 2/2] sched/deadline: Walk up cpuset hierarchy to decide root domain when hot-unplug
Date: Sun, 23 Nov 2025 23:24:55 -0500 [thread overview]
Message-ID: <54ccf6b4-8ad1-4954-84ba-6d1bf7b5bd65@redhat.com> (raw)
In-Reply-To: <CAF+s44QRGy77LYLGO+DK0x6ytCqaXD8XvE==ZHLJ-5XHteibKg@mail.gmail.com>
On 11/23/25 10:56 PM, Pingfan Liu wrote:
> On Mon, Nov 24, 2025 at 10:24 AM Waiman Long <llong@redhat.com> wrote:
> [...]
>>> Currently, all cpuset locks are encapsulated in
>>> kernel/cgroup/cpuset-internal.h. I'm not sure if it's appropriate to
>>> expose them. If exposing them is acceptable,
>>> cpuset_callback_lock_irq()/cpuset_callback_unlock_irq() would be
>>> preferable to cpuset_mutex assertion.
>>>
>>> @Waiman, @Ridong, could you kindly share your opinion?
>> The cpuset_cpus_allowed_locked() already has a
>> "lockdep_assert_held(&cpuset_mutex)" call to make sure that
>> cpuset_mutex is held, or a warning will be printed by the debug kernel.
>> So a check is there, it is just not in the deadline.c code. The
>> dl_add_task_root_domain() is called indirectly from
>> dl_rebuild_rd_accounting() in cpuset.c which does have an assertion on
>> cpuset_mutex.
>>
>> There is an external visible cpuset_lock/unlock() to acquire and release
>> the cpuset_mutex. However, there is no public API to assert that
>> cpuset_mutex is held. There is another set of patch series that is going
>> to add that in the near future. At this point, I don't think we need to
>> have such an API yet. I will suggest adding comment
>> to cpuset_cpus_allowed_locked() that it will warn if cpuset_mutex isn't
>> held.
>>
>> Providing a cpuset_callback_{lock|unlock}_irq() helpers may not be
>> helpful because we are back to the problem that callback_lock isn't a
>> raw_spinlock_t.
>>
> I meant to put them outside the pi_lock, so it can reflect the
> original purpose of this section -- cpuset read access instead of
> write. But yes, I agree that at this point, there is no need to
> introduce a public API.
By putting it outside of the pi_lock, you may as well just call
cpuset_cpus_allowed().
Cheers,
Longman
>>>>> void dl_add_task_root_domain(struct task_struct *p)
>>>>> {
> [...]
>
>>>>> + /*
>>>>> + * Get an active rq, whose rq->rd traces the correct root
>>>>> + * domain.
>>>>> + * Ideally this would be under cpuset reader lock until rq->rd is
>>>>> + * fetched. However, sleepable locks cannot nest inside pi_lock, so we
>>>>> + * rely on the caller of dl_add_task_root_domain() holds 'cpuset_mutex'
>>>>> + * to guarantee the CPU stays in the cpuset.
>>>>> + */
>>>>> + dl_get_task_effective_cpus(p, msk);
>>>>> + cpu = cpumask_first_and(cpu_active_mask, msk);
>>>>> + BUG_ON(cpu >= nr_cpu_ids);
>>>>> + rq = cpu_rq(cpu);
>>>>> dl_b = &rq->rd->dl_bw;
>>>>> - raw_spin_lock(&dl_b->lock);
>>>>> + /* End of fetching rd */
>>>> Not sure we need this comment above. :)
>>>>
>>> OK, I can remove them to keep the code neat.
> @Juri, sorry - I need to send out a fix that should be simple and
> focused: just the fix itself, without removing the comments. So I have
> not removed them. Anyway, they can remind us this is an atomic cpuset
> read context.
>
>
> Best Regards,
>
> Pingfan
>
next prev parent reply other threads:[~2025-11-24 4:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 9:55 [PATCHv7 0/2] " Pingfan Liu
2025-11-19 9:55 ` [PATCHv7 1/2] cgroup/cpuset: Introduce cpuset_cpus_allowed_locked() Pingfan Liu
2025-11-19 20:51 ` Waiman Long
2025-11-20 1:12 ` Chen Ridong
2025-11-19 9:55 ` [PATCHv7 2/2] sched/deadline: Walk up cpuset hierarchy to decide root domain when hot-unplug Pingfan Liu
2025-11-21 13:05 ` Juri Lelli
2025-11-24 1:45 ` Pingfan Liu
2025-11-24 2:24 ` Waiman Long
2025-11-24 3:56 ` Pingfan Liu
2025-11-24 4:24 ` Waiman Long [this message]
2025-11-25 3:26 ` [PATCHv2 0/2] sched/deadline: Fix potential race in dl_add_task_root_domain() Pingfan Liu
2025-11-25 3:26 ` [PATCHv2 1/2] sched/deadline: Remove unnecessary comment " Pingfan Liu
2026-01-13 10:43 ` [tip: sched/urgent] " tip-bot2 for Pingfan Liu
2025-11-25 3:26 ` [PATCHv2 2/2] sched/deadline: Fix potential race " Pingfan Liu
2026-01-13 10:43 ` [tip: sched/urgent] " tip-bot2 for Pingfan Liu
2025-11-25 8:14 ` [PATCHv2 0/2] " Juri Lelli
2026-01-07 19:57 ` Waiman Long
2026-01-08 11:42 ` Peter Zijlstra
2026-01-08 12:02 ` Pingfan Liu
2025-11-25 14:53 ` Waiman Long
2025-11-20 17:00 ` [PATCHv7 0/2] sched/deadline: Walk up cpuset hierarchy to decide root domain when hot-unplug 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=54ccf6b4-8ad1-4954-84ba-6d1bf7b5bd65@redhat.com \
--to=llong@redhat.com \
--cc=bsegall@google.com \
--cc=chenridong@huaweicloud.com \
--cc=dietmar.eggemann@arm.com \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=peterz@infradead.org \
--cc=pierre.gondois@arm.com \
--cc=piliu@redhat.com \
--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®