CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Jakub Jelinek <[email protected]>
CC: "Peter Zijlstra (Intel)" <[email protected]>
CC: Andrew Morton <[email protected]>
CC: Linux Memory Management List <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   d4d016caa4b85b9aa98d7ec8c84e928621a614bc
commit: 2f78788b55baa3410b1ec91a576286abe1ad4d6a ilog2: improve ilog2 for 
constant arguments
date:   9 months ago
:::::: branch date: 15 hours ago
:::::: commit date: 9 months ago
config: riscv-randconfig-c006-20210916 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 
8cbbd7e0b2aa21ce7e416cfb63d9965518948c35)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2f78788b55baa3410b1ec91a576286abe1ad4d6a
        git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 2f78788b55baa3410b1ec91a576286abe1ad4d6a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
                   ^
   include/asm-generic/bug.h:104:3: note: expanded from macro 'WARN_ON_ONCE'
                   __WARN_FLAGS(BUGFLAG_ONCE |                     \
                   ^
   arch/riscv/include/asm/bug.h:79:29: note: expanded from macro '__WARN_FLAGS'
   #define __WARN_FLAGS(flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
                               ^
   arch/riscv/include/asm/bug.h:53:32: note: expanded from macro '__BUG_FLAGS'
   #define __BUG_FLAGS(flags)                                      \
                                                                   ^
   kernel/irq/affinity.c:237:22: note: Division by zero
                                    numvecs * ncpus / remaining_ncpus);
                                                    ^
   include/linux/minmax.h:118:59: note: expanded from macro 'max_t'
   #define max_t(type, x, y)       __careful_cmp((type)(x), (type)(y), >)
                                                                   ^
   include/linux/minmax.h:44:17: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                                 ^
   include/linux/minmax.h:38:25: note: expanded from macro '__cmp_once'
                   typeof(y) unique_y = (y);               \
                                         ^
   Suppressed 11 warnings (4 in non-user code, 7 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   17 warnings generated.
   crypto/sm3_generic.c:121:2: warning: Value stored to 'a' is never read 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
           ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:2: note: Value stored to 'a' is never read
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
           ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:6: warning: Although the value stored to 'b' is 
used in the enclosing expression, the value is never actually read from 'b' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
               ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:6: note: Although the value stored to 'b' is used 
in the enclosing expression, the value is never actually read from 'b'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
               ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:10: warning: Although the value stored to 'c' is 
used in the enclosing expression, the value is never actually read from 'c' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                   ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:10: note: Although the value stored to 'c' is used 
in the enclosing expression, the value is never actually read from 'c'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                   ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:14: warning: Although the value stored to 'd' is 
used in the enclosing expression, the value is never actually read from 'd' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                       ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:14: note: Although the value stored to 'd' is used 
in the enclosing expression, the value is never actually read from 'd'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                       ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:18: warning: Although the value stored to 'e' is 
used in the enclosing expression, the value is never actually read from 'e' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                           ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:18: note: Although the value stored to 'e' is used 
in the enclosing expression, the value is never actually read from 'e'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                           ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:22: warning: Although the value stored to 'f' is 
used in the enclosing expression, the value is never actually read from 'f' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                               ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:22: note: Although the value stored to 'f' is used 
in the enclosing expression, the value is never actually read from 'f'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                               ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:26: warning: Although the value stored to 'g' is 
used in the enclosing expression, the value is never actually read from 'g' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                   ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:26: note: Although the value stored to 'g' is used 
in the enclosing expression, the value is never actually read from 'g'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                   ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:30: warning: Although the value stored to 'h' is 
used in the enclosing expression, the value is never actually read from 'h' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                       ^   ~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:30: note: Although the value stored to 'h' is used 
in the enclosing expression, the value is never actually read from 'h'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                       ^   ~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:34: warning: Although the value stored to 'ss1' is 
used in the enclosing expression, the value is never actually read from 'ss1' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                           ^     ~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:34: note: Although the value stored to 'ss1' is 
used in the enclosing expression, the value is never actually read from 'ss1'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                           ^     ~~~~~~~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:40: warning: Although the value stored to 'ss2' is 
used in the enclosing expression, the value is never actually read from 'ss2' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                                 ^     ~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:40: note: Although the value stored to 'ss2' is 
used in the enclosing expression, the value is never actually read from 'ss2'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                                 ^     ~~~~~~~~~~~~~
   crypto/sm3_generic.c:121:46: warning: Although the value stored to 'tt1' is 
used in the enclosing expression, the value is never actually read from 'tt1' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                                       ^     ~~~~~~~
   crypto/sm3_generic.c:121:46: note: Although the value stored to 'tt1' is 
used in the enclosing expression, the value is never actually read from 'tt1'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                                       ^     ~~~~~~~
   crypto/sm3_generic.c:121:52: warning: Although the value stored to 'tt2' is 
used in the enclosing expression, the value is never actually read from 'tt2' 
[clang-analyzer-deadcode.DeadStores]
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                                             ^     ~
   crypto/sm3_generic.c:121:52: note: Although the value stored to 'tt2' is 
used in the enclosing expression, the value is never actually read from 'tt2'
           a = b = c = d = e = f = g = h = ss1 = ss2 = tt1 = tt2 = 0;
                                                             ^     ~
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   13 warnings generated.
>> drivers/pci/endpoint/pci-epc-mem.c:29:7: warning: Assigned value is garbage 
>> or undefined [clang-analyzer-core.uninitialized.Assign]
           size >>= page_shift;
                ^
   drivers/pci/endpoint/pci-epc-mem.c:244:6: note: Assuming 'mem' is non-null
           if (!mem) {
               ^~~~
   drivers/pci/endpoint/pci-epc-mem.c:244:2: note: Taking false branch
           if (!mem) {
           ^
   drivers/pci/endpoint/pci-epc-mem.c:250:15: note: '?' condition is false
           page_shift = ilog2(page_size);
                        ^
   include/linux/log2.h:158:2: note: expanded from macro 'ilog2'
           __builtin_constant_p(n) ?       \
           ^
   drivers/pci/endpoint/pci-epc-mem.c:250:15: note: '?' condition is false
           page_shift = ilog2(page_size);
                        ^
   include/linux/log2.h:161:2: note: expanded from macro 'ilog2'
           (sizeof(n) <= 4) ?              \
           ^
   drivers/pci/endpoint/pci-epc-mem.c:254:10: note: Calling 
'pci_epc_mem_get_order'
           order = pci_epc_mem_get_order(mem, size);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/pci-epc-mem.c:26:28: note: '?' condition is false
           unsigned int page_shift = ilog2(mem->window.page_size);
                                     ^
   include/linux/log2.h:158:2: note: expanded from macro 'ilog2'
           __builtin_constant_p(n) ?       \
           ^
   drivers/pci/endpoint/pci-epc-mem.c:26:28: note: '?' condition is false
           unsigned int page_shift = ilog2(mem->window.page_size);
                                     ^
   include/linux/log2.h:161:2: note: expanded from macro 'ilog2'
           (sizeof(n) <= 4) ?              \
           ^
   drivers/pci/endpoint/pci-epc-mem.c:26:28: note: Calling '__ilog2_u64'
           unsigned int page_shift = ilog2(mem->window.page_size);
                                     ^
   include/linux/log2.h:163:2: note: expanded from macro 'ilog2'
           __ilog2_u64(n)                  \
           ^~~~~~~~~~~~~~
   include/linux/log2.h:32:2: note: Returning the value -1
           return fls64(n) - 1;
           ^~~~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/pci-epc-mem.c:26:28: note: Returning from '__ilog2_u64'
           unsigned int page_shift = ilog2(mem->window.page_size);
                                     ^
   include/linux/log2.h:163:2: note: expanded from macro 'ilog2'
           __ilog2_u64(n)                  \
           ^~~~~~~~~~~~~~
   drivers/pci/endpoint/pci-epc-mem.c:26:2: note: 'page_shift' initialized to 
4294967295
           unsigned int page_shift = ilog2(mem->window.page_size);
           ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/pci-epc-mem.c:29:7: note: Assigned value is garbage or 
undefined
           size >>= page_shift;
                ^   ~~~~~~~~~~
   Suppressed 12 warnings (5 in non-user code, 7 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   1 warning generated.
   lib/math/rational.c:82:35: warning: Division by zero 
[clang-analyzer-core.DivideZero]
                                                 (max_denominator - d0) / d1);
                                                                        ^
   include/linux/minmax.h:51:36: note: expanded from macro 'min'
   #define min(x, y)       __careful_cmp(x, y, <)
                                            ^
   include/linux/minmax.h:44:17: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                                 ^
   include/linux/minmax.h:38:25: note: expanded from macro '__cmp_once'
                   typeof(y) unique_y = (y);               \
                                         ^
   lib/math/rational.c:52:7: note: The value 0 is assigned to 'd1'
           n0 = d1 = 0;
                ^~~~~~
   lib/math/rational.c:55:2: note: Loop condition is true.  Entering loop body
           for (;;) {
           ^
   lib/math/rational.c:58:7: note: Assuming 'd' is not equal to 0
                   if (d == 0)
                       ^~~~~~
   lib/math/rational.c:58:3: note: Taking false branch
                   if (d == 0)
                   ^
   lib/math/rational.c:80:8: note: Assuming 'n2' is > 'max_numerator'
                   if ((n2 > max_numerator) || (d2 > max_denominator)) {
                        ^~~~~~~~~~~~~~~~~~
   lib/math/rational.c:80:28: note: Left side of '||' is true
                   if ((n2 > max_numerator) || (d2 > max_denominator)) {
                                            ^
   lib/math/rational.c:82:35: note: Division by zero
                                                 (max_denominator - d0) / d1);
                                                                        ^
   include/linux/minmax.h:51:36: note: expanded from macro 'min'
   #define min(x, y)       __careful_cmp(x, y, <)

vim +29 drivers/pci/endpoint/pci-epc-mem.c

5e8cb4033807e3 Kishon Vijay Abraham I 2017-04-10  14  
5e8cb4033807e3 Kishon Vijay Abraham I 2017-04-10  15  /**
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  16   * 
pci_epc_mem_get_order() - determine the allocation order of a memory size
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  17   * @mem: address space of 
the endpoint controller
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  18   * @size: the size for 
which to get the order
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  19   *
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  20   * Reimplement 
get_order() for mem->page_size since the generic get_order
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  21   * always gets order with 
a constant PAGE_SIZE.
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  22   */
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  23  static int 
pci_epc_mem_get_order(struct pci_epc_mem *mem, size_t size)
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  24  {
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  25    int order;
d45e3c1a5979ef Lad Prabhakar          2020-05-07  26    unsigned int page_shift 
= ilog2(mem->window.page_size);
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  27  
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  28    size--;
52c9285d47459c Kishon Vijay Abraham I 2017-08-18 @29    size >>= page_shift;
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  30  #if BITS_PER_LONG == 32
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  31    order = fls(size);
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  32  #else
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  33    order = fls64(size);
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  34  #endif
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  35    return order;
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  36  }
52c9285d47459c Kishon Vijay Abraham I 2017-08-18  37  

:::::: The code at line 29 was first introduced by commit
:::::: 52c9285d47459cf241e144c7d8ef15941ba1b181 PCI: endpoint: Add support for 
configurable page size

:::::: TO: Kishon Vijay Abraham I <[email protected]>
:::::: CC: Bjorn Helgaas <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to