* [IPSEC] flow : NUMA aware hash table allocation
@ 2008-01-01 12:44 Eric Dumazet
2008-01-02 3:23 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2008-01-01 12:44 UTC (permalink / raw)
To: David S. Miller; +Cc: Linux Netdev List
[-- Attachment #1: Type: text/plain, Size: 530 bytes --]
Using __get_free_pages() has some drawbacks :
1) Not NUMA aware
2) 2^X page granularity :
On arches with big PAGE_SIZE, we waste some ram for each cpu.
(We currently use 1024 pointers, that is at most 8192 bytes, but
PAGE_SIZE can be 65536 for example : With say 64 possible cpus,
thats about 56*64 Kbytes that are wasted)
Using kmalloc_node() can help to solve these two points.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
net/core/flow.c | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)
[-- Attachment #2: flow.patch --]
[-- Type: text/plain, Size: 886 bytes --]
diff --git a/net/core/flow.c b/net/core/flow.c
index a618f89..bcbbe2d 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -311,18 +311,13 @@ void flow_cache_flush(void)
static void __devinit flow_cache_cpu_prepare(int cpu)
{
struct tasklet_struct *tasklet;
- unsigned long order;
- for (order = 0;
- (PAGE_SIZE << order) <
- (sizeof(struct flow_cache_entry *)*flow_hash_size);
- order++)
- /* NOTHING */;
-
- flow_table(cpu) = (struct flow_cache_entry **)
- __get_free_pages(GFP_KERNEL|__GFP_ZERO, order);
+ flow_table(cpu) = kmalloc_node(
+ sizeof(struct flow_cache_entry *) * flow_hash_size,
+ GFP_KERNEL | __GFP_ZERO,
+ cpu_to_node(cpu));
if (!flow_table(cpu))
- panic("NET: failed to allocate flow cache order %lu\n", order);
+ panic("NET: failed to allocate flow cache for cpu %d\n", cpu);
flow_hash_rnd_recalc(cpu) = 1;
flow_count(cpu) = 0;
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [IPSEC] flow : NUMA aware hash table allocation
2008-01-01 12:44 [IPSEC] flow : NUMA aware hash table allocation Eric Dumazet
@ 2008-01-02 3:23 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2008-01-02 3:23 UTC (permalink / raw)
To: dada1; +Cc: netdev
From: Eric Dumazet <dada1@cosmosbay.com>
Date: Tue, 01 Jan 2008 13:44:15 +0100
> Using __get_free_pages() has some drawbacks :
>
> 1) Not NUMA aware
>
> 2) 2^X page granularity :
> On arches with big PAGE_SIZE, we waste some ram for each cpu.
>
> (We currently use 1024 pointers, that is at most 8192 bytes, but
> PAGE_SIZE can be 65536 for example : With say 64 possible cpus,
> thats about 56*64 Kbytes that are wasted)
>
> Using kmalloc_node() can help to solve these two points.
>
> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Applied, thanks Eric.
It reminds me that flow_hash_shift should at some point be dynamically
sized. However, currently the flow cache isn't so heavily used and
there are more important fish to fry right now.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-01-02 3:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-01 12:44 [IPSEC] flow : NUMA aware hash table allocation Eric Dumazet
2008-01-02 3:23 ` David Miller
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).