From nobody Sun Feb 8 04:11:14 2026 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (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 8BE0A207A20 for ; Sun, 18 Jan 2026 16:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768754473; cv=none; b=L6DSzzx6J6WZ5dl1dvO8vw21CfJyt+Mv5nMteGi+A+uE45VJJp40wfN9Kdx0vaL/VXxTQBgkN0pCccm5djfZ1vNIhsrb+GVflDv2PkZU1sj66bHfh5kTBB90BYH+hZI5FcDju7UCtMj8B1pmN1H4RHX8C8LI5u5CVH4Zx04uWe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768754473; c=relaxed/simple; bh=5M8+PnOkLtsD+OxYNuVjmuhn7pOypAI779/sOab/aEs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WC+9sQ/hOhAs6HUsSx0PZzrgFU1loNC2VyqrapmGbxKLHc4aAk36OorFlJqqW8vXRs9CI8+H+9sbQSuKmXfG3VnxpQNtmBTcf0Xa5Oi8hoVOd1DAK6U4JnppwWXsemrLBXb8gf1YsnIpy80nK7IGzDlYpWEx8NjLJ2U66MO7ETU= 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=IOPwH/rP; arc=none smtp.client-ip=91.218.175.179 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="IOPwH/rP" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1768754469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EFttAqFki6nqWJoMTJuJeWJm16rSKpHxYccKyXV1eEI=; b=IOPwH/rPRM1XV1BSPs0DlW++N3vcK1+XWfiAao9nG/IRb6RIycxk453je5uC8qQzU8vSqc w9u5D0XUAs8i8oxo7xIvG7oZPDlpUAZsZf6+VBMxRwAmFCZlou40s+DNSbett4HwlRZdBe MzOQU60EfBCYOlLqouaM//3FFlbJ4NY= From: wen.yang@linux.dev To: Greg Kroah-Hartman Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Andrzej Siewior , Jakub Kicinski , Paolo Abeni , Wen Yang Subject: [PATCH 6.1 2/3] net: Remove conditional threaded-NAPI wakeup based on task state. Date: Mon, 19 Jan 2026 00:40:32 +0800 Message-Id: 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: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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 e35f41e75bdd..83475b8b3e9d 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4447,13 +4447,7 @@ static inline void ____napi_schedule(struct softnet_= data *sd, */ thread =3D 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) !=3D TASK_INTERRUPTIBLE) - set_bit(NAPI_STATE_SCHED_THREADED, &napi->state); + set_bit(NAPI_STATE_SCHED_THREADED, &napi->state); wake_up_process(thread); return; } @@ -6672,8 +6666,6 @@ static int napi_poll(struct napi_struct *n, struct li= st_head *repoll) =20 static int napi_thread_wait(struct napi_struct *napi) { - bool woken =3D false; - set_current_state(TASK_INTERRUPTIBLE); =20 while (!kthread_should_stop()) { @@ -6682,15 +6674,13 @@ static int napi_thread_wait(struct napi_struct *nap= i) * 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; } =20 schedule(); - /* woken being true indicates this thread owns this napi. */ - woken =3D true; set_current_state(TASK_INTERRUPTIBLE); } __set_current_state(TASK_RUNNING); --=20 2.25.1