On Thu, Nov 25, 2010 at 11:23:42PM +0100, Mark Kettenis wrote:
> > Date: Thu, 25 Nov 2010 12:30:39 +0000
> > From: Owain Ainsworth <zer...@googlemail.com>
> > 
> > On Thu, Nov 25, 2010 at 11:50:06AM +0100, Claudio Jeker wrote:
> > > On Wed, Nov 24, 2010 at 05:42:59PM +0100, Mike Belopuhov wrote:
> > > > On Wed, Nov 24, 2010 at 17:06 +0100, Claudio Jeker wrote:
> > > > > This diff was made by oga@ some time ago -- I just fixed a few 
> > > > > conflicts
> > > > > and I would really like to see this going in.
> > > > > 
> > > > > netisr needs to be made a normal C function and not this madness it
> > > > > currently is. This is necessary to imporve the packet scheduling.
> > > > > 
> > > > > Tested myself on i386, amd64, sparc64, sparc, alpha and hppa
> > > > 
> > > > hi,
> > > > 
> > > > i like the diff, but why not get rid of netisr_dispatch.h?
> > > 
> > > I planned to this after this diff goes in. I did not want to change
> > > Owain's initial diff too much so I left that out for now.
> > 
> > Miod pointed out to me when I first sent this out that some archs use
> > something slightly different than this generic version.
> > 
> > For example hppa uses a specially aligned netisr variable so it can use
> > the pa-risc real atomic instructions which are quite a bit faster.
> 
> Especially on MP kernels.
> 
> > Similarly x86 uses compare-and-swap instead of test, then clear bits.
> > 
> > I meant to add some MD defines so that this could be kept (falling back
> > to the implementation in this diff)  since miod claims that it is useful
> > and significantly faster (I did not check this). I've cced miod so he
> > can answer with somewhat more authority.
> 
> The hppa and i386/amd64 approach are rather similar.  Both do an
> atomic load and clear, which happens to be the only atomic instruction
> available on hppa, and is easy to implement as an atomic swap with 0
> on i386/amd64.  But implementing this operation on other architectures
> shouldn't be much more difficult, and should work just as well as the
> proposed code that uses atomic_clearbits_int().  The MI code would
> look something like:
> 
> void
> netintr(void *unused)
> {
>       int n;
> 
>       n = atomic_load_and_clear(&netisr);
> #define DONETISR(bit, fn)                     \
>               do {                            \
>                       if (n & 1 << (bit))     \
>                               fn();           \
>               } while ( /* CONSTCOND */ 0)
> #include <net/netisr_dispatch.h>
> }

The only other thing to note is that you may need to define a type (or
whatever) since iirc the hppa one needs a specific alignment (cacheline
to itself).

Otherwise I like this approach, it is cleaner than what I was thinking
(not knowing exactly what hppa was doing other than it was faster didn't
help ;).

-0-
-- 
Sometimes I worry about being a success in a mediocre world.
                -- Lily Tomlin

Reply via email to