Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1665639rwl; Wed, 5 Apr 2023 22:23:52 -0700 (PDT) X-Google-Smtp-Source: AKy350ZHi/rD5VBSSVQQqH13k07zLA+4F+Ig0Cb/iCPO7qAzrcywpq7mr2OTYTil8whbnU5tknS2 X-Received: by 2002:a62:6203:0:b0:62a:9d6f:98dc with SMTP id w3-20020a626203000000b0062a9d6f98dcmr7826118pfb.11.1680758632625; Wed, 05 Apr 2023 22:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680758632; cv=none; d=google.com; s=arc-20160816; b=lSwvW70oyY6+3djeg8ttiJ2xLhJCZKSn3yq1+uHkLMENX6UvB/x0PHGWwQX9F+1hgq qhYS/fB3+yqcjcMYLH6TcTOZ3mSPAiCYH/SAOWIhA8h3J6Ii1UE3J396Q9T9AKc1z293 xvLrpb34b/rnq2jLIDr31fsg27HDKVy/bm8exYJfaC7h4RAyv42BGY2tdpR52LaOZ1sP sDpiW1AX/Fbk7Ozdjx3d9fpGOO8q/EwkNeVW2d3/+ttvrygCd1hES9C2OHk8mxY+b34l M9QRqivOLOmfHmWdb7vsVIOAGLrxmx2Ih2Di0q9DwYqIYT7iYKuKbQopu7mih2oH4CUx xk0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:sender:dkim-signature; bh=lTQen24Ps++j6vXq82pkSJOfvZNDwo+mL4QS7eMljms=; b=ur1XIdwpe5+gWoL61pXNiqXfbYQ6FWogyrrlxSG08ZZDdMqE9yBnLpSmALGTaU3lRD loZ1rFzradZx9dQ/Pj1pSP3kv9yrku9CZrEdDrefx22WtT6xberQWJTo+wLPAOv0cNLJ peOT/qAfXTtB2+joDwikMw3u3BFyltpx6EcwvoYtASjqIcwCiMcycmlqqq7TEUFczO1k PDhpymuIAGZdXxwPZ055jeo3JKKMyS+fs6eSaKJE9cS2EW3FegGo0OLAIMBOSeGlLWm2 CE/YaR7UjyCZCRIHsq2t9LPRRNA0/WoGwHxCEH3IYIN0SrFKRkot5rvqDSmATUcjFWu5 uy9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HzBo9Bui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i190-20020a6387c7000000b0050fa32db191si476364pge.40.2023.04.05.22.23.40; Wed, 05 Apr 2023 22:23:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HzBo9Bui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234793AbjDFFUf (ORCPT + 99 others); Thu, 6 Apr 2023 01:20:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234076AbjDFFUe (ORCPT ); Thu, 6 Apr 2023 01:20:34 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2011B5 for ; Wed, 5 Apr 2023 22:20:29 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-17e140619fdso41110696fac.11 for ; Wed, 05 Apr 2023 22:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680758429; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=lTQen24Ps++j6vXq82pkSJOfvZNDwo+mL4QS7eMljms=; b=HzBo9BuiVK+ieq4hAereyA6CLygTsynpDqwzI7aS46PfM0znN+VFQbdkLMhaGOapi7 V9Ix9g9UKKzS0+eJnQc2MWb55fRRuN9AjB/rWvza20Xpwq+y924YbjvIGx6QzG5uGiEW JMZXwW0EZVSdlN1170YYJmB3OD7jnSnmA8F8avP8eaB7GI6Eh/L3Xh4ySzrOA18zt6Uj fElxFu4eEghxFn2lSbpgjMy1KXuEgdPQ17HmJkiKqGeOhJrTfYT+Gf/wjvkygerHH5Iy TUBvxPDx4RG7B8ApWr/Mbo5nDa9jUopcXIY4ffiChfJgYHBWgVh8MM+ofRE2T6QV//dN mEBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680758429; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lTQen24Ps++j6vXq82pkSJOfvZNDwo+mL4QS7eMljms=; b=L1FU493DnukKFaDxztPnIViS9nalWV11DFOOxVDkk+B/Sncf/lba7BkmArJNU51eJp b94FRs8VafWJm/kSd6AudvInnS/NOwsD4Tr97VrfMjfXahmo68jZmZXa7hX8EVEkJtFL xnFsrBJlM2c7EnEqS6gLmJrgpDsC4sgRSN+I9A39v6bRt4pmZf0ck50r290KaolD9l97 WkHvK/qGNXlI1eRvQKcaad2CurZYYXzbBrHtCyaxYOWLoEhrc/+mMjKwdZxTmMduJDp4 psIjBBe0ujugFqpXRGJbkF+X/IGPjFa+xhCLStDgomiQeosJAydIoR4Z1UCPsCLk4K2s RnUw== X-Gm-Message-State: AAQBX9eXXXAO6RWLQMzJlwEDLBmNRbaPOt1kMUSdwvOSJMVswVnKI+bX JkYOxOZNpm4+Cu8CbblWGAEaVPTI4Yg= X-Received: by 2002:a05:6870:d356:b0:177:a92e:ee6 with SMTP id h22-20020a056870d35600b00177a92e0ee6mr4525131oag.54.1680758429001; Wed, 05 Apr 2023 22:20:29 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id y1-20020a056870458100b001777244e3f9sm341041oao.8.2023.04.05.22.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 22:20:28 -0700 (PDT) Sender: Guenter Roeck Date: Wed, 5 Apr 2023 22:20:26 -0700 From: Guenter Roeck To: "Kirill A. Shutemov" Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm-treewide-redefine-max_order-sanely-fix.txt Message-ID: <9460377a-38aa-4f39-ad57-fb73725f92db@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Mar 15, 2023 at 06:38:00PM +0300, Kirill A. Shutemov wrote: > fix min() warning > > Link: https://lkml.kernel.org/r/20230315153800.32wib3n5rickolvh@box > Reported-by: kernel test robot > Link: https://lore.kernel.org/oe-kbuild-all/202303152343.D93IbJmn-lkp@intel.com/ > Signed-off-by: "Kirill A. Shutemov" > Cc: "Kirill A. Shutemov" > Cc: Zi Yan > Signed-off-by: Andrew Morton This patch results in various boot failures (hang) on arm targets in linux-next. Debug messages reveal the reason. ########### MAX_ORDER=10 start=0 __ffs(start)=-1 min()=10 min_t=-1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If start==0, __ffs(start) returns 0xfffffff or (as int) -1, which min_t() interprets as such, while min() apparently uses the returned unsigned long value. Obviously a negative order isn't received well by the rest of the code. Guenter > --- > mm/memblock.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index 338b8cb0793e..7911224b1ed3 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2043,7 +2043,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end) > int order; > > while (start < end) { > - order = min(MAX_ORDER, __ffs(start)); > + order = min_t(int, MAX_ORDER, __ffs(start)); > > while (start + (1UL << order) > end) > order--; > -- > 2.39.2