lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1348126251.17345.7.camel@cr0>
Date:	Thu, 20 Sep 2012 15:30:51 +0800
From:	Cong Wang <amwang@...hat.com>
To:	Stephen Hemminger <shemminger@...tta.com>
Cc:	David Miller <davem@...emloft.net>,
	Eric Dumazet <dada1@...mosbay.com>, netdev@...r.kernel.org
Subject: Re: [RFC net-next] netpoll: use static branch

On Wed, 2012-09-19 at 13:00 -0700, Stephen Hemminger wrote:
> On Wed, 19 Sep 2012 12:50:10 +0800
> Cong Wang <amwang@...hat.com> wrote:
> 
> > On Tue, 2012-09-18 at 14:10 -0700, Stephen Hemminger wrote:
> > > This is an attempt to optimize netpoll when not used.
> > > 
> > > Since distro's enable everything and netpoll is only occasionally
> > > used, improve performance by getting netpoll condition check
> > > out of the Rx fastpath.
> > > 
> > > Compile tested only, I have no real use for netpoll.
> > > 
> > > Signed-off-by: Stephen Hemminger <shemminger@...tta.com>
> > > 
> > > 
> > > ---
> > >  include/linux/netpoll.h |   28 ++++++++++++++++++++--------
> > >  net/core/netpoll.c      |    8 +++++++-
> > >  2 files changed, 27 insertions(+), 9 deletions(-)
> > > 
> > > --- a/include/linux/netpoll.h	2012-09-18 13:25:15.575750004 -0700
> > > +++ b/include/linux/netpoll.h	2012-09-18 13:29:16.245323347 -0700
> > > @@ -66,10 +66,16 @@ static inline void netpoll_send_skb(stru
> > >  
> > > 
> > >  #ifdef CONFIG_NETPOLL
> > > +extern struct static_key netpoll_needed;
> > > +
> > >  static inline bool netpoll_rx_on(struct sk_buff *skb)
> > >  {
> > > -	struct netpoll_info *npinfo = rcu_dereference_bh(skb->dev->npinfo);
> > > +	struct netpoll_info *npinfo;
> > > +
> > > +	if (static_key_true(&netpoll_needed))
> > > +		return false;
> > >  
> > 
> > I think we should use static_key_false() here, as netpoll is an
> > "unlikely" code path.
> > 
> > Using static branch is a good idea though.
> > 
> > Thanks.
> 
> But static_key_true is just a wrapper around !static_key_false()

For !HAVE_JUMP_LABEL arch, the definition is below:

static __always_inline bool static_key_false(struct static_key *key)
{
        if (unlikely(atomic_read(&key->enabled)) > 0)
                return true;
        return false;
}       
        
static __always_inline bool static_key_true(struct static_key *key)
{       
        if (likely(atomic_read(&key->enabled)) > 0)
                return true;
        return false;
}


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