[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <00ec3c8e-6462-5cc4-ab79-e8887bcedad8@grsecurity.net>
Date: Fri, 5 Nov 2021 18:40:11 +0100
From: Mathias Krause <minipli@...ecurity.net>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Vincent Guittot <vincent.guittot@...aro.org>,
Michal Koutný <mkoutny@...e.com>,
Benjamin Segall <bsegall@...gle.com>,
Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Valentin Schneider <Valentin.Schneider@....com>,
linux-kernel@...r.kernel.org, Odin Ugedal <odin@...d.al>,
Kevin Tanguy <kevin.tanguy@...p.ovh.com>,
Brad Spengler <spender@...ecurity.net>
Subject: Re: [PATCH] sched/fair: Prevent dead task groups from regaining
cfs_rq's
Am 05.11.21 um 18:27 schrieb Peter Zijlstra:
> On Fri, Nov 05, 2021 at 06:14:33PM +0100, Mathias Krause wrote:
>> Am 05.11.21 um 17:58 schrieb Peter Zijlstra:
>>> On Fri, Nov 05, 2021 at 05:29:14PM +0100, Mathias Krause wrote:
>>>>> Looks like it needs to be the kfree_rcu() one in this case. I'll prepare
>>>>> a patch.
>>>>
>>>> Testing the below patch right now. Looking good so far. Will prepare a
>>>> proper patch later, if we all can agree that this covers all cases.
>>>>
>>>> But the basic idea is to defer the kfree()'s to after the next RCU GP,
>>>> which also means we need to free the tg object itself later. Slightly
>>>> ugly. :/
>>>
>>> Can't we add an rcu_head to struct task_group and simply call_rcu() the
>>> thing with a free function?
>>
>> There is already one and this patch makes use of it for the second RCU
>> GP requirement. Basically, the patch is doing what you request, no? See
>> the new free_fair_sched_group().
>
> For some reason I thought you still did kfree_rcu(), I suppose reading
> is hard. I'll give it another go after dinner.
I wanted to go for kfree_rcu() initially, true. But after realizing,
that adding a rcu_head to struct cfs_rg, sched_entity and task_group
(which already has one) might be too much for what's needed, I went the
call_rcu() route instead and re-used the rcu_head of task_group.
Actually re-using the rcu_head in task_group is safe, as we'll use it
only sequentially: first in sched_destroy_group() to schedule
sched_free_group_rcu() and then, when it's executing, in
free_fair_sched_group() to schedule free_tg().
rcu_head's get unlinked prior to getting their callback function
invoked, which makes the above a valid use case.
Thanks,
Mathias
Powered by blists - more mailing lists