* [PATCH net-next 1/2] net sched act_vlan: Change stats update to use per-core stats
@ 2017-10-11 2:32 Manish Kurup
2017-10-11 12:27 ` Jamal Hadi Salim
2017-10-11 13:15 ` Jiri Pirko
0 siblings, 2 replies; 5+ messages in thread
From: Manish Kurup @ 2017-10-11 2:32 UTC (permalink / raw)
To: jhs, xiyou.wangcong, jiri, davem, netdev, linux-kernel
Cc: aring, mrv, kurup.manish, manish.kurup
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.
Signed-off-by: Manish Kurup <manish.kurup@verizon.com>
---
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..14c262c 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/2] net sched act_vlan: Change stats update to use per-core stats
2017-10-11 2:32 [PATCH net-next 1/2] net sched act_vlan: Change stats update to use per-core stats Manish Kurup
@ 2017-10-11 12:27 ` Jamal Hadi Salim
2017-10-11 12:35 ` [E] " Kurup, Manish B
2017-10-11 13:15 ` Jiri Pirko
1 sibling, 1 reply; 5+ messages in thread
From: Jamal Hadi Salim @ 2017-10-11 12:27 UTC (permalink / raw)
To: Manish Kurup, xiyou.wangcong, jiri, davem, netdev
Cc: aring, mrv, manish.kurup
minus lk
On 17-10-10 10:32 PM, Manish Kurup wrote:
> 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.
>
> Signed-off-by: Manish Kurup <manish.kurup@verizon.com>
> ---
> 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..14c262c 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);
>
Indentation mismatch here?
Otherwise looks good to me.
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
cheers,
jamal
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [E] Re: [PATCH net-next 1/2] net sched act_vlan: Change stats update to use per-core stats
2017-10-11 12:27 ` Jamal Hadi Salim
@ 2017-10-11 12:35 ` Kurup, Manish B
2017-10-11 12:58 ` Jiri Pirko
0 siblings, 1 reply; 5+ messages in thread
From: Kurup, Manish B @ 2017-10-11 12:35 UTC (permalink / raw)
To: Jamal Hadi Salim, Manish Kurup, xiyou.wangcong@gmail.com,
jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org
Cc: aring@mojatatu.com, mrv@mojatatu.com
Hi Jamal, Yes, that's an indentation mismatch - I put in one tab too many. Shall fix before commit.
Thanks,
-Manish
-----Original Message-----
From: Jamal Hadi Salim [mailto:jhs@mojatatu.com]
Sent: Wednesday, October 11, 2017 8:28 AM
To: Manish Kurup; xiyou.wangcong@gmail.com; jiri@resnulli.us; davem@davemloft.net; netdev@vger.kernel.org
Cc: aring@mojatatu.com; mrv@mojatatu.com; Kurup, Manish B
Subject: [E] Re: [PATCH net-next 1/2] net sched act_vlan: Change stats update to use per-core stats
minus lk
On 17-10-10 10:32 PM, Manish Kurup wrote:
> 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.
>
> Signed-off-by: Manish Kurup <manish.kurup@verizon.com>
> ---
> 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..14c262c 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);
>
Indentation mismatch here?
Otherwise looks good to me.
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
cheers,
jamal
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [E] Re: [PATCH net-next 1/2] net sched act_vlan: Change stats update to use per-core stats
2017-10-11 12:35 ` [E] " Kurup, Manish B
@ 2017-10-11 12:58 ` Jiri Pirko
0 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2017-10-11 12:58 UTC (permalink / raw)
To: Kurup, Manish B
Cc: Jamal Hadi Salim, Manish Kurup, xiyou.wangcong@gmail.com,
davem@davemloft.net, netdev@vger.kernel.org, aring@mojatatu.com,
mrv@mojatatu.com
Wed, Oct 11, 2017 at 02:35:50PM CEST, manish.kurup@verizon.com wrote:
>Hi Jamal, Yes, that's an indentation mismatch - I put in one tab too many. Shall fix before commit.
No top-posting please!
>
>Thanks,
>
>-Manish
>
>-----Original Message-----
>From: Jamal Hadi Salim [mailto:jhs@mojatatu.com]
>Sent: Wednesday, October 11, 2017 8:28 AM
>To: Manish Kurup; xiyou.wangcong@gmail.com; jiri@resnulli.us; davem@davemloft.net; netdev@vger.kernel.org
>Cc: aring@mojatatu.com; mrv@mojatatu.com; Kurup, Manish B
>Subject: [E] Re: [PATCH net-next 1/2] net sched act_vlan: Change stats update to use per-core stats
>
>minus lk
>
>On 17-10-10 10:32 PM, Manish Kurup wrote:
>> 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.
>>
>> Signed-off-by: Manish Kurup <manish.kurup@verizon.com>
>> ---
>> 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..14c262c 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);
>>
>
>Indentation mismatch here?
>
>Otherwise looks good to me.
>
>Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
>
>cheers,
>jamal
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/2] net sched act_vlan: Change stats update to use per-core stats
2017-10-11 2:32 [PATCH net-next 1/2] net sched act_vlan: Change stats update to use per-core stats Manish Kurup
2017-10-11 12:27 ` Jamal Hadi Salim
@ 2017-10-11 13:15 ` Jiri Pirko
1 sibling, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2017-10-11 13:15 UTC (permalink / raw)
To: Manish Kurup
Cc: jhs, xiyou.wangcong, davem, netdev, linux-kernel, aring, mrv,
manish.kurup
Wed, Oct 11, 2017 at 04:32:27AM CEST, kurup.manish@gmail.com wrote:
>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.
>
>Signed-off-by: Manish Kurup <manish.kurup@verizon.com>
>---
> 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..14c262c 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);
Please fix this indent nit as pointed out by Jamal.
Feel free to add my tag:
Acked-by: Jiri Pirko <jiri@mellanox.com>
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-11 13:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-11 2:32 [PATCH net-next 1/2] net sched act_vlan: Change stats update to use per-core stats Manish Kurup
2017-10-11 12:27 ` Jamal Hadi Salim
2017-10-11 12:35 ` [E] " Kurup, Manish B
2017-10-11 12:58 ` Jiri Pirko
2017-10-11 13:15 ` Jiri Pirko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).