Skip to contentSkip to conversation

Per-cpu variable in mm/slab.c

PATCH New Rusty Russell 1 participant 1 message Jul 3, 2003 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Per-cpu variable in mm/slab.c

Linus, please apply. From Zwane.

Name: Make slab.c reap_timers per-cpu
Author: Zwane Mwaikambo
Status: Tested on 2.5.73

D: Rather trivial conversion. Tested on SMP.

Index: linux-2.5/mm/slab.c
===================================================================
RCS file: /home/cvs/linux-2.5/mm/slab.c,v
retrieving revision 1.91

mm/slab.c +3 -3
diff -u -p -B -r1.91 slab.c
@@ -441,7 +441,7 @@ enum {
 	FULL
 } g_cpucache_up;
 
-static struct timer_list reap_timers[NR_CPUS];
+static DEFINE_PER_CPU(struct timer_list, reap_timers);
 
 static void reap_timer_fnc(unsigned long data);
 
@@ -491,7 +491,7 @@ static void __slab_error(const char *fun
  */
 static void start_cpu_timer(int cpu)
 {
-	struct timer_list *rt = &reap_timers[cpu];
+	struct timer_list *rt = &per_cpu(reap_timers, cpu);
 
 	if (rt->function == NULL) {
 		init_timer(rt);
@@ -2382,7 +2382,7 @@ next:
 static void reap_timer_fnc(unsigned long data)
 {
 	int cpu = smp_processor_id();
-	struct timer_list *rt = &reap_timers[cpu];
+	struct timer_list *rt = &__get_cpu_var(reap_timers);
 
 	cache_reap();
 	mod_timer(rt, jiffies + REAPTIMEOUT_CPUC + cpu);

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.