🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13170

[PATCH net-next v3 2/4] net/sched: honor TCA_ACT_FLAGS_NO_PERCPU_STATS in bpf, ife and skbmod

#13170
From: Alexandre Cassen
Date: Mon, 09 Nov 2026 12:46
183 lines
15116 bytes
bpf, ife and skbmod are the last actions that ignore
TCA_ACT_FLAGS_NO_PERCPU_STATS. Commit 40bd094d65fc ("flow_offload: fill
flags to action structure") makes them store and dump the flag. They
still allocate per CPU stats, about 8 KB per action on a 128 CPU host.
Yet tc reports no_percpu on them.

Honor the flag here too. These actions run only in software. With
no_percpu every packet takes tcfa_lock to update the stats. Only the
users who set the flag pay this cost.

Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
 net/sched/act_bpf.c    |  8 ++++----
 net/sched/act_ife.c    | 24 ++++++++++++------------
 net/sched/act_skbmod.c |  8 ++++----
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c
index 06d8f78b7368..3aea3ff5785f 100644
--- a/net/sched/act_bpf.c
+++ b/net/sched/act_bpf.c
@@ -42,7 +42,7 @@ TC_INDIRECT_SCOPE int tcf_bpf_act(struct sk_buff *skb,
 	int action, filter_res;
 
 	tcf_lastuse_update(&prog->tcf_tm);
-	bstats_update(this_cpu_ptr(prog->common.cpu_bstats), skb);
+	tcf_action_update_bstats(&prog->common, skb);
 
 	filter = rcu_dereference_bh(prog->filter);
 	if (at_ingress) {
@@ -76,7 +76,7 @@ TC_INDIRECT_SCOPE int tcf_bpf_act(struct sk_buff *skb,
 		break;
 	case TC_ACT_SHOT:
 		action = filter_res;
-		qstats_cpu_drop_inc(prog->common.cpu_qstats);
+		tcf_action_inc_drop_qstats(&prog->common);
 		break;
 	case TC_ACT_UNSPEC:
 		action = prog->tcf_action;
@@ -305,8 +305,8 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla,
 	index = parm->index;
 	ret = tcf_idr_check_alloc(tn, &index, act, bind);
 	if (!ret) {
-		ret = tcf_idr_create(tn, index, est, act,
-				     &act_bpf_ops, bind, true, flags);
+		ret = tcf_idr_create_from_flags(tn, index, est, act,
+						&act_bpf_ops, bind, flags);
 		if (ret < 0) {
 			tcf_idr_cleanup(tn, index);
 			return ret;
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 3946a9589bb8..a931f0d353d2 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -551,8 +551,8 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
 	}
 
 	if (!exists) {
-		ret = tcf_idr_create(tn, index, est, a, &act_ife_ops,
-				     bind, true, flags);
+		ret = tcf_idr_create_from_flags(tn, index, est, a,
+						&act_ife_ops, bind, flags);
 		if (ret) {
 			tcf_idr_cleanup(tn, index);
 			kfree(p);
@@ -720,7 +720,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a,
 
 	p = rcu_dereference_bh(ife->params);
 
-	bstats_update(this_cpu_ptr(ife->common.cpu_bstats), skb);
+	tcf_action_update_bstats(&ife->common, skb);
 	tcf_lastuse_update(&ife->tcf_tm);
 
 	if (skb_at_tc_ingress(skb))
@@ -728,7 +728,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a,
 
 	tlv_data = ife_decode(skb, &metalen);
 	if (unlikely(!tlv_data)) {
-		qstats_cpu_drop_inc(ife->common.cpu_qstats);
+		tcf_action_inc_drop_qstats(&ife->common);
 		return TC_ACT_SHOT;
 	}
 
@@ -742,7 +742,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a,
 		curr_data = ife_tlv_meta_decode(tlv_data, ifehdr_end, &mtype,
 						&dlen, NULL);
 		if (!curr_data) {
-			qstats_cpu_drop_inc(ife->common.cpu_qstats);
+			tcf_action_inc_drop_qstats(&ife->common);
 			return TC_ACT_SHOT;
 		}
 
@@ -751,7 +751,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a,
 			/* abuse overlimits to count metadata we cannot
 			 * decode: no ops for it, or the decoder rejected it
 			 */
-			qstats_cpu_overlimit_inc(ife->common.cpu_qstats);
+			tcf_action_inc_overlimit_qstats(&ife->common);
 
 			if (ret == -ENOENT)
 				pr_info_ratelimited("Unknown metaid %d dlen %d\n",
@@ -763,7 +763,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a,
 	}
 
 	if (WARN_ON(tlv_data != ifehdr_end)) {
-		qstats_cpu_drop_inc(ife->common.cpu_qstats);
+		tcf_action_inc_drop_qstats(&ife->common);
 		return TC_ACT_SHOT;
 	}
 
@@ -819,21 +819,21 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
 			exceed_mtu = true;
 	}
 
-	bstats_update(this_cpu_ptr(ife->common.cpu_bstats), skb);
+	tcf_action_update_bstats(&ife->common, skb);
 	tcf_lastuse_update(&ife->tcf_tm);
 
 	if (!metalen) {		/* no metadata to send */
 		/* abuse overlimits to count when we allow packet
 		 * with no metadata
 		 */
-		qstats_cpu_overlimit_inc(ife->common.cpu_qstats);
+		tcf_action_inc_overlimit_qstats(&ife->common);
 		return action;
 	}
 	/* could be stupid policy setup or mtu config
 	 * so lets be conservative.. */
 	if ((action == TC_ACT_SHOT) || exceed_mtu) {
 drop:
-		qstats_cpu_drop_inc(ife->common.cpu_qstats);
+		tcf_action_inc_drop_qstats(&ife->common);
 		return TC_ACT_SHOT;
 	}
 
@@ -898,9 +898,9 @@ TC_INDIRECT_SCOPE int tcf_ife_act(struct sk_buff *skb,
 	int ret;
 
 	if (unlikely(!tcf_ife_is_eth_skb(skb))) {
-		bstats_update(this_cpu_ptr(ife->common.cpu_bstats), skb);
+		tcf_action_update_bstats(&ife->common, skb);
 		tcf_lastuse_update(&ife->tcf_tm);
-		qstats_cpu_drop_inc(ife->common.cpu_qstats);
+		tcf_action_inc_drop_qstats(&ife->common);
 		return TC_ACT_SHOT;
 	}
 
diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c
index 09e9dcf58253..72dedb9b19a6 100644
--- a/net/sched/act_skbmod.c
+++ b/net/sched/act_skbmod.c
@@ -32,7 +32,7 @@ TC_INDIRECT_SCOPE int tcf_skbmod_act(struct sk_buff *skb,
 	u64 flags;
 
 	tcf_lastuse_update(&d->tcf_tm);
-	bstats_update(this_cpu_ptr(d->common.cpu_bstats), skb);
+	tcf_action_update_bstats(&d->common, skb);
 
 	p = rcu_dereference_bh(d->skbmod_p);
 	if (unlikely(p->action == TC_ACT_SHOT))
@@ -91,7 +91,7 @@ TC_INDIRECT_SCOPE int tcf_skbmod_act(struct sk_buff *skb,
 	return p->action;
 
 drop:
-	qstats_cpu_overlimit_inc(d->common.cpu_qstats);
+	tcf_action_inc_overlimit_qstats(&d->common);
 	return TC_ACT_SHOT;
 }
 
@@ -171,8 +171,8 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla,
 	}
 
 	if (!exists) {
-		ret = tcf_idr_create(tn, index, est, a,
-				     &act_skbmod_ops, bind, true, flags);
+		ret = tcf_idr_create_from_flags(tn, index, est, a,
+						&act_skbmod_ops, bind, flags);
 		if (ret) {
 			tcf_idr_cleanup(tn, index);
 			return ret;
-- 
2.43.0
Technical Details
Message-ID: <20261109124618.933149-3-acassen@corp.free.fr>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359282-linux-kernel-netdev=dewy.ru
References: <20261109124618.933149-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!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359282-linux-kernel-netdev=dewy.ru
From: acassen@corp.free.fr (Alexandre Cassen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3 2/4] net/sched: honor TCA_ACT_FLAGS_NO_PERCPU_STATS in bpf, ife and skbmod
Date: Mon,  9 Nov 2026 13:46:13 +0100
Organization: Usenet Network
Message-ID: <20261109124618.933149-3-acassen@corp.free.fr>
References: <20261109124618.933149-1-acassen@corp.free.fr>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="355273"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:B66+a/+teRWhE9cENiAZGS8jFFQ= sha256:K6FdtqPLPSyiv205XlxHqJg4LzhYI6rxOe2p3S2aFTo=
	sha1:LDTzYlf2PUCFdDpwhyXKsJ6rZUw= sha256:o23d4zghRiF2KplymxzM/4l/4xFjmCP+jiGJv/Uz1w8=
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 1994B1137D1; Mon,  9 Nov 2026 15:47:54 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=corp.free.fr
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 siAn4CRpRL9h;
	Mon,  9 Nov 2026 15:47:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-359282-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=corp.free.fr
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id D315E1137C0; Mon,  9 Nov 2026 15:47:42 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id D6BE561BE55; Mon,  9 Nov 2026 12:46:48 +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=1794228397;
	b=LpQ4TD+ZQlr74DXS3K0ZzL+Zhm1p5OcWFNn8zW8QZEdzWJUMEmuqZBuBI5XleHiYKTi3
	 +W0/euMCxp8laer5E5NByxKL7bnlxsZtMuI9o6MDkeSR8axdnG+cyiG6/QWlT/iXUX/ST
	 KmixBAPbgQMTI9Ua9fTu4E9zA7RsqDdL9BUXLMPrYdh5Q8mHE31joMvbWP1gjXiwRRyfy
	 JKSecaI1/x1zOdX0RlTJhNu2oMwHwG1+0UYyPuFwAgTEO1mtYeJrZoljsgrO2btCakEwz
	 7U2X5rlnSxGFnZCgJekst0O5XgiNX0P7hfSZCot8f92gZwUxPKSExr1N7kkl8MS9qYA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794228397;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To:
	 Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=kh7rPhttLM/9UhZnWWZ9GH6qoA/1ey+mAVM6n12p29w=;
	b=BkEMcxu+SHhoUMwAD59hOYxaPY0l+a9A9u6NH1tpDB8dn9m5XIi6ZNYByNANsDdnTCNx
	 gN6OwnQBuZWTzYmoAgc1YTWDj1BjKdQuFpzDTIVYOuIxNEmziB0VKhXNXPaPP1a+NRBoR
	 fs8WWD80kG5v8jUHTSdx6FTYSSsxK49Q3zhI7M9jxgEGrSI+FvLUkqda/sYCVuTi9YkUw
	 fWi5IWg6KktfMDJySSFBRnRWlf2YdXbmCCJTb36zICh/mEp/u7EBcavNeD7GVfKF9vkKl
	 t0kE+jcCkMvgXfxF6Fuq4qvguGVEZGshiVA1jsojohcaFbbf6XPIc+zxcgaRiwzwImw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=corp.free.fr header.i=@corp.free.fr header.a=rsa-sha256 header.s=rcs header.b=GnJgdnUJ;
	dmarc=pass header.from=corp.free.fr;
	spf=pass smtp.mailfrom=corp.free.fr;
	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 B13BE606A330;
	Mon,  9 Nov 2026 12:46:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=corp.free.fr header.i=@corp.free.fr header.a=rsa-sha256 header.s=rcs header.b=GnJgdnUJ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=212.27.60.169
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794228386;
	b=L+CxN1hPktGisRW4V2Dc+bh4UE60Mq+/Z8hon1MM+u3DMnm7uhgyqebQDZEdNvOcXSsc
	 NLLsSxXh59OhOZ6I437HI13qBomRhaz07S/weD96ghVOc6MZ4gNn0rb4XJKp/oxrAWZH7
	 TCE4TKIsiHmxv85Fsga3ODnriL6q5kBCI9OUE+sQbUCnGhu93OUk7LORVPqn1R2N4Jnnn
	 f56yAS9pcaphzRr/C3Ktjf9nRJDLEiwqEs53d903lJEMw314eOk9rm89JMUoDvVcz2r28
	 Zrt+vGsiDLVQpENw2uWZt72IrUgiXk7kfuoDaAB4XvtANHWYvlNqNNbei3uIQsD93JQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794228386;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=kh7rPhttLM/9UhZnWWZ9GH6qoA/1ey+mAVM6n12p29w=;
	b=Lx7TJFeyyPShuvkEliklU7c/5WfHgtlOSm2tQe/2q4FlGGlAQ1UNI9U0G0mnb5tzq8mr
	 RyxbaZFICkyPjdKN1IJaH0xGMm3PnCzgIdOOW95XxvjHx188a45kd0UBOe5bS8B+QTbgA
	 DPeRvSKqdBp0JUjYTvqGqThV1CiKIxlpFGHnsMr9QYDu0wrUJc9v/6g1h20bGyyDs6zph
	 tQV4DHwJ08IHLOaq7liNg2oo9L0I6dpsGAuDxdqO3yETIGcDyKEjOWvvFikoBPNv7hnqe
	 XVH3OS9N6FS0HfvoFHhUlBinTNBQecRI8wEc4mjS5TN7MaBmZewiK3fUsnG9kG40pSg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=corp.free.fr;
	spf=pass smtp.mailfrom=corp.free.fr;
	dkim=pass header.d=corp.free.fr header.i=@corp.free.fr header.a=rsa-sha256 header.s=rcs header.b=GnJgdnUJ;
	arc=none smtp.remote-ip=212.27.60.169
X-Received: from rcs.proxad.net (rcs.proxad.net [212.27.60.169])
	(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 D6096606A325;
	Mon,  9 Nov 2026 12:46:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D6096606A325
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=corp.free.fr
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=corp.free.fr
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=corp.free.fr; s=rcs;
	t=1794228384; bh=7ZPGTPVH0/RD8EODqPSC8V+GK04omyIfEDmcx5TbHo4=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=GnJgdnUJ8FO7KxFUxm8vPAsdZCo5VNQAWW/jvWGNrYrUgrkNL9HskYrD6pUff5JIc
	 /2qZDWwqMh5BitC7DPcAVYr1WjnjGDDqbwoKxwvfibcw3cH6TtpQqTNRSrNo52HEHK
	 X/4vmdaDM1zi6dR/R85IB+ZcDzfr+WR7E0VmhtwEwBXNKQX75w4uuCezbopLe90pCC
	 IYLXvqdM86WZUmvQst53V4pnuzbPbALX7PZyyBYJq8jEBomP4Wg5RFYQRCALeN0d4s
	 wc5fpozXzfcviS3vDesAOoNILglbSrgcydfopLn51z/RwhTyJetTkZf4Uqq0cIt3p2
	 EtDmcxyfbsbSw==
X-Received: from lnxos-dev.home (82-66-150-212.subs.proxad.net [82.66.150.212])
	by rcs.proxad.net (Postfix) with ESMTPSA id E6FA944C0610;
	Mon,  9 Nov 2026 13:46:23 +0100 (CET)
X-Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Ido Schimmel <idosch@nvidia.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	netdev@vger.kernel.org,
	bpf@vger.kernel.org
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <20261109124618.933149-1-acassen@corp.free.fr>
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