Re: [PATCH v3 09/12] mm, swap: use the swap table to track the swap count
From: Chris Li
Date: Thu Feb 19 2026 - 02:06:30 EST
On Wed, Feb 18, 2026 at 4:23 AM Kairui Song <ryncsn@xxxxxxxxx> wrote:
>
> On Wed, Feb 18, 2026 at 06:40:16PM +0800, kernel test robot wrote:
> > Hi Kairui,
> >
> > kernel test robot noticed the following build warnings:
> >
> > [auto build test WARNING on d9982f38eb6e9a0cb6bdd1116cc87f75a1084aad]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Kairui-Song-via-B4-Relay/mm-swap-protect-si-swap_file-properly-and-use-as-a-mount-indicator/20260218-040852
> > base: d9982f38eb6e9a0cb6bdd1116cc87f75a1084aad
> > patch link: https://lore.kernel.org/r/20260218-swap-table-p3-v3-9-f4e34be021a7%40tencent.com
> > patch subject: [PATCH v3 09/12] mm, swap: use the swap table to track the swap count
> > config: i386-buildonly-randconfig-001-20260218 (https://download.01.org/0day-ci/archive/20260218/202602181835.58TEynxc-lkp@xxxxxxxxx/config)
> > compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260218/202602181835.58TEynxc-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/202602181835.58TEynxc-lkp@xxxxxxxxx/
> >
> > All warnings (new ones prefixed by >>):
> >
> > >> mm/swapfile.c:1627:6: warning: shift count >= width of type [-Wshift-count-overflow]
> > 1626 | VM_WARN_ON_ONCE(ci->extend_table[ci_off] >=
> > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 1627 | (BIT(BITS_PER_TYPE(ci->extend_table[0]))) - 1);
> > | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > include/vdso/bits.h:7:26: note: expanded from macro 'BIT'
> > 7 | #define BIT(nr) (UL(1) << (nr))
> > | ^
> > include/linux/mmdebug.h:123:50: note: expanded from macro 'VM_WARN_ON_ONCE'
> > 123 | #define VM_WARN_ON_ONCE(cond) (void)WARN_ON_ONCE(cond)
> > | ~~~~~~~~~~~~~^~~~~
> > include/asm-generic/bug.h:120:25: note: expanded from macro 'WARN_ON_ONCE'
> > 120 | int __ret_warn_on = !!(condition); \
> > | ^~~~~~~~~
> > 1 warning generated.
>
> Nice catch from the bot. It's a new added sanity check in V3 just
> in case the swap count maybe grow larger than UINT_MAX, which should
> never happen, but just in case.
>
> I really should just use the existing helper macro for that:
With this fix up.
Acked-by: Chris Li <chrisl@xxxxxxxxxx>
Chris
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 801d8092be51..34b38255f72a 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -1624,7 +1624,7 @@ static int __swap_cluster_dup_entry(struct swap_cluster_info *ci,
> }
> } else if (count == SWP_TB_COUNT_MAX) {
> VM_WARN_ON_ONCE(ci->extend_table[ci_off] >=
> - (BIT(BITS_PER_TYPE(ci->extend_table[0]))) - 1);
> + type_max(typeof(ci->extend_table[0])));
> ++ci->extend_table[ci_off];
> } else {
> /* Never happens unless counting went wrong */
>