All of lore.kernel.org
 help / color / mirror / Atom feed
* mm/page_alloc.c:984:9: warning: iteration 119304648 invokes undefined behavior
@ 2022-05-19 21:14 kernel test robot
  2022-05-19 21:28   ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2022-05-19 21:14 UTC (permalink / raw)
  To: Mel Gorman
  Cc: kbuild-all, linux-kernel, Andrew Morton, Linux Memory Management List

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b015dcd62b86d298829990f8261d5d154b8d7af5
commit: 44042b4498728f4376e84bae1ac8016d146d850b mm/page_alloc: allow high-order pages to be stored on the per-cpu lists
date:   11 months ago
config: powerpc-randconfig-r002-20220519 (https://download.01.org/0day-ci/archive/20220520/202205200521.65W2rpLt-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 11.3.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/torvalds/linux.git/commit/?id=44042b4498728f4376e84bae1ac8016d146d850b
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 44042b4498728f4376e84bae1ac8016d146d850b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   mm/page_alloc.c:3823:15: warning: no previous prototype for 'should_fail_alloc_page' [-Wmissing-prototypes]
    3823 | noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
         |               ^~~~~~~~~~~~~~~~~~~~~~
   {standard input}: Assembler messages:
   {standard input}:6471: Error: unrecognized opcode: `wrteei'
   {standard input}:6700: Error: unrecognized opcode: `wrtee'
   mm/page_alloc.c: In function 'rmqueue.isra':
>> mm/page_alloc.c:984:9: warning: iteration 119304648 invokes undefined behavior [-Waggressive-loop-optimizations]
     984 |         list_add(&page->lru, &area->free_list[migratetype]);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/page_alloc.c:2305:21: note: within this loop
    2305 |         while (high > low) {
         |                ~~~~~^~~~~
   {standard input}:9878: Error: unrecognized opcode: `wrteei'
   {standard input}:10902: Error: unrecognized opcode: `wrtee'
   {standard input}:11103: Error: unrecognized opcode: `wrteei'
   {standard input}:11321: Error: unrecognized opcode: `wrtee'
   {standard input}:12224: Error: unrecognized opcode: `wrteei'
   {standard input}:12816: Error: unrecognized opcode: `wrtee'
   {standard input}:12822: Error: unrecognized opcode: `wrteei'
   {standard input}:12831: Error: unrecognized opcode: `wrtee'
   {standard input}:14310: Error: unrecognized opcode: `wrteei'
   {standard input}:14402: Error: unrecognized opcode: `wrteei'
   {standard input}:14431: Error: unrecognized opcode: `wrteei'
   {standard input}:14476: Error: unrecognized opcode: `wrtee'
   {standard input}:14484: Error: unrecognized opcode: `wrtee'
   {standard input}:14503: Error: unrecognized opcode: `wrtee'
   {standard input}:17180: Error: unrecognized opcode: `wrteei'
   {standard input}:17816: Error: unrecognized opcode: `wrtee'
   {standard input}:17828: Error: unrecognized opcode: `wrtee'


vim +984 mm/page_alloc.c

5e1f0f098b4649 Mel Gorman      2019-03-05  977  
6ab0136310961e Alexander Duyck 2020-04-06  978  /* Used for pages not on another list */
6ab0136310961e Alexander Duyck 2020-04-06  979  static inline void add_to_free_list(struct page *page, struct zone *zone,
6ab0136310961e Alexander Duyck 2020-04-06  980  				    unsigned int order, int migratetype)
6ab0136310961e Alexander Duyck 2020-04-06  981  {
6ab0136310961e Alexander Duyck 2020-04-06  982  	struct free_area *area = &zone->free_area[order];
6ab0136310961e Alexander Duyck 2020-04-06  983  
6ab0136310961e Alexander Duyck 2020-04-06 @984  	list_add(&page->lru, &area->free_list[migratetype]);
6ab0136310961e Alexander Duyck 2020-04-06  985  	area->nr_free++;
6ab0136310961e Alexander Duyck 2020-04-06  986  }
6ab0136310961e Alexander Duyck 2020-04-06  987  

:::::: The code at line 984 was first introduced by commit
:::::: 6ab0136310961ebf4b5ecb565f0bf52c233dc093 mm: use zone and order instead of free area in free_list manipulators

:::::: TO: Alexander Duyck <alexander.h.duyck@linux.intel.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mm/page_alloc.c:984:9: warning: iteration 119304648 invokes undefined behavior
  2022-05-19 21:14 mm/page_alloc.c:984:9: warning: iteration 119304648 invokes undefined behavior kernel test robot
@ 2022-05-19 21:28   ` Matthew Wilcox
  0 siblings, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2022-05-19 21:28 UTC (permalink / raw)
  To: kernel test robot
  Cc: Mel Gorman, kbuild-all, linux-kernel, Andrew Morton,
	Linux Memory Management List

On Fri, May 20, 2022 at 05:14:52AM +0800, kernel test robot wrote:
> All warnings (new ones prefixed by >>):
> 
>    mm/page_alloc.c: In function 'rmqueue.isra':
> >> mm/page_alloc.c:984:9: warning: iteration 119304648 invokes undefined behavior [-Waggressive-loop-optimizations]
>      984 |         list_add(&page->lru, &area->free_list[migratetype]);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    mm/page_alloc.c:2305:21: note: within this loop
>     2305 |         while (high > low) {
>          |                ~~~~~^~~~~

That's OK.  'high' and 'low' are page orders.  They both lie in the
range [0,63], so this will not iterate 119304648 times (what a funny
number; I wonder why GCC chose it).

Can we make GCC happier by telling it that low and high are unsigned?
It should have figured out that 'high' is <= 63 already, as that's a
consequence of:

        unsigned long size = 1 << high;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mm/page_alloc.c:984:9: warning: iteration 119304648 invokes undefined behavior
@ 2022-05-19 21:28   ` Matthew Wilcox
  0 siblings, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2022-05-19 21:28 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 952 bytes --]

On Fri, May 20, 2022 at 05:14:52AM +0800, kernel test robot wrote:
> All warnings (new ones prefixed by >>):
> 
>    mm/page_alloc.c: In function 'rmqueue.isra':
> >> mm/page_alloc.c:984:9: warning: iteration 119304648 invokes undefined behavior [-Waggressive-loop-optimizations]
>      984 |         list_add(&page->lru, &area->free_list[migratetype]);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    mm/page_alloc.c:2305:21: note: within this loop
>     2305 |         while (high > low) {
>          |                ~~~~~^~~~~

That's OK.  'high' and 'low' are page orders.  They both lie in the
range [0,63], so this will not iterate 119304648 times (what a funny
number; I wonder why GCC chose it).

Can we make GCC happier by telling it that low and high are unsigned?
It should have figured out that 'high' is <= 63 already, as that's a
consequence of:

        unsigned long size = 1 << high;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-19 21:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 21:14 mm/page_alloc.c:984:9: warning: iteration 119304648 invokes undefined behavior kernel test robot
2022-05-19 21:28 ` Matthew Wilcox
2022-05-19 21:28   ` Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.