Re: [PATCH v2 2/2] kernel.h: Split out mathematical helpers

From: kbuild test robot
Date: Tue Feb 04 2020 - 20:57:58 EST


Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200203]
[cannot apply to nfs/linux-next rcu/dev linux/master linus/master v5.5 v5.5-rc7 v5.5-rc6 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/20200205-040141
base: cee5a42837d4a6c4189f06f7bf355b97a24c3c93
config: m68k-multi_defconfig (attached as .config)
compiler: m68k-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=m68k

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

lib/math/div64.c: In function 'div64_u64_rem':
>> lib/math/div64.c:112:11: error: implicit declaration of function 'fls' [-Werror=implicit-function-declaration]
int n = fls(high);
^~~
cc1: some warnings being treated as errors

vim +/fls +112 lib/math/div64.c

2418f4f28f8467 lib/div64.c Roman Zippel 2008-05-01 89
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 90 /**
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 91 * div64_u64_rem - unsigned 64bit divide with 64bit divisor and remainder
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 92 * @dividend: 64bit dividend
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 93 * @divisor: 64bit divisor
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 94 * @remainder: 64bit remainder
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 95 *
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 96 * This implementation is a comparable to algorithm used by div64_u64.
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 97 * But this operation, which includes math for calculating the remainder,
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 98 * is kept distinct to avoid slowing down the div64_u64 operation on 32bit
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 99 * systems.
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 100 */
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 101 #ifndef div64_u64_rem
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 102 u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 103 {
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 104 u32 high = divisor >> 32;
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 105 u64 quot;
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 106
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 107 if (high == 0) {
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 108 u32 rem32;
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 109 quot = div_u64_rem(dividend, divisor, &rem32);
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 110 *remainder = rem32;
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 111 } else {
cdc94a37493135 lib/div64.c Stanislaw Gruszka 2019-03-07 @112 int n = fls(high);
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 113 quot = div_u64(dividend >> n, divisor >> n);
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 114
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 115 if (quot != 0)
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 116 quot--;
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 117
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 118 *remainder = dividend - quot * divisor;
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 119 if (*remainder >= divisor) {
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 120 quot++;
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 121 *remainder -= divisor;
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 122 }
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 123 }
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 124
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 125 return quot;
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 126 }
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 127 EXPORT_SYMBOL(div64_u64_rem);
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 128 #endif
eb18cba78c2b92 lib/div64.c Mike Snitzer 2013-08-20 129

:::::: The code at line 112 was first introduced by commit
:::::: cdc94a37493135e355dfc0b0e086d84e3eadb50d lib/div64.c: off by one in shift

:::::: TO: Stanislaw Gruszka <sgruszka@xxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx Intel Corporation

Attachment: .config.gz
Description: application/gzip