aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/percpu.h13
-rw-r--r--include/linux/percpu.h331
2 files changed, 203 insertions, 141 deletions
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index d17784ea37ff..0703aa75b5e8 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -56,17 +56,17 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
56#define per_cpu(var, cpu) \ 56#define per_cpu(var, cpu) \
57 (*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu))) 57 (*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu)))
58 58
59#ifndef __this_cpu_ptr 59#ifndef raw_cpu_ptr
60#define __this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset) 60#define raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
61#endif 61#endif
62#ifdef CONFIG_DEBUG_PREEMPT 62#ifdef CONFIG_DEBUG_PREEMPT
63#define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset) 63#define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset)
64#else 64#else
65#define this_cpu_ptr(ptr) __this_cpu_ptr(ptr) 65#define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
66#endif 66#endif
67 67
68#define __get_cpu_var(var) (*this_cpu_ptr(&(var))) 68#define __get_cpu_var(var) (*this_cpu_ptr(&(var)))
69#define __raw_get_cpu_var(var) (*__this_cpu_ptr(&(var))) 69#define __raw_get_cpu_var(var) (*raw_cpu_ptr(&(var)))
70 70
71#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA 71#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
72extern void setup_per_cpu_areas(void); 72extern void setup_per_cpu_areas(void);
@@ -83,7 +83,7 @@ extern void setup_per_cpu_areas(void);
83#define __get_cpu_var(var) (*VERIFY_PERCPU_PTR(&(var))) 83#define __get_cpu_var(var) (*VERIFY_PERCPU_PTR(&(var)))
84#define __raw_get_cpu_var(var) (*VERIFY_PERCPU_PTR(&(var))) 84#define __raw_get_cpu_var(var) (*VERIFY_PERCPU_PTR(&(var)))
85#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) 85#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
86#define __this_cpu_ptr(ptr) this_cpu_ptr(ptr) 86#define raw_cpu_ptr(ptr) this_cpu_ptr(ptr)
87 87
88#endif /* SMP */ 88#endif /* SMP */
89 89
@@ -122,4 +122,7 @@ extern void setup_per_cpu_areas(void);
122#define PER_CPU_DEF_ATTRIBUTES 122#define PER_CPU_DEF_ATTRIBUTES
123#endif 123#endif
124 124
125/* Keep until we have removed all uses of __this_cpu_ptr */
126#define __this_cpu_ptr raw_cpu_ptr
127
125#endif /* _ASM_GENERIC_PERCPU_H_ */ 128#endif /* _ASM_GENERIC_PERCPU_H_ */
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index e3817d2441b6..4e4d2afcc0c7 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -243,6 +243,8 @@ do { \
243} while (0) 243} while (0)
244 244
245/* 245/*
246 * this_cpu operations (C) 2008-2013 Christoph Lameter <cl@linux.com>
247 *
246 * Optimized manipulation for memory allocated through the per cpu 248 * Optimized manipulation for memory allocated through the per cpu
247 * allocator or for addresses of per cpu variables. 249 * allocator or for addresses of per cpu variables.
248 * 250 *
@@ -296,7 +298,7 @@ do { \
296do { \ 298do { \
297 unsigned long flags; \ 299 unsigned long flags; \
298 raw_local_irq_save(flags); \ 300 raw_local_irq_save(flags); \
299 *__this_cpu_ptr(&(pcp)) op val; \ 301 *raw_cpu_ptr(&(pcp)) op val; \
300 raw_local_irq_restore(flags); \ 302 raw_local_irq_restore(flags); \
301} while (0) 303} while (0)
302 304
@@ -381,8 +383,8 @@ do { \
381 typeof(pcp) ret__; \ 383 typeof(pcp) ret__; \
382 unsigned long flags; \ 384 unsigned long flags; \
383 raw_local_irq_save(flags); \ 385 raw_local_irq_save(flags); \
384 __this_cpu_add(pcp, val); \ 386 raw_cpu_add(pcp, val); \
385 ret__ = __this_cpu_read(pcp); \ 387 ret__ = raw_cpu_read(pcp); \
386 raw_local_irq_restore(flags); \ 388 raw_local_irq_restore(flags); \
387 ret__; \ 389 ret__; \
388}) 390})
@@ -411,8 +413,8 @@ do { \
411({ typeof(pcp) ret__; \ 413({ typeof(pcp) ret__; \
412 unsigned long flags; \ 414 unsigned long flags; \
413 raw_local_irq_save(flags); \ 415 raw_local_irq_save(flags); \
414 ret__ = __this_cpu_read(pcp); \ 416 ret__ = raw_cpu_read(pcp); \
415 __this_cpu_write(pcp, nval); \ 417 raw_cpu_write(pcp, nval); \
416 raw_local_irq_restore(flags); \ 418 raw_local_irq_restore(flags); \
417 ret__; \ 419 ret__; \
418}) 420})
@@ -439,9 +441,9 @@ do { \
439 typeof(pcp) ret__; \ 441 typeof(pcp) ret__; \
440 unsigned long flags; \ 442 unsigned long flags; \
441 raw_local_irq_save(flags); \ 443 raw_local_irq_save(flags); \
442 ret__ = __this_cpu_read(pcp); \ 444 ret__ = raw_cpu_read(pcp); \
443 if (ret__ == (oval)) \ 445 if (ret__ == (oval)) \
444 __this_cpu_write(pcp, nval); \ 446 raw_cpu_write(pcp, nval); \
445 raw_local_irq_restore(flags); \ 447 raw_local_irq_restore(flags); \
446 ret__; \ 448 ret__; \
447}) 449})
@@ -476,7 +478,7 @@ do { \
476 int ret__; \ 478 int ret__; \
477 unsigned long flags; \ 479 unsigned long flags; \
478 raw_local_irq_save(flags); \ 480 raw_local_irq_save(flags); \
479 ret__ = __this_cpu_generic_cmpxchg_double(pcp1, pcp2, \ 481 ret__ = raw_cpu_generic_cmpxchg_double(pcp1, pcp2, \
480 oval1, oval2, nval1, nval2); \ 482 oval1, oval2, nval1, nval2); \
481 raw_local_irq_restore(flags); \ 483 raw_local_irq_restore(flags); \
482 ret__; \ 484 ret__; \
@@ -504,12 +506,8 @@ do { \
504#endif 506#endif
505 507
506/* 508/*
507 * Generic percpu operations for context that are safe from preemption/interrupts. 509 * Generic percpu operations for contexts where we do not want to do
508 * Either we do not care about races or the caller has the 510 * any checks for preemptiosn.
509 * responsibility of handling preemption/interrupt issues. Arch code can still
510 * override these instructions since the arch per cpu code may be more
511 * efficient and may actually get race freeness for free (that is the
512 * case for x86 for example).
513 * 511 *
514 * If there is no other protection through preempt disable and/or 512 * If there is no other protection through preempt disable and/or
515 * disabling interupts then one of these RMW operations can show unexpected 513 * disabling interupts then one of these RMW operations can show unexpected
@@ -517,211 +515,272 @@ do { \
517 * or an interrupt occurred and the same percpu variable was modified from 515 * or an interrupt occurred and the same percpu variable was modified from
518 * the interrupt context. 516 * the interrupt context.
519 */ 517 */
520#ifndef __this_cpu_read 518#ifndef raw_cpu_read
521# ifndef __this_cpu_read_1 519# ifndef raw_cpu_read_1
522# define __this_cpu_read_1(pcp) (*__this_cpu_ptr(&(pcp))) 520# define raw_cpu_read_1(pcp) (*raw_cpu_ptr(&(pcp)))
523# endif 521# endif
524# ifndef __this_cpu_read_2 522# ifndef raw_cpu_read_2
525# define __this_cpu_read_2(pcp) (*__this_cpu_ptr(&(pcp))) 523# define raw_cpu_read_2(pcp) (*raw_cpu_ptr(&(pcp)))
526# endif 524# endif
527# ifndef __this_cpu_read_4 525# ifndef raw_cpu_read_4
528# define __this_cpu_read_4(pcp) (*__this_cpu_ptr(&(pcp))) 526# define raw_cpu_read_4(pcp) (*raw_cpu_ptr(&(pcp)))
529# endif 527# endif
530# ifndef __this_cpu_read_8 528# ifndef raw_cpu_read_8
531# define __this_cpu_read_8(pcp) (*__this_cpu_ptr(&(pcp))) 529# define raw_cpu_read_8(pcp) (*raw_cpu_ptr(&(pcp)))
532# endif 530# endif
533# define __this_cpu_read(pcp) __pcpu_size_call_return(__this_cpu_read_, (pcp)) 531# define raw_cpu_read(pcp) __pcpu_size_call_return(raw_cpu_read_, (pcp))
534#endif 532#endif
535 533
536#define __this_cpu_generic_to_op(pcp, val, op) \ 534#define raw_cpu_generic_to_op(pcp, val, op) \
537do { \ 535do { \
538 *__this_cpu_ptr(&(pcp)) op val; \ 536 *raw_cpu_ptr(&(pcp)) op val; \
539} while (0) 537} while (0)
540 538
541#ifndef __this_cpu_write 539
542# ifndef __this_cpu_write_1 540#ifndef raw_cpu_write
543# define __this_cpu_write_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), =) 541# ifndef raw_cpu_write_1