view xen/include/asm-x86/percpu.h @ 19964:3952eaeb70b0

Introduce and use a per-CPU read-mostly sub-section

Since mixing data that only gets setup once and then (perhaps
frequently) gets read by remote CPUs with data that the local CPU may
modify (again, perhaps frequently) still causes undesirable cache
protocol related bus traffic, separate the former class of objects
from the latter.

These objects converted here are just picked based on their write-once
(or write-very-rarely) properties; perhaps some more adjustments may
be desirable subsequently. The primary users of the new sub-section
will result from the next patch.

Signed-off-by: Jan Beulich <>
author Keir Fraser <>
date Mon Jul 13 11:32:41 2009 +0100 (2009-07-13)
parents 3313efd1c367
children 9d3308d7be90
line source
1 #ifndef __X86_PERCPU_H__
2 #define __X86_PERCPU_H__
4 #define PERCPU_SHIFT 12
7 /* Separate out the type, so (int[3], foo) works. */
8 #define __DEFINE_PER_CPU(type, name, suffix) \
9 __attribute__((__section__(".data.percpu" #suffix))) \
10 __typeof__(type) per_cpu_##name
12 /* var is in discarded region: offset to particular copy we want */
13 #define per_cpu(var, cpu) \
14 (*RELOC_HIDE(&per_cpu__##var, ((unsigned int)(cpu))<<PERCPU_SHIFT))
15 #define __get_cpu_var(var) \
16 (per_cpu(var, smp_processor_id()))
18 #define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
20 #endif /* __X86_PERCPU_H__ */