From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796458166; b=jwP8rx+H9CKDq/mlKLlVSa4HqzMOeW6R076D8QovHxmTSVgqXEFDcDlDnK2H9UIpisEZ RunuNmA2xxqkJTKoWH/ojAtTQDjq4j04HanThx6OagfmIspCC9nD9dh0a0mMlJdgmvZSh y2UeeDhxXiZ8gm78m/FUWqBwNbVRT8sxDoUlwcfCJCcFO16Ag08mnGoYn874i3FZqy0K1 zX9WREjoP1Z3bm0hgT1mlQO0KM6gTuaOv7WMQ+VR5ynD+FL3y4id4y0J5R2WVxdjO5gTw 5vGBSbYSWJW/2HY/Yl4xVcBPEyWBRTDZbq4J8xTdOKKT7XwOBJPlyosI+zG7K9jx71A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796458166; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=YrLF2PdYC1LzZvhxxtK8aW2K75WBEceru/gwOlaI8LA=; b=zmKsxlBm0p36qcX4ED193cpcGcFJWT60BT+Otb1OIiqyo8SCz9yQIhqC3Sb4CzZflF6t skSu0XUPvt3v7wnrZN9bPShpqUzwan6cwmnciHixiYZxJsQ3QaJk7KHjrOFdaRdRGqPIK AutrO9drKTy8UDFHEsB6dsZ1kt8F3nBfJ1EI3ddDHM0ou7ubFVexfbYmwjS+lkMkd3RKc 4n6MnjzriMFIgeu0SG/kOTmgYjNYYUtAZBXiYutpug1N8HMKczYf+LZb2GcS71263LuXJ lldKgP/xjHmQ23XmVnbadLmunINDcED5LLFgs18cVl96JogytYzEwggKp/Ze2FuXRYw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FMVXRpEd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD74D606A332; Sat, 5 Dec 2026 08:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FMVXRpEd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DC591F0092B; Sat, 5 Dec 2026 08:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796458166; bh=YrLF2PdYC1LzZvhxxtK8aW2K75WBEceru/gwOlaI8LA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=FMVXRpEdYUwVBAtCkyTrvbGpA24NpD4Ai/tXiGo2lxnLa+evYtRol6alm1qOpDnw5 bwMKu1zoUoQVE8baFqe93EtCbW8p3M5BG6FLdzGZ81OIwSsSbdV6vNpGzOVURgJpFO lyunfhZ72OPgZEl+O6c4GcbbOUIm77IfQpQJGyqL6AZrqAS2spkkgr282KAl9JHGa+ zMejtPFNot7yDpmj7AtixxcXZqFZBidBccdCJZnDYBetHkLsC5S1B6lUt3s5DIbaex rY4fcEhS+twpOIGlLE72uaNhSUPvbXG2mx/zEMEz0nBOaR8TANDNF8JXY0KSklEOk8 w3io0ppz0xh8g== Subject: Re: [PATCH net] veth: disable preemption between the NAPI mark and its wake-up From: netdev-bot+sashiko@kernel.org To: fcarli@gmail.com Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, bigeasy@linutronix.de, clrkwllms@kernel.org, rostedt@goodmis.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, netdev@vger.kernel.org, linux-rt-devel@lists.linux.dev, bpf@vger.kernel.org, toshiaki.makita1@gmail.com, stable@vger.kernel.org Date: Sat, 05 Dec 2026 08:09:25 +0000 Message-ID: <179645816504.3146.9790849691773053454@kernel.org> In-Reply-To: <20261204-veth-napi-rt-v1-1-02b900f75067@gmail.com> References: <20261204-veth-napi-rt-v1-1-02b900f75067@gmail.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] With non-threaded NAPI on PREEMPT_RT, the veth fix does not remove the priority inversion the commit message describes. -- veth: disable preemption between the NAPI mark and its wake-up This patch adds a veth_napi_schedule() helper. The helper calls napi_schedule_prep() and __napi_schedule() with preemption disabled. __veth_xdp_flush() and the re-schedule at the end of veth_poll() now use it. The aim is to stop a preempted low priority producer on PREEMPT_RT from holding back the NAPI wake-up for every other producer of the same veth. > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index faa837acea7b7..a67a608e9ed1a 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -299,15 +299,26 @@ static void veth_ptr_free(void *ptr) > kfree_skb(ptr); > } > > -static void __veth_xdp_flush(struct veth_rq *rq) > +/* Mark the NAPI scheduled and wake it up. Once it is marked, the other > + * producers leave the wake-up to this caller. On PREEMPT_RT the callers > + * are preemptible: do not let a preemption hold the wake-up back. > + */ > +static void veth_napi_schedule(struct veth_rq *rq) > { > - /* Write ptr_ring before reading rx_notify_masked */ > - smp_mb(); > - if (!READ_ONCE(rq->rx_notify_masked) && > - napi_schedule_prep(&rq->xdp_napi)) { > + preempt_disable(); > + if (napi_schedule_prep(&rq->xdp_napi)) { > WRITE_ONCE(rq->rx_notify_masked, true); > __napi_schedule(&rq->xdp_napi); > } > + preempt_enable(); > +} [Severity: High] Does this close the window when the peer NAPI is not threaded? That is the default for veth, which registers its NAPI with plain netif_napi_add(). In that mode __napi_schedule() does not wake a task. ____napi_schedule() only queues the NAPI on the local CPU and raises the softirq: net/core/dev.c:____napi_schedule() { ... list_add_tail(&napi->poll_list, &sd->poll_list); WRITE_ONCE(napi->list_owner, smp_processor_id()); if (!sd->in_net_rx_action) raise_softirq_irqoff(NET_RX_SOFTIRQ); } On PREEMPT_RT, in_interrupt() is true while the current task has BH disabled, because softirq_count() there comes from current->softirq_disable_cnt. So raise_softirq_irqoff() skips wakeup_softirqd(): kernel/softirq.c:raise_softirq_irqoff() { ... if (!in_interrupt() && should_wake_ksoftirqd()) wakeup_softirqd(); } The pending NET_RX softirq then runs only when the same producer reaches its own local_bh_enable(). Take a nice 19 sender on CPU3 and a high priority sender on CPU1: CPU3 (nice 19) veth_xmit() __veth_xdp_flush() veth_napi_schedule() napi_schedule_prep() /* sets NAPI_STATE_SCHED */ rx_notify_masked = true __napi_schedule() /* only queued on CPU3 poll_list */ preempt_enable() CPU1 (SCHED_FIFO) veth_xmit() __veth_xdp_flush() READ_ONCE(rq->rx_notify_masked) == true, return Wouldn't CPU1's packets then stay in xdp_ring until the nice 19 task runs again? That is the same stall the commit message describes. The veth_poll() hunk seems to have the same problem. The commit message says: "and the re-schedule at the end of veth_poll(), which without threaded NAPI runs in whatever task processes the softirq and has the same window on PREEMPT_RT." In non-threaded mode, veth_poll() runs inside that task's net_rx_action(). It already owns NAPI_STATE_SCHED for the whole poll, and the poll can be preempted. The re-scheduled NAPI goes back on the same CPU's poll_list with in_net_rx_action set. So it is only served when that task resumes, whether it was preempted before or after __napi_schedule(). In threaded mode, veth_poll() runs in the NAPI thread and re-schedules itself. There doesn't seem to be a cross-task inversion there for preempt_disable() to fix. As far as I can tell, this only fixes the threaded NAPI producer case that the reproducer used. Could the comment on veth_napi_schedule() and the commit message be limited to that case? Or does the non-threaded case need a different approach, such as covering the whole BH-disabled section, or requiring threaded NAPI on PREEMPT_RT? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204-veth-napi-rt-v1-1-02b900f75067%40gmail.com