per-cpu sections inside modules
Subsystems (5)
Requires the last 4 patches.
Name: per-cpu support inside modules
Author: Rusty Russell
Status: Tested on 2.5.69-bk13
Depends: Misc/kmalloc_percpu-full.patch.gz
D: This adds percpu support for modules.
include/asm-generic/percpu.h +0 -2
@@ -5,10 +5,8 @@#ifdef CONFIG_SMP /* 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 #define __get_cpu_var (var) per_cpu(var, smp_processor_id())#define __get_cpu_ptr (ptr) per_cpu_ptr(ptr, smp_processor_id())
include/asm-ia64/percpu.h +0 -2
@@ -18,10 +18,8 @@#include <linux/threads.h> #ifdef CONFIG_SMP -#ifndef MODULE #define DEFINE_PER_CPU (type, name) \ __attribute__((__section__(".data.percpu"))) __typeof__(type) name##__per_cpu -#endif #define __get_cpu_var (var) (var##__per_cpu)#define __get_cpu_ptr (ptr) (ptr)
include/linux/module.h +3 -0
@@ -247,6 +247,9 @@ struct modulechar *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 -3
@@ -44,11 +44,8 @@ static inline void free_percpu(const voikfree (ptr); } -/* 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
net/ipv4/netfilter/ip_conntrack_core.c +12 -0
@@ -1402,11 +1402,23 @@ void ip_conntrack_cleanup(void)static int hashsize =0 ;MODULE_PARM (hashsize,"i" ); +#include <linux/percpu.h> +DEFINE_PER_CPU (int, percpu_int) =7 ; +int __init ip_conntrack_init (void ) {unsigned int i;int ret; +for (i =0 ; i <NR_CPUS ; i++) { +if (!cpu_possible (i)) +continue ; +printk ("cpu %u: value %p = %i\n" , i, &per_cpu (percpu_int, i), +per_cpu (percpu_int, i)); +per_cpu (percpu_int, i) += i; +printk ("cpu %u: value now %i\n" , i,per_cpu (percpu_int, i)); + } +/* Idea from tcp.c: use 1/16384 of memory. On i386: 32MB * machine has 256 buckets. >= 1GB machines have 8192 buckets. */ if (hashsize) {
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.