diff options
author | Christoph Lameter <christoph@lameter.com> | 2005-07-07 20:56:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-07 21:23:46 -0400 |
commit | 6c036527a630720063b67d9a65455e8caca2c8fa (patch) | |
tree | 316e947f5f4efcda0205e48044ed1d12665eaed1 | |
parent | 0db925af1db5f3dfe1691c35b39496e2baaff9c9 (diff) |
[PATCH] mostly_read data section
Add a new section called ".data.read_mostly" for data items that are read
frequently and rarely written to like cpumaps etc.
If these maps are placed in the .data section then these frequenly read
items may end up in cachelines with data is is frequently updated. In that
case all processors in an SMP system must needlessly reload the cachelines
again and again containing elements of those frequently used variables.
The ability to share these cachelines will allow each cpu in an SMP system
to keep local copies of those shared cachelines thereby optimizing
performance.
Signed-off-by: Alok N Kataria <alokk@calsoftinc.com>
Signed-off-by: Shobhit Dayal <shobhit@calsoftinc.com>
Signed-off-by: Christoph Lameter <christoph@scalex86.org>
Signed-off-by: Shai Fultheim <shai@scalex86.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/i386/kernel/cpu/intel.c | 2 | ||||
-rw-r--r-- | arch/i386/kernel/smpboot.c | 18 | ||||
-rw-r--r-- | arch/i386/kernel/time.c | 2 | ||||
-rw-r--r-- | arch/i386/kernel/timers/timer_hpet.c | 4 | ||||
-rw-r--r-- | arch/i386/kernel/vmlinux.lds.S | 3 | ||||
-rw-r--r-- | arch/x86_64/kernel/vmlinux.lds.S | 4 | ||||
-rw-r--r-- | drivers/char/random.c | 2 | ||||
-rw-r--r-- | fs/bio.c | 2 | ||||
-rw-r--r-- | include/linux/cache.h | 6 | ||||
-rw-r--r-- | kernel/profile.c | 4 | ||||
-rw-r--r-- | lib/radix-tree.c | 2 |
11 files changed, 31 insertions, 18 deletions
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c index 96a75d045835..a2c33c1a46c5 100644 --- a/arch/i386/kernel/cpu/intel.c +++ b/arch/i386/kernel/cpu/intel.c | |||
@@ -25,7 +25,7 @@ extern int trap_init_f00f_bug(void); | |||
25 | /* | 25 | /* |
26 | * Alignment at which movsl is preferred for bulk memory copies. | 26 | * Alignment at which movsl is preferred for bulk memory copies. |
27 | */ | 27 | */ |
28 | struct movsl_mask movsl_mask; | 28 | struct movsl_mask movsl_mask __read_mostly; |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | void __devinit early_intel_workaround(struct cpuinfo_x86 *c) | 31 | void __devinit early_intel_workaround(struct cpuinfo_x86 *c) |
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index d66bf489a2e9..8ac8e9fd5614 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c | |||
@@ -68,21 +68,21 @@ EXPORT_SYMBOL(smp_num_siblings); | |||
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | /* Package ID of each logical CPU */ | 70 | /* Package ID of each logical CPU */ |
71 | int phys_proc_id[NR_CPUS] = {[0 ... NR_CPUS-1] = BAD_APICID}; | 71 | int phys_proc_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID}; |
72 | EXPORT_SYMBOL(phys_proc_id); | 72 | EXPORT_SYMBOL(phys_proc_id); |
73 | 73 | ||
74 | /* Core ID of each logical CPU */ | 74 | /* Core ID of each logical CPU */ |
75 | int cpu_core_id[NR_CPUS] = {[0 ... NR_CPUS-1] = BAD_APICID}; | 75 | int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID}; |
76 | EXPORT_SYMBOL(cpu_core_id); | 76 | EXPORT_SYMBOL(cpu_core_id); |
77 | 77 | ||
78 | cpumask_t cpu_sibling_map[NR_CPUS]; | 78 | cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly; |
79 | EXPORT_SYMBOL(cpu_sibling_map); | 79 | EXPORT_SYMBOL(cpu_sibling_map); |
80 | 80 | ||
81 | cpumask_t cpu_core_map[NR_CPUS]; | 81 | cpumask_t cpu_core_map[NR_CPUS] __read_mostly; |
82 | EXPORT_SYMBOL(cpu_core_map); | 82 | EXPORT_SYMBOL(cpu_core_map); |
83 | 83 | ||
84 | /* bitmap of online cpus */ | 84 | /* bitmap of online cpus */ |
85 | cpumask_t cpu_online_map; | 85 | cpumask_t cpu_online_map __read_mostly; |
86 | EXPORT_SYMBOL(cpu_online_map); | 86 | EXPORT_SYMBOL(cpu_online_map); |
87 | 87 | ||
88 | cpumask_t cpu_callin_map; | 88 | cpumask_t cpu_callin_map; |
@@ -100,7 +100,7 @@ static int __devinitdata tsc_sync_disabled; | |||
100 | struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned; | 100 | struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned; |
101 | EXPORT_SYMBOL(cpu_data); | 101 | EXPORT_SYMBOL(cpu_data); |
102 | 102 | ||
103 | u8 x86_cpu_to_apicid[NR_CPUS] = | 103 | u8 x86_cpu_to_apicid[NR_CPUS] __read_mostly = |
104 | { [0 ... NR_CPUS-1] = 0xff }; | 104 | { [0 ... NR_CPUS-1] = 0xff }; |
105 | EXPORT_SYMBOL(x86_cpu_to_apicid); | 105 | EXPORT_SYMBOL(x86_cpu_to_apicid); |
106 | 106 | ||
@@ -550,10 +550,10 @@ extern struct { | |||
550 | #ifdef CONFIG_NUMA | 550 | #ifdef CONFIG_NUMA |
551 | 551 | ||
552 | /* which logical CPUs are on which nodes */ | 552 | /* which logical CPUs are on which nodes */ |
553 | cpumask_t node_2_cpu_mask[MAX_NUMNODES] = | 553 | cpumask_t node_2_cpu_mask[MAX_NUMNODES] __read_mostly = |
554 | { [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE }; | 554 | { [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE }; |
555 | /* which node each logical CPU is on */ | 555 | /* which node each logical CPU is on */ |
556 | int cpu_2_node[NR_CPUS] = { [0 ... NR_CPUS-1] = 0 }; | 556 | int cpu_2_node[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0 }; |
557 | EXPORT_SYMBOL(cpu_2_node); | 557 | EXPORT_SYMBOL(cpu_2_node); |
558 | 558 | ||
559 | /* set up a mapping between cpu and node. */ | 559 | /* set up a mapping between cpu and node. */ |
@@ -581,7 +581,7 @@ static inline void unmap_cpu_to_node(int cpu) | |||
581 | 581 | ||
582 | #endif /* CONFIG_NUMA */ | 582 | #endif /* CONFIG_NUMA */ |
583 | 583 | ||
584 | u8 cpu_2_logical_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID }; | 584 | u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID }; |
585 | 585 | ||
586 | static void map_cpu_to_logical_apicid(void) | 586 | static void map_cpu_to_logical_apicid(void) |
587 | { | 587 | { |
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c index 2854c357377f..0ee9dee8af06 100644 --- a/arch/i386/kernel/time.c +++ b/arch/i386/kernel/time.c | |||
@@ -91,7 +91,7 @@ EXPORT_SYMBOL(rtc_lock); | |||
91 | DEFINE_SPINLOCK(i8253_lock); | 91 | DEFINE_SPINLOCK(i8253_lock); |
92 | EXPORT_SYMBOL(i8253_lock); | 92 | EXPORT_SYMBOL(i8253_lock); |
93 | 93 | ||
94 | struct timer_opts *cur_timer = &timer_none; | 94 | struct timer_opts *cur_timer __read_mostly = &timer_none; |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * This is a special lock that is owned by the CPU and holds the index | 97 | * This is a special lock that is owned by the CPU and holds the index |
diff --git a/arch/i386/kernel/timers/timer_hpet.c b/arch/i386/kernel/timers/timer_hpet.c index d766e0963ac1..ef8dac5dd33b 100644 --- a/arch/i386/kernel/timers/timer_hpet.c +++ b/arch/i386/kernel/timers/timer_hpet.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include "mach_timer.h" | 18 | #include "mach_timer.h" |
19 | #include <asm/hpet.h> | 19 | #include <asm/hpet.h> |
20 | 20 | ||
21 | static unsigned long hpet_usec_quotient; /* convert hpet clks to usec */ | 21 | static unsigned long __read_mostly hpet_usec_quotient; /* convert hpet clks to usec */ |
22 | static unsigned long tsc_hpet_quotient; /* convert tsc to hpet clks */ | 22 | static unsigned long tsc_hpet_quotient; /* convert tsc to hpet clks */ |
23 | static unsigned long hpet_last; /* hpet counter value at last tick*/ | 23 | static unsigned long hpet_last; /* hpet counter value at last tick*/ |
24 | static unsigned long last_tsc_low; /* lsb 32 bits of Time Stamp Counter */ | 24 | static unsigned long last_tsc_low; /* lsb 32 bits of Time Stamp Counter */ |
@@ -180,7 +180,7 @@ static int __init init_hpet(char* override) | |||
180 | /************************************************************/ | 180 | /************************************************************/ |
181 | 181 | ||
182 | /* tsc timer_opts struct */ | 182 | /* tsc timer_opts struct */ |
183 | static struct timer_opts timer_hpet = { | 183 | static struct timer_opts timer_hpet __read_mostly = { |
184 | .name = "hpet", | 184 | .name = "hpet", |
185 | .mark_offset = mark_offset_hpet, | 185 | .mark_offset = mark_offset_hpet, |
186 | .get_offset = get_offset_hpet, | 186 | .get_offset = get_offset_hpet, |
diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S index 7e01a528a83a..761972f8cb6c 100644 --- a/arch/i386/kernel/vmlinux.lds.S +++ b/arch/i386/kernel/vmlinux.lds.S | |||
@@ -57,6 +57,9 @@ SECTIONS | |||
57 | *(.data.cacheline_aligned) | 57 | *(.data.cacheline_aligned) |
58 | } | 58 | } |
59 | 59 | ||
60 | /* rarely changed data like cpu maps */ | ||
61 | . = ALIGN(32); | ||
62 | .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { *(.data.read_mostly) } | ||
60 | _edata = .; /* End of data section */ | 63 | _edata = .; /* End of data section */ |
61 | 64 | ||
62 | . = ALIGN(THREAD_SIZE); /* init_task */ | 65 | . = ALIGN(THREAD_SIZE); /* init_task */ |
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S index 73389f51c4e5..61c12758ca70 100644 --- a/arch/x86_64/kernel/vmlinux.lds.S +++ b/arch/x86_64/kernel/vmlinux.lds.S | |||
@@ -56,6 +56,10 @@ SECTIONS | |||
56 | .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) { | 56 | .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) { |
57 | *(.data.cacheline_aligned) | 57 | *(.data.cacheline_aligned) |
58 | } | 58 | } |
59 | . = ALIGN(CONFIG_X86_L1_CACHE_BYTES); | ||
60 | .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { | ||
61 | *(.data.read_mostly) | ||
62 | } | ||
59 | 63 | ||
60 | #define VSYSCALL_ADDR (-10*1024*1024) | 64 | #define VSYSCALL_ADDR (-10*1024*1024) |
61 | #define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.cacheline_aligned) + SIZEOF(.data.cacheline_aligned) + 4095) & ~(4095)) | 65 | #define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.cacheline_aligned) + SIZEOF(.data.cacheline_aligned) + 4095) & ~(4095)) |
diff --git a/drivers/char/random.c b/drivers/char/random.c index 460b5d475edd..6b11d6b2129f 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -271,7 +271,7 @@ static int random_write_wakeup_thresh = 128; | |||
271 | * samples to avoid wasting CPU time and reduce lock contention. | 271 | * samples to avoid wasting CPU time and reduce lock contention. |
272 | */ | 272 | */ |
273 | 273 | ||
274 | static int trickle_thresh = INPUT_POOL_WORDS * 28; | 274 | static int trickle_thresh __read_mostly = INPUT_POOL_WORDS * 28; |
275 | 275 | ||
276 | static DEFINE_PER_CPU(int, trickle_count) = 0; | 276 | static DEFINE_PER_CPU(int, trickle_count) = 0; |
277 | 277 | ||
@@ -52,7 +52,7 @@ struct biovec_slab { | |||
52 | */ | 52 | */ |
53 | 53 | ||
54 | #define BV(x) { .nr_vecs = x, .name = "biovec-"__stringify(x) } | 54 | #define BV(x) { .nr_vecs = x, .name = "biovec-"__stringify(x) } |
55 | static struct biovec_slab bvec_slabs[BIOVEC_NR_POOLS] = { | 55 | static struct biovec_slab bvec_slabs[BIOVEC_NR_POOLS] __read_mostly = { |
56 | BV(1), BV(4), BV(16), BV(64), BV(128), BV(BIO_MAX_PAGES), | 56 | BV(1), BV(4), BV(16), BV(64), BV(128), BV(BIO_MAX_PAGES), |
57 | }; | 57 | }; |
58 | #undef BV | 58 | #undef BV |
diff --git a/include/linux/cache.h b/include/linux/cache.h index 4d767b93738a..2b66a36d85f0 100644 --- a/include/linux/cache.h +++ b/include/linux/cache.h | |||
@@ -13,6 +13,12 @@ | |||
13 | #define SMP_CACHE_BYTES L1_CACHE_BYTES | 13 | #define SMP_CACHE_BYTES L1_CACHE_BYTES |
14 | #endif | 14 | #endif |
15 | 15 | ||
16 | #ifdef CONFIG_X86 | ||
17 | #define __read_mostly __attribute__((__section__(".data.read_mostly"))) | ||
18 | #else | ||
19 | #define __read_mostly | ||
20 | #endif | ||
21 | |||
16 | #ifndef ____cacheline_aligned | 22 | #ifndef ____cacheline_aligned |
17 | #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES))) | 23 | #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES))) |
18 | #endif | 24 | #endif |
diff --git a/kernel/profile.c b/kernel/profile.c index ad8cbb75ffa2..f89248e6d704 100644 --- a/kernel/profile.c +++ b/kernel/profile.c | |||
@@ -35,11 +35,11 @@ struct profile_hit { | |||
35 | #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ) | 35 | #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ) |
36 | 36 | ||
37 | /* Oprofile timer tick hook */ | 37 | /* Oprofile timer tick hook */ |
38 | int (*timer_hook)(struct pt_regs *); | 38 | int (*timer_hook)(struct pt_regs *) __read_mostly; |
39 | 39 | ||
40 | static atomic_t *prof_buffer; | 40 | static atomic_t *prof_buffer; |
41 | static unsigned long prof_len, prof_shift; | 41 | static unsigned long prof_len, prof_shift; |
42 | static int prof_on; | 42 | static int prof_on __read_mostly; |
43 | static cpumask_t prof_cpu_mask = CPU_MASK_ALL; | 43 | static cpumask_t prof_cpu_mask = CPU_MASK_ALL; |
44 | #ifdef CONFIG_SMP | 44 | #ifdef CONFIG_SMP |
45 | static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits); | 45 | static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits); |
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 04d664377f2c..10bed1c8c3c3 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
@@ -58,7 +58,7 @@ struct radix_tree_path { | |||
58 | #define RADIX_TREE_INDEX_BITS (8 /* CHAR_BIT */ * sizeof(unsigned long)) | 58 | #define RADIX_TREE_INDEX_BITS (8 /* CHAR_BIT */ * sizeof(unsigned long)) |
59 | #define RADIX_TREE_MAX_PATH (RADIX_TREE_INDEX_BITS/RADIX_TREE_MAP_SHIFT + 2) | 59 | #define RADIX_TREE_MAX_PATH (RADIX_TREE_INDEX_BITS/RADIX_TREE_MAP_SHIFT + 2) |
60 | 60 | ||
61 | static unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH]; | 61 | static unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH] __read_mostly; |
62 | 62 | ||
63 | /* | 63 | /* |
64 | * Radix tree node cache. | 64 | * Radix tree node cache. |