Skip to content

Commit f6052cf

Browse files
dcarattidavem330
authored andcommitted
net/sched: act_csum: use per-core statistics
use per-CPU counters, like other TC actions do, instead of maintaining one set of stats across all cores. This allows updating act_csum stats without the need of protecting them using spin_{,un}lock_bh() invocations. Signed-off-by: Davide Caratti <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b76f418 commit f6052cf

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

net/sched/act_csum.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla,
6767

6868
if (!tcf_idr_check(tn, parm->index, a, bind)) {
6969
ret = tcf_idr_create(tn, parm->index, est, a,
70-
&act_csum_ops, bind, false);
70+
&act_csum_ops, bind, true);
7171
if (ret)
7272
return ret;
7373
ret = ACT_P_CREATED;
@@ -542,9 +542,9 @@ static int tcf_csum(struct sk_buff *skb, const struct tc_action *a,
542542
int action;
543543
u32 update_flags;
544544

545-
spin_lock(&p->tcf_lock);
546545
tcf_lastuse_update(&p->tcf_tm);
547-
bstats_update(&p->tcf_bstats, skb);
546+
bstats_cpu_update(this_cpu_ptr(p->common.cpu_bstats), skb);
547+
spin_lock(&p->tcf_lock);
548548
action = p->tcf_action;
549549
update_flags = p->update_flags;
550550
spin_unlock(&p->tcf_lock);
@@ -566,9 +566,7 @@ static int tcf_csum(struct sk_buff *skb, const struct tc_action *a,
566566
return action;
567567

568568
drop:
569-
spin_lock(&p->tcf_lock);
570-
p->tcf_qstats.drops++;
571-
spin_unlock(&p->tcf_lock);
569+
qstats_drop_inc(this_cpu_ptr(p->common.cpu_qstats));
572570
return TC_ACT_SHOT;
573571
}
574572

0 commit comments

Comments
 (0)