Skip to contentSkip to conversation

Support for __read_mostly

PATCH New Russell King - ARM Linux 2 participants 6 messages Dec 5, 2010 – Dec 6, 2010 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw

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
index 9d61220..75fe66b 100644
@@ -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
index cead889..1581f6d 100644
@@ -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
#2 lore raw

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.

---
?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
index 9d61220..75fe66b 100644
@@ -23,4 +23,6 @@

?#define ARCH_SLAB_MINALIGN 8
?#endif

arch/arm/include/asm/cache.h +2 -0
+#define __read_mostly __attribute__((__section__(".data..read_mostly")))
+

?#endif

arch/arm/kernel/vmlinux.lds.S +0 -0
index cead889..1581f6d 100644
@@ -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
#3 lore raw

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
index cead889..1581f6d 100644
@@ -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.

#4 lore raw

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
index cead889..1581f6d 100644
@@ -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.S what the cache line size is.

I haven't tried but can we not use CONFIG_ARM_L1_CACHE_SHIFT?

Signature · 1 line
Catalin
#5 lore raw

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
index 336f14e..8075e59 100644
@@ -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