Re: [PATCH net v2] net: fix race between napi kthread mode and busy poll

2021-02-28 Thread Jakub Kicinski
On Sat, 27 Feb 2021 15:23:56 -0800 Wei Wang wrote: > > > Indeed, looks like the task will be in WAKING state until it runs? > > > We can switch the check in napi_schedule() from > > > > > > if (thread->state == TASK_RUNNING) > > > > > > to > > > > > > if (!(thread->state & TASK_

Re: [PATCH net v2] net: fix race between napi kthread mode and busy poll

2021-02-26 Thread Jakub Kicinski
On Fri, 26 Feb 2021 17:35:21 -0800 Wei Wang wrote: > On Fri, Feb 26, 2021 at 5:22 PM Jakub Kicinski wrote: > > > > On Fri, 26 Feb 2021 17:02:17 -0800 Wei Wang wrote: > > > static int napi_thread_wait(struct napi_struct *napi) > > > { > > > + bool woken = false; > > > + > > > set_

Re: [PATCH net v2] net: fix race between napi kthread mode and busy poll

2021-02-26 Thread Jakub Kicinski
On Fri, 26 Feb 2021 17:02:17 -0800 Wei Wang wrote: > static int napi_thread_wait(struct napi_struct *napi) > { > + bool woken = false; > + > set_current_state(TASK_INTERRUPTIBLE); > > while (!kthread_should_stop() && !napi_disable_pending(napi)) { > - if (test

Re: [PATCH net v2] net: fix race between napi kthread mode and busy poll

2021-02-26 Thread Jakub Kicinski
On Fri, 26 Feb 2021 16:30:47 -0800 Wei Wang wrote: > thread = READ_ONCE(napi->thread); > if (thread) { > + set_bit(NAPI_STATE_SCHED_THREADED, &napi->state); > wake_up_process(thread); What about the version which checks RUNNING?