Commit c957ef2c59e952803766ddc22e89981ab534606f

Authored by Shaohua Li
Committed by H. Peter Anvin
1 parent f01f7c56a1

percpu: Introduce a read-mostly percpu API

Add a new readmostly percpu section and API.  This can be used to
avoid dirtying data lines which are generally not written to, which is
especially important for data which may be accessed by processors
other than the one for which the percpu area belongs to.

[ hpa: moved it *after* the page-aligned section, for obvious
  reasons. ]

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
LKML-Reference: <1287544022.4571.7.camel@sli10-conroe.sh.intel.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

Showing 2 changed files with 13 additions and 0 deletions Side-by-side Diff

include/asm-generic/vmlinux.lds.h
... ... @@ -677,7 +677,9 @@
677 677 - LOAD_OFFSET) { \
678 678 VMLINUX_SYMBOL(__per_cpu_start) = .; \
679 679 *(.data..percpu..first) \
  680 + . = ALIGN(PAGE_SIZE); \
680 681 *(.data..percpu..page_aligned) \
  682 + *(.data..percpu..readmostly) \
681 683 *(.data..percpu) \
682 684 *(.data..percpu..shared_aligned) \
683 685 VMLINUX_SYMBOL(__per_cpu_end) = .; \
... ... @@ -703,6 +705,8 @@
703 705 VMLINUX_SYMBOL(__per_cpu_load) = .; \
704 706 VMLINUX_SYMBOL(__per_cpu_start) = .; \
705 707 *(.data..percpu..first) \
  708 + . = ALIGN(PAGE_SIZE); \
  709 + *(.data..percpu..readmostly) \
706 710 *(.data..percpu..page_aligned) \
707 711 *(.data..percpu) \
708 712 *(.data..percpu..shared_aligned) \
include/linux/percpu-defs.h
... ... @@ -139,6 +139,15 @@
139 139 __aligned(PAGE_SIZE)
140 140  
141 141 /*
  142 + * Declaration/definition used for per-CPU variables that must be read mostly.
  143 + */
  144 +#define DECLARE_PER_CPU_READ_MOSTLY(type, name) \
  145 + DECLARE_PER_CPU_SECTION(type, name, "..readmostly")
  146 +
  147 +#define DEFINE_PER_CPU_READ_MOSTLY(type, name) \
  148 + DEFINE_PER_CPU_SECTION(type, name, "..readmostly")
  149 +
  150 +/*
142 151 * Intermodule exports for per-CPU variables. sparse forgets about
143 152 * address space across EXPORT_SYMBOL(), change EXPORT_SYMBOL() to
144 153 * noop if __CHECKER__.