mm/hugetlb.c:3424 gather_bootmem_prealloc_node() warn: unsigned '_x' is never less than zero.
From: kernel test robot
Date: Fri Feb 14 2025 - 12:34:03 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 128c8f96eb8638c060cd3532dc394d046ce64fe1
commit: b78b27d02930f6f0262353080d0f784ce7aa377e hugetlb: parallelize 1G hugetlb initialization
date: 12 months ago
config: riscv-randconfig-r073-20250213 (https://download.01.org/0day-ci/archive/20250215/202502150114.XM31HL0I-lkp@xxxxxxxxx/config)
compiler: riscv32-linux-gcc (GCC) 14.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502150114.XM31HL0I-lkp@xxxxxxxxx/
New smatch warnings:
mm/hugetlb.c:3424 gather_bootmem_prealloc_node() warn: unsigned '_x' is never less than zero.
Old smatch warnings:
include/asm-generic/io.h:1005 virt_to_phys() warn: unsigned '_x' is never less than zero.
arch/riscv/include/asm/atomic.h:204 arch_atomic_fetch_add_unless() warn: inconsistent indenting
vim +/_x +3424 mm/hugetlb.c
79359d6d24df2f Mike Kravetz 2023-10-18 3412
48b8d744ea841b Mike Kravetz 2021-06-30 3413 /*
48b8d744ea841b Mike Kravetz 2021-06-30 3414 * Put bootmem huge pages into the standard lists after mem_map is up.
5e0a760b44417f Kirill A. Shutemov 2023-12-28 3415 * Note: This only applies to gigantic (order > MAX_PAGE_ORDER) pages.
48b8d744ea841b Mike Kravetz 2021-06-30 3416 */
b78b27d02930f6 Gang Li 2024-02-22 3417 static void __init gather_bootmem_prealloc_node(unsigned long nid)
aa888a74977a8f Andi Kleen 2008-07-23 3418 {
d67e32f26713c3 Mike Kravetz 2023-10-18 3419 LIST_HEAD(folio_list);
aa888a74977a8f Andi Kleen 2008-07-23 3420 struct huge_bootmem_page *m;
d67e32f26713c3 Mike Kravetz 2023-10-18 3421 struct hstate *h = NULL, *prev_h = NULL;
aa888a74977a8f Andi Kleen 2008-07-23 3422
b78b27d02930f6 Gang Li 2024-02-22 3423 list_for_each_entry(m, &huge_boot_pages[nid], list) {
40d18ebffb3974 Mike Kravetz 2018-08-17 @3424 struct page *page = virt_to_page(m);
fde1c4ecf91640 Usama Arif 2023-09-13 3425 struct folio *folio = (void *)page;
d67e32f26713c3 Mike Kravetz 2023-10-18 3426
d67e32f26713c3 Mike Kravetz 2023-10-18 3427 h = m->hstate;
d67e32f26713c3 Mike Kravetz 2023-10-18 3428 /*
d67e32f26713c3 Mike Kravetz 2023-10-18 3429 * It is possible to have multiple huge page sizes (hstates)
d67e32f26713c3 Mike Kravetz 2023-10-18 3430 * in this list. If so, process each size separately.
d67e32f26713c3 Mike Kravetz 2023-10-18 3431 */
d67e32f26713c3 Mike Kravetz 2023-10-18 3432 if (h != prev_h && prev_h != NULL)
79359d6d24df2f Mike Kravetz 2023-10-18 3433 prep_and_add_bootmem_folios(prev_h, &folio_list);
d67e32f26713c3 Mike Kravetz 2023-10-18 3434 prev_h = h;
ee8f248d266ec6 Becky Bruce 2011-07-25 3435
48b8d744ea841b Mike Kravetz 2021-06-30 3436 VM_BUG_ON(!hstate_is_gigantic(h));
d1c6095572d0cf Sidhartha Kumar 2022-11-29 3437 WARN_ON(folio_ref_count(folio) != 1);
fde1c4ecf91640 Usama Arif 2023-09-13 3438
fde1c4ecf91640 Usama Arif 2023-09-13 3439 hugetlb_folio_init_vmemmap(folio, h,
fde1c4ecf91640 Usama Arif 2023-09-13 3440 HUGETLB_VMEMMAP_RESERVE_PAGES);
79359d6d24df2f Mike Kravetz 2023-10-18 3441 init_new_hugetlb_folio(h, folio);
d67e32f26713c3 Mike Kravetz 2023-10-18 3442 list_add(&folio->lru, &folio_list);
af0fb9df784174 Michal Hocko 2018-01-31 3443
b0320c7b7d1ac1 Rafael Aquini 2011-06-15 3444 /*
48b8d744ea841b Mike Kravetz 2021-06-30 3445 * We need to restore the 'stolen' pages to totalram_pages
48b8d744ea841b Mike Kravetz 2021-06-30 3446 * in order to fix confusing memory reports from free(1) and
48b8d744ea841b Mike Kravetz 2021-06-30 3447 * other side-effects, like CommitLimit going negative.
b0320c7b7d1ac1 Rafael Aquini 2011-06-15 3448 */
c78a7f3639932c Miaohe Lin 2021-02-24 3449 adjust_managed_page_count(page, pages_per_huge_page(h));
520495fe96d74e Cannon Matthews 2018-07-03 3450 cond_resched();
aa888a74977a8f Andi Kleen 2008-07-23 3451 }
d67e32f26713c3 Mike Kravetz 2023-10-18 3452
79359d6d24df2f Mike Kravetz 2023-10-18 3453 prep_and_add_bootmem_folios(h, &folio_list);
aa888a74977a8f Andi Kleen 2008-07-23 3454 }
fde1c4ecf91640 Usama Arif 2023-09-13 3455
:::::: The code at line 3424 was first introduced by commit
:::::: 40d18ebffb3974272a920c41f2d74431152cae98 mm/hugetlb: remove gigantic page support for HIGHMEM
:::::: TO: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki