diff mbox series

[net-next,3/3] net/sched: act_gate: use percpu stats

Message ID 20230210202725.446422-4-pctammela@mojatatu.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net/sched: transition actions to pcpu stats and rcu | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Pedro Tammela Feb. 10, 2023, 8:27 p.m. UTC
The tc action act_gate was using shared stats, move it to percpu stats.

tdc results:
1..12
ok 1 5153 - Add gate action with priority and sched-entry
ok 2 7189 - Add gate action with base-time
ok 3 a721 - Add gate action with cycle-time
ok 4 c029 - Add gate action with cycle-time-ext
ok 5 3719 - Replace gate base-time action
ok 6 d821 - Delete gate action with valid index
ok 7 3128 - Delete gate action with invalid index
ok 8 7837 - List gate actions
ok 9 9273 - Flush gate actions
ok 10 c829 - Add gate action with duplicate index
ok 11 3043 - Add gate action with invalid index
ok 12 2930 - Add gate action with cookie

Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
---
 net/sched/act_gate.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Paolo Abeni Feb. 14, 2023, 9:22 a.m. UTC | #1
On Fri, 2023-02-10 at 17:27 -0300, Pedro Tammela wrote:
> 
> diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c
> index 9b8def0be..684b7a79f 100644
> --- a/net/sched/act_gate.c
> +++ b/net/sched/act_gate.c
> @@ -120,10 +120,10 @@ TC_INDIRECT_SCOPE int tcf_gate_act(struct sk_buff *skb,
>  {
>  	struct tcf_gate *gact = to_gate(a);
>  
> -	spin_lock(&gact->tcf_lock);
> -
>  	tcf_lastuse_update(&gact->tcf_tm);
> -	bstats_update(&gact->tcf_bstats, skb);
> +	tcf_action_update_bstats(&gact->common, skb);
> +
> +	spin_lock(&gact->tcf_lock);

I think that RCU-ifying the 'current_gate_status' field, setting its
value with  WRITE_ONCE (both in _init and in gate_timer_func()) and
finally accessing it here with READ_ONCE, you could move pretty much
everything except the code touching *_octets update outside the
spinlock.

I'm not sure how much that will be relevant - e.g. how frequently we
expect to hit the 

	if (gact->current_max_octets >= 0) {

code path.

For sure the current code allocates per_cpu stats, but they are never
used.

Cheers,

Paolo
diff mbox series

Patch

diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c
index 9b8def0be..684b7a79f 100644
--- a/net/sched/act_gate.c
+++ b/net/sched/act_gate.c
@@ -120,10 +120,10 @@  TC_INDIRECT_SCOPE int tcf_gate_act(struct sk_buff *skb,
 {
 	struct tcf_gate *gact = to_gate(a);
 
-	spin_lock(&gact->tcf_lock);
-
 	tcf_lastuse_update(&gact->tcf_tm);
-	bstats_update(&gact->tcf_bstats, skb);
+	tcf_action_update_bstats(&gact->common, skb);
+
+	spin_lock(&gact->tcf_lock);
 
 	if (unlikely(gact->current_gate_status & GATE_ACT_PENDING)) {
 		spin_unlock(&gact->tcf_lock);
@@ -357,8 +357,8 @@  static int tcf_gate_init(struct net *net, struct nlattr *nla,
 		return 0;
 
 	if (!err) {
-		ret = tcf_idr_create(tn, index, est, a,
-				     &act_gate_ops, bind, false, flags);
+		ret = tcf_idr_create_from_flags(tn, index, est, a,
+						&act_gate_ops, bind, flags);
 		if (ret) {
 			tcf_idr_cleanup(tn, index);
 			return ret;