From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 307A0C433EF for ; Thu, 19 May 2022 21:28:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66FDA6B0071; Thu, 19 May 2022 17:28:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61F5C6B0072; Thu, 19 May 2022 17:28:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E8456B0073; Thu, 19 May 2022 17:28:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3BBC06B0071 for ; Thu, 19 May 2022 17:28:35 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 083CA80FB6 for ; Thu, 19 May 2022 21:28:35 +0000 (UTC) X-FDA: 79483781790.20.97DF9C7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 4ED5E180016 for ; Thu, 19 May 2022 21:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=iLKJL80pdLJpGRira2nJXXVQ3PoLCXZN+D6vBVWk5N8=; b=c87/WFkxD9GWe5V++LDIilAbI9 cbY0e1u8kgx9DA3mhAoDq6Agf3TdgrgE2ccS5388wym+BPGFJbuDzxWxZ83c05MWDEfKy/G1BnQVI PEkHuc8Eq0wg+GlZ1qWPPrTFoioo2WGmpN2WpWTLHGQnxeXDR/s8Wdhj7+CV36eormFEMuo6Zljk9 aMDwuZFYOkhVIyO8QqvV3flL1cQr8fZ7zPrqdJ2HtaaCrTTh1f/RJ0s6nkaE90BuFEfDdlwMiizhE CC7i0buKxIr+W6WFXQJngakRL9vWW9QbvCe9N/KSyoHHc4lOPSAm3J0suZTtO2eTcqce8gitFEEvQ Rkkl5IFQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrnh2-00D71X-6i; Thu, 19 May 2022 21:28:24 +0000 Date: Thu, 19 May 2022 22:28:24 +0100 From: Matthew Wilcox To: kernel test robot Cc: Mel Gorman , kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, Andrew Morton , Linux Memory Management List Subject: Re: mm/page_alloc.c:984:9: warning: iteration 119304648 invokes undefined behavior Message-ID: References: <202205200521.65W2rpLt-lkp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202205200521.65W2rpLt-lkp@intel.com> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 4ED5E180016 X-Stat-Signature: gtctwxgc5j7f99dz31jacaaqdkiixd8j X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="c87/WFkx"; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1652995711-547250 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;