Article View: linux.kernel.netdev
Article #1873Re: [PATCH net v2] net/sched: act_api: take tcfa_lock for hardware stats updates
From: Eric Dumazet
Date: Sun, 11 Oct 2026 08:24
Date: Sun, 11 Oct 2026 08:24
47 lines
8565 bytes
8565 bytes
Le sam. 10 oct. 2026 ร 17:22, Alexandre Cassen <acassen@corp.free.fr> a รฉcrit :
>
> Actions without per CPU stats update their counters under tcfa_lock in
> the software path but tcf_action_update_stats() adds hardware stats to
> the same counters without it. A dump of a filter without skip_hw does
> this even when nothing is offloaded, so such an action loses counter
> updates. On 32-bit, readers holding tcfa_lock can also observe torn
> 64-bit values.
>
> Callers disable preemption around this update for the per CPU stats.
> PREEMPT_RT forbids taking a spinlock_t with preemption disabled. Disable
> BH in the per CPU path instead. On 32-bit, this also keeps a softirq on
> the same CPU from updating or reading these counters in the middle of
> the update.
>
> Discovered by manual code inspection while letting more actions honor
> TCA_ACT_FLAGS_NO_PERCPU_STATS. Reproduced in a VM without kernel
> changes, where the second action counts fewer packets than the first:
>
> ip link add d0 type dummy && ip link set d0 up
> tc qdisc add dev d0 clsact
> tc filter add dev d0 ingress matchall \
> action gact pipe action gact pass no_percpu
> yes "filter show dev d0 ingress" | head -10000 > batch
> while :; do tc -s -b batch; done > /dev/null &
> samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh -i d0 -t 4
> tc -s filter show dev d0 ingress
>
> The 32-bit issue in the per CPU path comes from the Sashiko AI review
> of v1 [1] and was not reproduced.
>
> Tested with the reproducer and the tc-testing action, matchall and
> flower tests with lockdep enabled. Also tested for regressions on
> ConnectX-7 with firmware 28.48.1000.
>
> Fixes: 5e174d5e73df ("net: sched: modify stats helper functions to support regular stats")
> Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261009051703.3615846-1-acassen%40corp.free.fr [1]
> Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
> ---
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Thanks!
Technical Details
Message-ID:
<CAL4WiipPLTPOtm9VL+xpf=Bj=SgiPyafsYLynAyns3VNHVGBiA@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-344427-linux-kernel-netdev=dewy.ruReferences:
<20261010152227.401987-1-acassen@corp.free.fr>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-344427-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] net/sched: act_api: take tcfa_lock for hardware
stats updates
Date: Sun, 11 Oct 2026 10:24:39 +0200
Organization: Usenet Network
Message-ID: <CAL4WiipPLTPOtm9VL+xpf=Bj=SgiPyafsYLynAyns3VNHVGBiA@mail.gmail.com>
References: <20261010152227.401987-1-acassen@corp.free.fr>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="1498474"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:FMORFgPpb2KXsKxs8au3db+FOwI= sha256:k8XrHFkM8WT+JWsI7T6ymI6PG3PlAQ7pB804M4GwrIQ=
sha1:e5i1TgVeZ5wjlfEzuYYeMsXcKaY= sha256:F/7Ib259XqfttgVZABWKbBs0OOuSY/ZsXcoGiIkhHFs=
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 E903410F9C3; Sun, 11 Oct 2026 11:25:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
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=kernel.org
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 emogA_ny1Fme;
Sun, 11 Oct 2026 11:25:03 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-344427-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id B6C2110F7C9; Sun, 11 Oct 2026 11:24:56 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sea.lore.kernel.org (Postfix) with ESMTP id 831F32420F; Sun, 11 Oct 2026 08:24:53 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 493471F09AD;
Sun, 11 Oct 2026 08:24:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aIN0R08Q"
X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18])
(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 39F1A1C84CB
for <netdev@vger.kernel.org>; Sun, 11 Oct 2026 08:24:52 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791707093; cv=none; b=Hh/xdCOT0bHx7BwKdyYGx4CcHWIiizmHwHLHO0M7kclC3PfmhX1tKm923Bn83MQr642hIh4tz1jf0x+42arUYUmybbrj+z0rh0fiXDhbGzZITqqOoYHbPpanh/EsJ5k7jZyeldZzooUN/IGEitFluqnSkh7B+vnGttUCjGg91ac=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791707093; c=relaxed/simple;
bh=DVlvpcSU+l8MsocvPiXK14zDFL4lPwCgHGawjsFSaV8=;
h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:
To:Cc:Content-Type; b=gBL36DdL6H1m2cZ4BGAPj95cjTUtTOgJ+Xk5hJOoGl8QxatFGXWhEw+4+/TyTrlFNBu11CALDCc8Xj8jqsf0Ov3s0ugu6EDvzNE3VhbrYNGTlNbphnPXXftp1AF1KJbkG5mJ6Hw89xUC7NwoMJgs9Sj5zuNsS/I6mSAyTX7cCdg=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aIN0R08Q; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAF101F008A4
for <netdev@vger.kernel.org>; Sun, 11 Oct 2026 08:24:51 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1791707092;
bh=akBs+Ql74VJDQYf/bJz7IZtF57QSpbzonAG8FFo5X1E=;
h=References:In-Reply-To:From:Date:Subject:To:Cc;
b=aIN0R08QeTYF8z3n+LPWXdDcOyauwychHtT29FL5Hf0Ltpesb0n/yzXI4OA7+4TiJ
ZUT/AdXGa1Ma7CCzQ1mP0Nb2BTglp5AsomEMIsxy3Oek3Hq7vPEf4oitriPNyjwVZJ
V0OWhujeDfg05rMzCaFKeo7VSNx7AFWYmk7/B3B2IK6+JifXPTw8z08HIETxKek+qO
a2d0oOsJk+2ix+pocGD8wxyjiYvfEJp1T3bdp4I/1U/jXSRRCqvDhWQ/IOB7+5DGYm
B+pKwJ/VOCOiUn8RyRiXRjzjtM+pMuQExGyMvd5IwUh1E5ZS6lzYlvA1yadYJicko1
MtYOGTJ1ZvlHg==
X-Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-499f20c7054so618929fac.0
for <netdev@vger.kernel.org>; Sun, 11 Oct 2026 01:24:51 -0700 (PDT)
X-Forwarded-Encrypted: i=1; AKwUvBwm0dNN2DRpd3wNh3ToRHBWtjkn/0+mKPZNVFYFxkurQb4uqViYr63NXwzQLI2lEFRztAC1pTU=@vger.kernel.org
X-Gm-Message-State: AFq9FYIyFbLHdqpSyia03/WtjWM1GyAmVFIm1gJDO8//3RbJmb0YZn8a
+4UkbBV/rg61wZnfu35ns8kQ0441IPI9LyCN9VmpP+6GAEJ00FKo6/H3OoHFQAXN9bw0uEVpugC
WUn8vJd7jrchFjzJmyvDGaiKMHuDcUjE=
X-Received: by 2002:a05:6870:6586:b0:49e:16bf:1f87 with SMTP id
586e51a60fabf-4a2a8a7ad2cmr4961091fac.38.1791707091176; Sun, 11 Oct 2026
01:24:51 -0700 (PDT)
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-In-Reply-To: <20261010152227.401987-1-acassen@corp.free.fr>
X-Gmail-Original-Message-ID: <CAL4WiipPLTPOtm9VL+xpf=Bj=SgiPyafsYLynAyns3VNHVGBiA@mail.gmail.com>
X-Gm-Features: AclHuK8canZhdW4krwKcMXeuhtrZQXi4JcLCLKEyTFNxMtLkOk29RB2MYiar9Tw
X-Cc: Jamal Hadi Salim <jhs@mojatatu.com>, Jiri Pirko <jiri@resnulli.us>,
"David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Vlad Buslov <vladbu@nvidia.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>, netdev@vger.kernel.org