Skip to contentSkip to conversation

mm/page_alloc.c:6773:62: sparse: sparse: incorrect type in argument 3 (different base types)

PATCH kernel test robot 2 participants 2 messages Jul 21, 2025 Memory management

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   97987520025658f30bb787a99ffbd9bbff9ffc9d
commit: d1554fb6302093d353c8bf4601f9bf994b836904 [8632/11398] mm/page_isolation: remove migratetype parameter from more functions
config: arm64-randconfig-r132-20250721 (https://download.01.org/0day-ci/archive/20250722/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce: (https://download.01.org/0day-ci/archive/20250722/[email protected]/reproduce)

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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> mm/page_alloc.c:6773:62: sparse: sparse: incorrect type in argument 3 (different base types) @@     expected unsigned long nr_migrated @@     got restricted acr_flags_t [usertype] alloc_flags @@
   mm/page_alloc.c:6773:62: sparse:     expected unsigned long nr_migrated
   mm/page_alloc.c:6773:62: sparse:     got restricted acr_flags_t [usertype] alloc_flags
>> mm/page_alloc.c:6776:50: sparse: sparse: incorrect type in argument 6 (different base types) @@     expected restricted acr_flags_t [usertype] alloc_flags @@     got unsigned long [assigned] total_mapped @@

mm/page_alloc.c:6776:50: sparse: expected restricted acr_flags_t [usertype] alloc_flags
mm/page_alloc.c:6776:50: sparse: got unsigned long [assigned] total_mapped
mm/page_alloc.c:1526:13: sparse: sparse: context imbalance in 'free_one_page' - different lock contexts for basic block mm/page_alloc.c:2520:12: sparse: sparse: context imbalance in 'rmqueue_bulk' - different lock contexts for basic block mm/page_alloc.c:2878:13: sparse: sparse: context imbalance in '__free_frozen_pages' - different lock contexts for basic block mm/page_alloc.c:2981:33: sparse: sparse: context imbalance in 'free_unref_folios' - unexpected unlock mm/page_alloc.c:3271:20: sparse: sparse: context imbalance in 'rmqueue_pcplist' - different lock contexts for basic block mm/page_alloc.c:3143:13: sparse: sparse: context imbalance in 'get_page_from_freelist' - different lock contexts for basic block mm/page_alloc.c:5099:9: sparse: sparse: context imbalance in 'alloc_pages_bulk_noprof' - different lock contexts for basic block

vim +6773 mm/page_alloc.c

6693
6694 /*
6695 * [start, end) must belong to a single zone.
6696 * @alloc_flags: using acr_flags_t to filter the type of migration in
6697 * trace_mm_alloc_contig_migrate_range_info.
6698 */
6699 static int __alloc_contig_migrate_range(struct compact_control *cc,
6700 unsigned long start, unsigned long end,
6701 acr_flags_t alloc_flags)
6702 {
6703 /* This function is based on compact_zone() from compaction.c. */
6704 unsigned int nr_reclaimed;
6705 unsigned long pfn = start;
6706 unsigned int tries = 0;
6707 int ret = 0;
6708 struct migration_target_control mtc = {
6709 .nid = zone_to_nid(cc->zone),
6710 .gfp_mask = cc->gfp_mask,
6711 .reason = MR_CONTIG_RANGE,
6712 };
6713 struct page *page;
6714 unsigned long total_mapped = 0;
6715 unsigned long total_migrated = 0;
6716 unsigned long total_reclaimed = 0;
6717
6718 lru_cache_disable();
6719
6720 while (pfn < end || !list_empty(&cc->migratepages)) {
6721 if (fatal_signal_pending(current)) {
6722 ret = -EINTR;
6723 break;
6724 }
6725
6726 if (list_empty(&cc->migratepages)) {
6727 cc->nr_migratepages = 0;
6728 ret = isolate_migratepages_range(cc, pfn, end);
6729 if (ret && ret != -EAGAIN)
6730 break;
6731 pfn = cc->migrate_pfn;
6732 tries = 0;
6733 } else if (++tries == 5) {
6734 ret = -EBUSY;
6735 break;
6736 }
6737
6738 nr_reclaimed = reclaim_clean_pages_from_list(cc->zone,
6739 &cc->migratepages);
6740 cc->nr_migratepages -= nr_reclaimed;
6741
6742 if (trace_mm_alloc_contig_migrate_range_info_enabled()) {
6743 total_reclaimed += nr_reclaimed;
6744 list_for_each_entry(page, &cc->migratepages, lru) {
6745 struct folio *folio = page_folio(page);
6746
6747 total_mapped += folio_mapped(folio) *
6748 folio_nr_pages(folio);
6749 }
6750 }
6751
6752 ret = migrate_pages(&cc->migratepages, alloc_migration_target,
6753 NULL, (unsigned long)&mtc, cc->mode, MR_CONTIG_RANGE, NULL);
6754
6755 if (trace_mm_alloc_contig_migrate_range_info_enabled() && !ret)
6756 total_migrated += cc->nr_migratepages;
6757
6758 /*
6759 * On -ENOMEM, migrate_pages() bails out right away. It is pointless
6760 * to retry again over this error, so do the same here.
6761 */
6762 if (ret == -ENOMEM)
6763 break;
6764 }
6765
6766 lru_cache_enable();
6767 if (ret < 0) {
6768 if (!(cc->gfp_mask & __GFP_NOWARN) && ret == -EBUSY)
6769 alloc_contig_dump_pages(&cc->migratepages);
6770 putback_movable_pages(&cc->migratepages);
6771 }
6772

> 6773		trace_mm_alloc_contig_migrate_range_info(start, end, alloc_flags,
  6774							 total_migrated,
  6775							 total_reclaimed,
> 6776							 total_mapped);

6777 return (ret < 0) ? ret : 0;
6778 }
6779

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 28 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   97987520025658f30bb787a99ffbd9bbff9ffc9d
commit: d1554fb6302093d353c8bf4601f9bf994b836904 [8632/11398] mm/page_isolation: remove migratetype parameter from more functions
config: arm64-randconfig-r132-20250721 (https://download.01.org/0day-ci/archive/20250722/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce: (https://download.01.org/0day-ci/archive/20250722/[email protected]/reproduce)

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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

mm/page_alloc.c:6773:62: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected unsigned long nr_migrated @@ got restricted acr_flags_t [usertype] alloc_flags @@

mm/page_alloc.c:6773:62: sparse: expected unsigned long nr_migrated
mm/page_alloc.c:6773:62: sparse: got restricted acr_flags_t [usertype] alloc_flags

Quoted 1 line
Quoted 1 line

mm/page_alloc.c:6776:50: sparse: sparse: incorrect type in argument 6 (different base types) @@ expected restricted acr_flags_t [usertype] alloc_flags @@ got unsigned long [assigned] total_mapped @@

mm/page_alloc.c:6776:50: sparse: expected restricted acr_flags_t [usertype] alloc_flags
mm/page_alloc.c:6776:50: sparse: got unsigned long [assigned] total_mapped
mm/page_alloc.c:1526:13: sparse: sparse: context imbalance in 'free_one_page' - different lock contexts for basic block mm/page_alloc.c:2520:12: sparse: sparse: context imbalance in 'rmqueue_bulk' - different lock contexts for basic block mm/page_alloc.c:2878:13: sparse: sparse: context imbalance in '__free_frozen_pages' - different lock contexts for basic block mm/page_alloc.c:2981:33: sparse: sparse: context imbalance in 'free_unref_folios' - unexpected unlock mm/page_alloc.c:3271:20: sparse: sparse: context imbalance in 'rmqueue_pcplist' - different lock contexts for basic block mm/page_alloc.c:3143:13: sparse: sparse: context imbalance in 'get_page_from_freelist' - different lock contexts for basic block mm/page_alloc.c:5099:9: sparse: sparse: context imbalance in 'alloc_pages_bulk_noprof' - different lock contexts for basic block

vim +6773 mm/page_alloc.c

<snip>

Quoted 8 lines

6772

Quoted 1 line

6773 trace_mm_alloc_contig_migrate_range_info(start, end, alloc_flags,

6774 total_migrated,
6775 total_reclaimed,

Quoted 1 line

6776 total_mapped);

6777 return (ret < 0) ? ret : 0;
6778 }
6779

It seems that the original patch only moved migratetype from third parameter to the last one[1], so the trace event has been useless since it was added. My patch was just a mechanic change.

No one seems to notice the issue so far, maybe the trace event can be removed.

(Add other page allocator maintainer + David)

Hi Richard,

Let me know if this trace event is still useful to you. Otherwise, I am going to send a patch to remove it.

Thanks.

[1] https://lore.kernel.org/all/[email protected]/T/#u

Best Regards,
Yan, Zi