Commit 0f5e4816dbf38ce9488e611ca2296925c1e90d5e

Authored by Tejun Heo
1 parent 64ef291f46

percpu: remove some sparse warnings

Make the following changes to remove some sparse warnings.

* Make DEFINE_PER_CPU_SECTION() declare __pcpu_unique_* before
  defining it.

* Annotate pcpu_extend_area_map() that it is entered with pcpu_lock
  held, releases it and then reacquires it.

* Make percpu related macros use unique nested variable names.

* While at it, add pcpu prefix to __size_call[_return]() macros as
  to-be-implemented sparse annotations will add percpu specific stuff
  to these macros.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>

Showing 4 changed files with 39 additions and 37 deletions Side-by-side Diff

arch/x86/include/asm/percpu.h
... ... @@ -74,31 +74,31 @@
74 74  
75 75 #define percpu_to_op(op, var, val) \
76 76 do { \
77   - typedef typeof(var) T__; \
  77 + typedef typeof(var) pto_T__; \
78 78 if (0) { \
79   - T__ tmp__; \
80   - tmp__ = (val); \
  79 + pto_T__ pto_tmp__; \
  80 + pto_tmp__ = (val); \
81 81 } \
82 82 switch (sizeof(var)) { \
83 83 case 1: \
84 84 asm(op "b %1,"__percpu_arg(0) \
85 85 : "+m" (var) \
86   - : "qi" ((T__)(val))); \
  86 + : "qi" ((pto_T__)(val))); \
87 87 break; \
88 88 case 2: \
89 89 asm(op "w %1,"__percpu_arg(0) \
90 90 : "+m" (var) \
91   - : "ri" ((T__)(val))); \
  91 + : "ri" ((pto_T__)(val))); \
92 92 break; \
93 93 case 4: \
94 94 asm(op "l %1,"__percpu_arg(0) \
95 95 : "+m" (var) \
96   - : "ri" ((T__)(val))); \
  96 + : "ri" ((pto_T__)(val))); \
97 97 break; \
98 98 case 8: \
99 99 asm(op "q %1,"__percpu_arg(0) \
100 100 : "+m" (var) \
101   - : "re" ((T__)(val))); \
  101 + : "re" ((pto_T__)(val))); \
