Support for __read_mostly
cover Support for __read_mostly
This patch set adds support for __read_mostly - a separate section which is used to hold data which is hardly ever written.
The idea behind this feature is to reduce the amount of cache line bouncing between SMP cores by avoiding this data sharing cache lines with data which is written more frequently. As long as a cache line is not dirtied, several cores can keep a copy of the data in their caches.
PATCH 1/2 ARM: implement support for read-mostly sections
As our SMP implementation uses MESI protocols. Grouping together data which is mostly only read together means that we avoid unnecessary cache line bouncing when this code shares a cache line with other data.
In other words, cache lines associated with read-mostly data are expected to spend most of their time in shared state.
--- arch/arm/include/asm/cache.h | 2 ++ arch/arm/kernel/vmlinux.lds.S | 1 + 2 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/include/asm/cache.h +2 -0
@@ -23,4 +23,6 @@#define ARCH_SLAB_MINALIGN 8#endif +#define __read_mostly __attribute__((__section__(".data..read_mostly"))) +#endif
arch/arm/kernel/vmlinux.lds.S +1 -0
@@ -167,6 +167,7 @@ SECTIONS NOSAVE_DATA CACHELINE_ALIGNED_DATA(32) + READ_MOSTLY_DATA(32) /* * The exception fixup table (might need resorting at runtime)
Signature · 1 line
1.6.2.5
PATCH 1/2 ARM: implement support for read-mostly sections
Quoted 30 lines · Russell King - ARM Linux
As our SMP implementation uses MESI protocols. ?Grouping together data which is mostly only read together means that we avoid unnecessary cache line bouncing when this code shares a cache line with other data.
In other words, cache lines associated with read-mostly data are expected to spend most of their time in shared state.
Signed-off-by Russell King <[email protected]>---
?arch/arm/include/asm/cache.h ?| ? ?2 ++
?arch/arm/kernel/vmlinux.lds.S | ? ?1 +
?2 files changed, 3 insertions(+), 0 deletions(-)arch/arm/include/asm/cache.h +0
-0@@ -23,4 +23,6 @@?#define
ARCH_SLAB_MINALIGN8
?#endifarch/arm/include/asm/cache.h +2
-0+#define __read_mostly __attribute__((__section__(".data..read_mostly"))) +?#endif
arch/arm/kernel/vmlinux.lds.S +0
-0@@ -167,6 +167,7 @@ SECTIONS
Quoted 3 lines
? ? ? ? ? ? ? ?NOSAVE_DATA
? ? ? ? ? ? ? ?CACHELINE_ALIGNED_DATA(32)
+ ? ? ? ? ? ? ?READ_MOSTLY_DATA(32)
Should we change the alignments to 64?
Signature · 1 line
Catalin
PATCH 1/2 ARM: implement support for read-mostly sections
Quoted 8 lines · Catalin Marinas
Quoted 6 lines · Russell King - ARM Linux
arch/arm/kernel/vmlinux.lds.S +0
-0@@ -167,6 +167,7 @@ SECTIONS
Quoted 5 lines
Quoted 3 lines
? ? ? ? ? ? ? ?NOSAVE_DATA
? ? ? ? ? ? ? ?CACHELINE_ALIGNED_DATA(32)
+ ? ? ? ? ? ? ?READ_MOSTLY_DATA(32)Should we change the alignments to 64?
When we have some way to tell vmlinux.lds.S what the cache line size is. It should be a separate patch.
PATCH 1/2 ARM: implement support for read-mostly sections
Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Catalin Marinas
Quoted 6 lines · Russell King - ARM Linux
arch/arm/kernel/vmlinux.lds.S +0
-0@@ -167,6 +167,7 @@ SECTIONS
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
? ? ? ? ? ? ? ?NOSAVE_DATA
? ? ? ? ? ? ? ?CACHELINE_ALIGNED_DATA(32)
+ ? ? ? ? ? ? ?READ_MOSTLY_DATA(32)Should we change the alignments to 64?
When we have some way to tell
vmlinux.lds.Swhat the cache line size is.
I haven't tried but can we not use CONFIG_ARM_L1_CACHE_SHIFT?
Signature · 1 line
Catalin
PATCH 2/2 ARM: move high-usage mostly read variables in setup.c to __read_mostly
In reply to Russell King - ARM Linux--- arch/arm/kernel/setup.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
arch/arm/kernel/setup.c +8 -8
@@ -75,9 +75,9 @@ extern void reboot_setup(char *str);unsigned int processor_id;EXPORT_SYMBOL (processor_id); -unsigned int __machine_arch_type; +unsigned int __machine_arch_type__read_mostly ;EXPORT_SYMBOL (__machine_arch_type); -unsigned int cacheid; +unsigned int cacheid__read_mostly ;EXPORT_SYMBOL (cacheid);unsigned int __atags_pointer__initdata ;
@@ -91,24 +91,24 @@ EXPORT_SYMBOL(system_serial_low);unsigned int system_serial_high;EXPORT_SYMBOL (system_serial_high); -unsigned int elf_hwcap; +unsigned int elf_hwcap__read_mostly ;EXPORT_SYMBOL (elf_hwcap);#ifdef MULTI_CPU -struct processor processor; +struct processor processor__read_mostly ;#endif #ifdef MULTI_TLB -struct cpu_tlb_fns cpu_tlb; +struct cpu_tlb_fns cpu_tlb__read_mostly ;#endif #ifdef MULTI_USER -struct cpu_user_fns cpu_user; +struct cpu_user_fns cpu_user__read_mostly ;#endif #ifdef MULTI_CACHE -struct cpu_cache_fns cpu_cache; +struct cpu_cache_fns cpu_cache__read_mostly ;#endif #ifdef CONFIG_OUTER_CACHE -struct outer_cache_fns outer_cache; +struct outer_cache_fns outer_cache__read_mostly ;EXPORT_SYMBOL (outer_cache);#endif
Signature · 1 line
1.6.2.5