Re: [PATCH 2/2] kthread: don't use to_live_kthread() in kthread_park() and kthread_unpark()
From: Oleg Nesterov
Date: Wed Nov 09 2016 - 12:27:41 EST
On 11/09, Thomas Gleixner wrote:
>
> > - watchdog_park_threads() and it does not look nice. The code is actually
> > correct, get_online_cpus() ensures that kthread_park() can't race with
> > itself (note that kthread_park() can't handle this race correctly), but
> > imo it should not use kthread_park() directly.
>
> Should we provide an interface through the smpboot thread infrastructure for
> this?
IMHO yes, I'll write another email.
> I can see why that gpu driver wants to use the park mechanism and I guess
> there are other legitimate use cases as well. I prefer to implement a
> park/unpark variant which is safe to use on arbitrary kthreads
Yes, agreed. Again, I'll write another email. Perhaps we should even keep
park/unpark exported and change them to avoid the races with exit/itself,
I dunno.
My real point was, imo the KTHREAD_IS_PER_CPU/__kthread_bind(kthread->cpu)
logic in kthread_unpark() should be private to smpboot.c/cpu.c.
I'll send another patch tomorrow. kthread_create_worker_on_cpu() ab-uses
this logic too for no reason, but this is trivial.
> Reviewed-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Thanks!
Probably I should re-send these 2 short series to Ingo with your acks applied.
Oleg.