percpu.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. #ifndef __LINUX_PERCPU_H
  2. #define __LINUX_PERCPU_H
  3. #include <linux/preempt.h>
  4. #include <linux/smp.h>
  5. #include <linux/cpumask.h>
  6. #include <linux/pfn.h>
  7. #include <linux/init.h>
  8. #include <asm/percpu.h>
  9. /* enough to cover all DEFINE_PER_CPUs in modules */
  10. #ifdef CONFIG_MODULES
  11. #define PERCPU_MODULE_RESERVE (8 << 10)
  12. #else
  13. #define PERCPU_MODULE_RESERVE 0
  14. #endif
  15. #ifndef PERCPU_ENOUGH_ROOM
  16. #define PERCPU_ENOUGH_ROOM \
  17. (ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES) + \
  18. PERCPU_MODULE_RESERVE)
  19. #endif
  20. /*
  21. * Must be an lvalue. Since @var must be a simple identifier,
  22. * we force a syntax error here if it isn't.
  23. */
  24. #define get_cpu_var(var) (*({ \
  25. preempt_disable(); \
  26. &__get_cpu_var(var); }))
  27. /*
  28. * The weird & is necessary because sparse considers (void)(var) to be
  29. * a direct dereference of percpu variable (var).
  30. */
  31. #define put_cpu_var(var) do { \
  32. (void)&(var); \
  33. preempt_enable(); \
  34. } while (0)
  35. #define get_cpu_ptr(var) ({ \
  36. preempt_disable(); \
  37. this_cpu_ptr(var); })
  38. #define put_cpu_ptr(var) do { \
  39. (void)(var); \
  40. preempt_enable(); \
  41. } while (0)
  42. /* minimum unit size, also is the maximum supported allocation size */
  43. #define PCPU_MIN_UNIT_SIZE PFN_ALIGN(32 << 10)
  44. /*
  45. * Percpu allocator can serve percpu allocations before slab is
  46. * initialized which allows slab to depend on the percpu allocator.
  47. * The following two parameters decide how much resource to
  48. * preallocate for this. Keep PERCPU_DYNAMIC_RESERVE equal to or
  49. * larger than PERCPU_DYNAMIC_EARLY_SIZE.
  50. */
  51. #define PERCPU_DYNAMIC_EARLY_SLOTS 128
  52. #define PERCPU_DYNAMIC_EARLY_SIZE (12 << 10)
  53. /*
  54. * PERCPU_DYNAMIC_RESERVE indicates the amount of free area to piggy
  55. * back on the first chunk for dynamic percpu allocation if arch is
  56. * manually allocating and mapping it for faster access (as a part of
  57. * large page mapping for example).
  58. *
  59. * The following values give between one and two pages of free space
  60. * after typical minimal boot (2-way SMP, single disk and NIC) with
  61. * both defconfig and a distro config on x86_64 and 32. More
  62. * intelligent way to determine this would be nice.
  63. */
  64. #if BITS_PER_LONG > 32
  65. #define PERCPU_DYNAMIC_RESERVE (20 << 10)
  66. #else
  67. #define PERCPU_DYNAMIC_RESERVE (12 << 10)
  68. #endif
  69. extern void *pcpu_base_addr;
  70. extern const unsigned long *pcpu_unit_offsets;
  71. struct pcpu_group_info {
  72. int nr_units; /* aligned # of units */
  73. unsigned long base_offset; /* base address offset */
  74. unsigned int *cpu_map; /* unit->cpu map, empty
  75. * entries contain NR_CPUS */
  76. };
  77. struct pcpu_alloc_info {
  78. size_t static_size;
  79. size_t reserved_size;
  80. size_t dyn_size;
  81. size_t unit_size;
  82. size_t atom_size;
  83. size_t alloc_size;
  84. size_t __ai_size; /* internal, don't use */
  85. int nr_groups; /* 0 if grouping unnecessary */
  86. struct pcpu_group_info groups[];
  87. };
  88. enum pcpu_fc {
  89. PCPU_FC_AUTO,
  90. PCPU_FC_EMBED,
  91. PCPU_FC_PAGE,
  92. PCPU_FC_NR,
  93. };
  94. extern const char *pcpu_fc_names[PCPU_FC_NR];
  95. extern enum pcpu_fc pcpu_chosen_fc;
  96. typedef void * (*pcpu_fc_alloc_fn_t)(unsigned int cpu, size_t size,
  97. size_t align);
  98. typedef void (*pcpu_fc_free_fn_t)(void *ptr, size_t size);
  99. typedef void (*pcpu_fc_populate_pte_fn_t)(unsigned long addr);
  100. typedef int (pcpu_fc_cpu_distance_fn_t)(unsigned int from, unsigned int to);
  101. extern struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups,
  102. int nr_units);
  103. extern void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai);
  104. extern int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
  105. void *base_addr);
  106. #ifdef CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK
  107. extern int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
  108. size_t atom_size,
  109. pcpu_fc_cpu_distance_fn_t cpu_distance_fn,
  110. pcpu_fc_alloc_fn_t alloc_fn,
  111. pcpu_fc_free_fn_t free_fn);
  112. #endif
  113. #ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
  114. extern int __init pcpu_page_first_chunk(size_t reserved_size,
  115. pcpu_fc_alloc_fn_t alloc_fn,
  116. pcpu_fc_free_fn_t free_fn,
  117. pcpu_fc_populate_pte_fn_t populate_pte_fn);
  118. #endif
  119. /*
  120. * Use this to get to a cpu's version of the per-cpu object
  121. * dynamically allocated. Non-atomic access to the current CPU's
  122. * version should probably be combined with get_cpu()/put_cpu().
  123. */
  124. #ifdef CONFIG_SMP
  125. #define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu)))
  126. #else
  127. #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR((ptr)); })
  128. #endif
  129. extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align);
  130. extern bool is_kernel_percpu_address(unsigned long addr);
  131. #if !defined(CONFIG_SMP) || !defined(CONFIG_HAVE_SETUP_PER_CPU_AREA)
  132. extern void __init setup_per_cpu_areas(void);
  133. #endif
  134. extern void __init percpu_init_late(void);
  135. extern void __percpu *__alloc_percpu(size_t size, size_t align);
  136. extern void free_percpu(void __percpu *__pdata);
  137. extern phys_addr_t per_cpu_ptr_to_phys(void *addr);
  138. #define alloc_percpu(type) \
  139. (typeof(type) __percpu *)__alloc_percpu(sizeof(type), __alignof__(type))
  140. /*
  141. * Optional methods for optimized non-lvalue per-cpu variable access.
  142. *
  143. * @var can be a percpu variable or a field of it and its size should
  144. * equal char, int or long. percpu_read() evaluates to a lvalue and
  145. * all others to void.
  146. *
  147. * These operations are guaranteed to be atomic w.r.t. preemption.
  148. * The generic versions use plain get/put_cpu_var(). Archs are
  149. * encouraged to implement single-instruction alternatives which don't
  150. * require preemption protection.
  151. */
  152. #ifndef percpu_read
  153. # define percpu_read(var) \
  154. ({ \
  155. typeof(var) *pr_ptr__ = &(var); \
  156. typeof(var) pr_ret__; \
  157. pr_ret__ = get_cpu_var(*pr_ptr__); \
  158. put_cpu_var(*pr_ptr__); \
  159. pr_ret__; \
  160. })
  161. #endif
  162. #define __percpu_generic_to_op(var, val, op) \
  163. do { \
  164. typeof(var) *pgto_ptr__ = &(var); \
  165. get_cpu_var(*pgto_ptr__) op val; \
  166. put_cpu_var(*pgto_ptr__); \
  167. } while (0)
  168. #ifndef percpu_write
  169. # define percpu_write(var, val) __percpu_generic_to_op(var, (val), =)
  170. #endif
  171. #ifndef percpu_add
  172. # define percpu_add(var, val) __percpu_generic_to_op(var, (val), +=)
  173. #endif
  174. #ifndef percpu_sub
  175. # define percpu_sub(var, val) __percpu_generic_to_op(var, (val), -=)
  176. #endif
  177. #ifndef percpu_and
  178. # define percpu_and(var, val) __percpu_generic_to_op(var, (val), &=)
  179. #endif
  180. #ifndef percpu_or
  181. # define percpu_or(var, val) __percpu_generic_to_op(var, (val), |=)
  182. #endif
  183. #ifndef percpu_xor
  184. # define percpu_xor(var, val) __percpu_generic_to_op(var, (val), ^=)
  185. #endif
  186. /*
  187. * Branching function to split up a function into a set of functions that
  188. * are called for different scalar sizes of the objects handled.
  189. */
  190. extern void __bad_size_call_parameter(void);
  191. #define __pcpu_size_call_return(stem, variable) \
  192. ({ typeof(variable) pscr_ret__; \
  193. __verify_pcpu_ptr(&(variable)); \
  194. switch(sizeof(variable)) { \
  195. case 1: pscr_ret__ = stem##1(variable);break; \
  196. case 2: pscr_ret__ = stem##2(variable);break; \
  197. case 4: pscr_ret__ = stem##4(variable);break; \
  198. case 8: pscr_ret__ = stem##8(variable);break; \
  199. default: \
  200. __bad_size_call_parameter();break; \
  201. } \
  202. pscr_ret__; \
  203. })
  204. #define __pcpu_size_call_return2(stem, variable, ...) \
  205. ({ \
  206. typeof(variable) pscr2_ret__; \
  207. __verify_pcpu_ptr(&(variable)); \
  208. switch(sizeof(variable)) { \
  209. case 1: pscr2_ret__ = stem##1(variable, __VA_ARGS__); break; \
  210. case 2: pscr2_ret__ = stem##2(variable, __VA_ARGS__); break; \
  211. case 4: pscr2_ret__ = stem##4(variable, __VA_ARGS__); break; \
  212. case 8: pscr2_ret__ = stem##8(variable, __VA_ARGS__); break; \
  213. default: \
  214. __bad_size_call_parameter(); break; \
  215. } \
  216. pscr2_ret__; \
  217. })
  218. /*
  219. * Special handling for cmpxchg_double. cmpxchg_double is passed two
  220. * percpu variables. The first has to be aligned to a double word
  221. * boundary and the second has to follow directly thereafter.
  222. */
  223. #define __pcpu_double_call_return_bool(stem, pcp1, pcp2, ...) \
  224. ({ \
  225. bool pdcrb_ret__; \
  226. __verify_pcpu_ptr(&pcp1); \
  227. BUILD_BUG_ON(sizeof(pcp1) != sizeof(pcp2)); \
  228. VM_BUG_ON((unsigned long)(&pcp1) % (2 * sizeof(pcp1))); \
  229. VM_BUG_ON((unsigned long)(&pcp2) != \
  230. (unsigned long)(&pcp1) + sizeof(pcp1)); \
  231. switch(sizeof(pcp1)) { \
  232. case 1: pdcrb_ret__ = stem##1(pcp1, pcp2, __VA_ARGS__); break; \
  233. case 2: pdcrb_ret__ = stem##2(pcp1, pcp2, __VA_ARGS__); break; \
  234. case 4: pdcrb_ret__ = stem##4(pcp1, pcp2, __VA_ARGS__); break; \
  235. case 8: pdcrb_ret__ = stem##8(pcp1, pcp2, __VA_ARGS__); break; \
  236. default: \
  237. __bad_size_call_parameter(); break; \
  238. } \
  239. pdcrb_ret__; \
  240. })
  241. #define __pcpu_size_call(stem, variable, ...) \
  242. do { \
  243. __verify_pcpu_ptr(&(variable)); \
  244. switch(sizeof(variable)) { \
  245. case 1: stem##1(variable, __VA_ARGS__);break; \
  246. case 2: stem##2(variable, __VA_ARGS__);break; \
  247. case 4: stem##4(variable, __VA_ARGS__);break; \
  248. case 8: stem##8(variable, __VA_ARGS__);break; \
  249. default: \
  250. __bad_size_call_parameter();break; \
  251. } \
  252. } while (0)
  253. /*
  254. * Optimized manipulation for memory allocated through the per cpu
  255. * allocator or for addresses of per cpu variables.
  256. *
  257. * These operation guarantee exclusivity of access for other operations
  258. * on the *same* processor. The assumption is that per cpu data is only
  259. * accessed by a single processor instance (the current one).
  260. *
  261. * The first group is used for accesses that must be done in a
  262. * preemption safe way since we know that the context is not preempt
  263. * safe. Interrupts may occur. If the interrupt modifies the variable
  264. * too then RMW actions will not be reliable.
  265. *
  266. * The arch code can provide optimized functions in two ways:
  267. *
  268. * 1. Override the function completely. F.e. define this_cpu_add().
  269. * The arch must then ensure that the various scalar format passed
  270. * are handled correctly.
  271. *
  272. * 2. Provide functions for certain scalar sizes. F.e. provide
  273. * this_cpu_add_2() to provide per cpu atomic operations for 2 byte
  274. * sized RMW actions. If arch code does not provide operations for
  275. * a scalar size then the fallback in the generic code will be
  276. * used.
  277. */
  278. #define _this_cpu_generic_read(pcp) \
  279. ({ typeof(pcp) ret__; \
  280. preempt_disable(); \
  281. ret__ = *this_cpu_ptr(&(pcp)); \
  282. preempt_enable(); \
  283. ret__; \
  284. })
  285. #ifndef this_cpu_read
  286. # ifndef this_cpu_read_1
  287. # define this_cpu_read_1(pcp) _this_cpu_generic_read(pcp)
  288. # endif
  289. # ifndef this_cpu_read_2
  290. # define this_cpu_read_2(pcp) _this_cpu_generic_read(pcp)
  291. # endif
  292. # ifndef this_cpu_read_4
  293. # define this_cpu_read_4(pcp) _this_cpu_generic_read(pcp)
  294. # endif
  295. # ifndef this_cpu_read_8
  296. # define this_cpu_read_8(pcp) _this_cpu_generic_read(pcp)
  297. # endif
  298. # define this_cpu_read(pcp) __pcpu_size_call_return(this_cpu_read_, (pcp))
  299. #endif
  300. #define _this_cpu_generic_to_op(pcp, val, op) \
  301. do { \
  302. preempt_disable(); \
  303. *__this_cpu_ptr(&(pcp)) op val; \
  304. preempt_enable(); \
  305. } while (0)
  306. #ifndef this_cpu_write
  307. # ifndef this_cpu_write_1
  308. # define this_cpu_write_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), =)
  309. # endif
  310. # ifndef this_cpu_write_2
  311. # define this_cpu_write_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), =)
  312. # endif
  313. # ifndef this_cpu_write_4
  314. # define this_cpu_write_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), =)
  315. # endif
  316. # ifndef this_cpu_write_8
  317. # define this_cpu_write_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), =)
  318. # endif
  319. # define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, (pcp), (val))
  320. #endif
  321. #ifndef this_cpu_add
  322. # ifndef this_cpu_add_1
  323. # define this_cpu_add_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=)
  324. # endif
  325. # ifndef this_cpu_add_2
  326. # define this_cpu_add_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=)
  327. # endif
  328. # ifndef this_cpu_add_4
  329. # define this_cpu_add_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=)
  330. # endif
  331. # ifndef this_cpu_add_8
  332. # define this_cpu_add_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=)
  333. # endif
  334. # define this_cpu_add(pcp, val) __pcpu_size_call(this_cpu_add_, (pcp), (val))
  335. #endif
  336. #ifndef this_cpu_sub
  337. # define this_cpu_sub(pcp, val) this_cpu_add((pcp), -(val))
  338. #endif
  339. #ifndef this_cpu_inc
  340. # define this_cpu_inc(pcp) this_cpu_add((pcp), 1)
  341. #endif
  342. #ifndef this_cpu_dec
  343. # define this_cpu_dec(pcp) this_cpu_sub((pcp), 1)
  344. #endif
  345. #ifndef this_cpu_and
  346. # ifndef this_cpu_and_1
  347. # define this_cpu_and_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=)
  348. # endif
  349. # ifndef this_cpu_and_2
  350. # define this_cpu_and_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=)
  351. # endif
  352. # ifndef this_cpu_and_4
  353. # define this_cpu_and_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=)
  354. # endif
  355. # ifndef this_cpu_and_8
  356. # define this_cpu_and_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=)
  357. # endif
  358. # define this_cpu_and(pcp, val) __pcpu_size_call(this_cpu_and_, (pcp), (val))
  359. #endif
  360. #ifndef this_cpu_or
  361. # ifndef this_cpu_or_1
  362. # define this_cpu_or_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=)
  363. # endif
  364. # ifndef this_cpu_or_2
  365. # define this_cpu_or_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=)
  366. # endif
  367. # ifndef this_cpu_or_4
  368. # define this_cpu_or_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=)
  369. # endif
  370. # ifndef this_cpu_or_8
  371. # define this_cpu_or_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=)
  372. # endif
  373. # define this_cpu_or(pcp, val) __pcpu_size_call(this_cpu_or_, (pcp), (val))
  374. #endif
  375. #ifndef this_cpu_xor
  376. # ifndef this_cpu_xor_1
  377. # define this_cpu_xor_1(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=)
  378. # endif
  379. # ifndef this_cpu_xor_2
  380. # define this_cpu_xor_2(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=)
  381. # endif
  382. # ifndef this_cpu_xor_4
  383. # define this_cpu_xor_4(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=)
  384. # endif
  385. # ifndef this_cpu_xor_8
  386. # define this_cpu_xor_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=)
  387. # endif
  388. # define this_cpu_xor(pcp, val) __pcpu_size_call(this_cpu_or_, (pcp), (val))
  389. #endif
  390. #define _this_cpu_generic_add_return(pcp, val) \
  391. ({ \
  392. typeof(pcp) ret__; \
  393. preempt_disable(); \
  394. __this_cpu_add(pcp, val); \
  395. ret__ = __this_cpu_read(pcp); \
  396. preempt_enable(); \
  397. ret__; \
  398. })
  399. #ifndef this_cpu_add_return
  400. # ifndef this_cpu_add_return_1
  401. # define this_cpu_add_return_1(pcp, val) _this_cpu_generic_add_return(pcp, val)
  402. # endif
  403. # ifndef this_cpu_add_return_2
  404. # define this_cpu_add_return_2(pcp, val) _this_cpu_generic_add_return(pcp, val)
  405. # endif
  406. # ifndef this_cpu_add_return_4
  407. # define this_cpu_add_return_4(pcp, val) _this_cpu_generic_add_return(pcp, val)
  408. # endif
  409. # ifndef this_cpu_add_return_8
  410. # define this_cpu_add_return_8(pcp, val) _this_cpu_generic_add_return(pcp, val)
  411. # endif
  412. # define this_cpu_add_return(pcp, val) __pcpu_size_call_return2(this_cpu_add_return_, pcp, val)
  413. #endif
  414. #define this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(val))
  415. #define this_cpu_inc_return(pcp) this_cpu_add_return(pcp, 1)
  416. #define this_cpu_dec_return(pcp) this_cpu_add_return(pcp, -1)
  417. #define _this_cpu_generic_xchg(pcp, nval) \
  418. ({ typeof(pcp) ret__; \
  419. preempt_disable(); \
  420. ret__ = __this_cpu_read(pcp); \
  421. __this_cpu_write(pcp, nval); \
  422. preempt_enable(); \
  423. ret__; \
  424. })
  425. #ifndef this_cpu_xchg
  426. # ifndef this_cpu_xchg_1
  427. # define this_cpu_xchg_1(pcp, nval) _this_cpu_generic_xchg(pcp, nval)
  428. # endif
  429. # ifndef this_cpu_xchg_2
  430. # define this_cpu_xchg_2(pcp, nval) _this_cpu_generic_xchg(pcp, nval)
  431. # endif
  432. # ifndef this_cpu_xchg_4
  433. # define this_cpu_xchg_4(pcp, nval) _this_cpu_generic_xchg(pcp, nval)
  434. # endif
  435. # ifndef this_cpu_xchg_8
  436. # define this_cpu_xchg_8(pcp, nval) _this_cpu_generic_xchg(pcp, nval)
  437. # endif
  438. # define this_cpu_xchg(pcp, nval) \
  439. __pcpu_size_call_return2(this_cpu_xchg_, (pcp), nval)
  440. #endif
  441. #define _this_cpu_generic_cmpxchg(pcp, oval, nval) \
  442. ({ typeof(pcp) ret__; \
  443. preempt_disable(); \
  444. ret__ = __this_cpu_read(pcp); \
  445. if (ret__ == (oval)) \
  446. __this_cpu_write(pcp, nval); \
  447. preempt_enable(); \
  448. ret__; \
  449. })
  450. #ifndef this_cpu_cmpxchg
  451. # ifndef this_cpu_cmpxchg_1
  452. # define this_cpu_cmpxchg_1(pcp, oval, nval) _this_cpu_generic_cmpxchg(pcp, oval, nval)
  453. # endif
  454. # ifndef this_cpu_cmpxchg_2
  455. # define this_cpu_cmpxchg_2(pcp, oval, nval) _this_cpu_generic_cmpxchg(pcp, oval, nval)
  456. # endif
  457. # ifndef this_cpu_cmpxchg_4
  458. # define this_cpu_cmpxchg_4(pcp, oval, nval) _this_cpu_generic_cmpxchg(pcp, oval, nval)
  459. # endif
  460. # ifndef this_cpu_cmpxchg_8
  461. # define this_cpu_cmpxchg_8(pcp, oval, nval) _this_cpu_generic_cmpxchg(pcp, oval, nval)
  462. # endif
  463. # define this_cpu_cmpxchg(pcp, oval, nval) \
  464. __pcpu_size_call_return2(this_cpu_cmpxchg_, pcp, oval, nval)
  465. #endif
  466. /*
  467. * cmpxchg_double replaces two adjacent scalars at once. The first
  468. * two parameters are per cpu variables which have to be of the same
  469. * size. A truth value is returned to indicate success or failure
  470. * (since a double register result is difficult to handle). There is
  471. * very limited hardware support for these operations, so only certain
  472. * sizes may work.
  473. */
  474. #define _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  475. ({ \
  476. int ret__; \
  477. preempt_disable(); \
  478. ret__ = __this_cpu_generic_cmpxchg_double(pcp1, pcp2, \
  479. oval1, oval2, nval1, nval2); \
  480. preempt_enable(); \
  481. ret__; \
  482. })
  483. #ifndef this_cpu_cmpxchg_double
  484. # ifndef this_cpu_cmpxchg_double_1
  485. # define this_cpu_cmpxchg_double_1(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  486. _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  487. # endif
  488. # ifndef this_cpu_cmpxchg_double_2
  489. # define this_cpu_cmpxchg_double_2(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  490. _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  491. # endif
  492. # ifndef this_cpu_cmpxchg_double_4
  493. # define this_cpu_cmpxchg_double_4(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  494. _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  495. # endif
  496. # ifndef this_cpu_cmpxchg_double_8
  497. # define this_cpu_cmpxchg_double_8(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  498. _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  499. # endif
  500. # define this_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  501. __pcpu_double_call_return_bool(this_cpu_cmpxchg_double_, (pcp1), (pcp2), (oval1), (oval2), (nval1), (nval2))
  502. #endif
  503. /*
  504. * Generic percpu operations that do not require preemption handling.
  505. * Either we do not care about races or the caller has the
  506. * responsibility of handling preemptions issues. Arch code can still
  507. * override these instructions since the arch per cpu code may be more
  508. * efficient and may actually get race freeness for free (that is the
  509. * case for x86 for example).
  510. *
  511. * If there is no other protection through preempt disable and/or
  512. * disabling interupts then one of these RMW operations can show unexpected
  513. * behavior because the execution thread was rescheduled on another processor
  514. * or an interrupt occurred and the same percpu variable was modified from
  515. * the interrupt context.
  516. */
  517. #ifndef __this_cpu_read
  518. # ifndef __this_cpu_read_1
  519. # define __this_cpu_read_1(pcp) (*__this_cpu_ptr(&(pcp)))
  520. # endif
  521. # ifndef __this_cpu_read_2
  522. # define __this_cpu_read_2(pcp) (*__this_cpu_ptr(&(pcp)))
  523. # endif
  524. # ifndef __this_cpu_read_4
  525. # define __this_cpu_read_4(pcp) (*__this_cpu_ptr(&(pcp)))
  526. # endif
  527. # ifndef __this_cpu_read_8
  528. # define __this_cpu_read_8(pcp) (*__this_cpu_ptr(&(pcp)))
  529. # endif
  530. # define __this_cpu_read(pcp) __pcpu_size_call_return(__this_cpu_read_, (pcp))
  531. #endif
  532. #define __this_cpu_generic_to_op(pcp, val, op) \
  533. do { \
  534. *__this_cpu_ptr(&(pcp)) op val; \
  535. } while (0)
  536. #ifndef __this_cpu_write
  537. # ifndef __this_cpu_write_1
  538. # define __this_cpu_write_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), =)
  539. # endif
  540. # ifndef __this_cpu_write_2
  541. # define __this_cpu_write_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), =)
  542. # endif
  543. # ifndef __this_cpu_write_4
  544. # define __this_cpu_write_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), =)
  545. # endif
  546. # ifndef __this_cpu_write_8
  547. # define __this_cpu_write_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), =)
  548. # endif
  549. # define __this_cpu_write(pcp, val) __pcpu_size_call(__this_cpu_write_, (pcp), (val))
  550. #endif
  551. #ifndef __this_cpu_add
  552. # ifndef __this_cpu_add_1
  553. # define __this_cpu_add_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=)
  554. # endif
  555. # ifndef __this_cpu_add_2
  556. # define __this_cpu_add_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=)
  557. # endif
  558. # ifndef __this_cpu_add_4
  559. # define __this_cpu_add_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=)
  560. # endif
  561. # ifndef __this_cpu_add_8
  562. # define __this_cpu_add_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=)
  563. # endif
  564. # define __this_cpu_add(pcp, val) __pcpu_size_call(__this_cpu_add_, (pcp), (val))
  565. #endif
  566. #ifndef __this_cpu_sub
  567. # define __this_cpu_sub(pcp, val) __this_cpu_add((pcp), -(val))
  568. #endif
  569. #ifndef __this_cpu_inc
  570. # define __this_cpu_inc(pcp) __this_cpu_add((pcp), 1)
  571. #endif
  572. #ifndef __this_cpu_dec
  573. # define __this_cpu_dec(pcp) __this_cpu_sub((pcp), 1)
  574. #endif
  575. #ifndef __this_cpu_and
  576. # ifndef __this_cpu_and_1
  577. # define __this_cpu_and_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=)
  578. # endif
  579. # ifndef __this_cpu_and_2
  580. # define __this_cpu_and_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=)
  581. # endif
  582. # ifndef __this_cpu_and_4
  583. # define __this_cpu_and_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=)
  584. # endif
  585. # ifndef __this_cpu_and_8
  586. # define __this_cpu_and_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=)
  587. # endif
  588. # define __this_cpu_and(pcp, val) __pcpu_size_call(__this_cpu_and_, (pcp), (val))
  589. #endif
  590. #ifndef __this_cpu_or
  591. # ifndef __this_cpu_or_1
  592. # define __this_cpu_or_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=)
  593. # endif
  594. # ifndef __this_cpu_or_2
  595. # define __this_cpu_or_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=)
  596. # endif
  597. # ifndef __this_cpu_or_4
  598. # define __this_cpu_or_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=)
  599. # endif
  600. # ifndef __this_cpu_or_8
  601. # define __this_cpu_or_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=)
  602. # endif
  603. # define __this_cpu_or(pcp, val) __pcpu_size_call(__this_cpu_or_, (pcp), (val))
  604. #endif
  605. #ifndef __this_cpu_xor
  606. # ifndef __this_cpu_xor_1
  607. # define __this_cpu_xor_1(pcp, val) __this_cpu_generic_to_op((pcp), (val), ^=)
  608. # endif
  609. # ifndef __this_cpu_xor_2
  610. # define __this_cpu_xor_2(pcp, val) __this_cpu_generic_to_op((pcp), (val), ^=)
  611. # endif
  612. # ifndef __this_cpu_xor_4
  613. # define __this_cpu_xor_4(pcp, val) __this_cpu_generic_to_op((pcp), (val), ^=)
  614. # endif
  615. # ifndef __this_cpu_xor_8
  616. # define __this_cpu_xor_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), ^=)
  617. # endif
  618. # define __this_cpu_xor(pcp, val) __pcpu_size_call(__this_cpu_xor_, (pcp), (val))
  619. #endif
  620. #define __this_cpu_generic_add_return(pcp, val) \
  621. ({ \
  622. __this_cpu_add(pcp, val); \
  623. __this_cpu_read(pcp); \
  624. })
  625. #ifndef __this_cpu_add_return
  626. # ifndef __this_cpu_add_return_1
  627. # define __this_cpu_add_return_1(pcp, val) __this_cpu_generic_add_return(pcp, val)
  628. # endif
  629. # ifndef __this_cpu_add_return_2
  630. # define __this_cpu_add_return_2(pcp, val) __this_cpu_generic_add_return(pcp, val)
  631. # endif
  632. # ifndef __this_cpu_add_return_4
  633. # define __this_cpu_add_return_4(pcp, val) __this_cpu_generic_add_return(pcp, val)
  634. # endif
  635. # ifndef __this_cpu_add_return_8
  636. # define __this_cpu_add_return_8(pcp, val) __this_cpu_generic_add_return(pcp, val)
  637. # endif
  638. # define __this_cpu_add_return(pcp, val) __pcpu_size_call_return2(this_cpu_add_return_, pcp, val)
  639. #endif
  640. #define __this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(val))
  641. #define __this_cpu_inc_return(pcp) this_cpu_add_return(pcp, 1)
  642. #define __this_cpu_dec_return(pcp) this_cpu_add_return(pcp, -1)
  643. #define __this_cpu_generic_xchg(pcp, nval) \
  644. ({ typeof(pcp) ret__; \
  645. ret__ = __this_cpu_read(pcp); \
  646. __this_cpu_write(pcp, nval); \
  647. ret__; \
  648. })
  649. #ifndef __this_cpu_xchg
  650. # ifndef __this_cpu_xchg_1
  651. # define __this_cpu_xchg_1(pcp, nval) __this_cpu_generic_xchg(pcp, nval)
  652. # endif
  653. # ifndef __this_cpu_xchg_2
  654. # define __this_cpu_xchg_2(pcp, nval) __this_cpu_generic_xchg(pcp, nval)
  655. # endif
  656. # ifndef __this_cpu_xchg_4
  657. # define __this_cpu_xchg_4(pcp, nval) __this_cpu_generic_xchg(pcp, nval)
  658. # endif
  659. # ifndef __this_cpu_xchg_8
  660. # define __this_cpu_xchg_8(pcp, nval) __this_cpu_generic_xchg(pcp, nval)
  661. # endif
  662. # define __this_cpu_xchg(pcp, nval) \
  663. __pcpu_size_call_return2(__this_cpu_xchg_, (pcp), nval)
  664. #endif
  665. #define __this_cpu_generic_cmpxchg(pcp, oval, nval) \
  666. ({ \
  667. typeof(pcp) ret__; \
  668. ret__ = __this_cpu_read(pcp); \
  669. if (ret__ == (oval)) \
  670. __this_cpu_write(pcp, nval); \
  671. ret__; \
  672. })
  673. #ifndef __this_cpu_cmpxchg
  674. # ifndef __this_cpu_cmpxchg_1
  675. # define __this_cpu_cmpxchg_1(pcp, oval, nval) __this_cpu_generic_cmpxchg(pcp, oval, nval)
  676. # endif
  677. # ifndef __this_cpu_cmpxchg_2
  678. # define __this_cpu_cmpxchg_2(pcp, oval, nval) __this_cpu_generic_cmpxchg(pcp, oval, nval)
  679. # endif
  680. # ifndef __this_cpu_cmpxchg_4
  681. # define __this_cpu_cmpxchg_4(pcp, oval, nval) __this_cpu_generic_cmpxchg(pcp, oval, nval)
  682. # endif
  683. # ifndef __this_cpu_cmpxchg_8
  684. # define __this_cpu_cmpxchg_8(pcp, oval, nval) __this_cpu_generic_cmpxchg(pcp, oval, nval)
  685. # endif
  686. # define __this_cpu_cmpxchg(pcp, oval, nval) \
  687. __pcpu_size_call_return2(__this_cpu_cmpxchg_, pcp, oval, nval)
  688. #endif
  689. #define __this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  690. ({ \
  691. int __ret = 0; \
  692. if (__this_cpu_read(pcp1) == (oval1) && \
  693. __this_cpu_read(pcp2) == (oval2)) { \
  694. __this_cpu_write(pcp1, (nval1)); \
  695. __this_cpu_write(pcp2, (nval2)); \
  696. __ret = 1; \
  697. } \
  698. (__ret); \
  699. })
  700. #ifndef __this_cpu_cmpxchg_double
  701. # ifndef __this_cpu_cmpxchg_double_1
  702. # define __this_cpu_cmpxchg_double_1(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  703. __this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  704. # endif
  705. # ifndef __this_cpu_cmpxchg_double_2
  706. # define __this_cpu_cmpxchg_double_2(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  707. __this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  708. # endif
  709. # ifndef __this_cpu_cmpxchg_double_4
  710. # define __this_cpu_cmpxchg_double_4(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  711. __this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  712. # endif
  713. # ifndef __this_cpu_cmpxchg_double_8
  714. # define __this_cpu_cmpxchg_double_8(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  715. __this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  716. # endif
  717. # define __this_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  718. __pcpu_double_call_return_bool(__this_cpu_cmpxchg_double_, (pcp1), (pcp2), (oval1), (oval2), (nval1), (nval2))
  719. #endif
  720. /*
  721. * IRQ safe versions of the per cpu RMW operations. Note that these operations
  722. * are *not* safe against modification of the same variable from another
  723. * processors (which one gets when using regular atomic operations)
  724. * They are guaranteed to be atomic vs. local interrupts and
  725. * preemption only.
  726. */
  727. #define irqsafe_cpu_generic_to_op(pcp, val, op) \
  728. do { \
  729. unsigned long flags; \
  730. local_irq_save(flags); \
  731. *__this_cpu_ptr(&(pcp)) op val; \
  732. local_irq_restore(flags); \
  733. } while (0)
  734. #ifndef irqsafe_cpu_add
  735. # ifndef irqsafe_cpu_add_1
  736. # define irqsafe_cpu_add_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=)
  737. # endif
  738. # ifndef irqsafe_cpu_add_2
  739. # define irqsafe_cpu_add_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=)
  740. # endif
  741. # ifndef irqsafe_cpu_add_4
  742. # define irqsafe_cpu_add_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=)
  743. # endif
  744. # ifndef irqsafe_cpu_add_8
  745. # define irqsafe_cpu_add_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=)
  746. # endif
  747. # define irqsafe_cpu_add(pcp, val) __pcpu_size_call(irqsafe_cpu_add_, (pcp), (val))
  748. #endif
  749. #ifndef irqsafe_cpu_sub
  750. # define irqsafe_cpu_sub(pcp, val) irqsafe_cpu_add((pcp), -(val))
  751. #endif
  752. #ifndef irqsafe_cpu_inc
  753. # define irqsafe_cpu_inc(pcp) irqsafe_cpu_add((pcp), 1)
  754. #endif
  755. #ifndef irqsafe_cpu_dec
  756. # define irqsafe_cpu_dec(pcp) irqsafe_cpu_sub((pcp), 1)
  757. #endif
  758. #ifndef irqsafe_cpu_and
  759. # ifndef irqsafe_cpu_and_1
  760. # define irqsafe_cpu_and_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=)
  761. # endif
  762. # ifndef irqsafe_cpu_and_2
  763. # define irqsafe_cpu_and_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=)
  764. # endif
  765. # ifndef irqsafe_cpu_and_4
  766. # define irqsafe_cpu_and_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=)
  767. # endif
  768. # ifndef irqsafe_cpu_and_8
  769. # define irqsafe_cpu_and_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=)
  770. # endif
  771. # define irqsafe_cpu_and(pcp, val) __pcpu_size_call(irqsafe_cpu_and_, (val))
  772. #endif
  773. #ifndef irqsafe_cpu_or
  774. # ifndef irqsafe_cpu_or_1
  775. # define irqsafe_cpu_or_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=)
  776. # endif
  777. # ifndef irqsafe_cpu_or_2
  778. # define irqsafe_cpu_or_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=)
  779. # endif
  780. # ifndef irqsafe_cpu_or_4
  781. # define irqsafe_cpu_or_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=)
  782. # endif
  783. # ifndef irqsafe_cpu_or_8
  784. # define irqsafe_cpu_or_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=)
  785. # endif
  786. # define irqsafe_cpu_or(pcp, val) __pcpu_size_call(irqsafe_cpu_or_, (val))
  787. #endif
  788. #ifndef irqsafe_cpu_xor
  789. # ifndef irqsafe_cpu_xor_1
  790. # define irqsafe_cpu_xor_1(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=)
  791. # endif
  792. # ifndef irqsafe_cpu_xor_2
  793. # define irqsafe_cpu_xor_2(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=)
  794. # endif
  795. # ifndef irqsafe_cpu_xor_4
  796. # define irqsafe_cpu_xor_4(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=)
  797. # endif
  798. # ifndef irqsafe_cpu_xor_8
  799. # define irqsafe_cpu_xor_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=)
  800. # endif
  801. # define irqsafe_cpu_xor(pcp, val) __pcpu_size_call(irqsafe_cpu_xor_, (val))
  802. #endif
  803. #define irqsafe_cpu_generic_cmpxchg(pcp, oval, nval) \
  804. ({ \
  805. typeof(pcp) ret__; \
  806. unsigned long flags; \
  807. local_irq_save(flags); \
  808. ret__ = __this_cpu_read(pcp); \
  809. if (ret__ == (oval)) \
  810. __this_cpu_write(pcp, nval); \
  811. local_irq_restore(flags); \
  812. ret__; \
  813. })
  814. #ifndef irqsafe_cpu_cmpxchg
  815. # ifndef irqsafe_cpu_cmpxchg_1
  816. # define irqsafe_cpu_cmpxchg_1(pcp, oval, nval) irqsafe_cpu_generic_cmpxchg(pcp, oval, nval)
  817. # endif
  818. # ifndef irqsafe_cpu_cmpxchg_2
  819. # define irqsafe_cpu_cmpxchg_2(pcp, oval, nval) irqsafe_cpu_generic_cmpxchg(pcp, oval, nval)
  820. # endif
  821. # ifndef irqsafe_cpu_cmpxchg_4
  822. # define irqsafe_cpu_cmpxchg_4(pcp, oval, nval) irqsafe_cpu_generic_cmpxchg(pcp, oval, nval)
  823. # endif
  824. # ifndef irqsafe_cpu_cmpxchg_8
  825. # define irqsafe_cpu_cmpxchg_8(pcp, oval, nval) irqsafe_cpu_generic_cmpxchg(pcp, oval, nval)
  826. # endif
  827. # define irqsafe_cpu_cmpxchg(pcp, oval, nval) \
  828. __pcpu_size_call_return2(irqsafe_cpu_cmpxchg_, (pcp), oval, nval)
  829. #endif
  830. #define irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  831. ({ \
  832. int ret__; \
  833. unsigned long flags; \
  834. local_irq_save(flags); \
  835. ret__ = __this_cpu_generic_cmpxchg_double(pcp1, pcp2, \
  836. oval1, oval2, nval1, nval2); \
  837. local_irq_restore(flags); \
  838. ret__; \
  839. })
  840. #ifndef irqsafe_cpu_cmpxchg_double
  841. # ifndef irqsafe_cpu_cmpxchg_double_1
  842. # define irqsafe_cpu_cmpxchg_double_1(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  843. irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  844. # endif
  845. # ifndef irqsafe_cpu_cmpxchg_double_2
  846. # define irqsafe_cpu_cmpxchg_double_2(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  847. irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  848. # endif
  849. # ifndef irqsafe_cpu_cmpxchg_double_4
  850. # define irqsafe_cpu_cmpxchg_double_4(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  851. irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  852. # endif
  853. # ifndef irqsafe_cpu_cmpxchg_double_8
  854. # define irqsafe_cpu_cmpxchg_double_8(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  855. irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
  856. # endif
  857. # define irqsafe_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
  858. __pcpu_double_call_return_int(irqsafe_cpu_cmpxchg_double_, (pcp1), (pcp2), (oval1), (oval2), (nval1), (nval2))
  859. #endif
  860. #endif /* __LINUX_PERCPU_H */