From mboxrd@z Thu Jan 1 00:00:00 1970 From: Manish Kurup Subject: [PATCH net-next v4 1/3] net sched act_vlan: Change stats update to use per-core stats Date: Tue, 31 Oct 2017 14:15:06 -0400 Message-ID: <1509473706-4152-1-git-send-email-manish.kurup@verizon.com> Cc: aring@mojatatu.com, mrv@mojatatu.com, kurup.manish@gmail.com, Manish Kurup To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, jakub.kicinski@netronome.com, simon.horman@netronome.com, pieter.jansenvanvuuren@netronome.com, john.hurley@netronome.com, oss-drivers@netronome.com, davem@davemloft.net, netdev@vger.kernel.org Return-path: Received: from mail-qt0-f194.google.com ([209.85.216.194]:47964 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932682AbdJaSPP (ORCPT ); Tue, 31 Oct 2017 14:15:15 -0400 Received: by mail-qt0-f194.google.com with SMTP id z50so21886186qtj.4 for ; Tue, 31 Oct 2017 11:15:14 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: The VLAN action maintains one set of stats across all cores, and uses a spinlock to synchronize updates to it from the same. Changed this to use a per-CPU stats context instead. This change will result in better performance. Acked-by: Jamal Hadi Salim Acked-by: Jiri Pirko Signed-off-by: Manish Kurup --- net/sched/act_vlan.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index 16eb067..b093bad 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -30,9 +30,10 @@ static int tcf_vlan(struct sk_buff *skb, const struct tc_action *a, int err; u16 tci; - spin_lock(&v->tcf_lock); tcf_lastuse_update(&v->tcf_tm); - bstats_update(&v->tcf_bstats, skb); + bstats_cpu_update(this_cpu_ptr(v->common.cpu_bstats), skb); + + spin_lock(&v->tcf_lock); action = v->tcf_action; /* Ensure 'data' points at mac_header prior calling vlan manipulating @@ -85,7 +86,8 @@ static int tcf_vlan(struct sk_buff *skb, const struct tc_action *a, drop: action = TC_ACT_SHOT; - v->tcf_qstats.drops++; + qstats_drop_inc(this_cpu_ptr(v->common.cpu_qstats)); + unlock: if (skb_at_tc_ingress(skb)) skb_pull_rcsum(skb, skb->mac_len); @@ -172,7 +174,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, if (!exists) { ret = tcf_idr_create(tn, parm->index, est, a, - &act_vlan_ops, bind, false); + &act_vlan_ops, bind, true); if (ret) return ret; -- 2.7.4