On Thursday 19 October 2006 08:57, David Miller wrote:
> Switch to vmalloc() at the kmalloc() cut-off point, just like
> I did for the other hashes in the tree.
Yes, so you basically want option 4) :)
4) Use vmalloc() if size_lopt > PAGE_SIZE
keep a power_of two :
nr_table_entries = 2 ^ X;
size_lopt = sizeof(listen_sock) + nr_table_entries*sizeof(void*);
if (size > PAGE_SIZE)
ptr = vmalloc(size_lopt);
else
ptr = kmalloc(size_lopt);
Pros :
Only under one page is wasted (ie allocated but not used)
vmalloc() is nicer for NUMA, so I am pleased :)
vmalloc() has more chances to succeed when memory is fragmented
keep a power-of-two hash table size
Cons :
TLB cost
// for reference
struct listen_sock {
u8 max_qlen_log;
/* 3 bytes hole, try to use */
int qlen;
int qlen_young;
int clock_hand;
u32 hash_rnd;
u32 nr_table_entries;
struct request_sock *syn_table[0]; /* hash table follow this
header */
};
> BTW, this all reminds me that we need to be careful that this
> isn't allowing arbitrary users to eat up a ton of unswappable
> ram. It's pretty easy to open up a lot of listening sockets :)
With actual somaxconn=128 limit, my patch ends in allocating less ram (half of
a page) than current x86_64 kernel (2 pages)
Thank you
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html