Article View: linux.kernel.netdev
Article #26842Re: [PATCH net] veth: disable preemption between the NAPI mark and its wake-up
From: Sebastian Andrzej Siewior
Date: Fri, 04 Dec 2026 09:20
Date: Fri, 04 Dec 2026 09:20
54 lines
12454 bytes
12454 bytes
On 2026-12-04 08:51:52 [+0100], Florent Carli via B4 Relay wrote: > From: Florent Carli <fcarli@gmail.com> > > 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. … > 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
Technical Details
Message-ID:
<20261204092007.CKM9zFQP@linutronix.de>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377218-linux-kernel-netdev=dewy.ruReferences:
<20261204-veth-napi-rt-v1-1-02b900f75067@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377218-linux-kernel-netdev=dewy.ru From: bigeasy@linutronix.de (Sebastian Andrzej Siewior) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] veth: disable preemption between the NAPI mark and its wake-up Date: Fri, 4 Dec 2026 10:20:07 +0100 Organization: Usenet Network Message-ID: <20261204092007.CKM9zFQP@linutronix.de> References: <20261204-veth-napi-rt-v1-1-02b900f75067@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="2727621"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:QQNZFcS/owa1aRnbdFsnPAkUw9o= sha256:+fLl4UNNftMyK/KwEXZCTuGMyxaGkTByA6DUcqm55LU= sha1:Eu348++S1rdoxJO5lSLc3kZLseo= sha256:Cxr8XLHRQBj5Om0w1+m68A0oQqQAd+bY+GgmhFj5RnA= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 97D89117B83; Fri, 4 Dec 2026 12:34:44 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.298 X-Spam-Status: No, score=-3.298 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=linutronix.de header.b=M5aNgvMW; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b=GPV2xCrj X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E2Nhto0_R26f; Fri, 4 Dec 2026 12:34:38 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377218-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linutronix.de X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 91265117B75; Fri, 4 Dec 2026 12:34:23 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id A7F0729036; Fri, 4 Dec 2026 09:34:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796376858; b=BPO5lPiQnUYpgarFigHBTLB4/Fxbvnp0kupExD1ClLD0FB2FObzqjsQ7gcfb9tEPlzku l9gsfYmGZi3ojMfkiHFsBkIC9OiGb8BfgwYkwh2/m1mqnf2FbhRP/NA8henXZ8aojDs8X 1Vdue78pFXTqD9rclvxslU4nMH3x23IfimpCKVdn1ec/WWaNCOz81BfNbhBe+MftoMFrm YJukA5ya7rCdK2UuLu/hQNk8Gy+wV09UE+9bd+oYNhpO7byWA1g9H/wSJOovJRC91cG9D CMbvHgDs4zxc4b83tAlev49aKQvbwLcCgfXpn/fuJzeHSzUQQV9FRk0wnSBpAtQRjpA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796376858; h=X-Original-To:Received:DMARC-Filter:Date:DKIM-Signature: DKIM-Signature:From:To:Cc:Subject:Message-ID:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; bh=6GriDddAlICGt/Lt3+++lr1Ejyu6Rb9eASr6i9Y6Fk8=; b=wTf8UgG/7a2cYIbcNDXlg+GRs6+gPpxDFaWEjgh87aIHkQiHtmr1CZSK9QyjTFswU10A ylMQLmQXli1DA4S6U4C7ifuPSpAqlgnIyfqCPumM1nQub+NeUFuv9bLKPbl+pGucF/1CF W1qqN0+cwgjUryoZsRk/CDFIhjnU6c06BphYb9PUl/6QsH45pa6TQFu5lisllUVcX9mK+ IPupJC7tz0aQLJh1Y6XADlccyscxtBg1Yd7DyyAdOsauYLqzuNBVMymhaOeV34tHi3tXJ UddzVa9WS5vmPINq7EMTfTx+TdzwCbOYprWmZHfwf0FthPR6YdwMSG4j94/MttfkAyg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 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; dmarc=pass header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5CCE3606A686; Fri, 4 Dec 2026 09:34:18 +0000 (UTC) X-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 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=193.142.43.55 X-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== X-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== X-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 X-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) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 11BAD606A32D X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de X-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== X-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== X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Clark Williams <clrkwllms@kernel.org>, Steven Rostedt <rostedt@goodmis.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Jesper Dangaard Brouer <hawk@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Stanislav Fomichev <sdf@fomichev.me>, netdev@vger.kernel.org, linux-rt-devel@lists.linux.dev, bpf@vger.kernel.org, Toshiaki Makita <toshiaki.makita1@gmail.com>, stable@vger.kernel.org X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261204-veth-napi-rt-v1-1-02b900f75067@gmail.com>