percpu.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_GENERIC_PERCPU_H_
  3. #define _ASM_GENERIC_PERCPU_H_
  4. #include <linux/compiler.h>
  5. #include <linux/threads.h>
  6. #include <linux/percpu-defs.h>
  7. #ifdef CONFIG_SMP
  8. /*
  9. * per_cpu_offset() is the offset that has to be added to a
  10. * percpu variable to get to the instance for a certain processor.
  11. *
  12. * Most arches use the __per_cpu_offset array for those offsets but
  13. * some arches have their own ways of determining the offset (x86_64, s390).
  14. */
  15. #ifndef __per_cpu_offset
  16. extern unsigned long __per_cpu_offset[NR_CPUS];
  17. #define per_cpu_offset(x) (__per_cpu_offset[x])
  18. #endif
  19. /*
  20. * Determine the offset for the currently active processor.
  21. * An arch may define __my_cpu_offset to provide a more effective
  22. * means of obtaining the offset to the per cpu variables of the
  23. * current processor.
  24. */
  25. #ifndef __my_cpu_offset
  26. #define __my_cpu_offset per_cpu_offset(raw_smp_processor_id())
  27. #endif
  28. #ifdef CONFIG_DEBUG_PREEMPT
  29. #define my_cpu_offset per_cpu_offset(smp_processor_id())
  30. #else
  31. #define my_cpu_offset __my_cpu_offset
  32. #endif
  33. /*
  34. * Arch may define arch_raw_cpu_ptr() to provide more efficient address
  35. * translations for raw_cpu_ptr().
  36. */
  37. #ifndef arch_raw_cpu_ptr
  38. #define arch_raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
  39. #endif
  40. #ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
  41. extern void setup_per_cpu_areas(void);
  42. #endif
  43. #endif /* SMP */
  44. #ifndef PER_CPU_BASE_SECTION
  45. #ifdef CONFIG_SMP
  46. #define PER_CPU_BASE_SECTION ".data..percpu"
  47. #else
  48. #define PER_CPU_BASE_SECTION ".data"
  49. #endif
  50. #endif
  51. #ifndef PER_CPU_ATTRIBUTES
  52. #define PER_CPU_ATTRIBUTES
  53. #endif
  54. #define raw_cpu_generic_read(pcp) \
  55. ({ \
  56. *raw_cpu_ptr(&(pcp)); \
  57. })
  58. #define raw_cpu_generic_to_op(pcp, val, op) \
  59. do { \
  60. *raw_cpu_ptr(&(pcp)) op val; \
  61. } while (0)
  62. #define raw_cpu_generic_add_return(pcp, val) \
  63. ({ \
  64. typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \
  65. \
  66. *__p += val; \
  67. *__p; \
  68. })
  69. #define raw_cpu_generic_xchg(pcp, nval) \
  70. ({ \
  71. typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \
  72. typeof(pcp) __ret; \
  73. __ret = *__p; \
  74. *__p = nval; \
  75. __ret; \
  76. })
  77. #define __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, _cmpxchg) \
  78. ({ \
  79. typeof(pcp) __val, __old = *(ovalp); \
  80. __val = _cmpxchg(pcp, __old, nval); \
  81. if (__val != __old) \
  82. *(ovalp) = __val; \
  83. __val == __old; \
  84. })
  85. #define raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) \
  86. ({ \
  87. typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \
  88. typeof(pcp) __val = *__p, ___old = *(ovalp); \
  89. bool __ret; \
  90. if (__val == ___old) { \
  91. *__p = nval; \
  92. __ret = true; \
  93. } else { \
  94. *(ovalp) = __val; \
  95. __ret = false; \
  96. } \
  97. __ret; \
  98. })
  99. #define raw_cpu_generic_cmpxchg(pcp, oval, nval) \
  100. ({ \
  101. typeof(pcp) __old = (oval); \
  102. raw_cpu_generic_try_cmpxchg(pcp, &__old, nval); \
  103. __old; \
  104. })
  105. #define __this_cpu_generic_read_nopreempt(pcp) \
  106. ({ \
  107. typeof(pcp) ___ret; \
  108. preempt_disable_notrace(); \
  109. ___ret = READ_ONCE(*raw_cpu_ptr(&(pcp))); \
  110. preempt_enable_notrace(); \
  111. ___ret; \
  112. })
  113. #define __this_cpu_generic_read_noirq(pcp) \
  114. ({ \
  115. typeof(pcp) ___ret; \
  116. unsigned long ___flags; \
  117. raw_local_irq_save(___flags); \
  118. ___ret = raw_cpu_generic_read(pcp); \
  119. raw_local_irq_restore(___flags); \
  120. ___ret; \
  121. })
  122. #define this_cpu_generic_read(pcp) \
  123. ({ \
  124. typeof(pcp) __ret; \
  125. if (__native_word(pcp)) \
  126. __ret = __this_cpu_generic_read_nopreempt(pcp); \
  127. else \
  128. __ret = __this_cpu_generic_read_noirq(pcp); \
  129. __ret; \
  130. })
  131. #define this_cpu_generic_to_op(pcp, val, op) \
  132. do { \
  133. unsigned long __flags; \
  134. raw_local_irq_save(__flags); \
  135. raw_cpu_generic_to_op(pcp, val, op); \
  136. raw_local_irq_restore(__flags); \
  137. } while (0)
  138. #define this_cpu_generic_add_return(pcp, val) \
  139. ({ \
  140. typeof(pcp) __ret; \
  141. unsigned long __flags; \
  142. raw_local_irq_save(__flags); \
  143. __ret = raw_cpu_generic_add_return(pcp, val); \
  144. raw_local_irq_restore(__flags); \
  145. __ret; \
  146. })
  147. #define this_cpu_generic_xchg(pcp, nval) \
  148. ({ \
  149. typeof(pcp) __ret; \
  150. unsigned long __flags; \
  151. raw_local_irq_save(__flags); \
  152. __ret = raw_cpu_generic_xchg(pcp, nval); \
  153. raw_local_irq_restore(__flags); \
  154. __ret; \
  155. })
  156. #define this_cpu_generic_try_cmpxchg(pcp, ovalp, nval) \
  157. ({ \
  158. bool __ret; \
  159. unsigned long __flags; \
  160. raw_local_irq_save(__flags); \
  161. __ret = raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval); \
  162. raw_local_irq_restore(__flags); \
  163. __ret; \
  164. })
  165. #define this_cpu_generic_cmpxchg(pcp, oval, nval) \
  166. ({ \
  167. typeof(pcp) __ret; \
  168. unsigned long __flags; \
  169. raw_local_irq_save(__flags); \
  170. __ret = raw_cpu_generic_cmpxchg(pcp, oval, nval); \
  171. raw_local_irq_restore(__flags); \
  172. __ret; \
  173. })
  174. #ifndef raw_cpu_read_1
  175. #define raw_cpu_read_1(pcp) raw_cpu_generic_read(pcp)
  176. #endif
  177. #ifndef raw_cpu_read_2
  178. #define raw_cpu_read_2(pcp) raw_cpu_generic_read(pcp)
  179. #endif
  180. #ifndef raw_cpu_read_4
  181. #define raw_cpu_read_4(pcp) raw_cpu_generic_read(pcp)
  182. #endif
  183. #ifndef raw_cpu_read_8
  184. #define raw_cpu_read_8(pcp) raw_cpu_generic_read(pcp)
  185. #endif
  186. #ifndef raw_cpu_write_1
  187. #define raw_cpu_write_1(pcp, val) raw_cpu_generic_to_op(pcp, val, =)
  188. #endif
  189. #ifndef raw_cpu_write_2
  190. #define raw_cpu_write_2(pcp, val) raw_cpu_generic_to_op(pcp, val, =)
  191. #endif
  192. #ifndef raw_cpu_write_4
  193. #define raw_cpu_write_4(pcp, val) raw_cpu_generic_to_op(pcp, val, =)
  194. #endif
  195. #ifndef raw_cpu_write_8
  196. #define raw_cpu_write_8(pcp, val) raw_cpu_generic_to_op(pcp, val, =)
  197. #endif
  198. #ifndef raw_cpu_add_1
  199. #define raw_cpu_add_1(pcp, val) raw_cpu_generic_to_op(pcp, val, +=)
  200. #endif
  201. #ifndef raw_cpu_add_2
  202. #define raw_cpu_add_2(pcp, val) raw_cpu_generic_to_op(pcp, val, +=)
  203. #endif
  204. #ifndef raw_cpu_add_4
  205. #define raw_cpu_add_4(pcp, val) raw_cpu_generic_to_op(pcp, val, +=)
  206. #endif
  207. #ifndef raw_cpu_add_8
  208. #define raw_cpu_add_8(pcp, val) raw_cpu_generic_to_op(pcp, val, +=)
  209. #endif
  210. #ifndef raw_cpu_and_1
  211. #define raw_cpu_and_1(pcp, val) raw_cpu_generic_to_op(pcp, val, &=)
  212. #endif
  213. #ifndef raw_cpu_and_2
  214. #define raw_cpu_and_2(pcp, val) raw_cpu_generic_to_op(pcp, val, &=)
  215. #endif
  216. #ifndef raw_cpu_and_4
  217. #define raw_cpu_and_4(pcp, val) raw_cpu_generic_to_op(pcp, val, &=)
  218. #endif
  219. #ifndef raw_cpu_and_8
  220. #define raw_cpu_and_8(pcp, val) raw_cpu_generic_to_op(pcp, val, &=)
  221. #endif
  222. #ifndef raw_cpu_or_1
  223. #define raw_cpu_or_1(pcp, val) raw_cpu_generic_to_op(pcp, val, |=)
  224. #endif
  225. #ifndef raw_cpu_or_2
  226. #define raw_cpu_or_2(pcp, val) raw_cpu_generic_to_op(pcp, val, |=)
  227. #endif
  228. #ifndef raw_cpu_or_4
  229. #define raw_cpu_or_4(pcp, val) raw_cpu_generic_to_op(pcp, val, |=)
  230. #endif
  231. #ifndef raw_cpu_or_8
  232. #define raw_cpu_or_8(pcp, val) raw_cpu_generic_to_op(pcp, val, |=)
  233. #endif
  234. #ifndef raw_cpu_add_return_1
  235. #define raw_cpu_add_return_1(pcp, val) raw_cpu_generic_add_return(pcp, val)
  236. #endif
  237. #ifndef raw_cpu_add_return_2
  238. #define raw_cpu_add_return_2(pcp, val) raw_cpu_generic_add_return(pcp, val)
  239. #endif
  240. #ifndef raw_cpu_add_return_4
  241. #define raw_cpu_add_return_4(pcp, val) raw_cpu_generic_add_return(pcp, val)
  242. #endif
  243. #ifndef raw_cpu_add_return_8
  244. #define raw_cpu_add_return_8(pcp, val) raw_cpu_generic_add_return(pcp, val)
  245. #endif
  246. #ifndef raw_cpu_xchg_1
  247. #define raw_cpu_xchg_1(pcp, nval) raw_cpu_generic_xchg(pcp, nval)
  248. #endif
  249. #ifndef raw_cpu_xchg_2
  250. #define raw_cpu_xchg_2(pcp, nval) raw_cpu_generic_xchg(pcp, nval)
  251. #endif
  252. #ifndef raw_cpu_xchg_4
  253. #define raw_cpu_xchg_4(pcp, nval) raw_cpu_generic_xchg(pcp, nval)
  254. #endif
  255. #ifndef raw_cpu_xchg_8
  256. #define raw_cpu_xchg_8(pcp, nval) raw_cpu_generic_xchg(pcp, nval)
  257. #endif
  258. #ifndef raw_cpu_try_cmpxchg_1
  259. #ifdef raw_cpu_cmpxchg_1
  260. #define raw_cpu_try_cmpxchg_1(pcp, ovalp, nval) \
  261. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_1)
  262. #else
  263. #define raw_cpu_try_cmpxchg_1(pcp, ovalp, nval) \
  264. raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  265. #endif
  266. #endif
  267. #ifndef raw_cpu_try_cmpxchg_2
  268. #ifdef raw_cpu_cmpxchg_2
  269. #define raw_cpu_try_cmpxchg_2(pcp, ovalp, nval) \
  270. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_2)
  271. #else
  272. #define raw_cpu_try_cmpxchg_2(pcp, ovalp, nval) \
  273. raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  274. #endif
  275. #endif
  276. #ifndef raw_cpu_try_cmpxchg_4
  277. #ifdef raw_cpu_cmpxchg_4
  278. #define raw_cpu_try_cmpxchg_4(pcp, ovalp, nval) \
  279. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_4)
  280. #else
  281. #define raw_cpu_try_cmpxchg_4(pcp, ovalp, nval) \
  282. raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  283. #endif
  284. #endif
  285. #ifndef raw_cpu_try_cmpxchg_8
  286. #ifdef raw_cpu_cmpxchg_8
  287. #define raw_cpu_try_cmpxchg_8(pcp, ovalp, nval) \
  288. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg_8)
  289. #else
  290. #define raw_cpu_try_cmpxchg_8(pcp, ovalp, nval) \
  291. raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  292. #endif
  293. #endif
  294. #ifndef raw_cpu_try_cmpxchg64
  295. #ifdef raw_cpu_cmpxchg64
  296. #define raw_cpu_try_cmpxchg64(pcp, ovalp, nval) \
  297. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg64)
  298. #else
  299. #define raw_cpu_try_cmpxchg64(pcp, ovalp, nval) \
  300. raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  301. #endif
  302. #endif
  303. #ifndef raw_cpu_try_cmpxchg128
  304. #ifdef raw_cpu_cmpxchg128
  305. #define raw_cpu_try_cmpxchg128(pcp, ovalp, nval) \
  306. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, raw_cpu_cmpxchg128)
  307. #else
  308. #define raw_cpu_try_cmpxchg128(pcp, ovalp, nval) \
  309. raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  310. #endif
  311. #endif
  312. #ifndef raw_cpu_cmpxchg_1
  313. #define raw_cpu_cmpxchg_1(pcp, oval, nval) \
  314. raw_cpu_generic_cmpxchg(pcp, oval, nval)
  315. #endif
  316. #ifndef raw_cpu_cmpxchg_2
  317. #define raw_cpu_cmpxchg_2(pcp, oval, nval) \
  318. raw_cpu_generic_cmpxchg(pcp, oval, nval)
  319. #endif
  320. #ifndef raw_cpu_cmpxchg_4
  321. #define raw_cpu_cmpxchg_4(pcp, oval, nval) \
  322. raw_cpu_generic_cmpxchg(pcp, oval, nval)
  323. #endif
  324. #ifndef raw_cpu_cmpxchg_8
  325. #define raw_cpu_cmpxchg_8(pcp, oval, nval) \
  326. raw_cpu_generic_cmpxchg(pcp, oval, nval)
  327. #endif
  328. #ifndef raw_cpu_cmpxchg64
  329. #define raw_cpu_cmpxchg64(pcp, oval, nval) \
  330. raw_cpu_generic_cmpxchg(pcp, oval, nval)
  331. #endif
  332. #ifndef raw_cpu_cmpxchg128
  333. #define raw_cpu_cmpxchg128(pcp, oval, nval) \
  334. raw_cpu_generic_cmpxchg(pcp, oval, nval)
  335. #endif
  336. #ifndef this_cpu_read_1
  337. #define this_cpu_read_1(pcp) this_cpu_generic_read(pcp)
  338. #endif
  339. #ifndef this_cpu_read_2
  340. #define this_cpu_read_2(pcp) this_cpu_generic_read(pcp)
  341. #endif
  342. #ifndef this_cpu_read_4
  343. #define this_cpu_read_4(pcp) this_cpu_generic_read(pcp)
  344. #endif
  345. #ifndef this_cpu_read_8
  346. #define this_cpu_read_8(pcp) this_cpu_generic_read(pcp)
  347. #endif
  348. #ifndef this_cpu_write_1
  349. #define this_cpu_write_1(pcp, val) this_cpu_generic_to_op(pcp, val, =)
  350. #endif
  351. #ifndef this_cpu_write_2
  352. #define this_cpu_write_2(pcp, val) this_cpu_generic_to_op(pcp, val, =)
  353. #endif
  354. #ifndef this_cpu_write_4
  355. #define this_cpu_write_4(pcp, val) this_cpu_generic_to_op(pcp, val, =)
  356. #endif
  357. #ifndef this_cpu_write_8
  358. #define this_cpu_write_8(pcp, val) this_cpu_generic_to_op(pcp, val, =)
  359. #endif
  360. #ifndef this_cpu_add_1
  361. #define this_cpu_add_1(pcp, val) this_cpu_generic_to_op(pcp, val, +=)
  362. #endif
  363. #ifndef this_cpu_add_2
  364. #define this_cpu_add_2(pcp, val) this_cpu_generic_to_op(pcp, val, +=)
  365. #endif
  366. #ifndef this_cpu_add_4
  367. #define this_cpu_add_4(pcp, val) this_cpu_generic_to_op(pcp, val, +=)
  368. #endif
  369. #ifndef this_cpu_add_8
  370. #define this_cpu_add_8(pcp, val) this_cpu_generic_to_op(pcp, val, +=)
  371. #endif
  372. #ifndef this_cpu_and_1
  373. #define this_cpu_and_1(pcp, val) this_cpu_generic_to_op(pcp, val, &=)
  374. #endif
  375. #ifndef this_cpu_and_2
  376. #define this_cpu_and_2(pcp, val) this_cpu_generic_to_op(pcp, val, &=)
  377. #endif
  378. #ifndef this_cpu_and_4
  379. #define this_cpu_and_4(pcp, val) this_cpu_generic_to_op(pcp, val, &=)
  380. #endif
  381. #ifndef this_cpu_and_8
  382. #define this_cpu_and_8(pcp, val) this_cpu_generic_to_op(pcp, val, &=)
  383. #endif
  384. #ifndef this_cpu_or_1
  385. #define this_cpu_or_1(pcp, val) this_cpu_generic_to_op(pcp, val, |=)
  386. #endif
  387. #ifndef this_cpu_or_2
  388. #define this_cpu_or_2(pcp, val) this_cpu_generic_to_op(pcp, val, |=)
  389. #endif
  390. #ifndef this_cpu_or_4
  391. #define this_cpu_or_4(pcp, val) this_cpu_generic_to_op(pcp, val, |=)
  392. #endif
  393. #ifndef this_cpu_or_8
  394. #define this_cpu_or_8(pcp, val) this_cpu_generic_to_op(pcp, val, |=)
  395. #endif
  396. #ifndef this_cpu_add_return_1
  397. #define this_cpu_add_return_1(pcp, val) this_cpu_generic_add_return(pcp, val)
  398. #endif
  399. #ifndef this_cpu_add_return_2
  400. #define this_cpu_add_return_2(pcp, val) this_cpu_generic_add_return(pcp, val)
  401. #endif
  402. #ifndef this_cpu_add_return_4
  403. #define this_cpu_add_return_4(pcp, val) this_cpu_generic_add_return(pcp, val)
  404. #endif
  405. #ifndef this_cpu_add_return_8
  406. #define this_cpu_add_return_8(pcp, val) this_cpu_generic_add_return(pcp, val)
  407. #endif
  408. #ifndef this_cpu_xchg_1
  409. #define this_cpu_xchg_1(pcp, nval) this_cpu_generic_xchg(pcp, nval)
  410. #endif
  411. #ifndef this_cpu_xchg_2
  412. #define this_cpu_xchg_2(pcp, nval) this_cpu_generic_xchg(pcp, nval)
  413. #endif
  414. #ifndef this_cpu_xchg_4
  415. #define this_cpu_xchg_4(pcp, nval) this_cpu_generic_xchg(pcp, nval)
  416. #endif
  417. #ifndef this_cpu_xchg_8
  418. #define this_cpu_xchg_8(pcp, nval) this_cpu_generic_xchg(pcp, nval)
  419. #endif
  420. #ifndef this_cpu_try_cmpxchg_1
  421. #ifdef this_cpu_cmpxchg_1
  422. #define this_cpu_try_cmpxchg_1(pcp, ovalp, nval) \
  423. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_1)
  424. #else
  425. #define this_cpu_try_cmpxchg_1(pcp, ovalp, nval) \
  426. this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  427. #endif
  428. #endif
  429. #ifndef this_cpu_try_cmpxchg_2
  430. #ifdef this_cpu_cmpxchg_2
  431. #define this_cpu_try_cmpxchg_2(pcp, ovalp, nval) \
  432. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_2)
  433. #else
  434. #define this_cpu_try_cmpxchg_2(pcp, ovalp, nval) \
  435. this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  436. #endif
  437. #endif
  438. #ifndef this_cpu_try_cmpxchg_4
  439. #ifdef this_cpu_cmpxchg_4
  440. #define this_cpu_try_cmpxchg_4(pcp, ovalp, nval) \
  441. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_4)
  442. #else
  443. #define this_cpu_try_cmpxchg_4(pcp, ovalp, nval) \
  444. this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  445. #endif
  446. #endif
  447. #ifndef this_cpu_try_cmpxchg_8
  448. #ifdef this_cpu_cmpxchg_8
  449. #define this_cpu_try_cmpxchg_8(pcp, ovalp, nval) \
  450. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg_8)
  451. #else
  452. #define this_cpu_try_cmpxchg_8(pcp, ovalp, nval) \
  453. this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  454. #endif
  455. #endif
  456. #ifndef this_cpu_try_cmpxchg64
  457. #ifdef this_cpu_cmpxchg64
  458. #define this_cpu_try_cmpxchg64(pcp, ovalp, nval) \
  459. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg64)
  460. #else
  461. #define this_cpu_try_cmpxchg64(pcp, ovalp, nval) \
  462. this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  463. #endif
  464. #endif
  465. #ifndef this_cpu_try_cmpxchg128
  466. #ifdef this_cpu_cmpxchg128
  467. #define this_cpu_try_cmpxchg128(pcp, ovalp, nval) \
  468. __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, this_cpu_cmpxchg128)
  469. #else
  470. #define this_cpu_try_cmpxchg128(pcp, ovalp, nval) \
  471. this_cpu_generic_try_cmpxchg(pcp, ovalp, nval)
  472. #endif
  473. #endif
  474. #ifndef this_cpu_cmpxchg_1
  475. #define this_cpu_cmpxchg_1(pcp, oval, nval) \
  476. this_cpu_generic_cmpxchg(pcp, oval, nval)
  477. #endif
  478. #ifndef this_cpu_cmpxchg_2
  479. #define this_cpu_cmpxchg_2(pcp, oval, nval) \
  480. this_cpu_generic_cmpxchg(pcp, oval, nval)
  481. #endif
  482. #ifndef this_cpu_cmpxchg_4
  483. #define this_cpu_cmpxchg_4(pcp, oval, nval) \
  484. this_cpu_generic_cmpxchg(pcp, oval, nval)
  485. #endif
  486. #ifndef this_cpu_cmpxchg_8
  487. #define this_cpu_cmpxchg_8(pcp, oval, nval) \
  488. this_cpu_generic_cmpxchg(pcp, oval, nval)
  489. #endif
  490. #ifndef this_cpu_cmpxchg64
  491. #define this_cpu_cmpxchg64(pcp, oval, nval) \
  492. this_cpu_generic_cmpxchg(pcp, oval, nval)
  493. #endif
  494. #ifndef this_cpu_cmpxchg128
  495. #define this_cpu_cmpxchg128(pcp, oval, nval) \
  496. this_cpu_generic_cmpxchg(pcp, oval, nval)
  497. #endif
  498. #endif /* _ASM_GENERIC_PERCPU_H_ */