linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: kernel test robot <lkp@intel.com>
Cc: Mel Gorman <mgorman@suse.de>,
	kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: mm/page_alloc.c:984:9: warning: iteration 119304648 invokes undefined behavior
Date: Thu, 19 May 2022 22:28:24 +0100	[thread overview]
Message-ID: <Yoa2eJ6+nyvK1EL+@casper.infradead.org> (raw)
In-Reply-To: <202205200521.65W2rpLt-lkp@intel.com>

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;



      reply	other threads:[~2022-05-19 21:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yoa2eJ6+nyvK1EL+@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=mgorman@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).