Re: [PATCH] kthread/smpboot: Serialize kthread parking against wakeup

2018-04-24 Thread Kohli, Gaurav
On 4/24/2018 11:56 PM, Peter Zijlstra wrote: On Tue, Apr 24, 2018 at 02:58:25PM +0530, Gaurav Kohli wrote: The control cpu thread which initiates hotplug calls kthread_park() for hotplug thread and sets KTHREAD_SHOULD_PARK. After this control thread wakes up the hotplug thread. There is a

Re: [PATCH] kthread/smpboot: Serialize kthread parking against wakeup

2018-04-24 Thread Kohli, Gaurav
On 4/24/2018 11:56 PM, Peter Zijlstra wrote: On Tue, Apr 24, 2018 at 02:58:25PM +0530, Gaurav Kohli wrote: The control cpu thread which initiates hotplug calls kthread_park() for hotplug thread and sets KTHREAD_SHOULD_PARK. After this control thread wakes up the hotplug thread. There is a

Re: [PATCH] kthread/smpboot: Serialize kthread parking against wakeup

2018-04-24 Thread Peter Zijlstra
On Tue, Apr 24, 2018 at 02:58:25PM +0530, Gaurav Kohli wrote: > The control cpu thread which initiates hotplug calls kthread_park() > for hotplug thread and sets KTHREAD_SHOULD_PARK. After this control > thread wakes up the hotplug thread. There is a chance that wakeup > code sees the hotplug

Re: [PATCH] kthread/smpboot: Serialize kthread parking against wakeup

2018-04-24 Thread Peter Zijlstra
On Tue, Apr 24, 2018 at 02:58:25PM +0530, Gaurav Kohli wrote: > The control cpu thread which initiates hotplug calls kthread_park() > for hotplug thread and sets KTHREAD_SHOULD_PARK. After this control > thread wakes up the hotplug thread. There is a chance that wakeup > code sees the hotplug

Re: [PATCH] kthread/smpboot: Serialize kthread parking against wakeup

2018-04-24 Thread Peter Zijlstra
On Tue, Apr 24, 2018 at 08:12:49PM +0530, Kohli, Gaurav wrote: > @@ -157,6 +156,7 @@ static int smpboot_thread_fn(void *data) > >     if (!ht->thread_should_run(td->cpu)) { > >     preempt_enable_no_resched(); > > +  

Re: [PATCH] kthread/smpboot: Serialize kthread parking against wakeup

2018-04-24 Thread Peter Zijlstra
On Tue, Apr 24, 2018 at 08:12:49PM +0530, Kohli, Gaurav wrote: > @@ -157,6 +156,7 @@ static int smpboot_thread_fn(void *data) > >     if (!ht->thread_should_run(td->cpu)) { > >     preempt_enable_no_resched(); > > +  

Re: [PATCH] kthread/smpboot: Serialize kthread parking against wakeup

2018-04-24 Thread Kohli, Gaurav
Hi , We can also fix below race by smpboot code as well: @@ -109,7 +109,6 @@ static int smpboot_thread_fn(void *data)     struct smp_hotplug_thread *ht = td->ht;     while (1) { -   set_current_state(TASK_INTERRUPTIBLE);     preempt_disable();    

Re: [PATCH] kthread/smpboot: Serialize kthread parking against wakeup

2018-04-24 Thread Kohli, Gaurav
Hi , We can also fix below race by smpboot code as well: @@ -109,7 +109,6 @@ static int smpboot_thread_fn(void *data)     struct smp_hotplug_thread *ht = td->ht;     while (1) { -   set_current_state(TASK_INTERRUPTIBLE);     preempt_disable();    

[PATCH] kthread/smpboot: Serialize kthread parking against wakeup

2018-04-24 Thread Gaurav Kohli
The control cpu thread which initiates hotplug calls kthread_park() for hotplug thread and sets KTHREAD_SHOULD_PARK. After this control thread wakes up the hotplug thread. There is a chance that wakeup code sees the hotplug thread (running on AP core) in INTERRUPTIBLE state, but sets its state to

[PATCH] kthread/smpboot: Serialize kthread parking against wakeup

2018-04-24 Thread Gaurav Kohli
The control cpu thread which initiates hotplug calls kthread_park() for hotplug thread and sets KTHREAD_SHOULD_PARK. After this control thread wakes up the hotplug thread. There is a chance that wakeup code sees the hotplug thread (running on AP core) in INTERRUPTIBLE state, but sets its state to