From: Eric Dumazet <dada1@cosmosbay.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] [NET] Size listen hash tables using backlog hint
Date: Thu, 19 Oct 2006 07:12:58 +0200 [thread overview]
Message-ID: <4537095A.9010705@cosmosbay.com> (raw)
In-Reply-To: <20061018.203109.63997999.davem@davemloft.net>
David Miller a écrit :
> From: Eric Dumazet Hi <dada1@cosmosbay.com>
> Date: Tue, 17 Oct 2006 14:58:37 +0200
>
>> reqsk_queue_alloc() goal is to use a power of two size for the whole
>> listen_sock structure, to avoid wasting memory for large backlogs,
>> meaning the hash table nr_table_entries is not anymore a power of
>> two. (Hence one AND (nr_table_entries - 1) must be replaced by
>> MODULO nr_table_entries)
>
> Modulus can be very expensive for some small/slow cpus. Please round
> down to a power-of-2 instead of up if you think the wastage really
> matters.
>
> Thanks.
I am not sure I understand your points. Rounding up or down still need the
modulus. Only the size changes by a two factor. I feel you want me to remove
the modulus, thats unrelated to rounding.
A 66 MHz 486 can perform 1.000.000 divisions per second. Is it a 'slow' cpu ?
If we stay with a power-of-two, say 2^X hash slots, using (2^X)*sizeof(void*),
the extra bits added by struct listen_sock will *need* the same amount of
memory, because of kmalloc() alignment to next power-of-two. That basically
wastes half of the ram taken by struct listen_sock allocation, unless we add
yet another pointer to hash table and do two kmallocs(), one for pure
power-of-two hash table, one for struct listen_sock. If we keep current
scheme, the current max kmalloc size of 131072 bytes would limit us to 65536
bytes for the hash table itself, so 8192 slots on 64bits platforms. I was
expecting to use a 16380 slots hash size instead.
The modulus is done on two places :
inet_csk_search_req() : called from tcp_v4_err()/dccp_v4_err() only after
checks. Frequency of such events is rather low.
tcp_v4_hnd_req() : called from tcp_v4_do_rcv() for TCP_LISTEN state. Frequency
of such events is rather low, especially on machines driven by small/slow cpus...
inet_csk_reqsk_queue_hash_add()called from tcp_v4_conn_request() when a new
connection attempt is stored in hash table.
Thats in normal conditions two modulus done per new tcp/dccp sessions
establishments. In DOS situation, I doubt the extra cycles will do any difference.
So... what do you prefer :
1) Keep the modulus
2) allocate two blocks of ram (powser-of -two hash size, but one extra
indirection)
3) waste near half of ram because one block allocated, and power-of-two hash size.
Thank you
Eric
next prev parent reply other threads:[~2006-10-19 5:12 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-17 0:53 [PATCH] Bound TSO defer time (resend) John Heffner
2006-10-17 3:20 ` Stephen Hemminger
2006-10-17 4:18 ` John Heffner
2006-10-17 5:35 ` David Miller
2006-10-17 12:22 ` John Heffner
2006-10-19 3:39 ` David Miller
2006-10-17 12:58 ` [PATCH] [NET] Size listen hash tables using backlog hint Eric Dumazet Hi
2006-10-18 7:38 ` [PATCH] [NET] inet_peer : group together avl_left, avl_right, v4daddr to speedup lookups on some CPUS Eric Dumazet
2006-10-18 16:35 ` [PATCH] [NET] reduce per cpu ram used for loopback stats Eric Dumazet
2006-10-18 17:00 ` [PATCH, resent] " Eric Dumazet
2006-10-19 3:53 ` David Miller
2006-10-19 3:53 ` [PATCH] " David Miller
2006-10-19 3:44 ` [PATCH] [NET] inet_peer : group together avl_left, avl_right, v4daddr to speedup lookups on some CPUS David Miller
2006-10-19 10:57 ` Eric Dumazet
2006-10-19 15:45 ` [PATCH] [NET] One NET_INC_STATS() could be NET_INC_STATS_BH in tcp_v4_err() Eric Dumazet
2006-10-20 7:22 ` David Miller
2006-10-20 14:21 ` Arnaldo Carvalho de Melo
2006-10-20 7:28 ` [PATCH] [NET] inet_peer : group together avl_left, avl_right, v4daddr to speedup lookups on some CPUS David Miller
2006-10-19 3:31 ` [PATCH] [NET] Size listen hash tables using backlog hint David Miller
2006-10-19 4:54 ` Stephen Hemminger
2006-10-19 5:08 ` David Miller
2006-10-19 5:12 ` Eric Dumazet [this message]
2006-10-19 6:12 ` David Miller
2006-10-19 6:34 ` Eric Dumazet
2006-10-19 6:57 ` David Miller
2006-10-19 8:29 ` Eric Dumazet
2006-10-19 8:41 ` David Miller
2006-10-19 9:11 ` Eric Dumazet
2006-10-19 9:27 ` Eric Dumazet
2006-10-20 7:27 ` David Miller
2006-10-18 15:37 ` [PATCH] Bound TSO defer time (resend) Andi Kleen
2006-10-18 16:40 ` Stephen Hemminger
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=4537095A.9010705@cosmosbay.com \
--to=dada1@cosmosbay.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).