lkml.org 
[lkml]   [2006]   [Jan]   [5]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateThu, 05 Jan 2006 14:49:58 +0100
FromEric Dumazet <>
Subject[PATCH] reduce sizeof(percpu_data) and removes dependance against NR_CPUS
Hi Andrew

Current sizeof(percpu_data) is NR_CPUS*sizeof(void *)

This trivial patch makes percpu_data real size depends on 
highest_possible_processor_id() instead of NR_CPUS

percpu_data allocations are not performance critical, we can spend few CPU 
cycles and save some ram.

This patch should replace remove-unused-blkp-field-in-percpu_data.patch in mm tree

Thank you

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

--- linux-2.6.15/include/linux/percpu.h	2006-01-03 04:21:10.000000000 +0100
+++ linux-2.6.15-edum/include/linux/percpu.h	2006-01-05 14:45:48.000000000 +0100
@@ -18,8 +18,7 @@
 #ifdef CONFIG_SMP
 
 struct percpu_data {
-	void *ptrs[NR_CPUS];
-	void *blkp;
+	void *ptrs[1]; /* real size depends on highest_possible_processor_id() */
 };
 
 /* 
--- linux-2.6.15/mm/slab.c	2006-01-03 04:21:10.000000000 +0100
+++ linux-2.6.15-edum/mm/slab.c	2006-01-05 14:37:13.000000000 +0100
@@ -2949,7 +2949,8 @@
 void *__alloc_percpu(size_t size, size_t align)
 {
 	int i;
-	struct percpu_data *pdata = kmalloc(sizeof (*pdata), GFP_KERNEL);
+	size_t pdsize = highest_possible_processor_id() * sizeof(void *);
+	struct percpu_data *pdata = kmalloc(pdsize, GFP_KERNEL);
 
 	if (!pdata)
 		return NULL;
\
 
 \ /
  Last update: 2006-01-05 13:52    [from the cache]
©2003-2008