netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [RFC] networking structure holes
Date: Thu, 02 Nov 2006 07:55:59 +0100	[thread overview]
Message-ID: <4549967F.7050505@cosmosbay.com> (raw)
In-Reply-To: <39e6f6c70611011831m3521599boa5a6a77957d143a8@mail.gmail.com>

Arnaldo Carvalho de Melo a écrit :
> On 10/31/06, Eric Dumazet <dada1@cosmosbay.com> wrote:
>> Arnaldo Carvalho de Melo a écrit :
>> > Hi,
>> >
>> >       I've been working on some DWARF2 utilities and one of them,
>> > pahole (Poke-a-Hole) can be used to find holes due to alignment rules
>> > in structs, the full output of:
>> >
>> > [acme@newtoy net-2.6]$ pahole net/ipv4/tcp.o
>> >
>> >       is available at:
>> >
>> > http://oops.merseine.nu:81/acme/net.ipv4.tcp.o.pahole
>> >
>> >       Just to show what we can find with this tool here is the layout
>> > of struct net_device, that barring any cacheline locality optimization
>> > has 4 bytes to harvest, David, do you think reordering those fields to
>> > get 4 byts back is ok?
>>
>> I just want to bring your attention this net_device structure was 
>> re-ordered
>> (by me :)) so that separate cache lines are used on SMP machines.
>>
>> If you select CONFIG_SMP , you'll probably notice far more holes. But 
>> it was a
>> feature, not lazyness.
> 
> Thanks for commenting on this case!
> 
>> We can probably move some fields, but very carefully :)
> 
> Of course, in time I probably will try to combine valgrind's
> cachegrind or some new tool using the same principles I used in OSTRA
> to find out working sets of struct members to do automatic
> "suggestions" on how to reorder structs to avoid holes while keeping
> the relevant struct members close together as to exploit cacheline
> locality effects, like you do so well manually :-)
> 
> - Arnaldo
> 
> PS.: While we don't have tools to check out that the holes are not a
> problem because we want to exploit cacheline locality effects... what
> about some comments on the structs to explain that such holes are not
> a problem? :-)

I am all for automatic tools, if they can convince human beings :)

For example, I am using an optimization that is quite simple but which was not 
accepted by netdev community :

- Moving the struct flowi directly into "struct dst_entry", right after the 
'struct dst_entry *next;' pointer.


AFAIK all objects that include a 'struct dst_entry' also include a 'struct 
flowi', so this is just a small violation of layering.

This really helps because lookups now touch only one cache line per chained 
item instead of two/three. On loaded routers with 8 items per chain, thats 8 
or 16 cache lines CPU dont have to bring in its cache per IP packet.

Eric

      reply	other threads:[~2006-11-02  6:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-31 20:34 [RFC] networking structure holes Arnaldo Carvalho de Melo
2006-10-31 21:04 ` Eric Dumazet
2006-11-02  2:31   ` Arnaldo Carvalho de Melo
2006-11-02  6:55     ` Eric Dumazet [this message]

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=4549967F.7050505@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).