net/sched: rename qstats_overlimit_inc() to qstats_cpu_overlimit_inc()
Subsystems (3)
PATCH v4 1/1 net/sched: rename qstats_overlimit_inc() to qstats_cpu_overlimit_inc()
qstats_overlimit_inc() is only used to increment per cpu overlimits.
It can use this_cpu_inc() to avoid this_cpu_ptr() extra cost and avoid potential store tearing.
Change qstats_overlimit_inc() name and its argument type.
Also add a WRITE_ONCE() in qdisc_qstats_overlimit() to prevent store tearing.
$ scripts/bloat-o-meter -t vmlinux.0 vmlinux.1 add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-91 (-91) Function old new delta tcf_skbmod_act 772 764 -8 tcf_police_act 733 725 -8 tcf_gate_act 318 310 -8 tcf_pedit_act 1295 1284 -11 tcf_mirred_to_dev 1126 1114 -12 tcf_ife_act 1077 1061 -16 tcf_mirred_act 1324 1296 -28 Total: Before=24274627, After=24274536, chg -0.00%
--- include/net/act_api.h | 2 +- include/net/sch_generic.h | 6 +++--- net/sched/act_ife.c | 4 ++-- net/sched/act_police.c | 2 +- net/sched/act_skbmod.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-)
include/net/act_api.h +1 -1
@@ -250,7 +250,7 @@ static inline void tcf_action_inc_drop_qstats(struct tc_action *a)static inline void tcf_action_inc_overlimit_qstats (struct tc_action *a) {if (likely (a->cpu_qstats)) { -qstats_overlimit_inc (this_cpu_ptr (a->cpu_qstats)); +qstats_cpu_overlimit_inc (a->cpu_qstats);return ; }atomic_inc (&a->tcfa_overlimits);
include/net/sch_generic.h +3 -3
@@ -1004,9 +1004,9 @@ static inline void qstats_drop_inc(struct gnet_stats_queue *qstats) qstats->drops++; } -static inline void qstats_overlimit_inc (struct gnet_stats_queue *qstats) +static inline void qstats_cpu_overlimit_inc (struct gnet_stats_queue __percpu *qstats) { - qstats->overlimits++; +this_cpu_inc (qstats->overlimits); }static inline void qdisc_qstats_drop (struct Qdisc *sch)
@@ -1021,7 +1021,7 @@ static inline void qdisc_qstats_cpu_drop(struct Qdisc *sch)static inline void qdisc_qstats_overlimit (struct Qdisc *sch) { - sch->qstats.overlimits++; +WRITE_ONCE (sch->qstats.overlimits, sch->qstats.overlimits +1 ); }static inline int qdisc_qstats_copy (struct gnet_dump *d,struct Qdisc *sch)
net/sched/act_ife.c +2 -2
@@ -750,7 +750,7 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a,*/ pr_info_ratelimited ("Unknown metaid %d dlen %d\n" , mtype, dlen); -qstats_overlimit_inc (this_cpu_ptr (ife->common.cpu_qstats)); +qstats_cpu_overlimit_inc (ife->common.cpu_qstats); } }
@@ -814,7 +814,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,/* abuse overlimits to count when we allow packet * with no metadata */ -qstats_overlimit_inc (this_cpu_ptr (ife->common.cpu_qstats)); +qstats_cpu_overlimit_inc (ife->common.cpu_qstats);return action; }/* could be stupid policy setup or mtu config
net/sched/act_police.c +1 -1
@@ -307,7 +307,7 @@ TC_INDIRECT_SCOPE int tcf_police_act(struct sk_buff *skb, } inc_overlimits: -qstats_overlimit_inc (this_cpu_ptr (police->common.cpu_qstats)); +qstats_cpu_overlimit_inc (police->common.cpu_qstats); inc_drops:if (ret ==TC_ACT_SHOT )qstats_drop_inc (this_cpu_ptr (police->common.cpu_qstats));
net/sched/act_skbmod.c +1 -1
@@ -87,7 +87,7 @@ TC_INDIRECT_SCOPE int tcf_skbmod_act(struct sk_buff *skb,return p->action; drop: -qstats_overlimit_inc (this_cpu_ptr (d->common.cpu_qstats)); +qstats_cpu_overlimit_inc (d->common.cpu_qstats);return TC_ACT_SHOT ; }
Signature · 1 line
2.54.0.545.g6539524ca2-goog
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 28 Apr 2026 07:09:19 +0000 you wrote:
qstats_overlimit_inc()is only used to increment per cpu overlimits.It can use
this_cpu_inc()to avoidthis_cpu_ptr()extra cost and avoid potential store tearing.Change
qstats_overlimit_inc()name and its argument type.[...]
Here is the summary with links:
- [v4,net-next] net/sched: rename qstats_overlimit_inc() to qstats_cpu_overlimit_inc()
https://git.kernel.org/netdev/net-next/c/52472519ef61
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html