Skip to content

Commit 5a530c8

Browse files
committed
Revert "net: Remove conditional threaded-NAPI wakeup based on task state."
This reverts commit 03765d5 which is commit 56364c9 upstream. It is only for issues around PREEMPT_RT, which is not in the 6.6.y tree, so revert this for now. Link: https://lore.kernel.org/r/20260120103833.4kssDD1Y@linutronix.de Reported-by: Jakub Kicinski <kuba@kernel.org> Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Wen Yang <wen.yang@linux.dev> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 507692c commit 5a530c8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

net/core/dev.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4539,7 +4539,13 @@ static inline void ____napi_schedule(struct softnet_data *sd,
45394539
*/
45404540
thread = READ_ONCE(napi->thread);
45414541
if (thread) {
4542-
set_bit(NAPI_STATE_SCHED_THREADED, &napi->state);
4542+
/* Avoid doing set_bit() if the thread is in
4543+
* INTERRUPTIBLE state, cause napi_thread_wait()
4544+
* makes sure to proceed with napi polling
4545+
* if the thread is explicitly woken from here.
4546+
*/
4547+
if (READ_ONCE(thread->__state) != TASK_INTERRUPTIBLE)
4548+
set_bit(NAPI_STATE_SCHED_THREADED, &napi->state);
45434549
wake_up_process(thread);
45444550
return;
45454551
}
@@ -6695,6 +6701,8 @@ static int napi_poll(struct napi_struct *n, struct list_head *repoll)
66956701

66966702
static int napi_thread_wait(struct napi_struct *napi)
66976703
{
6704+
bool woken = false;
6705+
66986706
set_current_state(TASK_INTERRUPTIBLE);
66996707

67006708
while (!kthread_should_stop()) {
@@ -6703,13 +6711,15 @@ static int napi_thread_wait(struct napi_struct *napi)
67036711
* Testing SCHED bit is not enough because SCHED bit might be
67046712
* set by some other busy poll thread or by napi_disable().
67056713
*/
6706-
if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state)) {
6714+
if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state) || woken) {
67076715
WARN_ON(!list_empty(&napi->poll_list));
67086716
__set_current_state(TASK_RUNNING);
67096717
return 0;
67106718
}
67116719

67126720
schedule();
6721+
/* woken being true indicates this thread owns this napi. */
6722+
woken = true;
67136723
set_current_state(TASK_INTERRUPTIBLE);
67146724
}
67156725
__set_current_state(TASK_RUNNING);

0 commit comments

Comments
 (0)