Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef _ASM_GENERIC_PERCPU_H_ |
| 3 | #define _ASM_GENERIC_PERCPU_H_ |
David Howells | 5028eaa | 2009-04-21 23:00:29 +0100 | [diff] [blame] | 4 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <linux/compiler.h> |
Rusty Russell | ae1ee11 | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 6 | #include <linux/threads.h> |
David Howells | 5028eaa | 2009-04-21 23:00:29 +0100 | [diff] [blame] | 7 | #include <linux/percpu-defs.h> |
travis@sgi.com | acdac87 | 2008-01-30 13:32:52 +0100 | [diff] [blame] | 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #ifdef CONFIG_SMP |
| 10 | |
travis@sgi.com | acdac87 | 2008-01-30 13:32:52 +0100 | [diff] [blame] | 11 | /* |
| 12 | * per_cpu_offset() is the offset that has to be added to a |
| 13 | * percpu variable to get to the instance for a certain processor. |
| 14 | * |
| 15 | * Most arches use the __per_cpu_offset array for those offsets but |
| 16 | * some arches have their own ways of determining the offset (x86_64, s390). |
| 17 | */ |
| 18 | #ifndef __per_cpu_offset |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | extern unsigned long __per_cpu_offset[NR_CPUS]; |
| 20 | |
Ingo Molnar | a875a69 | 2006-07-03 00:24:26 -0700 | [diff] [blame] | 21 | #define per_cpu_offset(x) (__per_cpu_offset[x]) |
travis@sgi.com | acdac87 | 2008-01-30 13:32:52 +0100 | [diff] [blame] | 22 | #endif |
Ingo Molnar | a875a69 | 2006-07-03 00:24:26 -0700 | [diff] [blame] | 23 | |
travis@sgi.com | acdac87 | 2008-01-30 13:32:52 +0100 | [diff] [blame] | 24 | /* |
| 25 | * Determine the offset for the currently active processor. |
| 26 | * An arch may define __my_cpu_offset to provide a more effective |
| 27 | * means of obtaining the offset to the per cpu variables of the |
| 28 | * current processor. |
| 29 | */ |
| 30 | #ifndef __my_cpu_offset |
| 31 | #define __my_cpu_offset per_cpu_offset(raw_smp_processor_id()) |
Hugh Dickins | 1e83527 | 2008-02-23 19:40:17 +0000 | [diff] [blame] | 32 | #endif |
| 33 | #ifdef CONFIG_DEBUG_PREEMPT |
travis@sgi.com | acdac87 | 2008-01-30 13:32:52 +0100 | [diff] [blame] | 34 | #define my_cpu_offset per_cpu_offset(smp_processor_id()) |
| 35 | #else |
| 36 | #define my_cpu_offset __my_cpu_offset |
| 37 | #endif |
| 38 | |
| 39 | /* |
Tejun Heo | bbc344e | 2014-06-17 19:12:34 -0400 | [diff] [blame] | 40 | * Arch may define arch_raw_cpu_ptr() to provide more efficient address |
| 41 | * translations for raw_cpu_ptr(). |
| 42 | */ |
| 43 | #ifndef arch_raw_cpu_ptr |
| 44 | #define arch_raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset) |
Brian Gerst | db7829c | 2010-09-09 18:17:26 +0200 | [diff] [blame] | 45 | #endif |
Tejun Heo | bbc344e | 2014-06-17 19:12:34 -0400 | [diff] [blame] | 46 | |
Mike Travis | dd5af90 | 2008-01-30 13:33:32 +0100 | [diff] [blame] | 47 | #ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA |
travis@sgi.com | acdac87 | 2008-01-30 13:32:52 +0100 | [diff] [blame] | 48 | extern void setup_per_cpu_areas(void); |
| 49 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #endif /* SMP */ |
| 52 | |
David Howells | 9b8de74 | 2009-04-21 23:00:24 +0100 | [diff] [blame] | 53 | #ifndef PER_CPU_BASE_SECTION |
| 54 | #ifdef CONFIG_SMP |
Denys Vlasenko | 3d9a854 | 2010-02-20 01:03:43 +0100 | [diff] [blame] | 55 | #define PER_CPU_BASE_SECTION ".data..percpu" |
David Howells | 9b8de74 | 2009-04-21 23:00:24 +0100 | [diff] [blame] | 56 | #else |
| 57 | #define PER_CPU_BASE_SECTION ".data" |
| 58 | #endif |
| 59 | #endif |
| 60 | |
travis@sgi.com | acdac87 | 2008-01-30 13:32:52 +0100 | [diff] [blame] | 61 | #ifndef PER_CPU_ATTRIBUTES |
| 62 | #define PER_CPU_ATTRIBUTES |
| 63 | #endif |
| 64 | |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 65 | #define raw_cpu_generic_read(pcp) \ |
| 66 | ({ \ |
| 67 | *raw_cpu_ptr(&(pcp)); \ |
| 68 | }) |
| 69 | |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 70 | #define raw_cpu_generic_to_op(pcp, val, op) \ |
| 71 | do { \ |
| 72 | *raw_cpu_ptr(&(pcp)) op val; \ |
| 73 | } while (0) |
| 74 | |
| 75 | #define raw_cpu_generic_add_return(pcp, val) \ |
| 76 | ({ \ |
Luc Van Oostenryck | becef18 | 2019-12-04 02:06:23 +0100 | [diff] [blame] | 77 | typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 78 | \ |
| 79 | *__p += val; \ |
| 80 | *__p; \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 81 | }) |
| 82 | |
| 83 | #define raw_cpu_generic_xchg(pcp, nval) \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 84 | ({ \ |
Luc Van Oostenryck | becef18 | 2019-12-04 02:06:23 +0100 | [diff] [blame] | 85 | typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 86 | typeof(pcp) __ret; \ |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 87 | __ret = *__p; \ |
| 88 | *__p = nval; \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 89 | __ret; \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 90 | }) |
| 91 | |
| 92 | #define raw_cpu_generic_cmpxchg(pcp, oval, nval) \ |
| 93 | ({ \ |
Luc Van Oostenryck | becef18 | 2019-12-04 02:06:23 +0100 | [diff] [blame] | 94 | typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 95 | typeof(pcp) __ret; \ |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 96 | __ret = *__p; \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 97 | if (__ret == (oval)) \ |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 98 | *__p = nval; \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 99 | __ret; \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 100 | }) |
| 101 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 102 | #define raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 103 | ({ \ |
Luc Van Oostenryck | becef18 | 2019-12-04 02:06:23 +0100 | [diff] [blame] | 104 | typeof(pcp1) *__p1 = raw_cpu_ptr(&(pcp1)); \ |
| 105 | typeof(pcp2) *__p2 = raw_cpu_ptr(&(pcp2)); \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 106 | int __ret = 0; \ |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 107 | if (*__p1 == (oval1) && *__p2 == (oval2)) { \ |
| 108 | *__p1 = nval1; \ |
| 109 | *__p2 = nval2; \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 110 | __ret = 1; \ |
| 111 | } \ |
| 112 | (__ret); \ |
| 113 | }) |
| 114 | |
Mark Rutland | e88d62c | 2017-09-26 12:41:52 +0100 | [diff] [blame] | 115 | #define __this_cpu_generic_read_nopreempt(pcp) \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 116 | ({ \ |
Arnd Bergmann | 29813a2 | 2020-10-26 16:53:48 +0100 | [diff] [blame] | 117 | typeof(pcp) ___ret; \ |
Heiko Carstens | 7f8d61f | 2016-11-03 13:09:24 +0100 | [diff] [blame] | 118 | preempt_disable_notrace(); \ |
Arnd Bergmann | 29813a2 | 2020-10-26 16:53:48 +0100 | [diff] [blame] | 119 | ___ret = READ_ONCE(*raw_cpu_ptr(&(pcp))); \ |
Heiko Carstens | 7f8d61f | 2016-11-03 13:09:24 +0100 | [diff] [blame] | 120 | preempt_enable_notrace(); \ |
Arnd Bergmann | 29813a2 | 2020-10-26 16:53:48 +0100 | [diff] [blame] | 121 | ___ret; \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 122 | }) |
| 123 | |
Mark Rutland | e88d62c | 2017-09-26 12:41:52 +0100 | [diff] [blame] | 124 | #define __this_cpu_generic_read_noirq(pcp) \ |
| 125 | ({ \ |
Arnd Bergmann | 29813a2 | 2020-10-26 16:53:48 +0100 | [diff] [blame] | 126 | typeof(pcp) ___ret; \ |
| 127 | unsigned long ___flags; \ |
| 128 | raw_local_irq_save(___flags); \ |
| 129 | ___ret = raw_cpu_generic_read(pcp); \ |
| 130 | raw_local_irq_restore(___flags); \ |
| 131 | ___ret; \ |
Mark Rutland | e88d62c | 2017-09-26 12:41:52 +0100 | [diff] [blame] | 132 | }) |
| 133 | |
| 134 | #define this_cpu_generic_read(pcp) \ |
| 135 | ({ \ |
| 136 | typeof(pcp) __ret; \ |
| 137 | if (__native_word(pcp)) \ |
| 138 | __ret = __this_cpu_generic_read_nopreempt(pcp); \ |
| 139 | else \ |
| 140 | __ret = __this_cpu_generic_read_noirq(pcp); \ |
| 141 | __ret; \ |
| 142 | }) |
| 143 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 144 | #define this_cpu_generic_to_op(pcp, val, op) \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 145 | do { \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 146 | unsigned long __flags; \ |
| 147 | raw_local_irq_save(__flags); \ |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 148 | raw_cpu_generic_to_op(pcp, val, op); \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 149 | raw_local_irq_restore(__flags); \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 150 | } while (0) |
| 151 | |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 152 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 153 | #define this_cpu_generic_add_return(pcp, val) \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 154 | ({ \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 155 | typeof(pcp) __ret; \ |
| 156 | unsigned long __flags; \ |
| 157 | raw_local_irq_save(__flags); \ |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 158 | __ret = raw_cpu_generic_add_return(pcp, val); \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 159 | raw_local_irq_restore(__flags); \ |
| 160 | __ret; \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 161 | }) |
| 162 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 163 | #define this_cpu_generic_xchg(pcp, nval) \ |
| 164 | ({ \ |
| 165 | typeof(pcp) __ret; \ |
| 166 | unsigned long __flags; \ |
| 167 | raw_local_irq_save(__flags); \ |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 168 | __ret = raw_cpu_generic_xchg(pcp, nval); \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 169 | raw_local_irq_restore(__flags); \ |
| 170 | __ret; \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 171 | }) |
| 172 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 173 | #define this_cpu_generic_cmpxchg(pcp, oval, nval) \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 174 | ({ \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 175 | typeof(pcp) __ret; \ |
| 176 | unsigned long __flags; \ |
| 177 | raw_local_irq_save(__flags); \ |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 178 | __ret = raw_cpu_generic_cmpxchg(pcp, oval, nval); \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 179 | raw_local_irq_restore(__flags); \ |
| 180 | __ret; \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 181 | }) |
| 182 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 183 | #define this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 184 | ({ \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 185 | int __ret; \ |
| 186 | unsigned long __flags; \ |
| 187 | raw_local_irq_save(__flags); \ |
| 188 | __ret = raw_cpu_generic_cmpxchg_double(pcp1, pcp2, \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 189 | oval1, oval2, nval1, nval2); \ |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 190 | raw_local_irq_restore(__flags); \ |
| 191 | __ret; \ |
Tejun Heo | 9c28278a2 | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 192 | }) |
| 193 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 194 | #ifndef raw_cpu_read_1 |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 195 | #define raw_cpu_read_1(pcp) raw_cpu_generic_read(pcp) |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 196 | #endif |
| 197 | #ifndef raw_cpu_read_2 |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 198 | #define raw_cpu_read_2(pcp) raw_cpu_generic_read(pcp) |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 199 | #endif |
| 200 | #ifndef raw_cpu_read_4 |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 201 | #define raw_cpu_read_4(pcp) raw_cpu_generic_read(pcp) |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 202 | #endif |
| 203 | #ifndef raw_cpu_read_8 |
Nicholas Piggin | 1b5ca12 | 2016-09-22 11:55:54 -0400 | [diff] [blame] | 204 | #define raw_cpu_read_8(pcp) raw_cpu_generic_read(pcp) |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 205 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 206 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 207 | #ifndef raw_cpu_write_1 |
| 208 | #define raw_cpu_write_1(pcp, val) raw_cpu_generic_to_op(pcp, val, =) |
| 209 | #endif |
| 210 | #ifndef raw_cpu_write_2 |
| 211 | #define raw_cpu_write_2(pcp, val) raw_cpu_generic_to_op(pcp, val, =) |
| 212 | #endif |
| 213 | #ifndef raw_cpu_write_4 |
| 214 | #define raw_cpu_write_4(pcp, val) raw_cpu_generic_to_op(pcp, val, =) |
| 215 | #endif |
| 216 | #ifndef raw_cpu_write_8 |
| 217 | #define raw_cpu_write_8(pcp, val) raw_cpu_generic_to_op(pcp, val, =) |
| 218 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 219 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 220 | #ifndef raw_cpu_add_1 |
| 221 | #define raw_cpu_add_1(pcp, val) raw_cpu_generic_to_op(pcp, val, +=) |
| 222 | #endif |
| 223 | #ifndef raw_cpu_add_2 |
| 224 | #define raw_cpu_add_2(pcp, val) raw_cpu_generic_to_op(pcp, val, +=) |
| 225 | #endif |
| 226 | #ifndef raw_cpu_add_4 |
| 227 | #define raw_cpu_add_4(pcp, val) raw_cpu_generic_to_op(pcp, val, +=) |
| 228 | #endif |
| 229 | #ifndef raw_cpu_add_8 |
| 230 | #define raw_cpu_add_8(pcp, val) raw_cpu_generic_to_op(pcp, val, +=) |
| 231 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 232 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 233 | #ifndef raw_cpu_and_1 |
| 234 | #define raw_cpu_and_1(pcp, val) raw_cpu_generic_to_op(pcp, val, &=) |
| 235 | #endif |
| 236 | #ifndef raw_cpu_and_2 |
| 237 | #define raw_cpu_and_2(pcp, val) raw_cpu_generic_to_op(pcp, val, &=) |
| 238 | #endif |
| 239 | #ifndef raw_cpu_and_4 |
| 240 | #define raw_cpu_and_4(pcp, val) raw_cpu_generic_to_op(pcp, val, &=) |
| 241 | #endif |
| 242 | #ifndef raw_cpu_and_8 |
| 243 | #define raw_cpu_and_8(pcp, val) raw_cpu_generic_to_op(pcp, val, &=) |
| 244 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 245 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 246 | #ifndef raw_cpu_or_1 |
| 247 | #define raw_cpu_or_1(pcp, val) raw_cpu_generic_to_op(pcp, val, |=) |
| 248 | #endif |
| 249 | #ifndef raw_cpu_or_2 |
| 250 | #define raw_cpu_or_2(pcp, val) raw_cpu_generic_to_op(pcp, val, |=) |
| 251 | #endif |
| 252 | #ifndef raw_cpu_or_4 |
| 253 | #define raw_cpu_or_4(pcp, val) raw_cpu_generic_to_op(pcp, val, |=) |
| 254 | #endif |
| 255 | #ifndef raw_cpu_or_8 |
| 256 | #define raw_cpu_or_8(pcp, val) raw_cpu_generic_to_op(pcp, val, |=) |
| 257 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 258 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 259 | #ifndef raw_cpu_add_return_1 |
| 260 | #define raw_cpu_add_return_1(pcp, val) raw_cpu_generic_add_return(pcp, val) |
| 261 | #endif |
| 262 | #ifndef raw_cpu_add_return_2 |
| 263 | #define raw_cpu_add_return_2(pcp, val) raw_cpu_generic_add_return(pcp, val) |
| 264 | #endif |
| 265 | #ifndef raw_cpu_add_return_4 |
| 266 | #define raw_cpu_add_return_4(pcp, val) raw_cpu_generic_add_return(pcp, val) |
| 267 | #endif |
| 268 | #ifndef raw_cpu_add_return_8 |
| 269 | #define raw_cpu_add_return_8(pcp, val) raw_cpu_generic_add_return(pcp, val) |
| 270 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 271 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 272 | #ifndef raw_cpu_xchg_1 |
| 273 | #define raw_cpu_xchg_1(pcp, nval) raw_cpu_generic_xchg(pcp, nval) |
| 274 | #endif |
| 275 | #ifndef raw_cpu_xchg_2 |
| 276 | #define raw_cpu_xchg_2(pcp, nval) raw_cpu_generic_xchg(pcp, nval) |
| 277 | #endif |
| 278 | #ifndef raw_cpu_xchg_4 |
| 279 | #define raw_cpu_xchg_4(pcp, nval) raw_cpu_generic_xchg(pcp, nval) |
| 280 | #endif |
| 281 | #ifndef raw_cpu_xchg_8 |
| 282 | #define raw_cpu_xchg_8(pcp, nval) raw_cpu_generic_xchg(pcp, nval) |
| 283 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 284 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 285 | #ifndef raw_cpu_cmpxchg_1 |
| 286 | #define raw_cpu_cmpxchg_1(pcp, oval, nval) \ |
| 287 | raw_cpu_generic_cmpxchg(pcp, oval, nval) |
| 288 | #endif |
| 289 | #ifndef raw_cpu_cmpxchg_2 |
| 290 | #define raw_cpu_cmpxchg_2(pcp, oval, nval) \ |
| 291 | raw_cpu_generic_cmpxchg(pcp, oval, nval) |
| 292 | #endif |
| 293 | #ifndef raw_cpu_cmpxchg_4 |
| 294 | #define raw_cpu_cmpxchg_4(pcp, oval, nval) \ |
| 295 | raw_cpu_generic_cmpxchg(pcp, oval, nval) |
| 296 | #endif |
| 297 | #ifndef raw_cpu_cmpxchg_8 |
| 298 | #define raw_cpu_cmpxchg_8(pcp, oval, nval) \ |
| 299 | raw_cpu_generic_cmpxchg(pcp, oval, nval) |
| 300 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 301 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 302 | #ifndef raw_cpu_cmpxchg_double_1 |
| 303 | #define raw_cpu_cmpxchg_double_1(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 304 | raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 305 | #endif |
| 306 | #ifndef raw_cpu_cmpxchg_double_2 |
| 307 | #define raw_cpu_cmpxchg_double_2(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 308 | raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 309 | #endif |
| 310 | #ifndef raw_cpu_cmpxchg_double_4 |
| 311 | #define raw_cpu_cmpxchg_double_4(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 312 | raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 313 | #endif |
| 314 | #ifndef raw_cpu_cmpxchg_double_8 |
| 315 | #define raw_cpu_cmpxchg_double_8(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 316 | raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 317 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 318 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 319 | #ifndef this_cpu_read_1 |
| 320 | #define this_cpu_read_1(pcp) this_cpu_generic_read(pcp) |
| 321 | #endif |
| 322 | #ifndef this_cpu_read_2 |
| 323 | #define this_cpu_read_2(pcp) this_cpu_generic_read(pcp) |
| 324 | #endif |
| 325 | #ifndef this_cpu_read_4 |
| 326 | #define this_cpu_read_4(pcp) this_cpu_generic_read(pcp) |
| 327 | #endif |
| 328 | #ifndef this_cpu_read_8 |
| 329 | #define this_cpu_read_8(pcp) this_cpu_generic_read(pcp) |
| 330 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 331 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 332 | #ifndef this_cpu_write_1 |
| 333 | #define this_cpu_write_1(pcp, val) this_cpu_generic_to_op(pcp, val, =) |
| 334 | #endif |
| 335 | #ifndef this_cpu_write_2 |
| 336 | #define this_cpu_write_2(pcp, val) this_cpu_generic_to_op(pcp, val, =) |
| 337 | #endif |
| 338 | #ifndef this_cpu_write_4 |
| 339 | #define this_cpu_write_4(pcp, val) this_cpu_generic_to_op(pcp, val, =) |
| 340 | #endif |
| 341 | #ifndef this_cpu_write_8 |
| 342 | #define this_cpu_write_8(pcp, val) this_cpu_generic_to_op(pcp, val, =) |
| 343 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 344 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 345 | #ifndef this_cpu_add_1 |
| 346 | #define this_cpu_add_1(pcp, val) this_cpu_generic_to_op(pcp, val, +=) |
| 347 | #endif |
| 348 | #ifndef this_cpu_add_2 |
| 349 | #define this_cpu_add_2(pcp, val) this_cpu_generic_to_op(pcp, val, +=) |
| 350 | #endif |
| 351 | #ifndef this_cpu_add_4 |
| 352 | #define this_cpu_add_4(pcp, val) this_cpu_generic_to_op(pcp, val, +=) |
| 353 | #endif |
| 354 | #ifndef this_cpu_add_8 |
| 355 | #define this_cpu_add_8(pcp, val) this_cpu_generic_to_op(pcp, val, +=) |
| 356 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 357 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 358 | #ifndef this_cpu_and_1 |
| 359 | #define this_cpu_and_1(pcp, val) this_cpu_generic_to_op(pcp, val, &=) |
| 360 | #endif |
| 361 | #ifndef this_cpu_and_2 |
| 362 | #define this_cpu_and_2(pcp, val) this_cpu_generic_to_op(pcp, val, &=) |
| 363 | #endif |
| 364 | #ifndef this_cpu_and_4 |
| 365 | #define this_cpu_and_4(pcp, val) this_cpu_generic_to_op(pcp, val, &=) |
| 366 | #endif |
| 367 | #ifndef this_cpu_and_8 |
| 368 | #define this_cpu_and_8(pcp, val) this_cpu_generic_to_op(pcp, val, &=) |
| 369 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 370 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 371 | #ifndef this_cpu_or_1 |
| 372 | #define this_cpu_or_1(pcp, val) this_cpu_generic_to_op(pcp, val, |=) |
| 373 | #endif |
| 374 | #ifndef this_cpu_or_2 |
| 375 | #define this_cpu_or_2(pcp, val) this_cpu_generic_to_op(pcp, val, |=) |
| 376 | #endif |
| 377 | #ifndef this_cpu_or_4 |
| 378 | #define this_cpu_or_4(pcp, val) this_cpu_generic_to_op(pcp, val, |=) |
| 379 | #endif |
| 380 | #ifndef this_cpu_or_8 |
| 381 | #define this_cpu_or_8(pcp, val) this_cpu_generic_to_op(pcp, val, |=) |
| 382 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 383 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 384 | #ifndef this_cpu_add_return_1 |
| 385 | #define this_cpu_add_return_1(pcp, val) this_cpu_generic_add_return(pcp, val) |
| 386 | #endif |
| 387 | #ifndef this_cpu_add_return_2 |
| 388 | #define this_cpu_add_return_2(pcp, val) this_cpu_generic_add_return(pcp, val) |
| 389 | #endif |
| 390 | #ifndef this_cpu_add_return_4 |
| 391 | #define this_cpu_add_return_4(pcp, val) this_cpu_generic_add_return(pcp, val) |
| 392 | #endif |
| 393 | #ifndef this_cpu_add_return_8 |
| 394 | #define this_cpu_add_return_8(pcp, val) this_cpu_generic_add_return(pcp, val) |
| 395 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 396 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 397 | #ifndef this_cpu_xchg_1 |
| 398 | #define this_cpu_xchg_1(pcp, nval) this_cpu_generic_xchg(pcp, nval) |
| 399 | #endif |
| 400 | #ifndef this_cpu_xchg_2 |
| 401 | #define this_cpu_xchg_2(pcp, nval) this_cpu_generic_xchg(pcp, nval) |
| 402 | #endif |
| 403 | #ifndef this_cpu_xchg_4 |
| 404 | #define this_cpu_xchg_4(pcp, nval) this_cpu_generic_xchg(pcp, nval) |
| 405 | #endif |
| 406 | #ifndef this_cpu_xchg_8 |
| 407 | #define this_cpu_xchg_8(pcp, nval) this_cpu_generic_xchg(pcp, nval) |
| 408 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 409 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 410 | #ifndef this_cpu_cmpxchg_1 |
| 411 | #define this_cpu_cmpxchg_1(pcp, oval, nval) \ |
| 412 | this_cpu_generic_cmpxchg(pcp, oval, nval) |
| 413 | #endif |
| 414 | #ifndef this_cpu_cmpxchg_2 |
| 415 | #define this_cpu_cmpxchg_2(pcp, oval, nval) \ |
| 416 | this_cpu_generic_cmpxchg(pcp, oval, nval) |
| 417 | #endif |
| 418 | #ifndef this_cpu_cmpxchg_4 |
| 419 | #define this_cpu_cmpxchg_4(pcp, oval, nval) \ |
| 420 | this_cpu_generic_cmpxchg(pcp, oval, nval) |
| 421 | #endif |
| 422 | #ifndef this_cpu_cmpxchg_8 |
| 423 | #define this_cpu_cmpxchg_8(pcp, oval, nval) \ |
| 424 | this_cpu_generic_cmpxchg(pcp, oval, nval) |
| 425 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 426 | |
Tejun Heo | eba1178 | 2014-06-17 19:12:40 -0400 | [diff] [blame] | 427 | #ifndef this_cpu_cmpxchg_double_1 |
| 428 | #define this_cpu_cmpxchg_double_1(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
| 429 | this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) |
| 430 | #endif |
| 431 | #ifndef this_cpu_cmpxchg_double_2 |
| 432 | #define this_cpu_cmpxchg_double_2(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
| 433 | this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) |
| 434 | #endif |
| 435 | #ifndef this_cpu_cmpxchg_double_4 |
| 436 | #define this_cpu_cmpxchg_double_4(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
| 437 | this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) |
| 438 | #endif |
| 439 | #ifndef this_cpu_cmpxchg_double_8 |
| 440 | #define this_cpu_cmpxchg_double_8(pcp1, pcp2, oval1, oval2, nval1, nval2) \ |
| 441 | this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) |
| 442 | #endif |
Tejun Heo | 47b69ad | 2014-06-17 19:12:39 -0400 | [diff] [blame] | 443 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | #endif /* _ASM_GENERIC_PERCPU_H_ */ |