Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2297998rwl; Thu, 6 Apr 2023 08:20:49 -0700 (PDT) X-Google-Smtp-Source: AKy350aIBc43vpybSK4vAzbUSvfQ+kgWLKERSp3PUSThVCG2ciNlohPNLvzP1mbutC3NbjNNqE40 X-Received: by 2002:a17:90b:1807:b0:23d:e0c1:8b8e with SMTP id lw7-20020a17090b180700b0023de0c18b8emr11391677pjb.17.1680794449365; Thu, 06 Apr 2023 08:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680794449; cv=none; d=google.com; s=arc-20160816; b=Eb/muiQghFAipOs0+WlJoGciem4pp++uQgh8kqA8ruXQTSPmGVS6kZx/rNtzWoG985 b6N21zrKe6yGfmdEAv4h1lrEtX17e1Wr7tq8JDERvH5f3iEfydcSVPtzwW+JDpHPve7m qoqXUZha4nSx8UJ9nxqqsgEeSkUCkHiPd3E20TcDOADLPanazeZD1mReKFvgO5L9jMN7 EbEV1w0ahMQP6+HON3wanT4n81AwqRhqz+NtQDofWiXAx3qPBDCP8IKG6ixaJMk0+vZC FwrP3DlwsbU/GH6LUbF+wA06pKNL0dTlOfPKDvlKJ3doIPsh43FREqDGNCWJOQW8yn9m DzqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=kle+3MjwA/FACHeFyfz4d/CYe30DnTpHJq8Ft3L5awo=; b=npa8XSo9glBL99GF3iapiyW62iKuKssRUWnGghzGbVniF3ODVMt2ScZPaz7+MdTb4O waKhwI9gCX1XbUH+hQcREmnKVtCGa3lJiS29lnfAUaFpvvWn2rImbgLGi9+uBRdeTp/o n1/moHSfdcDpW2Yv85bSaF9ryBBdEkMhng15aHvu1PkSpQPD03MejuWFLEz66P2Ue18l oJ9ApkN6Ixaz5jru64rViQLcESctwZz2RRWbUeXsVONKY6SRNmFW71UnTxlV5EhYSo/1 KZWoPfzIqnJMlx7f2WEqfmHyoeFKfpMiaZXK/eFCEgeE5O+sNq4iqxsxCjHEkCCHODXb 5qtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm1 header.b=qqFxeVR8; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Vwa+ngHm; 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 x22-20020a17090a0bd600b0023d3f169c1csi4094134pjd.2.2023.04.06.08.20.36; Thu, 06 Apr 2023 08:20:49 -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=@shutemov.name header.s=fm1 header.b=qqFxeVR8; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Vwa+ngHm; 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 S239590AbjDFPKg (ORCPT + 99 others); Thu, 6 Apr 2023 11:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbjDFPKe (ORCPT ); Thu, 6 Apr 2023 11:10:34 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E0EF619F for ; Thu, 6 Apr 2023 08:10:21 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id E59215C0074; Thu, 6 Apr 2023 11:10:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 06 Apr 2023 11:10:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1680793818; x= 1680880218; bh=kle+3MjwA/FACHeFyfz4d/CYe30DnTpHJq8Ft3L5awo=; b=q qFxeVR8kQzRjSzroq+RMsVS1LiHsTBJBncFK3aBNqfVe7wnvkWragFvgfXxbgpZ7 s2gG7CBKUs6z+2BrXqaOEpOFtZZ7WpbgV9+277RH1K448dAnhsipYaoO6C9mz9aL 09QRzAZ5cOdle1Cy3QCUgSyGKt6H6KYc1myTtXIvgUyWGy+WwPr5pmMnPxHHhVrW sCKemEfPzMkeARhvLBopCe4OL5xVJVJD/cfrPqdrYSl2gT31qksMRc8QVwx4dy1m UJDjhhhxta+LtMjPr5k4xVTuhP2V/dUFKo9UT6c7wZFUwlZ7+1YLVuNds9Z/ZEre wInek6feFMwmcelwTgwow== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1680793818; x=1680880218; bh=kle+3MjwA/FAC HeFyfz4d/CYe30DnTpHJq8Ft3L5awo=; b=Vwa+ngHmVkHe7IrHgxRyO/cCv779M PYkVagl7CbDgF+i63Y5nCTWEd9719OPRVhrO2RifY6e2seMjompaMQxkasbGF7SZ gPxSWYRj2KeE/ojuthkmSOJXtaCPmXqisx5HvxXzGiLRThmjWK1UXFOdjRcmzgdJ vaobDDkKH7ob1XYwr3EgJuDlGWeFlLOCqVRpTFutyDP4+ojk2869zxX5n7mVV6qs WLI/QXuEDPc9sfhegs33zrIyfYI0GDzEoCAV+VDx97csE6OeZgiqJS8J/yTbaA5X rRCJIoCLOsj/HQryW2JtxNQsxE+dC7ggJQXwg/D7RQXDAM7e9M/bFPiqg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdejfedgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehttd dttddttddvnecuhfhrohhmpedfmfhirhhilhhlucetrdcuufhhuhhtvghmohhvfdcuoehk ihhrihhllhesshhhuhhtvghmohhvrdhnrghmvgeqnecuggftrfgrthhtvghrnheplefghf efteelhfevffelveffgfetffefleefudduhfejudetgefgieehfeetheejnecuffhomhgr ihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 6 Apr 2023 11:10:18 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 13781109B00; Thu, 6 Apr 2023 18:10:15 +0300 (+03) Date: Thu, 6 Apr 2023 18:10:15 +0300 From: "Kirill A. Shutemov" To: Guenter Roeck , Mike Rapoport 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: <20230406151015.yndcm24fyxitvqyc@box.shutemov.name> References: <9460377a-38aa-4f39-ad57-fb73725f92db@roeck-us.net> <20230406072529.vupqyrzqnhyozeyh@box.shutemov.name> <83e6bc46-dfc0-0e95-e69c-5b996af1e50b@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <83e6bc46-dfc0-0e95-e69c-5b996af1e50b@roeck-us.net> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 On Thu, Apr 06, 2023 at 06:57:41AM -0700, Guenter Roeck wrote: > On 4/6/23 00:25, Kirill A. Shutemov wrote: > > On Wed, Apr 05, 2023 at 10:20:26PM -0700, Guenter Roeck wrote: > > > 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. > > > > Actually, __ffs() is not defined for 0. > > > > Maybe something like this? > > > > diff --git a/mm/memblock.c b/mm/memblock.c > > index 7911224b1ed3..63603b943bd0 100644 > > --- a/mm/memblock.c > > +++ b/mm/memblock.c > > @@ -2043,7 +2043,11 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end) > > int order; > > while (start < end) { > > - order = min_t(int, MAX_ORDER, __ffs(start)); > > + /* __ffs() behaviour is undefined for 0 */ > > + if (start) > > + order = min_t(int, MAX_ORDER, __ffs(start)); > > + else > > + order = MAX_ORDER; > > Shouldn't that be > else > order = 0; > ? +Mike. No. start == 0 is MAX_ORDER-aligned. We want to free the pages in the largest chunks alignment allows. -- Kiryl Shutsemau / Kirill A. Shutemov