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: e22ce8eb631bdc47a4a4ea7ecf4e4ba499db4f93 commit: 2f78788b55baa3410b1ec91a576286abe1ad4d6a ilog2: improve ilog2 for constant arguments date: 8 months ago :::::: branch date: 7 hours ago :::::: commit date: 8 months ago config: riscv-randconfig-c006-20210822 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 9e9d70591e72fc6762b4b9a226b68ed1307419bf) 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 >>) ^ mm/page-writeback.c:1925:2: note: Taking true branch if (unlikely(current->nr_dirtied >= ratelimit)) ^ mm/page-writeback.c:1926:3: note: Calling 'balance_dirty_pages' balance_dirty_pages(wb, current->nr_dirtied); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/page-writeback.c:1561:47: note: '?' condition is false struct dirty_throttle_control * const mdtc = mdtc_valid(&mdtc_stor) ? ^ mm/page-writeback.c:1577:2: note: Loop condition is true. Entering loop body for (;;) { ^ mm/page-writeback.c:1590:7: note: Assuming 'strictlimit' is false if (unlikely(strictlimit)) { ^ include/linux/compiler.h:78:40: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^~~~ mm/page-writeback.c:1590:3: note: Taking false branch if (unlikely(strictlimit)) { ^ mm/page-writeback.c:1602:7: note: 'mdtc' is null if (mdtc) { ^~~~ mm/page-writeback.c:1602:3: note: Taking false branch if (mdtc) { ^ mm/page-writeback.c:1640:7: note: Assuming the condition is true if (dirty <= dirty_freerun_ceiling(thresh, bg_thresh) && ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/page-writeback.c:1640:7: note: Left side of '&&' is true mm/page-writeback.c:1641:9: note: 'mdtc' is null (!mdtc || ^~~~ mm/page-writeback.c:1641:14: note: Left side of '||' is true (!mdtc || ^ mm/page-writeback.c:1647:11: note: Calling 'dirty_poll_interval' intv = dirty_poll_interval(dirty, thresh); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/page-writeback.c:1407:6: note: Assuming 'thresh' is > 'dirty' if (thresh > dirty) ^~~~~~~~~~~~~~ mm/page-writeback.c:1407:2: note: Taking true branch if (thresh > dirty) ^ mm/page-writeback.c:1408:18: note: '?' condition is false return 1UL << (ilog2(thresh - dirty) >> 1); ^ include/linux/log2.h:158:2: note: expanded from macro 'ilog2' __builtin_constant_p(n) ? \ ^ mm/page-writeback.c:1408:18: note: '?' condition is false return 1UL << (ilog2(thresh - dirty) >> 1); ^ include/linux/log2.h:161:2: note: expanded from macro 'ilog2' (sizeof(n) <= 4) ? \ ^ mm/page-writeback.c:1408:14: note: The result of the left shift is undefined because the right operand is negative return 1UL << (ilog2(thresh - dirty) >> 1); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppressed 13 warnings (6 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. 5 warnings generated. 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. Suppressed 13 warnings (6 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. 13 warnings generated. Suppressed 13 warnings (6 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. 15 warnings generated. mm/workingset.c:206:2: warning: Value stored to 'nid' is never read [clang-analyzer-deadcode.DeadStores] nid = entry & ((1UL << NODES_SHIFT) - 1); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/workingset.c:206:2: note: Value stored to 'nid' is never read nid = entry & ((1UL << NODES_SHIFT) - 1); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppressed 14 warnings (6 in non-user code, 8 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. 13 warnings generated. Suppressed 13 warnings (6 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. 13 warnings generated. Suppressed 13 warnings (6 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. 16 warnings generated. Suppressed 16 warnings (6 in non-user code, 10 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. 49 warnings generated. mm/nommu.c:881:6: warning: Value stored to 'prot' is never read [clang-analyzer-deadcode.DeadStores] prot |= PROT_EXEC; ^ mm/nommu.c:881:6: note: Value stored to 'prot' is never read mm/nommu.c:899:4: warning: Value stored to 'prot' is never read [clang-analyzer-deadcode.DeadStores] prot |= PROT_EXEC; ^ mm/nommu.c:899:4: note: Value stored to 'prot' is never read >> mm/nommu.c:1010:12: warning: The result of the left shift is undefined due >> to shifting by '32', which is greater or equal to the width of type 'int' >> [clang-analyzer-core.UndefinedBinaryOperatorResult] total = 1 << order; ^ mm/nommu.c:1091:6: note: 'ret' is >= 0 if (ret < 0) ^~~ mm/nommu.c:1091:2: note: Taking false branch if (ret < 0) ^ mm/nommu.c:1104:6: note: Assuming 'region' is non-null if (!region) ^~~~~~~ mm/nommu.c:1104:2: note: Taking false branch if (!region) ^ mm/nommu.c:1108:6: note: Assuming 'vma' is non-null if (!vma) ^~~~ mm/nommu.c:1108:2: note: Taking false branch if (!vma) ^ mm/nommu.c:1118:6: note: 'file' is null if (file) { ^~~~ mm/nommu.c:1118:2: note: Taking false branch if (file) { ^ mm/nommu.c:1133:6: note: Assuming the condition is false if (vm_flags & VM_MAYSHARE) { ^~~~~~~~~~~~~~~~~~~~~~ mm/nommu.c:1133:2: note: Taking false branch if (vm_flags & VM_MAYSHARE) { ^ mm/nommu.c:1230:6: note: 'file' is null if (file && vma->vm_flags & VM_SHARED) ^~~~ mm/nommu.c:1230:11: note: Left side of '&&' is false if (file && vma->vm_flags & VM_SHARED) ^ mm/nommu.c:1233:9: note: Calling 'do_mmap_private' ret = do_mmap_private(vma, region, len, capabilities); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/nommu.c:988:2: note: Taking false branch if (capabilities & NOMMU_MAP_DIRECT) { ^ mm/nommu.c:1009:10: note: Calling 'get_order' order = get_order(len); ^~~~~~~~~~~~~~ include/asm-generic/getorder.h:31:2: note: Taking false branch if (__builtin_constant_p(size)) { ^ include/asm-generic/getorder.h:46:9: note: Calling 'fls64' return fls64(size); ^~~~~~~~~~~ include/asm-generic/bitops/fls64.h:29:6: note: Assuming 'x' is not equal to 0 if (x == 0) ^~~~~~ include/asm-generic/bitops/fls64.h:29:2: note: Taking false branch if (x == 0) ^ include/asm-generic/bitops/fls64.h:31:2: note: Returning the value 32 return __fls(x) + 1; ^~~~~~~~~~~~~~~~~~~ include/asm-generic/getorder.h:46:9: note: Returning from 'fls64' return fls64(size); ^~~~~~~~~~~ include/asm-generic/getorder.h:46:2: note: Returning the value 32 return fls64(size); ^~~~~~~~~~~~~~~~~~ mm/nommu.c:1009:10: note: Returning from 'get_order' order = get_order(len); ^~~~~~~~~~~~~~ mm/nommu.c:1009:2: note: The value 32 is assigned to 'order' order = get_order(len); ^~~~~~~~~~~~~~~~~~~~~~ mm/nommu.c:1010:12: note: The result of the left shift is undefined due to shifting by '32', which is greater or equal to the width of type 'int' total = 1 << order; ^ ~~~~~ mm/nommu.c:1010:12: warning: The result of the left shift is undefined due to shifting by '33', which is greater or equal to the width of type 'int' [clang-analyzer-core.UndefinedBinaryOperatorResult] total = 1 << order; ^ mm/nommu.c:1091:6: note: 'ret' is >= 0 if (ret < 0) ^~~ mm/nommu.c:1091:2: note: Taking false branch if (ret < 0) ^ mm/nommu.c:1104:6: note: Assuming 'region' is non-null if (!region) ^~~~~~~ mm/nommu.c:1104:2: note: Taking false branch if (!region) ^ mm/nommu.c:1108:6: note: Assuming 'vma' is non-null if (!vma) ^~~~ mm/nommu.c:1108:2: note: Taking false branch if (!vma) ^ mm/nommu.c:1118:6: note: 'file' is null if (file) { vim +1010 mm/nommu.c ^1da177e4c3f41 Linus Torvalds 2005-04-16 971 ^1da177e4c3f41 Linus Torvalds 2005-04-16 972 /* ^1da177e4c3f41 Linus Torvalds 2005-04-16 973 * set up a private mapping or an anonymous shared mapping ^1da177e4c3f41 Linus Torvalds 2005-04-16 974 */ 8feae13110d60c David Howells 2009-01-08 975 static int do_mmap_private(struct vm_area_struct *vma, 8feae13110d60c David Howells 2009-01-08 976 struct vm_region *region, 645d83c5db970a David Howells 2009-09-24 977 unsigned long len, 645d83c5db970a David Howells 2009-09-24 978 unsigned long capabilities) ^1da177e4c3f41 Linus Torvalds 2005-04-16 979 { dbc8358c72373d Joonsoo Kim 2014-12-12 980 unsigned long total, point; ^1da177e4c3f41 Linus Torvalds 2005-04-16 981 void *base; 8feae13110d60c David Howells 2009-01-08 982 int ret, order; ^1da177e4c3f41 Linus Torvalds 2005-04-16 983 ^1da177e4c3f41 Linus Torvalds 2005-04-16 984 /* invoke the file's mapping function so that it can keep track of ^1da177e4c3f41 Linus Torvalds 2005-04-16 985 * shared mappings on devices or memory ^1da177e4c3f41 Linus Torvalds 2005-04-16 986 * - VM_MAYSHARE will be set if it may attempt to share ^1da177e4c3f41 Linus Torvalds 2005-04-16 987 */ b4caecd48005fb Christoph Hellwig 2015-01-14 988 if (capabilities & NOMMU_MAP_DIRECT) { f74ac01520c9f6 Miklos Szeredi 2017-02-20 989 ret = call_mmap(vma->vm_file, vma); dd8632a12e500a Paul Mundt 2009-01-08 990 if (ret == 0) { ^1da177e4c3f41 Linus Torvalds 2005-04-16 991 /* shouldn't return success if we're not sharing */ dd8632a12e500a Paul Mundt 2009-01-08 992 BUG_ON(!(vma->vm_flags & VM_MAYSHARE)); dd8632a12e500a Paul Mundt 2009-01-08 993 vma->vm_region->vm_top = vma->vm_region->vm_end; 645d83c5db970a David Howells 2009-09-24 994 return 0; ^1da177e4c3f41 Linus Torvalds 2005-04-16 995 } dd8632a12e500a Paul Mundt 2009-01-08 996 if (ret != -ENOSYS) dd8632a12e500a Paul Mundt 2009-01-08 997 return ret; ^1da177e4c3f41 Linus Torvalds 2005-04-16 998 ^1da177e4c3f41 Linus Torvalds 2005-04-16 999 /* getting an ENOSYS error indicates that direct mmap isn't ^1da177e4c3f41 Linus Torvalds 2005-04-16 1000 * possible (as opposed to tried but failed) so we'll try to ^1da177e4c3f41 Linus Torvalds 2005-04-16 1001 * make a private copy of the data and map that instead */ ^1da177e4c3f41 Linus Torvalds 2005-04-16 1002 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 1003 8feae13110d60c David Howells 2009-01-08 1004 ^1da177e4c3f41 Linus Torvalds 2005-04-16 1005 /* allocate some memory to hold the mapping ^1da177e4c3f41 Linus Torvalds 2005-04-16 1006 * - note that this may not return a page-aligned address if the object ^1da177e4c3f41 Linus Torvalds 2005-04-16 1007 * we're allocating is smaller than a page ^1da177e4c3f41 Linus Torvalds 2005-04-16 1008 */ f67d9b1576c1c6 Bob Liu 2011-05-24 1009 order = get_order(len); 8feae13110d60c David Howells 2009-01-08 @1010 total = 1 << order; f67d9b1576c1c6 Bob Liu 2011-05-24 1011 point = len >> PAGE_SHIFT; dd8632a12e500a Paul Mundt 2009-01-08 1012 dbc8358c72373d Joonsoo Kim 2014-12-12 1013 /* we don't want to allocate a power-of-2 sized page set */ 22cc877b32202b Leon Romanovsky 2015-06-24 1014 if (sysctl_nr_trim_pages && total - point >= sysctl_nr_trim_pages) dbc8358c72373d Joonsoo Kim 2014-12-12 1015 total = point; 8feae13110d60c David Howells 2009-01-08 1016 da616534ed7f6e Joonsoo Kim 2015-02-27 1017 base = alloc_pages_exact(total << PAGE_SHIFT, GFP_KERNEL); dbc8358c72373d Joonsoo Kim 2014-12-12 1018 if (!base) dbc8358c72373d Joonsoo Kim 2014-12-12 1019 goto enomem; dbc8358c72373d Joonsoo Kim 2014-12-12 1020 dbc8358c72373d Joonsoo Kim 2014-12-12 1021 atomic_long_add(total, &mmap_pages_allocated); 8feae13110d60c David Howells 2009-01-08 1022 8feae13110d60c David Howells 2009-01-08 1023 region->vm_flags = vma->vm_flags |= VM_MAPPED_COPY; 8feae13110d60c David Howells 2009-01-08 1024 region->vm_start = (unsigned long) base; f67d9b1576c1c6 Bob Liu 2011-05-24 1025 region->vm_end = region->vm_start + len; dd8632a12e500a Paul Mundt 2009-01-08 1026 region->vm_top = region->vm_start + (total << PAGE_SHIFT); 8feae13110d60c David Howells 2009-01-08 1027 8feae13110d60c David Howells 2009-01-08 1028 vma->vm_start = region->vm_start; 8feae13110d60c David Howells 2009-01-08 1029 vma->vm_end = region->vm_start + len; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1030 ^1da177e4c3f41 Linus Torvalds 2005-04-16 1031 if (vma->vm_file) { ^1da177e4c3f41 Linus Torvalds 2005-04-16 1032 /* read the contents of a file into the copy */ ^1da177e4c3f41 Linus Torvalds 2005-04-16 1033 loff_t fpos; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1034 ^1da177e4c3f41 Linus Torvalds 2005-04-16 1035 fpos = vma->vm_pgoff; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1036 fpos <<= PAGE_SHIFT; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1037 b4bf802a5a6563 Christoph Hellwig 2017-09-01 1038 ret = kernel_read(vma->vm_file, base, len, &fpos); ^1da177e4c3f41 Linus Torvalds 2005-04-16 1039 if (ret < 0) ^1da177e4c3f41 Linus Torvalds 2005-04-16 1040 goto error_free; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1041 ^1da177e4c3f41 Linus Torvalds 2005-04-16 1042 /* clear the last little bit */ f67d9b1576c1c6 Bob Liu 2011-05-24 1043 if (ret < len) f67d9b1576c1c6 Bob Liu 2011-05-24 1044 memset(base + ret, 0, len - ret); ^1da177e4c3f41 Linus Torvalds 2005-04-16 1045 bfd40eaff5abb9 Kirill A. Shutemov 2018-07-26 1046 } else { bfd40eaff5abb9 Kirill A. Shutemov 2018-07-26 1047 vma_set_anonymous(vma); ^1da177e4c3f41 Linus Torvalds 2005-04-16 1048 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 1049 ^1da177e4c3f41 Linus Torvalds 2005-04-16 1050 return 0; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1051 ^1da177e4c3f41 Linus Torvalds 2005-04-16 1052 error_free: 7223bb4a829628 Namhyung Kim 2011-05-24 1053 free_page_series(region->vm_start, region->vm_top); 8feae13110d60c David Howells 2009-01-08 1054 region->vm_start = vma->vm_start = 0; 8feae13110d60c David Howells 2009-01-08 1055 region->vm_end = vma->vm_end = 0; dd8632a12e500a Paul Mundt 2009-01-08 1056 region->vm_top = 0; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1057 return ret; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1058 ^1da177e4c3f41 Linus Torvalds 2005-04-16 1059 enomem: b1de0d139c97a6 Mitchel Humpherys 2014-06-06 1060 pr_err("Allocation of length %lu from process %d (%s) failed\n", 05ae6fa31874ed Greg Ungerer 2009-01-13 1061 len, current->pid, current->comm); 9af744d743170b Michal Hocko 2017-02-22 1062 show_free_areas(0, NULL); ^1da177e4c3f41 Linus Torvalds 2005-04-16 1063 return -ENOMEM; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1064 } ^1da177e4c3f41 Linus Torvalds 2005-04-16 1065 :::::: The code at line 1010 was first introduced by commit :::::: 8feae13110d60cc6287afabc2887366b0eb226c2 NOMMU: Make VMAs per MM as for MMU-mode linux :::::: TO: David Howells <[email protected]> :::::: CC: David Howells <[email protected]> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected]
.config.gz
Description: application/gzip
_______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
