public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Changli Gao <xiaosuo@gmail.com>
Cc: David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org, therbert@google.com
Subject: Re: [PATCH net-next-2.6] rps: avoid one atomic in enqueue_to_backlog
Date: Fri, 07 May 2010 12:05:58 +0200	[thread overview]
Message-ID: <1273226758.2261.44.camel@edumazet-laptop> (raw)
In-Reply-To: <m2x412e6f7f1005070301h627d5c76z35b3277f3a369c69@mail.gmail.com>

Le vendredi 07 mai 2010 à 18:01 +0800, Changli Gao a écrit :
> On Fri, May 7, 2010 at 5:51 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > Le vendredi 07 mai 2010 à 07:16 +0200, Eric Dumazet a écrit :
> >> Le jeudi 06 mai 2010 à 22:07 -0700, David Miller a écrit :
> >>
> >> > Looks great, applied, thanks Eric.
> >>
> >> Thanks, I have a followup to avoid one atomic in enqueue phase too ;)
> >>
> >
> > [PATCH net-next-2.6] rps: avoid one atomic in enqueue_to_backlog
> >
> > If CONFIG_SMP=y, then we own a queue spinlock, we can avoid the atomic
> > test_and_set_bit() from napi_schedule_prep().
> >
> > We now have same number of atomic ops per netif_rx() calls than with
> > pre-RPS kernel.
> >
> > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> > ---
> > diff --git a/net/core/dev.c b/net/core/dev.c
> > index 32611c8..49fa5a6 100644
> > --- a/net/core/dev.c
> > +++ b/net/core/dev.c
> > @@ -2426,8 +2426,10 @@ enqueue:
> >                        return NET_RX_SUCCESS;
> >                }
> >
> > -               /* Schedule NAPI for backlog device */
> > -               if (napi_schedule_prep(&sd->backlog)) {
> > +               /* Schedule NAPI for backlog device
> > +                * We can use non atomic operation since we own the queue lock
> > +                */
> > +               if (!__test_and_set_bit(NAPI_STATE_SCHED, &sd->backlog.state)) {
> >                        if (!rps_ipi_queued(sd))
> >                                ____napi_schedule(sd, &sd->backlog);
> >                }
> >
> 
> Why not use a wrapper function?
> 
> sth. like:
> 
> static inline int __napi_schedule_prep(struct napi_struct *n)
> {
>    return (!__test_and_set_bit(NAPI_STATE_SCHED, &n->state)
> }
> 


For one user ? 
Not sure it helps code readability.

Right now we all have our minds knowing every bit of this code, but next
year ?




  reply	other threads:[~2010-05-07 10:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-06  8:58 [PATCH net-next-2.6] rps: Various optimizations Eric Dumazet
2010-05-07  5:07 ` David Miller
2010-05-07  5:16   ` Eric Dumazet
2010-05-07  9:51     ` [PATCH net-next-2.6] rps: avoid one atomic in enqueue_to_backlog Eric Dumazet
2010-05-07 10:01       ` Changli Gao
2010-05-07 10:05         ` Eric Dumazet [this message]
2010-05-18  0:22       ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1273226758.2261.44.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=therbert@google.com \
    --cc=xiaosuo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox