Skip to content

Commit

Permalink
[PATCH] __GENERIC_PER_CPU changes
Browse files Browse the repository at this point in the history
Now CONFIG_DEBUG_INITDATA is in, initial percpu data
[__per_cpu_start,__per_cpu_end] can be declared as a redzone, and invalid
accesses after boot can be detected, at least for i386.

We can let non possible cpus percpu data point to this 'redzone' instead of
NULL .

NULL was not a good choice because part of [0..32768] memory may be
readable and invalid accesses may happen unnoticed.

If CONFIG_DEBUG_INITDATA is not defined, each non possible cpu points to
the initial percpu data (__per_cpu_offset[cpu] == 0), thus invalid accesses
wont be detected/crash.

This patch also moves __per_cpu_offset[] to read_mostly area to avoid false
sharing.

Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Eric Dumazet authored and Linus Torvalds committed Mar 23, 2006
1 parent 394e390 commit b73b459
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
#else

#ifdef __GENERIC_PER_CPU
unsigned long __per_cpu_offset[NR_CPUS];
unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;

EXPORT_SYMBOL(__per_cpu_offset);

Expand All @@ -343,11 +343,7 @@ static void __init setup_per_cpu_areas(void)
#endif
ptr = alloc_bootmem(size * nr_possible_cpus);

for (i = 0; i < NR_CPUS; i++) {
if (!cpu_possible(i)) {
__per_cpu_offset[i] = (char*)0 - __per_cpu_start;
continue;
}
for_each_cpu(i) {
__per_cpu_offset[i] = ptr - __per_cpu_start;
memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
ptr += size;
Expand Down

0 comments on commit b73b459

Please sign in to comment.