On Mon,  1 Mar 2021 17:21:13 -0800 Wei Wang wrote:
> Currently, napi_thread_wait() checks for NAPI_STATE_SCHED bit to
> determine if the kthread owns this napi and could call napi->poll() on
> it. However, if socket busy poll is enabled, it is possible that the
> busy poll thread grabs this SCHED bit (after the previous napi->poll()
> invokes napi_complete_done() and clears SCHED bit) and tries to poll
> on the same napi. napi_disable() could grab the SCHED bit as well.
> This patch tries to fix this race by adding a new bit
> NAPI_STATE_SCHED_THREADED in napi->state. This bit gets set in
> ____napi_schedule() if the threaded mode is enabled, and gets cleared
> in napi_complete_done(), and we only poll the napi in kthread if this
> bit is set. This helps distinguish the ownership of the napi between
> kthread and other scenarios and fixes the race issue.
> 
> Fixes: 29863d41bb6e ("net: implement threaded-able napi poll loop support")
> Reported-by: Martin Zaharinov <micro...@gmail.com>
> Suggested-by: Jakub Kicinski <k...@kernel.org>
> Signed-off-by: Wei Wang <wei...@google.com>
> Cc: Alexander Duyck <alexanderdu...@fb.com>
> Cc: Eric Dumazet <eduma...@google.com>
> Cc: Paolo Abeni <pab...@redhat.com>
> Cc: Hannes Frederic Sowa <han...@stressinduktion.org>

Signed-off-by: Jakub Kicinski <k...@kernel.org>

Thanks!

Reply via email to