All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: jigsaw <jigsaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "dev-VfR2kkLFssw@public.gmane.org" <dev-VfR2kkLFssw@public.gmane.org>
Subject: Re: 答复:  [PATCH] Add user defined tag calculation callback tolibrte_distributor.
Date: Fri, 7 Nov 2014 15:04:29 +0000	[thread overview]
Message-ID: <20141107150429.GD12092@bricha3-MOBL3> (raw)
In-Reply-To: <CAHVfvh6HxAVynbvCXFESMfFyHpiaLkgUPwM7eWEjNAF53qJDXg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Fri, Nov 07, 2014 at 04:52:46PM +0200, jigsaw wrote:
> Yeah that's better. As below, right?

Yep.

> 
> @@ -290,6 +294,7 @@ rte_distributor_process(struct rte_distributor *d,
>                                 match |= (!(d->in_flight_tags[i] ^ new_tag)
>                                         << i);
> 
> +                       match &= d->in_flight_bitmask;
>                         if (match) {
>                                 next_mb = NULL;
>                                 unsigned worker = __builtin_ctz(match);
> 
> 
> On Fri, Nov 7, 2014 at 4:44 PM, Bruce Richardson <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
> > wrote:
> 
> > On Fri, Nov 07, 2014 at 04:31:18PM +0200, jigsaw wrote:
> > > Hi Bruce,
> > >
> > > Pls have a quick look at the diff to see if this is exactly what you mean
> > > about the bitmask.
> > > I just wrote it without even compiling, just to express the idea. So it
> > may
> > > leave some places unpatched.
> > > If this is agreed, I will make a decent test to verify it before sending
> > > the patch for RFC.
> > >
> > > diff --git a/lib/librte_distributor/rte_distributor.c
> > > b/lib/librte_distributor/rte_di
> > > index 585ff88..d606bcf 100644
> > > --- a/lib/librte_distributor/rte_distributor.c
> > > +++ b/lib/librte_distributor/rte_distributor.c
> > > @@ -92,6 +92,8 @@ struct rte_distributor {
> > >         unsigned num_workers;                 /**< Number of workers
> > > polling */
> > >
> > >         uint32_t in_flight_tags[RTE_MAX_LCORE];
> > > +       uint32_t in_flight_bitmask;
> > > +
> > >         struct rte_distributor_backlog backlog[RTE_MAX_LCORE];
> > >
> > >         union rte_distributor_buffer bufs[RTE_MAX_LCORE];
> > > @@ -188,6 +190,7 @@ static inline void
> > >  handle_worker_shutdown(struct rte_distributor *d, unsigned wkr)
> > >  {
> > >         d->in_flight_tags[wkr] = 0;
> > > +       d->in_flight_mask &= ~(1 << wkr);
> > >         d->bufs[wkr].bufptr64 = 0;
> > >         if (unlikely(d->backlog[wkr].count != 0)) {
> > >                 /* On return of a packet, we need to move the
> > > @@ -241,6 +244,7 @@ process_returns(struct rte_distributor *d)
> > >                         else {
> > >                                 d->bufs[wkr].bufptr64 =
> > RTE_DISTRIB_GET_BUF;
> > >                                 d->in_flight_tags[wkr] = 0;
> > > +                               d->in_flight_mask &= ~(1 << wkr);
> > >                         }
> > >                         oldbuf = data >> RTE_DISTRIB_FLAG_BITS;
> > >                 } else if (data & RTE_DISTRIB_RETURN_BUF) {
> > > @@ -282,12 +286,13 @@ rte_distributor_process(struct rte_distributor *d,
> > >                         next_mb = mbufs[next_idx++];
> > >                         next_value = (((int64_t)(uintptr_t)next_mb)
> > >                                         << RTE_DISTRIB_FLAG_BITS);
> > > -                       new_tag = (next_mb->hash.rss | 1);
> > > +                       new_tag = next_mb->hash.rss;
> > >
> > >                         uint32_t match = 0;
> > >                         unsigned i;
> > >                         for (i = 0; i < d->num_workers; i++)
> > > -                               match |= (!(d->in_flight_tags[i] ^
> > new_tag)
> > > +                               match |= (((!(d->in_flight_tags[i] ^
> > > new_tag)) &
> > > +                                               (d->in_flight_bitmask >>
> > i))
> >
> > I would not do the bitmask comparison here, as that's extra instruction in
> > the
> > loop. Instead, because its a bitmask, build up the match variable as it was
> > before, and then just do a single and operation afterwards, outside the
> > loop
> > body.
> >
> > /Bruce
> >
> > >                                         << i);
> > >
> > >                         if (match) {
> > > @@ -309,6 +314,7 @@ rte_distributor_process(struct rte_distributor *d,
> > >                         else {
> > >                                 d->bufs[wkr].bufptr64 = next_value;
> > >                                 d->in_flight_tags[wkr] = new_tag;
> > > +                               d->in_flight_bitmask |= 1 << wkr;
> > >                                 next_mb = NULL;
> > >                         }
> > >                         oldbuf = data >> RTE_DISTRIB_FLAG_BITS;
> > >
> > >
> > >
> >

  parent reply	other threads:[~2014-11-07 15:04 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-05 13:30 [PATCH] Add user defined tag calculation callback to librte_distributor Qinglai Xiao
     [not found] ` <1415194237-1219-1-git-send-email-jigsaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-11-05 14:27   ` Bruce Richardson
2014-11-05 15:11     ` jigsaw
     [not found]       ` <CAHVfvh4yAdF-aDnV+sh+PgJpEUW18+aF0=JoZDwJtGHhh=5ZzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-05 16:36         ` Bruce Richardson
2014-11-05 17:24           ` jigsaw
     [not found]             ` <CAHVfvh4X_sUPUzSJTqBdEnkS94t2Jwj_98Vg0xbUS3MPSeo2ZA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-06  9:22               ` Bruce Richardson
2014-11-06 10:14                 ` jigsaw
2014-11-06 10:36                 ` Thomas Monjalon
2014-11-06 12:36                   ` 答复: [PATCH] Add user defined tag calculation callback tolibrte_distributor Qinglai Xiao
     [not found]                     ` <545b6b74.a96db40a.26af.ffffe7fb-ATjtLOhZ0NVl57MIdRCFDg@public.gmane.org>
2014-11-06 13:59                       ` Bruce Richardson
2014-11-06 18:01                         ` jigsaw
     [not found]                           ` <CAHVfvh4U4PZKZSue_kKDQKATC2snb_=10OD08LGmUtieBc_LzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-06 19:52                             ` jigsaw
     [not found]                               ` <CAHVfvh5SzJ-kpQQ9h=1wmMihiitcJXeR9mcNa1in8x6Gb6tSqQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-07  9:45                                 ` Bruce Richardson
2014-11-07 12:38                                   ` jigsaw
     [not found]                                     ` <CAHVfvh6y4f7+bMhzmwOu5c0Y4wzwNaxj4sQPtq8cabGbdHrzXg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-07 13:53                                       ` Bruce Richardson
2014-11-07 14:31                                         ` jigsaw
     [not found]                                           ` <CAHVfvh7ggGB_q1Rs1c3-9PRwDr_GKA+etaMXRSeKCfUKoUx8hQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-07 14:44                                             ` Bruce Richardson
2014-11-07 14:52                                               ` jigsaw
     [not found]                                                 ` <CAHVfvh6HxAVynbvCXFESMfFyHpiaLkgUPwM7eWEjNAF53qJDXg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-07 15:04                                                   ` Bruce Richardson [this message]
2014-11-07 15:18                                                     ` jigsaw
2014-11-06 13:55                   ` [PATCH] distributor: add comments to make code more readable Bruce Richardson
     [not found]                     ` <1415282132-11056-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-11-07 14:08                       ` Thomas Monjalon
2014-11-07 14:31                         ` jigsaw
2014-11-06 13:57                   ` [PATCH] Add user defined tag calculation callback to librte_distributor Bruce Richardson
2014-11-05 15:13     ` Ananyev, Konstantin
     [not found]       ` <2601191342CEEE43887BDE71AB977258213A2938-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-11-05 15:24         ` jigsaw

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=20141107150429.GD12092@bricha3-MOBL3 \
    --to=bruce.richardson-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    --cc=jigsaw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.