diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 02aeca21479a..4109d828a564 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h @@ -16,7 +16,12 @@ * space qualifier). */ #ifndef __percpu_qual -# define __percpu_qual +# if __has_attribute(address_space) && \ + defined(CONFIG_CC_HAS_TYPEOF_UNQUAL) && !defined(__CHECKER__) +# define __percpu_qual __attribute__((address_space(3))) +# else +# define __percpu_qual +# endif #endif #ifdef CONFIG_SMP diff --git a/include/linux/device.h b/include/linux/device.h index 667cb6db9019..1d6a55d5250a 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -431,9 +431,9 @@ static inline int __devm_add_action_or_reset(struct device *dev, void (*action)( * RETURNS: * Pointer to allocated memory on success, NULL on failure. */ -#define devm_alloc_percpu(dev, type) \ - ((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), \ - __alignof__(type))) +#define devm_alloc_percpu(dev, type) \ + ((TYPEOF_UNQUAL(type) __percpu *)__devm_alloc_percpu((dev), \ + sizeof(type), __alignof__(type))) void __percpu *__devm_alloc_percpu(struct device *dev, size_t size, size_t align); diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 52b5ea663b9f..c3bf040aba66 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h @@ -148,13 +148,13 @@ extern void __percpu *pcpu_alloc_noprof(size_t size, size_t align, bool reserved alloc_hooks(pcpu_alloc_noprof(_size, _align, true, GFP_KERNEL)) #define alloc_percpu_gfp(type, gfp) \ - (typeof(type) __percpu *)__alloc_percpu_gfp(sizeof(type), \ + (TYPEOF_UNQUAL(type) __percpu *)__alloc_percpu_gfp(sizeof(type), \ __alignof__(type), gfp) #define alloc_percpu(type) \ - (typeof(type) __percpu *)__alloc_percpu(sizeof(type), \ + (TYPEOF_UNQUAL(type) __percpu *)__alloc_percpu(sizeof(type), \ __alignof__(type)) #define alloc_percpu_noprof(type) \ - ((typeof(type) __percpu *)pcpu_alloc_noprof(sizeof(type), \ + ((TYPEOF_UNQUAL(type) __percpu *)pcpu_alloc_noprof(sizeof(type), \ __alignof__(type), false, GFP_KERNEL)) extern void free_percpu(void __percpu *__pdata);