From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=193.142.43.55 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796376857; b=tGGQtqDXicD51X8fXeQteELgk5iXTtiRZSzkWZG/HDN3k1ke/2S8RYm6aM12ALu30/o4 wXhCbzO0UgX9Bwsz8nl8M72Flb149DN1ijyF9zF0AwRuvb97iWS/7tbujMENycfRSC93j ufuSMdqv6Qtvr/v5r+2CGPHLAafegjNaq2rDdvWfQc/aTq24S2viuqChfQ/ZvIgrfU3Fg vubvsVWyYsOlNWOKIVll8dPu0DFD8p3RFjYfF3bsw/XcfP6cSLnWZqHkiDgUo0p4uqv1B QpjFDMLuq6NmodG4ITnhH1rJ2ljFzCbhGXCcpY+xDmJfSAKtQDEYx2fxYvUB/QWcqKQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796376857; h=DMARC-Filter:Date:DKIM-Signature:DKIM-Signature:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=6GriDddAlICGt/Lt3+++lr1Ejyu6Rb9eASr6i9Y6Fk8=; b=KqNXhOJ0uRzSjl1kxGQYxFHh3enb/RDFmlV21BoBIl+YfAVA+rl04x2kUjVL23PYtb1r tdntYl0nUwGRwQwLduxvL6QAKHbsnI9pvOmjXnhQn7jIPLO7yk/UBT6fJ8sErqV4lZ1vE c9GYkoXJf7ykC1uuICuJ1qvz5yxDsYZmRidhzn+YXCZ7lEbE3tdtPKYMS9QdxMGQ0bC4R qQ8/zC5MkBOfUDNbuJVbTZw2/fFcXeSDp77n10HtxNdqZRb5wr+gNIOJkkuTIWOhA5BqS 659/evMjX0MgMfVoayX/OOl0sb3uT9PaQChU56qBUA4+q0Y7w5BSO48hXXr4exkHZLQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=M5aNgvMW; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=GPV2xCrj; arc=none smtp.remote-ip=193.142.43.55 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11BAD606A32D; Fri, 4 Dec 2026 09:34:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 11BAD606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=M5aNgvMW; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=GPV2xCrj Date: Fri, 4 Dec 2026 10:20:07 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1796376008; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6GriDddAlICGt/Lt3+++lr1Ejyu6Rb9eASr6i9Y6Fk8=; b=M5aNgvMWnGTyHJn8k9sblhKvigr142SIOF5EfjZ/C3KxoRhaxjbkcnV4klpLdZ4hGunfnv 5IhIJ3NXof4kKU3cvGFGF3Mu3L8tcO4aEzQCqZplRHYgg5eY3vkNpWYouljTuOgoqRT12y WQYMDaYr1hJ+vmlDFyvL7ekYT+eQaDijoThuQu8HHtC6jD4Ij3lCBSRnEOtnCRl5cxODwS 3ZtKOuLQbxGgX9xAgSNHgktin7J27OE2d8J6IcBHknCDHyg/uFZUtkOsu73jH8H8TfLGc8 ClwKPKkuM7Hxy5W4ZGmub/GxHYT8gACgfZKN4h0aYyZWYsMNKTrk2GSnMDzW6g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1796376008; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6GriDddAlICGt/Lt3+++lr1Ejyu6Rb9eASr6i9Y6Fk8=; b=GPV2xCrj2UI7txygZV8vwWIHHTznD9+0+Q5BwBTlENjcg1Ls1tl1Mm+yLR42emZf4mhM5S weOqgVw58/vgJ4BQ== From: Sebastian Andrzej Siewior To: fcarli@gmail.com Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Clark Williams , Steven Rostedt , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , netdev@vger.kernel.org, linux-rt-devel@lists.linux.dev, bpf@vger.kernel.org, Toshiaki Makita , stable@vger.kernel.org Subject: Re: [PATCH net] veth: disable preemption between the NAPI mark and its wake-up Message-ID: <20261204092007.CKM9zFQP@linutronix.de> References: <20261204-veth-napi-rt-v1-1-02b900f75067@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20261204-veth-napi-rt-v1-1-02b900f75067@gmail.com> On 2026-12-04 08:51:52 [+0100], Florent Carli via B4 Relay wrote: > From: Florent Carli >=20 > On PREEMPT_RT the callers of __veth_xdp_flush() are preemptible: the > BH-disabled sections of the transmit path do not disable preemption > there. A producer can be preempted after napi_schedule_prep() has > marked the peer's NAPI as scheduled, before __napi_schedule() wakes it > up. Every later producer then sees rx_notify_masked or > NAPI_STATE_SCHED set, queues its packet in the ptr_ring and returns, > and the NAPI sleeps until the preempted producer runs again. No lock is > held across that window, so priority inheritance cannot shorten it. Right but if you schedule NAPI at low priority in a BH disabled section, then the NAPI callback is invoked once BH is enabled again. So there is no gain. > A low priority sender can thus hold the packets of every higher > priority sender of the same veth for as long as it stays preempted. We > hit this with IEC 61850 sampled values delivered through a veth whose > peer runs threaded NAPI, to a real-time reader on an isolated CPU: a > nice 19 sender was preempted for 4.33 ms between the two calls, the > peer's NAPI thread was not woken during that time, then was woken 4 us > after the sender ran again and polled 23 packets at once. I *think* if you have critical sender in your environment then it should not run at low priority. =E2=80=A6 > Reproducer, in a PREEMPT_RT guest of this tree (4 vCPUs, each on its > own host CPU): a veth pair, the peer with GRO on and threaded NAPI, > its thread SCHED_FIFO 50 on CPU 2; a SCHED_FIFO 50 task sends a so this needed, threaded NAPI. Otherwise the NAPI task would remain in your context and you gain nothing. With this change you push it to another thread. > timestamped packet every 250 us from CPU 1; a nice 19 task sends > 100k packets/s on the same veth from CPU 3, where a SCHED_FIFO 10 task > runs 1 ms out of every 1.2 ms; a SCHED_FIFO 60 packet socket reader on > the peer measures the delay of each periodic packet, 480000 per run. > To make the race frequent, the test kernels also delay 50 us between > napi_schedule_prep() and __napi_schedule() (not part of this patch): You have low priority sender and high prio sender and when the low priority one owns NAPI and the high priority one stuffs packets into queue without processing. I would argue that you shouldn't have a nice-19 task sending packets. With real hardware, the traffic is usually split into high and low priority. For that NICs provide queues and you can configure them. This is something I would expect one to do. Sebastian