[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <de4bdebf-89ad-fd74-bac0-c3359994b488@gmail.com>
Date: Sun, 20 Dec 2020 14:42:10 +0000
From: Pavel Begunkov <asml.silence@...il.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Al Viro <viro@...iv.linux.org.uk>, linux-kernel@...r.kernel.org,
Jens Axboe <axboe@...nel.dk>
Subject: Re: [RFC] exit: do exit_task_work() before shooting off mm
On 20/12/2020 13:58, Oleg Nesterov wrote:
> On 12/20, Pavel Begunkov wrote:
>>
>> On 08/12/2020 01:37, Al Viro wrote:
>>> On Thu, Dec 03, 2020 at 02:30:46AM +0000, Pavel Begunkov wrote:
>>>> Handle task works and lock it earlier before it starts killing off
>>>> task's resources like mm. io_uring makes use of it a lot and it'd
>>>> nicer to have all added task_work finding tasks in a consistent state.
>
> I too do not understand this patch. task_work_add() will fail after
> exit_task_work(). This means that, for example, exit_files() will use
> schedule_delayed_work().
The first one? Between PF_EXITING and exit_task_work() do_exit() will
kill mm/etc., I wanted to not see tasks half dismantled for task_works
run in the exit_task_work(). Anyway, forget about it :)
>> One more moment, after we've set PF_EXITING any task_work_run() would be
>> equivalent to exit_task_work()
>
> Yes, currently task_work_run() can not be called after exit_signals().
> And shouldn't be called imo ;)
>
>> io_uring
>> may want (currently doesn't) to run works for cancellation purposes.t
>
> Please see https://lore.kernel.org/io-uring/20200407163816.GB9655@redhat.com/>> Shouldn't it be like below (not tested)? Also simplifies task_work_run().
>
> I'd prefer the patch from the link above, but your version looks correct too.
I missed the thread, thanks! tbh, splitting into 2 functions looks better
to me, but it's not like that matters
> However, I still think it would be better to not abuse task_work_run() too
> much...
The problem is that io_uring cancels requests in exit_files() and some
of them may be sitting in task_works, and we need to get them out of there
to complete.
Also, I need to double check, but seems new requests may be added during
and by cancellation because we did not yet set it to work_exited by the
time (in exit_files()).
--
Pavel Begunkov
Powered by blists - more mailing lists