From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6198A303C87; Fri, 9 Jan 2026 12:23:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767961409; cv=none; b=XH5FlNuPueBrio/FxS8cvtZ2AbUKEjxy5q5N69dy9w0D5sK1RgmKzyO2UN73VR/FVOyIHSos1+jhAmQOXe51qXkqy/VpK2dSj2tICkAIXmQAXcVms6Ej+gOtfaU/ABc/fcl69u+RoC6lhH6/lvBf4qUnSz4kWLWUWvmOMuj/WqM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767961409; c=relaxed/simple; bh=nHEEOiOal034vzwrP0Xwgau0Fns2xUojiJjLRavDIlU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eskNhQ/g/xIE9/ClNaxrV1InnirFWsfZYW5QDWoXvKrZM2C08XGBCiewAg/8bKvIKVWSlc4QFWf31TMvK9jGsmk4Cik0MlXAvVIyl2eXffr4xtGb7r21zwoZ1XQWC/0ISPQmiRi4wy6OL/fPllG+EnPQPbGapFOgarToTKJ1obQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QahODZqp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QahODZqp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9181C4CEF1; Fri, 9 Jan 2026 12:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767961409; bh=nHEEOiOal034vzwrP0Xwgau0Fns2xUojiJjLRavDIlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QahODZqpgTKQ3+6Ngv6c/XPEyYRWWrGAzCmV+z1TNRefoDyt5CYdcN51Wq+ANrn9H o26fC8yf3maofKsibXB+QSzzE2N0vc95fCAbUrMgF36wqCEbIUJO4Sx9LweCc9NGk5 fEtoyt7h7IkQQ/opJakSQ98LQNqutWXoMA6prYNU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jakub Kicinski , Sebastian Andrzej Siewior , Paolo Abeni , Wen Yang Subject: [PATCH 6.6 712/737] net: Remove conditional threaded-NAPI wakeup based on task state. Date: Fri, 9 Jan 2026 12:44:11 +0100 Message-ID: <20260109112200.859495184@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109112133.973195406@linuxfoundation.org> References: <20260109112133.973195406@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sebastian Andrzej Siewior commit 56364c910691f6d10ba88c964c9041b9ab777bd6 upstream. A NAPI thread is scheduled by first setting NAPI_STATE_SCHED bit. If successful (the bit was not yet set) then the NAPI_STATE_SCHED_THREADED is set but only if thread's state is not TASK_INTERRUPTIBLE (is TASK_RUNNING) followed by task wakeup. If the task is idle (TASK_INTERRUPTIBLE) then the NAPI_STATE_SCHED_THREADED bit is not set. The thread is no relying on the bit but always leaving the wait-loop after returning from schedule() because there must have been a wakeup. The smpboot-threads implementation for per-CPU threads requires an explicit condition and does not support "if we get out of schedule() then there must be something to do". Removing this optimisation simplifies the following integration. Set NAPI_STATE_SCHED_THREADED unconditionally on wakeup and rely on it in the wait path by removing the `woken' condition. Acked-by: Jakub Kicinski Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Paolo Abeni Signed-off-by: Wen Yang Signed-off-by: Greg Kroah-Hartman --- net/core/dev.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4526,13 +4526,7 @@ static inline void ____napi_schedule(str */ thread = READ_ONCE(napi->thread); if (thread) { - /* Avoid doing set_bit() if the thread is in - * INTERRUPTIBLE state, cause napi_thread_wait() - * makes sure to proceed with napi polling - * if the thread is explicitly woken from here. - */ - if (READ_ONCE(thread->__state) != TASK_INTERRUPTIBLE) - set_bit(NAPI_STATE_SCHED_THREADED, &napi->state); + set_bit(NAPI_STATE_SCHED_THREADED, &napi->state); wake_up_process(thread); return; } @@ -6688,8 +6682,6 @@ static int napi_poll(struct napi_struct static int napi_thread_wait(struct napi_struct *napi) { - bool woken = false; - set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop()) { @@ -6698,15 +6690,13 @@ static int napi_thread_wait(struct napi_ * Testing SCHED bit is not enough because SCHED bit might be * set by some other busy poll thread or by napi_disable(). */ - if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state) || woken) { + if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state)) { WARN_ON(!list_empty(&napi->poll_list)); __set_current_state(TASK_RUNNING); return 0; } schedule(); - /* woken being true indicates this thread owns this napi. */ - woken = true; set_current_state(TASK_INTERRUPTIBLE); } __set_current_state(TASK_RUNNING);