Re: [PATCH 1/2] mm: printk: introduce new format %pGs for slab flags

From: kernel test robot
Date: Wed May 22 2024 - 16:26:58 EST


Hi Sukrit,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on akpm-mm/mm-nonmm-unstable linus/master v6.9 next-20240522]
[cannot apply to vbabka-slab/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Sukrit-Bhatnagar/mm-printk-introduce-new-format-pGs-for-slab-flags/20240522-154443
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20240522074629.2420423-2-Sukrit.Bhatnagar%40sony.com
patch subject: [PATCH 1/2] mm: printk: introduce new format %pGs for slab flags
config: x86_64-randconfig-123-20240522 (https://download.01.org/0day-ci/archive/20240523/202405230441.A0LFA9SY-lkp@xxxxxxxxx/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240523/202405230441.A0LFA9SY-lkp@xxxxxxxxx/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 <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405230441.A0LFA9SY-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> lib/test_printf.c:692:15: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long [addressable] [assigned] flags @@ got restricted slab_flags_t @@
lib/test_printf.c:692:15: sparse: expected unsigned long [addressable] [assigned] flags
lib/test_printf.c:692:15: sparse: got restricted slab_flags_t
lib/test_printf.c:708:49: sparse: sparse: cast from restricted gfp_t
lib/test_printf.c:712:58: sparse: sparse: cast from restricted gfp_t
lib/test_printf.c: note: in included file (through include/linux/mmzone.h, include/linux/gfp.h, include/linux/umh.h, include/linux/kmod.h, ...):
include/linux/page-flags.h:240:46: sparse: sparse: self-comparison always evaluates to false
include/linux/page-flags.h:240:46: sparse: sparse: self-comparison always evaluates to false

vim +692 lib/test_printf.c

656
657 static void __init
658 flags(void)
659 {
660 unsigned long flags;
661 char *cmp_buffer;
662 gfp_t gfp;
663 unsigned int page_type;
664
665 cmp_buffer = kmalloc(BUF_SIZE, GFP_KERNEL);
666 if (!cmp_buffer)
667 return;
668
669 flags = 0;
670 page_flags_test(0, 0, 0, 0, 0, flags, "", cmp_buffer);
671
672 flags = 1UL << NR_PAGEFLAGS;
673 page_flags_test(0, 0, 0, 0, 0, flags, "", cmp_buffer);
674
675 flags |= 1UL << PG_uptodate | 1UL << PG_dirty | 1UL << PG_lru
676 | 1UL << PG_active | 1UL << PG_swapbacked;
677 page_flags_test(1, 1, 1, 0x1fffff, 1, flags,
678 "uptodate|dirty|lru|active|swapbacked",
679 cmp_buffer);
680
681 flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
682 test("read|exec|mayread|maywrite|mayexec", "%pGv", &flags);
683
684 flags = 0;
685 scnprintf(cmp_buffer, BUF_SIZE, "%#x(%s)", (unsigned int) flags, "");
686 test(cmp_buffer, "%pGs", &flags);
687
688 flags = 1U << _SLAB_FLAGS_LAST_BIT;
689 scnprintf(cmp_buffer, BUF_SIZE, "%#x(%s)", (unsigned int) flags, "");
690 test(cmp_buffer, "%pGs", &flags);
691
> 692 flags = SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_NO_USER_FLAGS;
693 scnprintf(cmp_buffer, BUF_SIZE, "%#x(%s)", (unsigned int) flags,
694 "HWCACHE_ALIGN|PANIC|NO_USER_FLAGS");
695 test(cmp_buffer, "%pGs", &flags);
696
697 gfp = GFP_TRANSHUGE;
698 test("GFP_TRANSHUGE", "%pGg", &gfp);
699
700 gfp = GFP_ATOMIC|__GFP_DMA;
701 test("GFP_ATOMIC|GFP_DMA", "%pGg", &gfp);
702
703 gfp = __GFP_HIGH;
704 test("__GFP_HIGH", "%pGg", &gfp);
705
706 /* Any flags not translated by the table should remain numeric */
707 gfp = ~__GFP_BITS_MASK;
708 snprintf(cmp_buffer, BUF_SIZE, "%#lx", (unsigned long) gfp);
709 test(cmp_buffer, "%pGg", &gfp);
710
711 snprintf(cmp_buffer, BUF_SIZE, "__GFP_HIGH|%#lx",
712 (unsigned long) gfp);
713 gfp |= __GFP_HIGH;
714 test(cmp_buffer, "%pGg", &gfp);
715
716 page_type = ~0;
717 page_type_test(page_type, "", cmp_buffer);
718
719 page_type = 10;
720 page_type_test(page_type, "", cmp_buffer);
721
722 page_type = ~PG_buddy;
723 page_type_test(page_type, "buddy", cmp_buffer);
724
725 page_type = ~(PG_table | PG_buddy);
726 page_type_test(page_type, "table|buddy", cmp_buffer);
727
728 kfree(cmp_buffer);
729 }
730

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki