From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757398AbdJKNaU (ORCPT ); Wed, 11 Oct 2017 09:30:20 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34535 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753146AbdJKNaF (ORCPT ); Wed, 11 Oct 2017 09:30:05 -0400 X-Google-Smtp-Source: AOwi7QB4BuVVuqwTENEErNQC1+WXVktBDX+XpA09QcYSzDMPBHMez0BT+4LKFiYTjD4bA8jJy+7gXw== Message-ID: <1507728603.31614.23.camel@edumazet-glaptop3.roam.corp.google.com> Subject: Re: [PATCH net-next 2/2] net sched act_vlan: VLAN action rewrite to use RCU lock/unlock and update From: Eric Dumazet To: Manish Kurup Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, aring@mojatatu.com, mrv@mojatatu.com, manish.kurup@verizon.com Date: Wed, 11 Oct 2017 06:30:03 -0700 In-Reply-To: <1507727429.31614.22.camel@edumazet-glaptop3.roam.corp.google.com> References: <1507689219-22993-1-git-send-email-manish.kurup@verizon.com> <1507727429.31614.22.camel@edumazet-glaptop3.roam.corp.google.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2017-10-11 at 06:10 -0700, Eric Dumazet wrote: > On Tue, 2017-10-10 at 22:33 -0400, Manish Kurup wrote: > > Using a spinlock in the VLAN action causes performance issues when the VLAN > > action is used on multiple cores. Rewrote the VLAN action to use RCU read > > locking for reads and updates instead. > > > > Signed-off-by: Manish Kurup > > --- > > include/net/tc_act/tc_vlan.h | 21 ++++++++----- > > net/sched/act_vlan.c | 73 ++++++++++++++++++++++++++++++-------------- > > 2 files changed, 63 insertions(+), 31 deletions(-) > > > > diff --git a/include/net/tc_act/tc_vlan.h b/include/net/tc_act/tc_vlan.h > > index c2090df..67fd355 100644 > > --- a/include/net/tc_act/tc_vlan.h > > +++ b/include/net/tc_act/tc_vlan.h > > @@ -13,12 +13,17 @@ > > #include > > #include > > > > +struct tcf_vlan_params { > > + struct rcu_head rcu; > > + int tcfv_action; > > + u16 tcfv_push_vid; > > + __be16 tcfv_push_proto; > > + u8 tcfv_push_prio; > > +}; > > + > > struct tcf_vlan { > > struct tc_action common; > > - int tcfv_action; > > - u16 tcfv_push_vid; > > - __be16 tcfv_push_proto; > > - u8 tcfv_push_prio; > > + struct tcf_vlan_params __rcu *vlan_p; > > }; > > #define to_vlan(a) ((struct tcf_vlan *)a) > > > > @@ -33,22 +38,22 @@ static inline bool is_tcf_vlan(const struct tc_action *a) > > > > static inline u32 tcf_vlan_action(const struct tc_action *a) > > { > > - return to_vlan(a)->tcfv_action; > > + return to_vlan(a)->vlan_p->tcfv_action; > > This is not proper RCU : ->vlan_p should be read once, and using > rcu_dereference() > > So the caller should provide to this helper the 'p' pointer instead of > 'a' > > > CONFIG_SPARSE_RCU_POINTER=y > > and make C=2 would probably give you warnings about that. > BTW no need to change your .config after : commit 41a2901e7d220875752a8c870e0b53288a578c20 Author: Paul E. McKenney Date: Fri May 12 15:56:35 2017 -0700 rcu: Remove SPARSE_RCU_POINTER Kconfig option The sparse-based checking for non-RCU accesses to RCU-protected pointers has been around for a very long time, and it is now the only type of sparse-based checking that is optional. This commit therefore makes it unconditional. Reported-by: Ingo Molnar Signed-off-by: Paul E. McKenney Cc: Fengguang Wu