Re: [PATCH v3] signal: break out of wait loops on kthread_stop()

From: Eric W. Biederman
Date: Mon Jul 11 2022 - 18:04:36 EST


"Jason A. Donenfeld" <Jason@xxxxxxxxx> writes:

> Hi Eric,
>
> Thanks for the review.
>
>> Which I guess my long way of saying I think you can just change
>> kthread_stop to say:
>>
>> diff --git a/kernel/kthread.c b/kernel/kthread.c
>> index 544fd4097406..52e9b3432496 100644
>> --- a/kernel/kthread.c
>> +++ b/kernel/kthread.c
>> @@ -704,6 +704,7 @@ int kthread_stop(struct task_struct *k)
>> kthread = to_kthread(k);
>> set_bit(KTHREAD_SHOULD_STOP, &kthread->flags);
>> kthread_unpark(k);
>> + set_tsk_thread_flag(k, TIF_NOTIFY_SIGNAL);
>> wake_up_process(k);
>> wait_for_completion(&kthread->exited);
>> ret = kthread->result;
>>
>
> Okay. I'll constrain it to just kthread_stop(). But please file away in
> the back of your mind the potential for kthread_park() to be problematic
> down the line, in case we have to fix that later.

Definitely. Right now I am certain you are motivated to test and make
certain the kthread_stop case will work. I just have the feeling that
we don't care enough about kthread_park, and so attempting to solve it
now is as likely to cause problems as solve them.

Eric