[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a705454c-b64d-c58b-7ed1-6a3554582a6b@redhat.com>
Date: Thu, 2 Nov 2023 14:08:54 -0400
From: Waiman Long <longman@...hat.com>
To: Juri Lelli <juri.lelli@...hat.com>
Cc: Michal Koutný <mkoutny@...e.com>,
Tejun Heo <tj@...nel.org>, Zefan Li <lizefan.x@...edance.com>,
Johannes Weiner <hannes@...xchg.org>,
linux-kernel@...r.kernel.org, cgroups@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Qais Yousef <qyousef@...alina.io>, Hao Luo <haoluo@...gle.com>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Xia Fukun <xiafukun@...wei.com>
Subject: Re: [PATCH v2] cgroup/cpuset: Change nr_deadline_tasks to an atomic_t
value
On 11/2/23 09:01, Waiman Long wrote:
>
> On 11/2/23 06:26, Juri Lelli wrote:
>> Hi Waiman,
>>
>> On 01/11/23 13:59, Waiman Long wrote:
>>> On 11/1/23 12:34, Michal Koutný wrote:
>>>> On Tue, Oct 24, 2023 at 10:18:34AM -0400, Waiman Long
>>>> <longman@...hat.com> wrote:
>>>>> The nr_deadline_tasks field in cpuset structure was introduced by
>>>>> commit 6c24849f5515 ("sched/cpuset: Keep track of SCHED_DEADLINE task
>>>>> in cpusets"). Unlike nr_migrate_dl_tasks which is only modified under
>>>>> cpuset_mutex, nr_deadline_tasks can be updated under two different
>>>>> locks - cpuset_mutex in most cases or css_set_lock in
>>>>> cgroup_exit(). As
>>>>> a result, data races can happen leading to incorrect
>>>>> nr_deadline_tasks
>>>>> value.
>>>> The effect is that dl_update_tasks_root_domain() processes tasks
>>>> unnecessarily or that it incorrectly skips dl_add_task_root_domain()?
>>> The effect is that dl_update_tasks_root_domain() may return
>>> incorrectly or
>>> it is doing unnecessary work. Will update the commit log to reflect
>>> that.
>>>>> Since it is not practical to somehow take cpuset_mutex in
>>>>> cgroup_exit(),
>>>>> the easy way out to avoid this possible race condition is by making
>>>>> nr_deadline_tasks an atomic_t value.
>>>> If css_set_lock is useless for this fields and it's going to be
>>>> atomic,
>>>> could you please add (presumably) a cleanup that moves
>>>> dec_dl_tasks_cs()
>>>> from under css_set_lock in cgroup_exit() to a (new but specific)
>>>> cpuset_cgrp_subsys.exit() handler?
>>> But css_set_lock is needed for updating other css data. It is true
>>> that we
>>> can move dec_dl_tasks_cs() outside of the lock. I can do that in the
>>> next
>>> version.
>> Not sure if you had a chance to check my last question/comment on your
>> previous posting?
>>
>> https://lore.kernel.org/lkml/ZSjfBWgZf15TchA5@localhost.localdomain/
>
> Thanks for the reminder. I look at your comment again. Even though
> dl_rebuild_rd_accounting() operates on css(es) via
> css_task_iter_start() and css_task_iter_next(), the css_set_lock is
> released at the end of it. So it is still possible that a task can
> call cgroup_exit() after css_task_iter_next() and is being processed
> by dl_add_task_root_domain(). Is there a helper in the do_exit() path
> to nullify the dl_task() check. Or maybe we can also check for
> PF_EXITING in dl_add_task_root_domain() under the pi_lock and do the
> dl_task() check the under pi_lock to synchronize with
> dl_add_task_root_domain(). What do you think?
>
> I still believe that it doesn't really matter if we call
> dec_dl_tasks_cs() inside or outside the css_set_lock.
Just curious. Does the deadline code remove the deadline quota of an
exiting task?
Regards,
Longman
Powered by blists - more mailing lists