From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-156.mta1.migadu.com [95.215.58.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0061526A9F for ; Tue, 13 Oct 2026 18:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.156 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791914577; cv=none; b=Ae3+lhO03LRJh72ogfyHXBNxmp/rsKisqysonGRel/gJd/IF1XesrhP/ou2NjDPi8TlUcbxsa8qRgCBr1sqG10od7SFFTLZGMh/2LqS2JY68oz1UtCnSUEN3Q8/7FYeUlwtsXlSlJ4y2EbYV+4ooJS5af3mNn4LN+NoywvxsZNY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791914577; c=relaxed/simple; bh=whcFEX3jnzSYg1cdi6AXcu2fgt3Rhuv4tn7VIPvBHdY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q+IqdCBOGsflMwK1SXW8+eROm6uWLCpMJ9U1dnvpFTupRUwHlAToFg/kA15JiWAcMkmgDNAn8HT/lkhPcqC9OYyEfUkpiojYgUcJ4tKXgD1C+zpeJrp0rBn2zjjllZslznP1LP1OVhL9tt/mv4xmTTnvJloxH4AEQSN2nPFkX0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=AQUm+y03; arc=none smtp.client-ip=95.215.58.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="AQUm+y03" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=whcFEX3jnzSYg1cdi6AXcu2fgt3Rhuv4tn7VIPvBHdY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1791914569; v=1; x=1792519369; b=AQUm+y03MO+O7GRNDJ8QJquPieZtVRHUxSfz2ukcnvu5geBhpy5hsvJjtHDTGlx70wS/YUd6 ixZ/26MjkWLdcvHsJzdaVVa2eZrtebonaX+q9FfbVotKMnyIcOlv6VZUvhFtSpA8JXdUauqT9yr NSuicid2A5zwRUA7D7WX4/RI= X-Envelope-To: linux-kernel@vger.kernel.org Received: by mta12.migadu.com with ESMTPS id 5b93d21ada605208; Tue, 13 Oct 2026 18:02:49 +0000 X-Mizu-Trace-ID: 5b93d21ada605208 X-Migadu-Flow: FLOW_OUT From: wen.yang@linux.dev To: Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: Eric Dumazet , Jesper Dangaard Brouer , Jakub Kicinski , Paolo Abeni , linux-rt-devel@list.kernel.org, linux-kernel@vger.kernel.org, Wen Yang Subject: [PATCH 12/15] net: Remove conditional threaded-NAPI wakeup based on task state. Date: Wed, 14 Oct 2026 02:02:28 +0800 Message-Id: <4b2a0a8dd6a143b1b2a3d222ac9953d9acee9130.1791912669.git.wen.yang@linux.dev> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- net/core/dev.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index ab012a7eee94..0b2cf2f0f5a4 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4485,13 +4485,7 @@ static inline void ____napi_schedule(struct softnet_data *sd, */ 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; } @@ -6716,8 +6710,6 @@ static int napi_poll(struct napi_struct *n, struct list_head *repoll) static int napi_thread_wait(struct napi_struct *napi) { - bool woken = false; - set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop()) { @@ -6726,15 +6718,13 @@ static int napi_thread_wait(struct napi_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); -- 2.25.1