102 102 break; \
103 103 default: __bad_percpu_size(); \
104 104 } \
105 105  
106 106  
107 107  
108 108  
109 109  
... ... @@ -106,31 +106,31 @@
106 106  
107 107 #define percpu_from_op(op, var, constraint) \
108 108 ({ \
109   - typeof(var) ret__; \
  109 + typeof(var) pfo_ret__; \
110 110 switch (sizeof(var)) { \
111 111 case 1: \
112 112 asm(op "b "__percpu_arg(1)",%0" \
113   - : "=q" (ret__) \
  113 + : "=q" (pfo_ret__) \
114 114 : constraint); \
115 115 break; \
116 116 case 2: \
117 117 asm(op "w "__percpu_arg(1)",%0" \
118   - : "=r" (ret__) \
  118 + : "=r" (pfo_ret__) \
119 119 : constraint); \
120 120 break; \
121 121 case 4: \
122 122 asm(op "l "__percpu_arg(1)",%0" \
123   - : "=r" (ret__) \
  123 + : "=r" (pfo_ret__) \
124 124 : constraint); \
125 125 break; \
126 126 case 8: \
127 127 asm(op "q "__percpu_arg(1)",%0" \
128   - : "=r" (ret__) \
  128 + : "=r" (pfo_ret__) \
129 129 : constraint); \
130 130 break; \
131 131 default: __bad_percpu_size(); \
132 132 } \
133   - ret__; \
  133 + pfo_ret__; \
134 134 })
135 135  
136 136 /*
include/linux/percpu-defs.h
... ... @@ -60,6 +60,7 @@
60 60  
61 61 #define DEFINE_PER_CPU_SECTION(type, name, sec) \
62 62 __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
  63 + extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
63 64 __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
64 65 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \
65 66 __typeof__(type) per_cpu__##name
include/linux/percpu.h
... ... @@ -226,20 +226,20 @@
226 226  
227 227 extern void __bad_size_call_parameter(void);
228 228  
229   -#define __size_call_return(stem, variable) \
230   -({ typeof(variable) ret__; \
  229 +#define __pcpu_size_call_return(stem, variable) \
  230 +({ typeof(variable) pscr_ret__; \
231 231 switch(sizeof(variable)) { \
232   - case 1: ret__ = stem##1(variable);break; \
233   - case 2: ret__ = stem##2(variable);break; \
234   - case 4: ret__ = stem##4(variable);break; \
235   - case 8: ret__ = stem##8(variable);break; \
  232 + case 1: pscr_ret__ = stem##1(variable);break; \
  233 + case 2: pscr_ret__ = stem##2(variable);break; \
  234 + case 4: pscr_ret__ = stem##4(variable);break; \
  235 + case 8: pscr_ret__ = stem##8(variable);break; \
236 236 default: \
237 237 __bad_size_call_parameter();break; \
238 238 } \
239   - ret__; \
  239 + pscr_ret__; \
240 240 })
241 241  
242   -#define __size_call(stem, variable, ...) \
  242 +#define __pcpu_size_call(stem, variable, ...) \
243 243 do { \
244 244 switch(sizeof(variable)) { \
245 245 case 1: stem##1(variable, __VA_ARGS__);break; \
... ... @@ -299,7 +299,7 @@
299 299 # ifndef this_cpu_read_8
300 300 # define this_cpu_read_8(pcp) _this_cpu_generic_read(pcp)
301 301 # endif
302   -# define this_cpu_read(pcp) __size_call_return(this_cpu_read_, (pcp))
  302 +# define this_cpu_read(pcp) __pcpu_size_call_return(this_cpu_read_, (pcp))
303 303 #endif
304 304  
305 305 #define _this_cpu_generic_to_op(pcp, val, op) \
... ... @@ -322,7 +322,7 @@
322 322 # ifndef this_cpu_write_8
323 323 # define this_cpu_write_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), =)
324 324 # endif
325   -# define this_cpu_write(pcp, val) __size_call(this_cpu_write_, (pcp), (val))
  325 +# define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, (pcp), (val))
326 326 #endif
327 327  
328 328 #ifndef this_cpu_add
... ... @@ -338,7 +338,7 @@
338 338 # ifndef this_cpu_add_8
339 339 # define this_cpu_add_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), +=)
340 340 # endif
341   -# define this_cpu_add(pcp, val) __size_call(this_cpu_add_, (pcp), (val))
  341 +# define this_cpu_add(pcp, val) __pcpu_size_call(this_cpu_add_, (pcp), (val))
342 342 #endif
343 343  
344 344 #ifndef this_cpu_sub
... ... @@ -366,7 +366,7 @@
366 366 # ifndef this_cpu_and_8
367 367 # define this_cpu_and_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), &=)
368 368 # endif
369   -# define this_cpu_and(pcp, val) __size_call(this_cpu_and_, (pcp), (val))
  369 +# define this_cpu_and(pcp, val) __pcpu_size_call(this_cpu_and_, (pcp), (val))
370 370 #endif
371 371  
372 372 #ifndef this_cpu_or
... ... @@ -382,7 +382,7 @@
382 382 # ifndef this_cpu_or_8
383 383 # define this_cpu_or_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), |=)
384 384 # endif
385   -# define this_cpu_or(pcp, val) __size_call(this_cpu_or_, (pcp), (val))
  385 +# define this_cpu_or(pcp, val) __pcpu_size_call(this_cpu_or_, (pcp), (val))
386 386 #endif
387 387  
388 388 #ifndef this_cpu_xor
... ... @@ -398,7 +398,7 @@
398 398 # ifndef this_cpu_xor_8
399 399 # define this_cpu_xor_8(pcp, val) _this_cpu_generic_to_op((pcp), (val), ^=)
400 400 # endif
401   -# define this_cpu_xor(pcp, val) __size_call(this_cpu_or_, (pcp), (val))
  401 +# define this_cpu_xor(pcp, val) __pcpu_size_call(this_cpu_or_, (pcp), (val))
402 402 #endif
403 403  
404 404 /*
... ... @@ -428,7 +428,7 @@
428 428 # ifndef __this_cpu_read_8
429 429 # define __this_cpu_read_8(pcp) (*__this_cpu_ptr(&(pcp)))
430 430 # endif
431   -# define __this_cpu_read(pcp) __size_call_return(__this_cpu_read_, (pcp))
  431 +# define __this_cpu_read(pcp) __pcpu_size_call_return(__this_cpu_read_, (pcp))
432 432 #endif
433 433  
434 434 #define __this_cpu_generic_to_op(pcp, val, op) \
... ... @@ -449,7 +449,7 @@
449 449 # ifndef __this_cpu_write_8
450 450 # define __this_cpu_write_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), =)
451 451 # endif
452   -# define __this_cpu_write(pcp, val) __size_call(__this_cpu_write_, (pcp), (val))
  452 +# define __this_cpu_write(pcp, val) __pcpu_size_call(__this_cpu_write_, (pcp), (val))
453 453 #endif
454 454  
455 455 #ifndef __this_cpu_add
... ... @@ -465,7 +465,7 @@
465 465 # ifndef __this_cpu_add_8
466 466 # define __this_cpu_add_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), +=)
467 467 # endif
468   -# define __this_cpu_add(pcp, val) __size_call(__this_cpu_add_, (pcp), (val))
  468 +# define __this_cpu_add(pcp, val) __pcpu_size_call(__this_cpu_add_, (pcp), (val))
469 469 #endif
470 470  
471 471 #ifndef __this_cpu_sub
... ... @@ -493,7 +493,7 @@
493 493 # ifndef __this_cpu_and_8
494 494 # define __this_cpu_and_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), &=)
495 495 # endif
496   -# define __this_cpu_and(pcp, val) __size_call(__this_cpu_and_, (pcp), (val))
  496 +# define __this_cpu_and(pcp, val) __pcpu_size_call(__this_cpu_and_, (pcp), (val))
497 497 #endif
498 498  
499 499 #ifndef __this_cpu_or
... ... @@ -509,7 +509,7 @@
509 509 # ifndef __this_cpu_or_8
510 510 # define __this_cpu_or_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), |=)
511 511 # endif
512   -# define __this_cpu_or(pcp, val) __size_call(__this_cpu_or_, (pcp), (val))
  512 +# define __this_cpu_or(pcp, val) __pcpu_size_call(__this_cpu_or_, (pcp), (val))
513 513 #endif
514 514  
515 515 #ifndef __this_cpu_xor
... ... @@ -525,7 +525,7 @@
525 525 # ifndef __this_cpu_xor_8
526 526 # define __this_cpu_xor_8(pcp, val) __this_cpu_generic_to_op((pcp), (val), ^=)
527 527 # endif
528   -# define __this_cpu_xor(pcp, val) __size_call(__this_cpu_xor_, (pcp), (val))
  528 +# define __this_cpu_xor(pcp, val) __pcpu_size_call(__this_cpu_xor_, (pcp), (val))
529 529 #endif
530 530  
531 531 /*
... ... @@ -556,7 +556,7 @@
556 556 # ifndef irqsafe_cpu_add_8
557 557 # define irqsafe_cpu_add_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), +=)
558 558 # endif
559   -# define irqsafe_cpu_add(pcp, val) __size_call(irqsafe_cpu_add_, (pcp), (val))
  559 +# define irqsafe_cpu_add(pcp, val) __pcpu_size_call(irqsafe_cpu_add_, (pcp), (val))
560 560 #endif
561 561  
562 562 #ifndef irqsafe_cpu_sub
... ... @@ -584,7 +584,7 @@
584 584 # ifndef irqsafe_cpu_and_8
585 585 # define irqsafe_cpu_and_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), &=)
586 586 # endif
587   -# define irqsafe_cpu_and(pcp, val) __size_call(irqsafe_cpu_and_, (val))
  587 +# define irqsafe_cpu_and(pcp, val) __pcpu_size_call(irqsafe_cpu_and_, (val))
588 588 #endif
589 589  
590 590 #ifndef irqsafe_cpu_or
... ... @@ -600,7 +600,7 @@
600 600 # ifndef irqsafe_cpu_or_8
601 601 # define irqsafe_cpu_or_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), |=)
602 602 # endif
603   -# define irqsafe_cpu_or(pcp, val) __size_call(irqsafe_cpu_or_, (val))
  603 +# define irqsafe_cpu_or(pcp, val) __pcpu_size_call(irqsafe_cpu_or_, (val))
604 604 #endif
605 605  
606 606 #ifndef irqsafe_cpu_xor
... ... @@ -616,7 +616,7 @@
616 616 # ifndef irqsafe_cpu_xor_8
617 617 # define irqsafe_cpu_xor_8(pcp, val) irqsafe_cpu_generic_to_op((pcp), (val), ^=)
618 618 # endif
619   -# define irqsafe_cpu_xor(pcp, val) __size_call(irqsafe_cpu_xor_, (val))
  619 +# define irqsafe_cpu_xor(pcp, val) __pcpu_size_call(irqsafe_cpu_xor_, (val))
620 620 #endif
621 621  
622 622 #endif /* __LINUX_PERCPU_H */
... ... @@ -365,6 +365,7 @@
365 365 * 0 if noop, 1 if successfully extended, -errno on failure.
366 366 */
367 367 static int pcpu_extend_area_map(struct pcpu_chunk *chunk)
  368 + __releases(lock) __acquires(lock)
368 369 {
369 370 int new_alloc;
370 371 int *new;