kernel.h: Split out min()/max() et al helpers
Subsystems (11)
PATCH v3 1/4 kernel.h: Split out min()/max() et al helpers
kernel.h is being used as a dump for all kinds of stuff for a long time. Here is the attempt to start cleaning it up by splitting out min()/max() et al helpers.
At the same time convert users in header and lib folder to use new header. Though for time being include new header back to kernel.h to avoid twisted indirected includes for existing users.
---
v3: no change
include/linux/blkdev.h | 1 + include/linux/bvec.h | 6 +- include/linux/jiffies.h | 3 +- include/linux/kernel.h | 142 +------------------------------------ include/linux/minmax.h | 145 ++++++++++++++++++++++++++++++++++++++ include/linux/nodemask.h | 2 +- include/linux/uaccess.h | 1 + kernel/range.c | 3 +- lib/find_bit.c | 1 + lib/hexdump.c | 1 + lib/math/rational.c | 2 +- lib/math/reciprocal_div.c | 1 + 12 files changed, 162 insertions(+), 146 deletions(-) create mode 100644 include/linux/minmax.h
include/linux/blkdev.h +1 -0
@@ -11,6 +11,7 @@#include <linux/genhd.h> #include <linux/list.h> #include <linux/llist.h> +#include <linux/minmax.h> #include <linux/timer.h> #include <linux/workqueue.h> #include <linux/pagemap.h>
include/linux/bvec.h +5 -1
@@ -7,10 +7,14 @@#ifndef __LINUX_BVEC_ITER_H#define __LINUX_BVEC_ITER_H -#include <linux/kernel.h> #include <linux/bug.h> #include <linux/errno.h> +#include <linux/limits.h> +#include <linux/minmax.h> #include <linux/mm.h> +#include <linux/types.h> + +struct page ;/* * was unsigned short, but we might as well be ready for > 64kB I/O pages
include/linux/jiffies.h +2 -1
@@ -3,8 +3,9 @@#define _LINUX_JIFFIES_H#include <linux/cache.h> +#include <linux/limits.h> #include <linux/math64.h> -#include <linux/kernel.h> +#include <linux/minmax.h> #include <linux/types.h> #include <linux/time.h> #include <linux/timex.h>
include/linux/kernel.h +1 -141
154 lines not on this page · raw message
include/linux/minmax.h new file +145 -0
145 lines not on this page · raw message
include/linux/nodemask.h +1 -1
@@ -90,9 +90,9 @@* for such situations. See below and CPUMASK_ALLOC also. */ -#include <linux/kernel.h> #include <linux/threads.h> #include <linux/bitmap.h> +#include <linux/minmax.h> #include <linux/numa.h> typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
include/linux/uaccess.h +1 -0
@@ -2,6 +2,7 @@#ifndef __LINUX_UACCESS_H__#define __LINUX_UACCESS_H__ +#include <linux/minmax.h> #include <linux/sched.h> #include <linux/thread_info.h> #include <linux/kasan-checks.h>
kernel/range.c +2 -1
@@ -2,8 +2,9 @@/* * Range add and subtract */ -#include <linux/kernel.h> #include <linux/init.h> +#include <linux/minmax.h> +#include <linux/printk.h> #include <linux/sort.h> #include <linux/string.h> #include <linux/range.h>
lib/find_bit.c +1 -0
@@ -16,6 +16,7 @@#include <linux/bitmap.h> #include <linux/export.h> #include <linux/kernel.h> +#include <linux/minmax.h> #if !defined(find_next_bit) || !defined(find_next_zero_bit) || \ !defined(find_next_bit_le) || !defined(find_next_zero_bit_le) || \
lib/hexdump.c +1 -0
@@ -7,6 +7,7 @@#include <linux/ctype.h> #include <linux/errno.h> #include <linux/kernel.h> +#include <linux/minmax.h> #include <linux/export.h> #include <asm/unaligned.h>
lib/math/rational.c +1 -1
@@ -11,7 +11,7 @@#include <linux/rational.h> #include <linux/compiler.h> #include <linux/export.h> -#include <linux/kernel.h> +#include <linux/minmax.h> /* * calculate best rational approximation for a given fraction
lib/math/reciprocal_div.c +1 -0
@@ -4,6 +4,7 @@#include <asm/div64.h> #include <linux/reciprocal_div.h> #include <linux/export.h> +#include <linux/minmax.h> /* * For a description of the algorithm please have a look at
Signature · 1 line
2.24.1
PATCH v3 2/4 kernel.h: Split out mathematical helpers
kernel.h is being used as a dump for all kinds of stuff for a long time. Here is the attempt to start cleaning it up by splitting out mathematical helpers.
At the same time convert users in header and lib folder to use new header. Though for time being include new header back to kernel.h to avoid twisted indirected includes for existing users.
---
v3: fix compilation error (kbuild test robot)
fs/nfs/callback_proc.c | 5 + include/linux/bitops.h | 11 ++- include/linux/dcache.h | 1 + include/linux/iommu-helper.h | 4 +- include/linux/kernel.h | 174 +-------------------------------- include/linux/math.h | 177 ++++++++++++++++++++++++++++++++++ include/linux/rcu_node_tree.h | 2 + include/linux/units.h | 2 +- lib/errname.c | 1 + lib/find_bit.c | 3 +- lib/math/div64.c | 3 +- lib/math/int_pow.c | 2 +- lib/math/int_sqrt.c | 3 +- lib/math/reciprocal_div.c | 8 +- 14 files changed, 212 insertions(+), 184 deletions(-) create mode 100644 include/linux/math.h
fs/nfs/callback_proc.c +5 -0
@@ -6,10 +6,15 @@* * NFSv4 callback procedures */ + +#include <linux/errno.h> +#include <linux/math.h> #include <linux/nfs4.h> #include <linux/nfs_fs.h> #include <linux/slab.h> #include <linux/rcupdate.h> +#include <linux/types.h> +#include "nfs4_fs.h" #include "callback.h" #include "delegation.h"
include/linux/bitops.h +7 -4
@@ -1,9 +1,12 @@/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _LINUX_BITOPS_H#define _LINUX_BITOPS_H +#include <asm/types.h> #include <linux/bits.h> +#include <uapi/linux/kernel.h> +/* Set bits in the first 'n' bytes when loaded from memory */ #ifdef __LITTLE_ENDIAN# define aligned_byte_mask (n) ((1UL << 8*(n))-1)
@@ -12,10 +15,10 @@#endif #define BITS_PER_TYPE (type) (sizeof(type) * BITS_PER_BYTE) -#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long)) -#define BITS_TO_U64 (nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(u64)) -#define BITS_TO_U32 (nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(u32)) -#define BITS_TO_BYTES (nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(char)) +#define BITS_TO_LONGS (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(long)) +#define BITS_TO_U64 (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u64)) +#define BITS_TO_U32 (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u32)) +#define BITS_TO_BYTES (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(char))extern unsigned int __sw_hweight8 (unsigned int w);extern unsigned int __sw_hweight16 (unsigned int w);
include/linux/dcache.h +1 -0
@@ -4,6 +4,7 @@#include <linux/atomic.h> #include <linux/list.h> +#include <linux/math.h> #include <linux/rculist.h> #include <linux/rculist_bl.h> #include <linux/spinlock.h>
include/linux/iommu-helper.h +3 -1
@@ -3,7 +3,9 @@#define _LINUX_IOMMU_HELPER_H#include <linux/bug.h> -#include <linux/kernel.h> +#include <linux/log2.h> +#include <linux/math.h> +#include <linux/types.h> static inline unsigned long iommu_device_max_index(unsigned long size, unsigned long offset,
include/linux/kernel.h +3 -171
215 lines not on this page · raw message
include/linux/math.h new file +177 -0
177 lines not on this page · raw message
include/linux/rcu_node_tree.h +2 -0
@@ -20,6 +20,8 @@#ifndef __LINUX_RCU_NODE_TREE_H#define __LINUX_RCU_NODE_TREE_H +#include <linux/math.h> +/* * Define shape of hierarchy based on NR_CPUS, CONFIG_RCU_FANOUT, and * CONFIG_RCU_FANOUT_LEAF.
include/linux/units.h +1 -1
@@ -2,7 +2,7 @@#ifndef _LINUX_UNITS_H#define _LINUX_UNITS_H -#include <linux/kernel.h> +#include <linux/math.h> #define ABSOLUTE_ZERO_MILLICELSIUS -273150
lib/errname.c +1 -0
@@ -3,6 +3,7 @@#include <linux/errno.h> #include <linux/errname.h> #include <linux/kernel.h> +#include <linux/math.h> /* * Ensure these tables do not accidentally become gigantic if some
lib/find_bit.c +2 -1
@@ -15,8 +15,9 @@#include <linux/bitops.h> #include <linux/bitmap.h> #include <linux/export.h> -#include <linux/kernel.h> +#include <linux/math.h> #include <linux/minmax.h> +#include <linux/swab.h> #if !defined(find_next_bit) || !defined(find_next_zero_bit) || \ !defined(find_next_bit_le) || !defined(find_next_zero_bit_le) || \
lib/math/div64.c +2 -1
@@ -18,8 +18,9 @@* or by defining a preprocessor macro in arch/include/asm/div64.h. */ +#include <linux/bitops.h> #include <linux/export.h> -#include <linux/kernel.h> +#include <linux/math.h> #include <linux/math64.h> /* Not needed on 64bit architectures */
lib/math/int_pow.c +1 -1
@@ -6,7 +6,7 @@*/ #include <linux/export.h> -#include <linux/kernel.h> +#include <linux/math.h> #include <linux/types.h> /**
lib/math/int_sqrt.c +2 -1
@@ -6,9 +6,10 @@* square root from Guy L. Steele. */ -#include <linux/kernel.h> #include <linux/export.h> #include <linux/bitops.h> +#include <linux/limits.h> +#include <linux/math.h> /** * int_sqrt - computes the integer square root
lib/math/reciprocal_div.c +5 -3
@@ -1,10 +1,12 @@// SPDX-License-Identifier: GPL-2.0 +#include <linux/bitops.h> #include <linux/bug.h> -#include <linux/kernel.h> -#include <asm/div64.h> -#include <linux/reciprocal_div.h> #include <linux/export.h> +#include <linux/math.h> #include <linux/minmax.h> +#include <linux/types.h> + +#include <linux/reciprocal_div.h> /* * For a description of the algorithm please have a look at
Signature · 1 line
2.24.1
PATCH v3 3/4 kernel.h: Split out might_sleep() and friends
In reply to Andy Shevchenkokernel.h is being used as a dump for all kinds of stuff for a long time. Here is the attempt to start cleaning it up by splitting out might_sleep() and friends.
At the same time convert users in header and crypto folder to use new header. Though for time being include new header back to kernel.h to avoid twisted indirected includes for existing users.
---
v3: new patch
crypto/asymmetric_keys/pkcs7_trust.c | 3 +- include/linux/kernel.h | 67 +------------------------ include/linux/might_sleep.h | 73 ++++++++++++++++++++++++++++ include/linux/percpu-rwsem.h | 1 + include/linux/sched.h | 1 + include/linux/wait_bit.h | 1 + 6 files changed, 79 insertions(+), 67 deletions(-) create mode 100644 include/linux/might_sleep.h
crypto/asymmetric_keys/pkcs7_trust.c +2 -1
@@ -6,8 +6,9 @@*/ #define pr_fmt (fmt) "PKCS7: "fmt -#include <linux/kernel.h> #include <linux/export.h> +#include <linux/might_sleep.h> +#include <linux/printk.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/asn1.h>
include/linux/kernel.h +1 -66
79 lines not on this page · raw message
include/linux/might_sleep.h new file +73 -0
73 lines not on this page · raw message
include/linux/percpu-rwsem.h +1 -0
@@ -3,6 +3,7 @@#define _LINUX_PERCPU_RWSEM_H#include <linux/atomic.h> +#include <linux/might_sleep.h> #include <linux/rwsem.h> #include <linux/percpu.h> #include <linux/rcuwait.h>
include/linux/sched.h +1 -0
@@ -15,6 +15,7 @@#include <linux/sem.h> #include <linux/shm.h> #include <linux/kcov.h> +#include <linux/might_sleep.h> #include <linux/mutex.h> #include <linux/plist.h> #include <linux/hrtimer.h>
include/linux/wait_bit.h +1 -0
@@ -5,6 +5,7 @@/* * Linux wait-bit related types and methods: */ +#include <linux/might_sleep.h> #include <linux/wait.h> struct wait_bit_key {
Signature · 1 line
2.24.1
kbuild test robot
build botRe: [PATCH v3 3/4] kernel.h: Split out might_sleep() and friends
I love your patch! Yet something to improve:
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on next-20200207]
[cannot apply to nfs/linux-next rcu/dev cryptodev/master crypto/master dennis-percpu/for-next tip/sched/core linux/master v5.5] [if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Andy-Shevchenko/kernel-h-Split-out-min-max-et-al-helpers/20200209-041358 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git f757165705e92db62f85a1ad287e9251d1f2cd82 config: alpha-randconfig-a001-20200209 (attached as .config) compiler: alpha-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=alpha
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
In file included from include/asm-generic/current.h:5:0,
from ./arch/alpha/include/generated/asm/current.h:1, from include/linux/might_sleep.h:6,
from include/linux/kernel.h:14,
from include/asm-generic/bug.h:19,
from arch/alpha/include/asm/bug.h:23, from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
include/linux/thread_info.h: In function 'copy_overflow':
>> include/linux/thread_info.h:134:2: error: implicit declaration of function 'WARN' [-Werror=implicit-function-declaration]
WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
^~~~
include/linux/thread_info.h: In function 'check_copy_size':
>> include/linux/thread_info.h:150:6: error: implicit declaration of function 'WARN_ON_ONCE'; did you mean 'WRITE_ONCE'? [-Werror=implicit-function-declaration] if (WARN_ON_ONCE(bytes > INT_MAX))
^~~~~~~~~~~~
WRITE_ONCE
cc1: some warnings being treated as errors make[2]: *** [kernel/bounds.s] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [sub-make] Error 2
10 real 3 user 4 sys 83.61% cpu make prepare
vim +/WARN +134 include/linux/thread_info.h
b0377fedb652808 Al Viro 2017-06-29 131
b0377fedb652808 Al Viro 2017-06-29 132 static inline void copy_overflow(int size, unsigned long count)
b0377fedb652808 Al Viro 2017-06-29 133 {
b0377fedb652808 Al Viro 2017-06-29 @134 WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
b0377fedb652808 Al Viro 2017-06-29 135 }
b0377fedb652808 Al Viro 2017-06-29 136
9dd819a15162f8f Kees Cook 2019-09-25 137 static __always_inline __must_check bool
b0377fedb652808 Al Viro 2017-06-29 138 check_copy_size(const void *addr, size_t bytes, bool is_source)
b0377fedb652808 Al Viro 2017-06-29 139 {
b0377fedb652808 Al Viro 2017-06-29 140 int sz = __compiletime_object_size(addr);
b0377fedb652808 Al Viro 2017-06-29 141 if (unlikely(sz >= 0 && sz < bytes)) {
b0377fedb652808 Al Viro 2017-06-29 142 if (!__builtin_constant_p(bytes))
b0377fedb652808 Al Viro 2017-06-29 143 copy_overflow(sz, bytes);
b0377fedb652808 Al Viro 2017-06-29 144 else if (is_source)
b0377fedb652808 Al Viro 2017-06-29 145 __bad_copy_from();
b0377fedb652808 Al Viro 2017-06-29 146 else
b0377fedb652808 Al Viro 2017-06-29 147 __bad_copy_to();
b0377fedb652808 Al Viro 2017-06-29 148 return false;
b0377fedb652808 Al Viro 2017-06-29 149 }
6d13de1489b6bf5 Kees Cook 2019-12-04 @150 if (WARN_ON_ONCE(bytes > INT_MAX))
6d13de1489b6bf5 Kees Cook 2019-12-04 151 return false;
b0377fedb652808 Al Viro 2017-06-29 152 check_object_size(addr, bytes, is_source);
b0377fedb652808 Al Viro 2017-06-29 153 return true;
b0377fedb652808 Al Viro 2017-06-29 154 }b0377fedb652808 Al Viro 2017-06-29 155
:::::: The code at line 134 was first introduced by commit
:::::: b0377fedb6528087ed319b0d054d6ed82240372c copy_{to,from}_user(): consolidate object size checks
:::::: TO: Al Viro <[email protected]>
:::::: CC: Al Viro <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kbuild test robot
build botRe: [PATCH v3 3/4] kernel.h: Split out might_sleep() and friends
In reply to Andy ShevchenkoI love your patch! Yet something to improve:
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on next-20200207]
[cannot apply to nfs/linux-next rcu/dev cryptodev/master crypto/master dennis-percpu/for-next tip/sched/core linux/master v5.5] [if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Andy-Shevchenko/kernel-h-Split-out-min-max-et-al-helpers/20200209-041358 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git f757165705e92db62f85a1ad287e9251d1f2cd82 config: openrisc-or1ksim_defconfig (attached as .config) compiler: or1k-linux-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=openrisc
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
In file included from include/asm-generic/current.h:5,
from ./arch/openrisc/include/generated/asm/current.h:1,
from include/linux/might_sleep.h:6,
from include/linux/kernel.h:14,
from include/asm-generic/bug.h:19,
from ./arch/openrisc/include/generated/asm/bug.h:1,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
include/linux/thread_info.h: In function 'copy_overflow':
include/linux/thread_info.h:134:2: error: implicit declaration of function 'WARN' [-Werror=implicit-function-declaration]
134 | WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
| ^~~~
include/linux/thread_info.h: In function 'check_copy_size':
>> include/linux/thread_info.h:150:6: error: implicit declaration of function 'WARN_ON_ONCE' [-Werror=implicit-function-declaration]
150 | if (WARN_ON_ONCE(bytes > INT_MAX))
| ^~~~~~~~~~~~ cc1: some warnings being treated as errors make[2]: *** [kernel/bounds.s] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [sub-make] Error 2
16 real 6 user 7 sys 83.27% cpu make prepare
vim +/WARN_ON_ONCE +150 include/linux/thread_info.h
b0377fedb652808 Al Viro 2017-06-29 136
9dd819a15162f8f Kees Cook 2019-09-25 137 static __always_inline __must_check bool
b0377fedb652808 Al Viro 2017-06-29 138 check_copy_size(const void *addr, size_t bytes, bool is_source)
b0377fedb652808 Al Viro 2017-06-29 139 {
b0377fedb652808 Al Viro 2017-06-29 140 int sz = __compiletime_object_size(addr);
b0377fedb652808 Al Viro 2017-06-29 141 if (unlikely(sz >= 0 && sz < bytes)) {
b0377fedb652808 Al Viro 2017-06-29 142 if (!__builtin_constant_p(bytes))
b0377fedb652808 Al Viro 2017-06-29 143 copy_overflow(sz, bytes);
b0377fedb652808 Al Viro 2017-06-29 144 else if (is_source)
b0377fedb652808 Al Viro 2017-06-29 145 __bad_copy_from();
b0377fedb652808 Al Viro 2017-06-29 146 else
b0377fedb652808 Al Viro 2017-06-29 147 __bad_copy_to();
b0377fedb652808 Al Viro 2017-06-29 148 return false;
b0377fedb652808 Al Viro 2017-06-29 149 }
6d13de1489b6bf5 Kees Cook 2019-12-04 @150 if (WARN_ON_ONCE(bytes > INT_MAX))
6d13de1489b6bf5 Kees Cook 2019-12-04 151 return false;
b0377fedb652808 Al Viro 2017-06-29 152 check_object_size(addr, bytes, is_source);
b0377fedb652808 Al Viro 2017-06-29 153 return true;
b0377fedb652808 Al Viro 2017-06-29 154 }b0377fedb652808 Al Viro 2017-06-29 155
:::::: The code at line 150 was first introduced by commit
:::::: 6d13de1489b6bf539695f96d945de3860e6d5e17 uaccess: disallow > INT_MAX copy sizes
:::::: TO: Kees Cook <[email protected]> :::::: CC: Linus Torvalds <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kbuild test robot
build botRe: [PATCH v3 3/4] kernel.h: Split out might_sleep() and friends
In reply to Andy ShevchenkoI love your patch! Perhaps something to improve:
Hi Andy,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on next-20200207]
[cannot apply to nfs/linux-next rcu/dev cryptodev/master crypto/master dennis-percpu/for-next tip/sched/core linux/master v5.5] [if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Andy-Shevchenko/kernel-h-Split-out-min-max-et-al-helpers/20200209-041358 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git f757165705e92db62f85a1ad287e9251d1f2cd82 reproduce: # apt-get install sparse # sparse version: v0.6.1-162-g98276e61-dirty make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
sparse warnings: (new ones prefixed by >>)
>> arch/x86/include/asm/current.h:11:1: sparse: sparse: 'DECLARE_PER_CPU()' has implicit return type
vim +11 arch/x86/include/asm/current.h
f0766440dda7ac include/asm-x86/current.h Christoph Lameter 2008-05-09 10f0766440dda7ac include/asm-x86/current.h Christoph Lameter 2008-05-09 @11 DECLARE_PER_CPU(struct task_struct *, current_task); f0766440dda7ac include/asm-x86/current.h Christoph Lameter 2008-05-09 12
:::::: The code at line 11 was first introduced by commit :::::: f0766440dda7ace8a43b030f75e2dcb82449fb85 x86: unify current.h
:::::: TO: Christoph Lameter <[email protected]>
:::::: CC: Thomas Gleixner <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v3 4/4 kernel.h: Move lower_32_bits()/upper_32_bits() to bitops.h
In reply to Andy ShevchenkoMove lower_32_bits()/upper_32_bits() to bitops.h.
---
v3: new patch
include/linux/bitops.h | 16 ++++++++++++++++ include/linux/kernel.h | 16 ---------------- lib/clz_ctz.c | 2 +- lib/lz4/lz4defs.h | 1 + lib/math/gcd.c | 2 ++ 5 files changed, 20 insertions(+), 17 deletions(-)
include/linux/bitops.h +16 -0
@@ -20,6 +20,22 @@#define BITS_TO_U32 (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u32))#define BITS_TO_BYTES (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(char)) +/** +* upper_32_bits - return bits 32-63 of a number +* @n: the number we're accessing +* +* A basic shift-right of a 64- or 32-bit quantity. Use this to suppress +* the "right shift count >= width of type" warning when that quantity is +* 32-bits. +*/ +#define upper_32_bits (n) ((u32)(((n) >> 16) >> 16)) + +/** +* lower_32_bits - return bits 0-31 of a number +* @n: the number we're accessing +*/ +#define lower_32_bits (n) ((u32)(n)) +extern unsigned int __sw_hweight8 (unsigned int w);extern unsigned int __sw_hweight16 (unsigned int w);extern unsigned int __sw_hweight32 (unsigned int w);
include/linux/kernel.h +0 -16
@@ -60,22 +60,6 @@#define _RET_IP_ (unsigned long)__builtin_return_address(0)#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) -/** -* upper_32_bits - return bits 32-63 of a number -* @n: the number we're accessing -* -* A basic shift-right of a 64- or 32-bit quantity. Use this to suppress -* the "right shift count >= width of type" warning when that quantity is -* 32-bits. -*/ -#define upper_32_bits (n) ((u32)(((n) >> 16) >> 16)) - -/** -* lower_32_bits - return bits 0-31 of a number -* @n: the number we're accessing -*/ -#define lower_32_bits (n) ((u32)(n)) -struct completion ;struct pt_regs ;
lib/clz_ctz.c +1 -1
@@ -11,8 +11,8 @@* __c[lt]z[sd]i2 can be overridden by linking arch-specific versions. */ +#include <linux/bitops.h> #include <linux/export.h> -#include <linux/kernel.h> int __weak __ctzsi2 (int val);int __weak __ctzsi2 (int val)
lib/lz4/lz4defs.h +1 -0
@@ -36,6 +36,7 @@*/ #include <asm/unaligned.h> +#include <linux/bitops.h> #include <linux/string.h> /* memset, memcpy */ #define FORCE_INLINE __always_inline
lib/math/gcd.c +2 -0
@@ -1,4 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/bitops.h> #include <linux/kernel.h> #include <linux/gcd.h> #include <linux/export.h>
Signature · 1 line
2.24.1
Re: [PATCH v3 4/4] kernel.h: Move lower_32_bits()/upper_32_bits() to bitops.h
Quoted 1 line · Andy Shevchenko
Move lower_32_bits()/upper_32_bits() to
bitops.h.
while these macros includes bits, i think they are not appropriate to be moved to bitops.h as they generally work on values that are either 32 or 64 bit addresses.