kbuild test robot
2018-11-30 18:05:56 UTC
tree: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git block-dm-4.21-inflight
head: d694c9be5e3948e25ce95162fac9ab47ecc8c589
commit: 2f111f36ecbedc0cff9e87cdca3bfecc71d210d5 [5/6] block: switch to per-cpu in-flight counters
config: i386-randconfig-x000-201847 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
git checkout 2f111f36ecbedc0cff9e87cdca3bfecc71d210d5
# save the attached .config to linux build tree
make ARCH=i386
All error/warnings (new ones prefixed by >>):
In file included from include/asm-generic/percpu.h:7:0,
from arch/x86/include/asm/percpu.h:544,
from arch/x86/include/asm/preempt.h:6,
from include/linux/preempt.h:81,
from include/linux/spinlock.h:51,
from include/linux/seqlock.h:36,
from include/linux/time.h:6,
from include/linux/stat.h:19,
from include/linux/module.h:10,
~~~~~ ^
^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
^~~~~~~~~~~
^~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
^~~~~~~~~~~
~~~~~ ^
^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:55:13: note: in expansion of macro 'per_cpu_ptr'
local_inc(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
^~~~~~~~~~~
^~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:55:13: note: in expansion of macro 'per_cpu_ptr'
local_inc(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
^~~~~~~~~~~
~~~~~ ^
^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:63:12: note: in expansion of macro 'per_cpu_ptr'
local_dec(per_cpu_ptr(part->dkstats, cpu)->in_flight);
^~~~~~~~~~~
^~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:63:12: note: in expansion of macro 'per_cpu_ptr'
local_dec(per_cpu_ptr(part->dkstats, cpu)->in_flight);
^~~~~~~~~~~
~~~~~ ^
^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:65:13: note: in expansion of macro 'per_cpu_ptr'
local_dec(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
^~~~~~~~~~~
^~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:65:13: note: in expansion of macro 'per_cpu_ptr'
local_dec(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
^~~~~~~~~~~
In file included from include/linux/genhd.h:20:0,
~~~~~ ^
arch/x86/include/asm/local.h:16:42: note: in definition of macro 'local_read'
#define local_read(l) atomic_long_read(&(l)->a)
^
^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:80:30: note: in expansion of macro 'per_cpu_ptr'
inflight[0] += local_read(&per_cpu_ptr(part->dkstats, cpu)->in_flight[0]) +
^~~~~~~~~~~
^~~~~~
arch/x86/include/asm/local.h:16:42: note: in definition of macro 'local_read'
#define local_read(l) atomic_long_read(&(l)->a)
^
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:80:30: note: in expansion of macro 'per_cpu_ptr'
inflight[0] += local_read(&per_cpu_ptr(part->dkstats, cpu)->in_flight[0]) +
^~~~~~~~~~~
~~~~~ ^
arch/x86/include/asm/local.h:16:42: note: in definition of macro 'local_read'
#define local_read(l) atomic_long_read(&(l)->a)
^
^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:81:17: note: in expansion of macro 'per_cpu_ptr'
local_read(&per_cpu_ptr(part->dkstats, cpu)->in_flight[1]);
^~~~~~~~~~~
^~~~~~
arch/x86/include/asm/local.h:16:42: note: in definition of macro 'local_read'
#define local_read(l) atomic_long_read(&(l)->a)
^
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:81:17: note: in expansion of macro 'per_cpu_ptr'
local_read(&per_cpu_ptr(part->dkstats, cpu)->in_flight[1]);
^~~~~~~~~~~
vim +219 include/linux/percpu-defs.h
62fde54123 Tejun Heo 2014-06-17 205
9c28278a24 Tejun Heo 2014-06-17 206 /*
6fbc07bbe2 Tejun Heo 2014-06-17 207 * __verify_pcpu_ptr() verifies @ptr is a percpu pointer without evaluating
6fbc07bbe2 Tejun Heo 2014-06-17 208 * @ptr and is invoked once before a percpu area is accessed by all
6fbc07bbe2 Tejun Heo 2014-06-17 209 * accessors and operations. This is performed in the generic part of
6fbc07bbe2 Tejun Heo 2014-06-17 210 * percpu and arch overrides don't need to worry about it; however, if an
6fbc07bbe2 Tejun Heo 2014-06-17 211 * arch wants to implement an arch-specific percpu accessor or operation,
6fbc07bbe2 Tejun Heo 2014-06-17 212 * it may use __verify_pcpu_ptr() to verify the parameters.
9c28278a24 Tejun Heo 2014-06-17 213 *
9c28278a24 Tejun Heo 2014-06-17 214 * + 0 is required in order to convert the pointer type from a
9c28278a24 Tejun Heo 2014-06-17 215 * potential array type to a pointer to a single item of the array.
9c28278a24 Tejun Heo 2014-06-17 216 */
eba117889a Tejun Heo 2014-06-17 217 #define __verify_pcpu_ptr(ptr) \
eba117889a Tejun Heo 2014-06-17 218 do { \
9c28278a24 Tejun Heo 2014-06-17 @219 const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \
9c28278a24 Tejun Heo 2014-06-17 220 (void)__vpp_verify; \
9c28278a24 Tejun Heo 2014-06-17 221 } while (0)
9c28278a24 Tejun Heo 2014-06-17 222
62fde54123 Tejun Heo 2014-06-17 223 #ifdef CONFIG_SMP
62fde54123 Tejun Heo 2014-06-17 224
62fde54123 Tejun Heo 2014-06-17 225 /*
62fde54123 Tejun Heo 2014-06-17 226 * Add an offset to a pointer but keep the pointer as-is. Use RELOC_HIDE()
62fde54123 Tejun Heo 2014-06-17 227 * to prevent the compiler from making incorrect assumptions about the
62fde54123 Tejun Heo 2014-06-17 228 * pointer value. The weird cast keeps both GCC and sparse happy.
62fde54123 Tejun Heo 2014-06-17 229 */
eba117889a Tejun Heo 2014-06-17 230 #define SHIFT_PERCPU_PTR(__p, __offset) \
6fbc07bbe2 Tejun Heo 2014-06-17 231 RELOC_HIDE((typeof(*(__p)) __kernel __force *)(__p), (__offset))
6fbc07bbe2 Tejun Heo 2014-06-17 232
6fbc07bbe2 Tejun Heo 2014-06-17 233 #define per_cpu_ptr(ptr, cpu) \
eba117889a Tejun Heo 2014-06-17 234 ({ \
6fbc07bbe2 Tejun Heo 2014-06-17 235 __verify_pcpu_ptr(ptr); \
6fbc07bbe2 Tejun Heo 2014-06-17 236 SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))); \
62fde54123 Tejun Heo 2014-06-17 237 })
62fde54123 Tejun Heo 2014-06-17 238
6fbc07bbe2 Tejun Heo 2014-06-17 239 #define raw_cpu_ptr(ptr) \
6fbc07bbe2 Tejun Heo 2014-06-17 240 ({ \
6fbc07bbe2 Tejun Heo 2014-06-17 241 __verify_pcpu_ptr(ptr); \
6fbc07bbe2 Tejun Heo 2014-06-17 242 arch_raw_cpu_ptr(ptr); \
6fbc07bbe2 Tejun Heo 2014-06-17 243 })
62fde54123 Tejun Heo 2014-06-17 244
62fde54123 Tejun Heo 2014-06-17 245 #ifdef CONFIG_DEBUG_PREEMPT
6fbc07bbe2 Tejun Heo 2014-06-17 246 #define this_cpu_ptr(ptr) \
6fbc07bbe2 Tejun Heo 2014-06-17 247 ({ \
6fbc07bbe2 Tejun Heo 2014-06-17 248 __verify_pcpu_ptr(ptr); \
6fbc07bbe2 Tejun Heo 2014-06-17 249 SHIFT_PERCPU_PTR(ptr, my_cpu_offset); \
6fbc07bbe2 Tejun Heo 2014-06-17 250 })
62fde54123 Tejun Heo 2014-06-17 251 #else
62fde54123 Tejun Heo 2014-06-17 252 #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
62fde54123 Tejun Heo 2014-06-17 253 #endif
62fde54123 Tejun Heo 2014-06-17 254
62fde54123 Tejun Heo 2014-06-17 255 #else /* CONFIG_SMP */
62fde54123 Tejun Heo 2014-06-17 256
eba117889a Tejun Heo 2014-06-17 257 #define VERIFY_PERCPU_PTR(__p) \
eba117889a Tejun Heo 2014-06-17 258 ({ \
eba117889a Tejun Heo 2014-06-17 @259 __verify_pcpu_ptr(__p); \
62fde54123 Tejun Heo 2014-06-17 @260 (typeof(*(__p)) __kernel __force *)(__p); \
62fde54123 Tejun Heo 2014-06-17 261 })
62fde54123 Tejun Heo 2014-06-17 262
:::::: The code at line 219 was first introduced by commit
:::::: 9c28278a24c01c0073fb89e53c1d2a605ab9587d percpu: reorder macros in percpu header files
:::::: TO: Tejun Heo <***@kernel.org>
:::::: CC: Tejun Heo <***@kernel.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
head: d694c9be5e3948e25ce95162fac9ab47ecc8c589
commit: 2f111f36ecbedc0cff9e87cdca3bfecc71d210d5 [5/6] block: switch to per-cpu in-flight counters
config: i386-randconfig-x000-201847 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
git checkout 2f111f36ecbedc0cff9e87cdca3bfecc71d210d5
# save the attached .config to linux build tree
make ARCH=i386
All error/warnings (new ones prefixed by >>):
In file included from include/asm-generic/percpu.h:7:0,
from arch/x86/include/asm/percpu.h:544,
from arch/x86/include/asm/preempt.h:6,
from include/linux/preempt.h:81,
from include/linux/spinlock.h:51,
from include/linux/seqlock.h:36,
from include/linux/time.h:6,
from include/linux/stat.h:19,
from include/linux/module.h:10,
include/linux/percpu-defs.h:219:52: error: invalid operands to binary + (have 'struct disk_stats' and 'int')
const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \~~~~~ ^
include/linux/percpu-defs.h:259:2: note: in expansion of macro '__verify_pcpu_ptr'
__verify_pcpu_ptr(__p); \^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:53:12: note: in expansion of macro 'per_cpu_ptr'
local_inc(per_cpu_ptr(part->dkstats, cpu)->in_flight);^~~~~~~~~~~
include/linux/percpu-defs.h:260:10: error: invalid type argument of unary '*' (have 'struct disk_stats')
(typeof(*(__p)) __kernel __force *)(__p); \^~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:53:12: note: in expansion of macro 'per_cpu_ptr'
local_inc(per_cpu_ptr(part->dkstats, cpu)->in_flight);^~~~~~~~~~~
include/linux/percpu-defs.h:219:52: error: invalid operands to binary + (have 'struct disk_stats' and 'int')
const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \~~~~~ ^
include/linux/percpu-defs.h:259:2: note: in expansion of macro '__verify_pcpu_ptr'
__verify_pcpu_ptr(__p); \^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:55:13: note: in expansion of macro 'per_cpu_ptr'
local_inc(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
^~~~~~~~~~~
include/linux/percpu-defs.h:260:10: error: invalid type argument of unary '*' (have 'struct disk_stats')
(typeof(*(__p)) __kernel __force *)(__p); \^~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:55:13: note: in expansion of macro 'per_cpu_ptr'
local_inc(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
^~~~~~~~~~~
include/linux/percpu-defs.h:219:52: error: invalid operands to binary + (have 'struct disk_stats' and 'int')
const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \~~~~~ ^
include/linux/percpu-defs.h:259:2: note: in expansion of macro '__verify_pcpu_ptr'
__verify_pcpu_ptr(__p); \^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:63:12: note: in expansion of macro 'per_cpu_ptr'
local_dec(per_cpu_ptr(part->dkstats, cpu)->in_flight);
^~~~~~~~~~~
include/linux/percpu-defs.h:260:10: error: invalid type argument of unary '*' (have 'struct disk_stats')
(typeof(*(__p)) __kernel __force *)(__p); \^~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:63:12: note: in expansion of macro 'per_cpu_ptr'
local_dec(per_cpu_ptr(part->dkstats, cpu)->in_flight);
^~~~~~~~~~~
include/linux/percpu-defs.h:219:52: error: invalid operands to binary + (have 'struct disk_stats' and 'int')
const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \~~~~~ ^
include/linux/percpu-defs.h:259:2: note: in expansion of macro '__verify_pcpu_ptr'
__verify_pcpu_ptr(__p); \^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:65:13: note: in expansion of macro 'per_cpu_ptr'
local_dec(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
^~~~~~~~~~~
include/linux/percpu-defs.h:260:10: error: invalid type argument of unary '*' (have 'struct disk_stats')
(typeof(*(__p)) __kernel __force *)(__p); \^~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:65:13: note: in expansion of macro 'per_cpu_ptr'
local_dec(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
^~~~~~~~~~~
In file included from include/linux/genhd.h:20:0,
include/linux/percpu-defs.h:219:52: error: invalid operands to binary + (have 'struct disk_stats' and 'int')
const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \~~~~~ ^
arch/x86/include/asm/local.h:16:42: note: in definition of macro 'local_read'
#define local_read(l) atomic_long_read(&(l)->a)
^
include/linux/percpu-defs.h:259:2: note: in expansion of macro '__verify_pcpu_ptr'
__verify_pcpu_ptr(__p); \^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:80:30: note: in expansion of macro 'per_cpu_ptr'
inflight[0] += local_read(&per_cpu_ptr(part->dkstats, cpu)->in_flight[0]) +
^~~~~~~~~~~
include/linux/percpu-defs.h:260:10: error: invalid type argument of unary '*' (have 'struct disk_stats')
(typeof(*(__p)) __kernel __force *)(__p); \^~~~~~
arch/x86/include/asm/local.h:16:42: note: in definition of macro 'local_read'
#define local_read(l) atomic_long_read(&(l)->a)
^
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:80:30: note: in expansion of macro 'per_cpu_ptr'
inflight[0] += local_read(&per_cpu_ptr(part->dkstats, cpu)->in_flight[0]) +
^~~~~~~~~~~
include/linux/percpu-defs.h:219:52: error: invalid operands to binary + (have 'struct disk_stats' and 'int')
const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \~~~~~ ^
arch/x86/include/asm/local.h:16:42: note: in definition of macro 'local_read'
#define local_read(l) atomic_long_read(&(l)->a)
^
include/linux/percpu-defs.h:259:2: note: in expansion of macro '__verify_pcpu_ptr'
__verify_pcpu_ptr(__p); \^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:81:17: note: in expansion of macro 'per_cpu_ptr'
local_read(&per_cpu_ptr(part->dkstats, cpu)->in_flight[1]);
^~~~~~~~~~~
include/linux/percpu-defs.h:260:10: error: invalid type argument of unary '*' (have 'struct disk_stats')
(typeof(*(__p)) __kernel __force *)(__p); \^~~~~~
arch/x86/include/asm/local.h:16:42: note: in definition of macro 'local_read'
#define local_read(l) atomic_long_read(&(l)->a)
^
include/linux/percpu-defs.h:263:47: note: in expansion of macro 'VERIFY_PERCPU_PTR'
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })
^~~~~~~~~~~~~~~~~
block/genhd.c:81:17: note: in expansion of macro 'per_cpu_ptr'
local_read(&per_cpu_ptr(part->dkstats, cpu)->in_flight[1]);
^~~~~~~~~~~
vim +219 include/linux/percpu-defs.h
62fde54123 Tejun Heo 2014-06-17 205
9c28278a24 Tejun Heo 2014-06-17 206 /*
6fbc07bbe2 Tejun Heo 2014-06-17 207 * __verify_pcpu_ptr() verifies @ptr is a percpu pointer without evaluating
6fbc07bbe2 Tejun Heo 2014-06-17 208 * @ptr and is invoked once before a percpu area is accessed by all
6fbc07bbe2 Tejun Heo 2014-06-17 209 * accessors and operations. This is performed in the generic part of
6fbc07bbe2 Tejun Heo 2014-06-17 210 * percpu and arch overrides don't need to worry about it; however, if an
6fbc07bbe2 Tejun Heo 2014-06-17 211 * arch wants to implement an arch-specific percpu accessor or operation,
6fbc07bbe2 Tejun Heo 2014-06-17 212 * it may use __verify_pcpu_ptr() to verify the parameters.
9c28278a24 Tejun Heo 2014-06-17 213 *
9c28278a24 Tejun Heo 2014-06-17 214 * + 0 is required in order to convert the pointer type from a
9c28278a24 Tejun Heo 2014-06-17 215 * potential array type to a pointer to a single item of the array.
9c28278a24 Tejun Heo 2014-06-17 216 */
eba117889a Tejun Heo 2014-06-17 217 #define __verify_pcpu_ptr(ptr) \
eba117889a Tejun Heo 2014-06-17 218 do { \
9c28278a24 Tejun Heo 2014-06-17 @219 const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \
9c28278a24 Tejun Heo 2014-06-17 220 (void)__vpp_verify; \
9c28278a24 Tejun Heo 2014-06-17 221 } while (0)
9c28278a24 Tejun Heo 2014-06-17 222
62fde54123 Tejun Heo 2014-06-17 223 #ifdef CONFIG_SMP
62fde54123 Tejun Heo 2014-06-17 224
62fde54123 Tejun Heo 2014-06-17 225 /*
62fde54123 Tejun Heo 2014-06-17 226 * Add an offset to a pointer but keep the pointer as-is. Use RELOC_HIDE()
62fde54123 Tejun Heo 2014-06-17 227 * to prevent the compiler from making incorrect assumptions about the
62fde54123 Tejun Heo 2014-06-17 228 * pointer value. The weird cast keeps both GCC and sparse happy.
62fde54123 Tejun Heo 2014-06-17 229 */
eba117889a Tejun Heo 2014-06-17 230 #define SHIFT_PERCPU_PTR(__p, __offset) \
6fbc07bbe2 Tejun Heo 2014-06-17 231 RELOC_HIDE((typeof(*(__p)) __kernel __force *)(__p), (__offset))
6fbc07bbe2 Tejun Heo 2014-06-17 232
6fbc07bbe2 Tejun Heo 2014-06-17 233 #define per_cpu_ptr(ptr, cpu) \
eba117889a Tejun Heo 2014-06-17 234 ({ \
6fbc07bbe2 Tejun Heo 2014-06-17 235 __verify_pcpu_ptr(ptr); \
6fbc07bbe2 Tejun Heo 2014-06-17 236 SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))); \
62fde54123 Tejun Heo 2014-06-17 237 })
62fde54123 Tejun Heo 2014-06-17 238
6fbc07bbe2 Tejun Heo 2014-06-17 239 #define raw_cpu_ptr(ptr) \
6fbc07bbe2 Tejun Heo 2014-06-17 240 ({ \
6fbc07bbe2 Tejun Heo 2014-06-17 241 __verify_pcpu_ptr(ptr); \
6fbc07bbe2 Tejun Heo 2014-06-17 242 arch_raw_cpu_ptr(ptr); \
6fbc07bbe2 Tejun Heo 2014-06-17 243 })
62fde54123 Tejun Heo 2014-06-17 244
62fde54123 Tejun Heo 2014-06-17 245 #ifdef CONFIG_DEBUG_PREEMPT
6fbc07bbe2 Tejun Heo 2014-06-17 246 #define this_cpu_ptr(ptr) \
6fbc07bbe2 Tejun Heo 2014-06-17 247 ({ \
6fbc07bbe2 Tejun Heo 2014-06-17 248 __verify_pcpu_ptr(ptr); \
6fbc07bbe2 Tejun Heo 2014-06-17 249 SHIFT_PERCPU_PTR(ptr, my_cpu_offset); \
6fbc07bbe2 Tejun Heo 2014-06-17 250 })
62fde54123 Tejun Heo 2014-06-17 251 #else
62fde54123 Tejun Heo 2014-06-17 252 #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
62fde54123 Tejun Heo 2014-06-17 253 #endif
62fde54123 Tejun Heo 2014-06-17 254
62fde54123 Tejun Heo 2014-06-17 255 #else /* CONFIG_SMP */
62fde54123 Tejun Heo 2014-06-17 256
eba117889a Tejun Heo 2014-06-17 257 #define VERIFY_PERCPU_PTR(__p) \
eba117889a Tejun Heo 2014-06-17 258 ({ \
eba117889a Tejun Heo 2014-06-17 @259 __verify_pcpu_ptr(__p); \
62fde54123 Tejun Heo 2014-06-17 @260 (typeof(*(__p)) __kernel __force *)(__p); \
62fde54123 Tejun Heo 2014-06-17 261 })
62fde54123 Tejun Heo 2014-06-17 262
:::::: The code at line 219 was first introduced by commit
:::::: 9c28278a24c01c0073fb89e53c1d2a605ab9587d percpu: reorder macros in percpu header files
:::::: TO: Tejun Heo <***@kernel.org>
:::::: CC: Tejun Heo <***@kernel.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation