Re: [linux-next:master 3853/4127] mm/zsmalloc.c:2220:69: warning: right shift count >= width of type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On (22/10/29 19:33), kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   fd8dab197cca2746e1fcd399a218eec5164726d4
> commit: 280bbecded35eea30bbb5537f4f0a8a7e0e1b784 [3853/4127] zsmalloc: turn zspage order into runtime variable
> config: parisc-randconfig-r023-20221029
> compiler: hppa64-linux-gcc (GCC) 12.1.0
> 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
>         # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=280bbecded35eea30bbb5537f4f0a8a7e0e1b784
>         git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
>         git fetch --no-tags linux-next master
>         git checkout 280bbecded35eea30bbb5537f4f0a8a7e0e1b784
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc64 SHELL=/bin/bash
> 
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> 
> All warnings (new ones prefixed by >>):
> 
>    mm/zsmalloc.c: In function 'zs_create_pool':
> >> mm/zsmalloc.c:2220:69: warning: right shift count >= width of type [-Wshift-count-overflow]
>     2220 |         pool->min_alloc_size = (max_pages_per_zspage << PAGE_SHIFT) >>
>          |                                                                     ^~

Haven't seen any warnings on my side. I guess the following should do
the trick:

---
 mm/zsmalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 0bc9ed1f1a5d..181bfc66249b 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -2211,6 +2211,7 @@ struct zs_pool *zs_create_pool(const char *name, u32 max_pages_per_zspage)
 	int i;
 	struct zs_pool *pool;
 	struct size_class *prev_class = NULL;
+	unsigned long num_pages = max_pages_per_zspage;
 
 	if (WARN_ON(max_pages_per_zspage < ZS_MIN_PAGES_PER_ZSPAGE ||
 		    max_pages_per_zspage > ZS_MAX_PAGES_PER_ZSPAGE))
@@ -2221,8 +2222,7 @@ struct zs_pool *zs_create_pool(const char *name, u32 max_pages_per_zspage)
 		return NULL;
 
 	/* min_alloc_size must be multiple of ZS_ALIGN */
-	pool->min_alloc_size = (max_pages_per_zspage << PAGE_SHIFT) >>
-		OBJ_INDEX_BITS;
+	pool->min_alloc_size = num_pages << PAGE_SHIFT >> OBJ_INDEX_BITS;
 	pool->min_alloc_size = max(pool->min_alloc_size, ZS_MIN_ALLOC_SIZE);
 
 	pool->num_size_classes =
-- 
2.38.1.273.g43a17bfeac-goog





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux