netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: dada1@cosmosbay.com
Cc: linux@horizon.com, akepner@sgi.com, netdev@vger.kernel.org
Subject: Re: [PATCH] NET : change layout of ehash table
Date: Thu, 08 Feb 2007 14:56:32 -0800 (PST)	[thread overview]
Message-ID: <20070208.145632.74749802.davem@davemloft.net> (raw)
In-Reply-To: <200702071159.34935.dada1@cosmosbay.com>

From: Eric Dumazet <dada1@cosmosbay.com>
Date: Wed, 7 Feb 2007 11:59:34 +0100

> ehash table layout is currently this one :
> 
> First half of this table is used by sockets not in TIME_WAIT state
> Second half of it is used by sockets in TIME_WAIT state.
> 
> This is non optimal because of for a given hash or socket, the two chain heads 
> are located in separate cache lines.
> Moreover the locks of the second half are never used.
> 
> If instead of this halving, we use two list heads in inet_ehash_bucket instead 
> of only one, we probably can avoid one cache miss, and reduce ram usage, 
> particularly if sizeof(rwlock_t) is big (various CONFIG_DEBUG_SPINLOCK, 
> CONFIG_DEBUG_LOCK_ALLOC settings). So we still halves the table but we keep 
> together related chains to speedup lookups and socket state change.
> 
> In this patch I did not try to align struct inet_ehash_bucket, but a future 
> patch could try to make this structure have a convenient size (a power of two 
> or a multiple of L1_CACHE_SIZE).
> I guess rwlock will just vanish as soon as RCU is plugged into ehash :) , so 
> maybe we dont need to scratch our heads to align the bucket...
> 
> Note : In case struct inet_ehash_bucket is not a power of two, we could 
> probably change alloc_large_system_hash() (in case it use __get_free_pages()) 
> to free the unused space. It currently allocates a big zone, but the last 
> quarter of it could be freed. Again, this should be a temporary 'problem'.
> 
> Patch tested on ipv4 tcp only, but should be OK for IPV6 and DCCP.
> 
> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

I've applied this, but I _REALLY_ don't like the new multiply
instructions that are used now in the hash indexing paths when
CONFIG_SMP is set.

I think that's a higher cost than the memory waste.

  reply	other threads:[~2007-02-08 22:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-19  8:56 [PATCH] irlan: handle out of memory errors Akinobu Mita
2006-12-19 22:47 ` Samuel Ortiz
2007-02-07  8:12   ` David Miller
2007-02-07 10:59     ` [PATCH] NET : change layout of ehash table Eric Dumazet
2007-02-08 22:56       ` David Miller [this message]
2007-02-09  9:18         ` Andi Kleen
2007-02-09  8:40           ` David Miller
2007-02-09  8:57             ` Andi Kleen
2007-02-09  9:06             ` Eric Dumazet
2007-02-09  9:15               ` David Miller
2007-02-09  9:36                 ` Eric Dumazet
2007-02-09  9:43                   ` David Miller
2007-02-09 10:10                     ` Andi Kleen
2007-02-09 17:44                     ` [PATCH] NET : UDP can use sk_hash to speedup lookups Eric Dumazet
2007-02-09 23:45                       ` 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=20070208.145632.74749802.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=akepner@sgi.com \
    --cc=dada1@cosmosbay.com \
    --cc=linux@horizon.com \
    --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).