Skip to contentSkip to conversation

per-cpu data in modules.

PATCH New Rusty Russell 1 participant 1 message May 5, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 per-cpu data in modules.

Hi Andrew,

This uses the previous __alloc_percpu patch, to allow per-cpu
data within modules.

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

Name: per-cpu support inside modules
Author: Rusty Russell
Status: Tested on 2.5.69
Depends: Misc/kmalloc_percpu.patch.gz

D: This adds percpu support for modules.

include/linux/module.h +3 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12664-linux-2.5.69/include/linux/module.h .12664-linux-2.5.69.updated/include/linux/module.h
@@ -247,6 +247,9 @@ struct module
 	char *strtab;
 #endif
 
+	/* Per-cpu data. */
+	void *percpu;
+
 	/* The command line arguments (may be mangled).  People like
 	   keeping pointers to this stuff */
 	char *args;
include/linux/percpu.h +0 -5
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12664-linux-2.5.69/include/linux/percpu.h .12664-linux-2.5.69.updated/include/linux/percpu.h
@@ -31,10 +31,8 @@ extern void kfree_percpu(const void *);
 extern unsigned long __per_cpu_offset[NR_CPUS];
 
 /* Separate out the type, so (int[3], foo) works. */
-#ifndef MODULE
 #define DEFINE_PER_CPU(type, name) \
     __attribute__((__section__(".data.percpu"))) __typeof__(type) name##__per_cpu
-#endif
 
 /* var is in discarded region: offset to particular copy we want */
 #define per_cpu(var, cpu) (*RELOC_HIDE(&var##__per_cpu, __per_cpu_offset[cpu]))
@@ -43,11 +41,8 @@ extern unsigned long __per_cpu_offset[NR
 extern void setup_per_cpu_areas(void);
 #else /* !CONFIG_SMP */
 
-/* Can't define per-cpu variables in modules.  Sorry --RR */
-#ifndef MODULE
 #define DEFINE_PER_CPU(type, name) \
     __typeof__(type) name##__per_cpu
-#endif
 
 #define per_cpu(var, cpu)			((void)(cpu), var##__per_cpu)
 #define __get_cpu_var(var)			var##__per_cpu
kernel/module.c +37 -7

101 lines not on this page · raw message