1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds #ifndef _ASM_GENERIC_PERCPU_H_ 31da177e4SLinus Torvalds #define _ASM_GENERIC_PERCPU_H_ 45028eaa9SDavid Howells 51da177e4SLinus Torvalds #include <linux/compiler.h> 6ae1ee11bSRusty Russell #include <linux/threads.h> 75028eaa9SDavid Howells #include <linux/percpu-defs.h> 8acdac872S[email protected] 9*6cea5ae7SUros Bizjak /* 10*6cea5ae7SUros Bizjak * __percpu_qual is the qualifier for the percpu named address space. 11*6cea5ae7SUros Bizjak * 12*6cea5ae7SUros Bizjak * Most arches use generic named address space for percpu variables but 13*6cea5ae7SUros Bizjak * some arches define percpu variables in different named address space 14*6cea5ae7SUros Bizjak * (on the x86 arch, percpu variable may be declared as being relative 15*6cea5ae7SUros Bizjak * to the %fs or %gs segments using __seg_fs or __seg_gs named address 16*6cea5ae7SUros Bizjak * space qualifier). 17*6cea5ae7SUros Bizjak */ 18*6cea5ae7SUros Bizjak #ifndef __percpu_qual 19*6cea5ae7SUros Bizjak # define __percpu_qual 20*6cea5ae7SUros Bizjak #endif 21*6cea5ae7SUros Bizjak 221da177e4SLinus Torvalds #ifdef CONFIG_SMP 231da177e4SLinus Torvalds 24acdac872S[email protected] /* 25acdac872S[email protected] * per_cpu_offset() is the offset that has to be added to a 26acdac872S[email protected] * percpu variable to get to the instance for a certain processor. 27acdac872S[email protected] * 28acdac872S[email protected] * Most arches use the __per_cpu_offset array for those offsets but 29acdac872S[email protected] * some arches have their own ways of determining the offset (x86_64, s390). 30acdac872S[email protected] */ 31acdac872S[email protected] #ifndef __per_cpu_offset 321da177e4SLinus Torvalds extern unsigned long __per_cpu_offset[NR_CPUS]; 331da177e4SLinus Torvalds 34a875a69fSIngo Molnar #define per_cpu_offset(x) (__per_cpu_offset[x]) 35acdac872S[email protected] #endif 36a875a69fSIngo Molnar 37acdac872S[email protected] /* 38acdac872S[email protected] * Determine the offset for the currently active processor. 39acdac872S[email protected] * An arch may define __my_cpu_offset to provide a more effective 40acdac872S[email protected] * means of obtaining the offset to the per cpu variables of the 41acdac872S[email protected] * current processor. 42acdac872S[email protected] */ 43acdac872S[email protected] #ifndef __my_cpu_offset 44acdac872S[email protected] #define __my_cpu_offset per_cpu_offset(raw_smp_processor_id()) 451e835278SHugh Dickins #endif 461e835278SHugh Dickins #ifdef CONFIG_DEBUG_PREEMPT 47acdac872S[email protected] #define my_cpu_offset per_cpu_offset(smp_processor_id()) 48acdac872S[email protected] #else 49acdac872S[email protected] #define my_cpu_offset __my_cpu_offset 50acdac872S[email protected] #endif 51acdac872S[email protected] 52acdac872S[email protected] /* 53bbc344e1STejun Heo * Arch may define arch_raw_cpu_ptr() to provide more efficient address 54bbc344e1STejun Heo * translations for raw_cpu_ptr(). 55bbc344e1STejun Heo */ 56bbc344e1STejun Heo #ifndef arch_raw_cpu_ptr 57bbc344e1STejun Heo #define arch_raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset) 58db7829c6SBrian Gerst #endif 59bbc344e1STejun Heo 60dd5af90aSMike Travis #ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA 61acdac872S[email protected] extern void setup_per_cpu_areas(void); 62acdac872S[email protected] #endif 631da177e4SLinus Torvalds 641da177e4SLinus Torvalds #endif /* SMP */ 651da177e4SLinus Torvalds 669b8de747SDavid Howells #ifndef PER_CPU_BASE_SECTION 679b8de747SDavid Howells #ifdef CONFIG_SMP 683d9a854cSDenys Vlasenko #define PER_CPU_BASE_SECTION ".data..percpu" 699b8de747SDavid Howells #else 709b8de747SDavid Howells #define PER_CPU_BASE_SECTION ".data" 719b8de747SDavid Howells #endif 729b8de747SDavid Howells #endif 739b8de747SDavid Howells 74acdac872S[email protected] #ifndef PER_CPU_ATTRIBUTES 75acdac872S[email protected] #define PER_CPU_ATTRIBUTES 76acdac872S[email protected] #endif 77acdac872S[email protected] 781b5ca121SNicholas Piggin #define raw_cpu_generic_read(pcp) \ 791b5ca121SNicholas Piggin ({ \ 801b5ca121SNicholas Piggin *raw_cpu_ptr(&(pcp)); \ 811b5ca121SNicholas Piggin }) 821b5ca121SNicholas Piggin 839c28278aSTejun Heo #define raw_cpu_generic_to_op(pcp, val, op) \ 849c28278aSTejun Heo do { \ 859c28278aSTejun Heo *raw_cpu_ptr(&(pcp)) op val; \ 869c28278aSTejun Heo } while (0) 879c28278aSTejun Heo 889c28278aSTejun Heo #define raw_cpu_generic_add_return(pcp, val) \ 899c28278aSTejun Heo ({ \ 908a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ 911b5ca121SNicholas Piggin \ 921b5ca121SNicholas Piggin *__p += val; \ 931b5ca121SNicholas Piggin *__p; \ 949c28278aSTejun Heo }) 959c28278aSTejun Heo 969c28278aSTejun Heo #define raw_cpu_generic_xchg(pcp, nval) \ 97eba11788STejun Heo ({ \ 988a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ 998a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) __ret; \ 1001b5ca121SNicholas Piggin __ret = *__p; \ 1011b5ca121SNicholas Piggin *__p = nval; \ 102eba11788STejun Heo __ret; \ 1039c28278aSTejun Heo }) 1049c28278aSTejun Heo 105c5c0ba95SPeter Zijlstra #define __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, _cmpxchg) \ 106c5c0ba95SPeter Zijlstra ({ \ 1078a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) __val, __old = *(ovalp); \ 108c5c0ba95SPeter Zijlstra __val = _cmpxchg(pcp, __old, nval); \ 109c5c0ba95SPeter Zijlstra if (__val != __old) \ 110c5c0ba95SPeter Zijlstra *(ovalp) = __val; \ 111c5c0ba95SPeter Zijlstra __val == __old; \ 112c5c0ba95SPeter Zijlstra }) 113c5c0ba95SPeter Zijlstra 114c5c0ba95SPeter Zijlstra #define raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) \ 1159c28278aSTejun Heo ({ \ 1168a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ 1178a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) __val = *__p, ___old = *(ovalp); \ 118c5c0ba95SPeter Zijlstra bool __ret; \ 119093d9b24SNathan Chancellor if (__val == ___old) { \ 1201b5ca121SNicholas Piggin *__p = nval; \ 121c5c0ba95SPeter Zijlstra __ret = true; \ 122c5c0ba95SPeter Zijlstra } else { \ 123c5c0ba95SPeter Zijlstra *(ovalp) = __val; \ 124c5c0ba95SPeter Zijlstra __ret = false; \ 125c5c0ba95SPeter Zijlstra } \ 126eba11788STejun Heo __ret; \ 1279c28278aSTejun Heo }) 1289c28278aSTejun Heo 129c5c0ba95SPeter Zijlstra #define raw_cpu_generic_cmpxchg(pcp, oval, nval) \ 130c5c0ba95SPeter Zijlstra ({ \ 1318a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) __old = (oval); \ 132c5c0ba95SPeter Zijlstra raw_cpu_generic_try_cmpxchg(pcp, &__old, nval); \ 133c5c0ba95SPeter Zijlstra __old; \ 134c5c0ba95SPeter Zijlstra }) 135c5c0ba95SPeter Zijlstra 136e88d62cdSMark Rutland #define __this_cpu_generic_read_nopreempt(pcp) \ 137eba11788STejun Heo ({ \ 1388a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) ___ret; \ 1397f8d61f0SHeiko Carstens preempt_disable_notrace(); \ 14029813a22SArnd Bergmann ___ret = READ_ONCE(*raw_cpu_ptr(&(pcp))); \ 1417f8d61f0SHeiko Carstens preempt_enable_notrace(); \ 14229813a22SArnd Bergmann ___ret; \ 1439c28278aSTejun Heo }) 1449c28278aSTejun Heo 145e88d62cdSMark Rutland #define __this_cpu_generic_read_noirq(pcp) \ 146e88d62cdSMark Rutland ({ \ 1478a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) ___ret; \ 14829813a22SArnd Bergmann unsigned long ___flags; \ 14929813a22SArnd Bergmann raw_local_irq_save(___flags); \ 15029813a22SArnd Bergmann ___ret = raw_cpu_generic_read(pcp); \ 15129813a22SArnd Bergmann raw_local_irq_restore(___flags); \ 15229813a22SArnd Bergmann ___ret; \ 153e88d62cdSMark Rutland }) 154e88d62cdSMark Rutland 155e88d62cdSMark Rutland #define this_cpu_generic_read(pcp) \ 156e88d62cdSMark Rutland ({ \ 1578a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) __ret; \ 158e88d62cdSMark Rutland if (__native_word(pcp)) \ 159e88d62cdSMark Rutland __ret = __this_cpu_generic_read_nopreempt(pcp); \ 160e88d62cdSMark Rutland else \ 161e88d62cdSMark Rutland __ret = __this_cpu_generic_read_noirq(pcp); \ 162e88d62cdSMark Rutland __ret; \ 163e88d62cdSMark Rutland }) 164e88d62cdSMark Rutland 165eba11788STejun Heo #define this_cpu_generic_to_op(pcp, val, op) \ 1669c28278aSTejun Heo do { \ 167eba11788STejun Heo unsigned long __flags; \ 168eba11788STejun Heo raw_local_irq_save(__flags); \ 1691b5ca121SNicholas Piggin raw_cpu_generic_to_op(pcp, val, op); \ 170eba11788STejun Heo raw_local_irq_restore(__flags); \ 1719c28278aSTejun Heo } while (0) 1729c28278aSTejun Heo 1731b5ca121SNicholas Piggin 174eba11788STejun Heo #define this_cpu_generic_add_return(pcp, val) \ 1759c28278aSTejun Heo ({ \ 1768a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) __ret; \ 177eba11788STejun Heo unsigned long __flags; \ 178eba11788STejun Heo raw_local_irq_save(__flags); \ 1791b5ca121SNicholas Piggin __ret = raw_cpu_generic_add_return(pcp, val); \ 180eba11788STejun Heo raw_local_irq_restore(__flags); \ 181eba11788STejun Heo __ret; \ 1829c28278aSTejun Heo }) 1839c28278aSTejun Heo 184eba11788STejun Heo #define this_cpu_generic_xchg(pcp, nval) \ 1859c28278aSTejun Heo ({ \ 1868a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) __ret; \ 187eba11788STejun Heo unsigned long __flags; \ 188eba11788STejun Heo raw_local_irq_save(__flags); \ 1891b5ca121SNicholas Piggin __ret = raw_cpu_generic_xchg(pcp, nval); \ 190eba11788STejun Heo raw_local_irq_restore(__flags); \ 191eba11788STejun Heo __ret; \ 1929c28278aSTejun Heo }) 1939c28278aSTejun Heo 194c5c0ba95SPeter Zijlstra #define this_cpu_generic_try_cmpxchg(pcp, ovalp, nval) \ 195c5c0ba95SPeter Zijlstra ({ \ 196c5c0ba95SPeter Zijlstra bool __ret; \ 197c5c0ba95SPeter Zijlstra unsigned long __flags; \ 198c5c0ba95SPeter Zijlstra raw_local_irq_save(__flags); \ 199c5c0ba95SPeter Zijlstra __ret = raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval); \ 200c5c0ba95SPeter Zijlstra raw_local_irq_restore(__flags); \ 201c5c0ba95SPeter Zijlstra __ret; \ 202c5c0ba95SPeter Zijlstra }) 203c5c0ba95SPeter Zijlstra 204eba11788STejun Heo #define this_cpu_generic_cmpxchg(pcp, oval, nval) \ 2059c28278aSTejun Heo ({ \ 2068a3c3923SUros Bizjak TYPEOF_UNQUAL(pcp) __ret; \ 207eba11788STejun Heo unsigned long __flags; \ 208eba11788STejun Heo raw_local_irq_save(__flags); \ 2091b5ca121SNicholas Piggin __ret = raw_cpu_generic_cmpxchg(pcp, oval, nval); \ 210eba11788STejun Heo raw_local_irq_restore(__flags); \ 211eba11788STejun Heo __ret; \ 212eba11788STejun Heo }) 213eba11788STejun Heo 21447b69ad6STejun Heo #ifndef raw_cpu_read_1 2151b5ca121SNicholas Piggin #define raw_cpu_read_1(pcp) raw_cpu_generic_read(pcp) 21647b69ad6STejun Heo #endif 21747b69ad6STejun Heo #ifndef raw_cpu_read_2 2181b5ca121SNicholas Piggin #define raw_cpu_read_2(pcp) raw_cpu_generic_read(pcp) 21947b69ad6STejun Heo #endif 22047b69ad6STejun Heo #ifndef raw_cpu_read_4 2211b5ca121SNicholas Piggin #define raw_cpu_read_4(pcp) raw_cpu_generic_read(pcp) 22247b69ad6STejun Heo #endif 22347b69ad6STejun Heo #ifndef raw_cpu_read_8 2241b5ca121SNicholas Piggin #define raw_cpu_read_8(pcp) raw_cpu_generic_read(pcp) 22547b69ad6STejun Heo #endif 22647b69ad6STejun Heo 22747b69ad6STejun Heo #ifndef raw_cpu_write_1 228eba11788STejun Heo #define raw_cpu_write_1(pcp, val) raw_cpu_generic_to_op(pcp, val, =) 22947b69ad6STejun Heo #endif 23047b69ad6STejun Heo #ifndef raw_cpu_write_2 231eba11788STejun Heo #define raw_cpu_write_2(pcp, val) raw_cpu_generic_to_op(pcp, val, =) 23247b69ad6STejun Heo #endif 23347b69ad6STejun Heo #ifndef raw_cpu_write_4 234eba11788STejun Heo #define raw_cpu_write_4(pcp, val) raw_cpu_generic_to_op(pcp, val, =) 23547b69ad6STejun Heo #endif 23647b69ad6STejun Heo #ifndef raw_cpu_write_8 237eba11788STejun Heo #define raw_cpu_write_8(pcp, val) raw_cpu_generic_to_op(pcp, val, =) 23847b69ad6STejun Heo #endif 23947b69ad6STejun Heo 24047b69ad6STejun Heo #ifndef raw_cpu_add_1 241eba11788STejun Heo #define raw_cpu_add_1(pcp, val) raw_cpu_generic_to_op(pcp, val, +=) 24247b69ad6STejun Heo #endif 24347b69ad6STejun Heo #ifndef raw_cpu_add_2 244eba11788STejun Heo #define raw_cpu_add_2(pcp, val) raw_cpu_generic_to_op(pcp, val, +=) 24547b69ad6STejun Heo #endif 24647b69ad6STejun Heo #ifndef raw_cpu_add_4 247eba11788STejun Heo #define raw_cpu_add_4(pcp, val) raw_cpu_generic_to_op(pcp, val, +=) 24847b69ad6STejun Heo #endif 24947b69ad6STejun Heo #ifndef raw_cpu_add_8 250eba11788STejun Heo #define raw_cpu_add_8(pcp, val) raw_cpu_generic_to_op(pcp, val, +=) 25147b69ad6STejun Heo #endif 25247b69ad6STejun Heo 25347b69ad6STejun Heo #ifndef raw_cpu_and_1 254eba11788STejun Heo #define raw_cpu_and_1(pcp, val) raw_cpu_generic_to_op(pcp, val, &=) 25547b69ad6STejun Heo #endif 25647b69ad6STejun Heo #ifndef raw_cpu_and_2 257eba11788STejun Heo #define raw_cpu_and_2(pcp, val) raw_cpu_generic_to_op(pcp, val, &=) 25847b69ad6STejun Heo #endif 25947b69ad6STejun Heo #ifndef raw_cpu_and_4 260eba11788STejun Heo #define raw_cpu_and_4(pcp, val) raw_cpu_generic_to_op(pcp, val, &=) 26147b69ad6STejun Heo #endif 26247b69ad6STejun Heo #ifndef raw_cpu_and_8 263eba11788STejun Heo #define raw_cpu_and_8(pcp, val) raw_cpu_generic_to_op(pcp, val, &=) 26447b69ad6STejun Heo #endif 26547b69ad6STejun Heo 26647b69ad6STejun Heo #ifndef raw_cpu_or_1 267eba11788STejun Heo #define raw_cpu_or_1(pcp, val) raw_cpu_generic_to_op(pcp, val, |=) 26847b69ad6STejun Heo #endif 26947b69ad6STejun Heo #ifndef raw_cpu_or_2 270eba11788STejun Heo #define raw_cpu_or_2(pcp, val) raw_cpu_generic_to_op(pcp, val, |=) 27147b69ad6STejun Heo #endif 27247b69ad6STejun Heo #ifndef raw_cpu_or_4 273eba11788STejun Heo #define raw_cpu_or_4(pcp, val) raw_cpu_generic_to_op(pcp, val, |=) 27447b69ad6STejun Heo #endif 27547b69ad6STejun Heo #ifndef raw_cpu_or_8 276eba11788STejun Heo #define raw_cpu_or_8(pcp, val) raw_cpu_generic_to_op(pcp, val, |=) 27747b69ad6STejun Heo #endif 27847b69ad6STejun Heo 27947b69ad6STejun Heo #ifndef raw_cpu_add_return_1 28047b69ad6STejun Heo #define raw_cpu_add_return_1(pcp, val) raw_cpu_generic_add_return(pcp, val) 28147b69ad6STejun Heo #endif 28247b69ad6STejun Heo #ifndef raw_cpu_add_return_2 28347b69ad6STejun Heo #define raw_cpu_add_return_2(pcp, val) raw_cpu_generic_add_return(pcp, val) 28447b69ad6STejun Heo #endif 28547b69ad6STejun Heo #ifndef raw_cpu_add_return_4 28647b69ad6STejun Heo #define raw_cpu_add_return_4(pcp, val) raw_cpu_generic_add_return(pcp, val) 28747b69ad6STejun Heo #endif 28847b69ad6STejun Heo #ifndef raw_cpu_add_return_8 28947b69ad6STejun Heo #define raw_cpu_add_return_8(pcp, val) raw_cpu_generic_add_return(pcp, val) 29047b69ad6STejun Heo #endif 29147b69ad6STejun Heo 29247b69ad6STejun Heo #ifndef raw_cpu_xchg_1 29347b69ad6STejun Heo #define raw_cpu_xchg_1(pcp, nval) raw_cpu_generic_xchg(pcp, nval) 29447b69ad6STejun Heo #endif 29547b69ad6STejun Heo #ifndef raw_cpu_xchg_2 29647b69ad6STejun Heo #define raw_cpu_xchg_2(pcp, nval) raw_cpu_generic_xchg(pcp, nval) 29747b69ad6STejun Heo #endif 29847b69ad6STejun Heo #ifndef raw_cpu_xchg_4 29947b69ad6STejun Heo #define raw_cpu_xchg_4(pcp, nval) raw_cpu_generic_xchg(pcp, nval) 30047b69ad6STejun Heo #endif 30147b69ad6STejun Heo #ifndef raw_cpu_xchg_8 30247b69ad6STejun Heo #define raw_cpu_xchg_8(pcp, nval) raw_cpu_generic_xchg(pcp, nval) 30347b69ad6STejun Heo #endif 30447b69ad6STejun Heo 305c5c0ba95SPeter Zijlstra #ifndef raw_cpu_try_cmpxchg_1 306c5c0ba95SPeter Zijlstra #ifdef raw_cpu_cmpxchg_1 307c5c0ba95SPeter Zijlstra #define raw_cpu_try_cmpxchg_1(pcp, ovalp, nval) \ 308c5c0ba95SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_1) 309c5c0ba95SPeter Zijlstra #else 310c5c0ba95SPeter Zijlstra #define raw_cpu_try_cmpxchg_1(pcp, ovalp, nval) \ 311c5c0ba95SPeter Zijlstra raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 312c5c0ba95SPeter Zijlstra #endif 313c5c0ba95SPeter Zijlstra #endif 314c5c0ba95SPeter Zijlstra #ifndef raw_cpu_try_cmpxchg_2 315c5c0ba95SPeter Zijlstra #ifdef raw_cpu_cmpxchg_2 316c5c0ba95SPeter Zijlstra #define raw_cpu_try_cmpxchg_2(pcp, ovalp, nval) \ 317c5c0ba95SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_2) 318c5c0ba95SPeter Zijlstra #else 319c5c0ba95SPeter Zijlstra #define raw_cpu_try_cmpxchg_2(pcp, ovalp, nval) \ 320c5c0ba95SPeter Zijlstra raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 321c5c0ba95SPeter Zijlstra #endif 322c5c0ba95SPeter Zijlstra #endif 323c5c0ba95SPeter Zijlstra #ifndef raw_cpu_try_cmpxchg_4 324c5c0ba95SPeter Zijlstra #ifdef raw_cpu_cmpxchg_4 325c5c0ba95SPeter Zijlstra #define raw_cpu_try_cmpxchg_4(pcp, ovalp, nval) \ 326c5c0ba95SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_4) 327c5c0ba95SPeter Zijlstra #else 328c5c0ba95SPeter Zijlstra #define raw_cpu_try_cmpxchg_4(pcp, ovalp, nval) \ 329c5c0ba95SPeter Zijlstra raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 330c5c0ba95SPeter Zijlstra #endif 331c5c0ba95SPeter Zijlstra #endif 332c5c0ba95SPeter Zijlstra #ifndef raw_cpu_try_cmpxchg_8 333c5c0ba95SPeter Zijlstra #ifdef raw_cpu_cmpxchg_8 334c5c0ba95SPeter Zijlstra #define raw_cpu_try_cmpxchg_8(pcp, ovalp, nval) \ 335c5c0ba95SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_8) 336c5c0ba95SPeter Zijlstra #else 337c5c0ba95SPeter Zijlstra #define raw_cpu_try_cmpxchg_8(pcp, ovalp, nval) \ 338c5c0ba95SPeter Zijlstra raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 339c5c0ba95SPeter Zijlstra #endif 340c5c0ba95SPeter Zijlstra #endif 341c5c0ba95SPeter Zijlstra 3426d12c8d3SPeter Zijlstra #ifndef raw_cpu_try_cmpxchg64 3436d12c8d3SPeter Zijlstra #ifdef raw_cpu_cmpxchg64 3446d12c8d3SPeter Zijlstra #define raw_cpu_try_cmpxchg64(pcp, ovalp, nval) \ 3456d12c8d3SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg64) 3466d12c8d3SPeter Zijlstra #else 3476d12c8d3SPeter Zijlstra #define raw_cpu_try_cmpxchg64(pcp, ovalp, nval) \ 3486d12c8d3SPeter Zijlstra raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 3496d12c8d3SPeter Zijlstra #endif 3506d12c8d3SPeter Zijlstra #endif 3516d12c8d3SPeter Zijlstra #ifndef raw_cpu_try_cmpxchg128 3526d12c8d3SPeter Zijlstra #ifdef raw_cpu_cmpxchg128 3536d12c8d3SPeter Zijlstra #define raw_cpu_try_cmpxchg128(pcp, ovalp, nval) \ 3546d12c8d3SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg128) 3556d12c8d3SPeter Zijlstra #else 3566d12c8d3SPeter Zijlstra #define raw_cpu_try_cmpxchg128(pcp, ovalp, nval) \ 3576d12c8d3SPeter Zijlstra raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 3586d12c8d3SPeter Zijlstra #endif 3596d12c8d3SPeter Zijlstra #endif 3606d12c8d3SPeter Zijlstra 36147b69ad6STejun Heo #ifndef raw_cpu_cmpxchg_1 362eba11788STejun Heo #define raw_cpu_cmpxchg_1(pcp, oval, nval) \ 363eba11788STejun Heo raw_cpu_generic_cmpxchg(pcp, oval, nval) 36447b69ad6STejun Heo #endif 36547b69ad6STejun Heo #ifndef raw_cpu_cmpxchg_2 366eba11788STejun Heo #define raw_cpu_cmpxchg_2(pcp, oval, nval) \ 367eba11788STejun Heo raw_cpu_generic_cmpxchg(pcp, oval, nval) 36847b69ad6STejun Heo #endif 36947b69ad6STejun Heo #ifndef raw_cpu_cmpxchg_4 370eba11788STejun Heo #define raw_cpu_cmpxchg_4(pcp, oval, nval) \ 371eba11788STejun Heo raw_cpu_generic_cmpxchg(pcp, oval, nval) 37247b69ad6STejun Heo #endif 37347b69ad6STejun Heo #ifndef raw_cpu_cmpxchg_8 374eba11788STejun Heo #define raw_cpu_cmpxchg_8(pcp, oval, nval) \ 375eba11788STejun Heo raw_cpu_generic_cmpxchg(pcp, oval, nval) 37647b69ad6STejun Heo #endif 37747b69ad6STejun Heo 3786d12c8d3SPeter Zijlstra #ifndef raw_cpu_cmpxchg64 3796d12c8d3SPeter Zijlstra #define raw_cpu_cmpxchg64(pcp, oval, nval) \ 3806d12c8d3SPeter Zijlstra raw_cpu_generic_cmpxchg(pcp, oval, nval) 3816d12c8d3SPeter Zijlstra #endif 3826d12c8d3SPeter Zijlstra #ifndef raw_cpu_cmpxchg128 3836d12c8d3SPeter Zijlstra #define raw_cpu_cmpxchg128(pcp, oval, nval) \ 3846d12c8d3SPeter Zijlstra raw_cpu_generic_cmpxchg(pcp, oval, nval) 3856d12c8d3SPeter Zijlstra #endif 3866d12c8d3SPeter Zijlstra 38747b69ad6STejun Heo #ifndef this_cpu_read_1 388eba11788STejun Heo #define this_cpu_read_1(pcp) this_cpu_generic_read(pcp) 38947b69ad6STejun Heo #endif 39047b69ad6STejun Heo #ifndef this_cpu_read_2 391eba11788STejun Heo #define this_cpu_read_2(pcp) this_cpu_generic_read(pcp) 39247b69ad6STejun Heo #endif 39347b69ad6STejun Heo #ifndef this_cpu_read_4 394eba11788STejun Heo #define this_cpu_read_4(pcp) this_cpu_generic_read(pcp) 39547b69ad6STejun Heo #endif 39647b69ad6STejun Heo #ifndef this_cpu_read_8 397eba11788STejun Heo #define this_cpu_read_8(pcp) this_cpu_generic_read(pcp) 39847b69ad6STejun Heo #endif 39947b69ad6STejun Heo 40047b69ad6STejun Heo #ifndef this_cpu_write_1 401eba11788STejun Heo #define this_cpu_write_1(pcp, val) this_cpu_generic_to_op(pcp, val, =) 40247b69ad6STejun Heo #endif 40347b69ad6STejun Heo #ifndef this_cpu_write_2 404eba11788STejun Heo #define this_cpu_write_2(pcp, val) this_cpu_generic_to_op(pcp, val, =) 40547b69ad6STejun Heo #endif 40647b69ad6STejun Heo #ifndef this_cpu_write_4 407eba11788STejun Heo #define this_cpu_write_4(pcp, val) this_cpu_generic_to_op(pcp, val, =) 40847b69ad6STejun Heo #endif 40947b69ad6STejun Heo #ifndef this_cpu_write_8 410eba11788STejun Heo #define this_cpu_write_8(pcp, val) this_cpu_generic_to_op(pcp, val, =) 41147b69ad6STejun Heo #endif 41247b69ad6STejun Heo 41347b69ad6STejun Heo #ifndef this_cpu_add_1 414eba11788STejun Heo #define this_cpu_add_1(pcp, val) this_cpu_generic_to_op(pcp, val, +=) 41547b69ad6STejun Heo #endif 41647b69ad6STejun Heo #ifndef this_cpu_add_2 417eba11788STejun Heo #define this_cpu_add_2(pcp, val) this_cpu_generic_to_op(pcp, val, +=) 41847b69ad6STejun Heo #endif 41947b69ad6STejun Heo #ifndef this_cpu_add_4 420eba11788STejun Heo #define this_cpu_add_4(pcp, val) this_cpu_generic_to_op(pcp, val, +=) 42147b69ad6STejun Heo #endif 42247b69ad6STejun Heo #ifndef this_cpu_add_8 423eba11788STejun Heo #define this_cpu_add_8(pcp, val) this_cpu_generic_to_op(pcp, val, +=) 42447b69ad6STejun Heo #endif 42547b69ad6STejun Heo 42647b69ad6STejun Heo #ifndef this_cpu_and_1 427eba11788STejun Heo #define this_cpu_and_1(pcp, val) this_cpu_generic_to_op(pcp, val, &=) 42847b69ad6STejun Heo #endif 42947b69ad6STejun Heo #ifndef this_cpu_and_2 430eba11788STejun Heo #define this_cpu_and_2(pcp, val) this_cpu_generic_to_op(pcp, val, &=) 43147b69ad6STejun Heo #endif 43247b69ad6STejun Heo #ifndef this_cpu_and_4 433eba11788STejun Heo #define this_cpu_and_4(pcp, val) this_cpu_generic_to_op(pcp, val, &=) 43447b69ad6STejun Heo #endif 43547b69ad6STejun Heo #ifndef this_cpu_and_8 436eba11788STejun Heo #define this_cpu_and_8(pcp, val) this_cpu_generic_to_op(pcp, val, &=) 43747b69ad6STejun Heo #endif 43847b69ad6STejun Heo 43947b69ad6STejun Heo #ifndef this_cpu_or_1 440eba11788STejun Heo #define this_cpu_or_1(pcp, val) this_cpu_generic_to_op(pcp, val, |=) 44147b69ad6STejun Heo #endif 44247b69ad6STejun Heo #ifndef this_cpu_or_2 443eba11788STejun Heo #define this_cpu_or_2(pcp, val) this_cpu_generic_to_op(pcp, val, |=) 44447b69ad6STejun Heo #endif 44547b69ad6STejun Heo #ifndef this_cpu_or_4 446eba11788STejun Heo #define this_cpu_or_4(pcp, val) this_cpu_generic_to_op(pcp, val, |=) 44747b69ad6STejun Heo #endif 44847b69ad6STejun Heo #ifndef this_cpu_or_8 449eba11788STejun Heo #define this_cpu_or_8(pcp, val) this_cpu_generic_to_op(pcp, val, |=) 45047b69ad6STejun Heo #endif 45147b69ad6STejun Heo 45247b69ad6STejun Heo #ifndef this_cpu_add_return_1 453eba11788STejun Heo #define this_cpu_add_return_1(pcp, val) this_cpu_generic_add_return(pcp, val) 45447b69ad6STejun Heo #endif 45547b69ad6STejun Heo #ifndef this_cpu_add_return_2 456eba11788STejun Heo #define this_cpu_add_return_2(pcp, val) this_cpu_generic_add_return(pcp, val) 45747b69ad6STejun Heo #endif 45847b69ad6STejun Heo #ifndef this_cpu_add_return_4 459eba11788STejun Heo #define this_cpu_add_return_4(pcp, val) this_cpu_generic_add_return(pcp, val) 46047b69ad6STejun Heo #endif 46147b69ad6STejun Heo #ifndef this_cpu_add_return_8 462eba11788STejun Heo #define this_cpu_add_return_8(pcp, val) this_cpu_generic_add_return(pcp, val) 46347b69ad6STejun Heo #endif 46447b69ad6STejun Heo 46547b69ad6STejun Heo #ifndef this_cpu_xchg_1 466eba11788STejun Heo #define this_cpu_xchg_1(pcp, nval) this_cpu_generic_xchg(pcp, nval) 46747b69ad6STejun Heo #endif 46847b69ad6STejun Heo #ifndef this_cpu_xchg_2 469eba11788STejun Heo #define this_cpu_xchg_2(pcp, nval) this_cpu_generic_xchg(pcp, nval) 47047b69ad6STejun Heo #endif 47147b69ad6STejun Heo #ifndef this_cpu_xchg_4 472eba11788STejun Heo #define this_cpu_xchg_4(pcp, nval) this_cpu_generic_xchg(pcp, nval) 47347b69ad6STejun Heo #endif 47447b69ad6STejun Heo #ifndef this_cpu_xchg_8 475eba11788STejun Heo #define this_cpu_xchg_8(pcp, nval) this_cpu_generic_xchg(pcp, nval) 47647b69ad6STejun Heo #endif 47747b69ad6STejun Heo 478c5c0ba95SPeter Zijlstra #ifndef this_cpu_try_cmpxchg_1 479c5c0ba95SPeter Zijlstra #ifdef this_cpu_cmpxchg_1 480c5c0ba95SPeter Zijlstra #define this_cpu_try_cmpxchg_1(pcp, ovalp, nval) \ 481c5c0ba95SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_1) 482c5c0ba95SPeter Zijlstra #else 483c5c0ba95SPeter Zijlstra #define this_cpu_try_cmpxchg_1(pcp, ovalp, nval) \ 484c5c0ba95SPeter Zijlstra this_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 485c5c0ba95SPeter Zijlstra #endif 486c5c0ba95SPeter Zijlstra #endif 487c5c0ba95SPeter Zijlstra #ifndef this_cpu_try_cmpxchg_2 488c5c0ba95SPeter Zijlstra #ifdef this_cpu_cmpxchg_2 489c5c0ba95SPeter Zijlstra #define this_cpu_try_cmpxchg_2(pcp, ovalp, nval) \ 490c5c0ba95SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_2) 491c5c0ba95SPeter Zijlstra #else 492c5c0ba95SPeter Zijlstra #define this_cpu_try_cmpxchg_2(pcp, ovalp, nval) \ 493c5c0ba95SPeter Zijlstra this_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 494c5c0ba95SPeter Zijlstra #endif 495c5c0ba95SPeter Zijlstra #endif 496c5c0ba95SPeter Zijlstra #ifndef this_cpu_try_cmpxchg_4 497c5c0ba95SPeter Zijlstra #ifdef this_cpu_cmpxchg_4 498c5c0ba95SPeter Zijlstra #define this_cpu_try_cmpxchg_4(pcp, ovalp, nval) \ 499c5c0ba95SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_4) 500c5c0ba95SPeter Zijlstra #else 501c5c0ba95SPeter Zijlstra #define this_cpu_try_cmpxchg_4(pcp, ovalp, nval) \ 502c5c0ba95SPeter Zijlstra this_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 503c5c0ba95SPeter Zijlstra #endif 504c5c0ba95SPeter Zijlstra #endif 505c5c0ba95SPeter Zijlstra #ifndef this_cpu_try_cmpxchg_8 506c5c0ba95SPeter Zijlstra #ifdef this_cpu_cmpxchg_8 507c5c0ba95SPeter Zijlstra #define this_cpu_try_cmpxchg_8(pcp, ovalp, nval) \ 508c5c0ba95SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_8) 509c5c0ba95SPeter Zijlstra #else 510c5c0ba95SPeter Zijlstra #define this_cpu_try_cmpxchg_8(pcp, ovalp, nval) \ 511c5c0ba95SPeter Zijlstra this_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 512c5c0ba95SPeter Zijlstra #endif 513c5c0ba95SPeter Zijlstra #endif 514c5c0ba95SPeter Zijlstra 5156d12c8d3SPeter Zijlstra #ifndef this_cpu_try_cmpxchg64 5166d12c8d3SPeter Zijlstra #ifdef this_cpu_cmpxchg64 5176d12c8d3SPeter Zijlstra #define this_cpu_try_cmpxchg64(pcp, ovalp, nval) \ 5186d12c8d3SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg64) 5196d12c8d3SPeter Zijlstra #else 5206d12c8d3SPeter Zijlstra #define this_cpu_try_cmpxchg64(pcp, ovalp, nval) \ 5216d12c8d3SPeter Zijlstra this_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 5226d12c8d3SPeter Zijlstra #endif 5236d12c8d3SPeter Zijlstra #endif 5246d12c8d3SPeter Zijlstra #ifndef this_cpu_try_cmpxchg128 5256d12c8d3SPeter Zijlstra #ifdef this_cpu_cmpxchg128 5266d12c8d3SPeter Zijlstra #define this_cpu_try_cmpxchg128(pcp, ovalp, nval) \ 5276d12c8d3SPeter Zijlstra __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg128) 5286d12c8d3SPeter Zijlstra #else 5296d12c8d3SPeter Zijlstra #define this_cpu_try_cmpxchg128(pcp, ovalp, nval) \ 5306d12c8d3SPeter Zijlstra this_cpu_generic_try_cmpxchg(pcp, ovalp, nval) 5316d12c8d3SPeter Zijlstra #endif 5326d12c8d3SPeter Zijlstra #endif 5336d12c8d3SPeter Zijlstra 53447b69ad6STejun Heo #ifndef this_cpu_cmpxchg_1 535eba11788STejun Heo #define this_cpu_cmpxchg_1(pcp, oval, nval) \ 536eba11788STejun Heo this_cpu_generic_cmpxchg(pcp, oval, nval) 53747b69ad6STejun Heo #endif 53847b69ad6STejun Heo #ifndef this_cpu_cmpxchg_2 539eba11788STejun Heo #define this_cpu_cmpxchg_2(pcp, oval, nval) \ 540eba11788STejun Heo this_cpu_generic_cmpxchg(pcp, oval, nval) 54147b69ad6STejun Heo #endif 54247b69ad6STejun Heo #ifndef this_cpu_cmpxchg_4 543eba11788STejun Heo #define this_cpu_cmpxchg_4(pcp, oval, nval) \ 544eba11788STejun Heo this_cpu_generic_cmpxchg(pcp, oval, nval) 54547b69ad6STejun Heo #endif 54647b69ad6STejun Heo #ifndef this_cpu_cmpxchg_8 547eba11788STejun Heo #define this_cpu_cmpxchg_8(pcp, oval, nval) \ 548eba11788STejun Heo this_cpu_generic_cmpxchg(pcp, oval, nval) 54947b69ad6STejun Heo #endif 55047b69ad6STejun Heo 5516d12c8d3SPeter Zijlstra #ifndef this_cpu_cmpxchg64 5526d12c8d3SPeter Zijlstra #define this_cpu_cmpxchg64(pcp, oval, nval) \ 5536d12c8d3SPeter Zijlstra this_cpu_generic_cmpxchg(pcp, oval, nval) 5546d12c8d3SPeter Zijlstra #endif 5556d12c8d3SPeter Zijlstra #ifndef this_cpu_cmpxchg128 5566d12c8d3SPeter Zijlstra #define this_cpu_cmpxchg128(pcp, oval, nval) \ 5576d12c8d3SPeter Zijlstra this_cpu_generic_cmpxchg(pcp, oval, nval) 5586d12c8d3SPeter Zijlstra #endif 5596d12c8d3SPeter Zijlstra 5601da177e4SLinus Torvalds #endif /* _ASM_GENERIC_PERCPU_H_ */ 561