Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp232933rdb; Thu, 2 Nov 2023 01:56:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGy5r/aC9xw93IByChwmic/bxZy0Ju0WV3ZRZ5vFmzr6UgLVda8XZg0t7sBfkbt2bYLcAh3 X-Received: by 2002:a05:6a00:24d6:b0:68e:2478:d6c9 with SMTP id d22-20020a056a0024d600b0068e2478d6c9mr17444797pfv.2.1698915406748; Thu, 02 Nov 2023 01:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698915406; cv=none; d=google.com; s=arc-20160816; b=BsxHOwUPm83QAwRlHkt84eKYzgKUt6lVr+kJ4OBacmwh0p9lulIsThiWlEGId+oTIc FEhCUL4g5ta239DnkWcsMv0F214ERYWf4DgFXKAlHJIJMmvNRuvlzDF7np8tUjSKLnvU Dirx4qKDwrft4UgppoH4B+EIz6gL3sHWYiCvDqJWz/4JPyLRpP/xWOUSx43OeDmWdArW o96U167MP+K88cGcRVrswlPHnN+oBsMw7IctcikGWCqwztNB4ZFsq31Li5MyaUHwcGdE WqwD1sARlF8h2afgMd5c22XzNm6GwEz2ux00V8XM3yrOwtbH5QLAn3g/F0cDOVGe1Z6h p+Bg== 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:dkim-signature; bh=E71F4fGVkzPvvC7T0SvVgSk3UcNYR1KYBkhmBETecFk=; fh=TBVQzEWACmmnwOlK+JmOsHetFEC1OImkhiCEfOdvbHw=; b=J+M2lZgh46RtRKhMah0SFo+O5SMcZc2KZrerbrMhtv9C5lBZdrONjGiFHeyhgS8o9U TB//NRXzk7SDTVSQ4uJsns+/P9hLzl+FiQLpQjwkRBv1nhMrYbku/f9BqM96//q7qZ9Q JVY5aSNLakyx1py23iNyDf6tNkqmq+A/tNM+4cvr/42UsVGRor4URZ5wVKJpjd8JAmBq PLyHfvv5J8uyWGznh6m1DFibQk/zYSSkeEPPeB4L+32fVRLt5Ctd1K+d6fPc0zILsBDo rM6p1MvbwKk2jHxgTnAVPG9uX8k0EQ0V2OXKcxE8/QbJ02/otEFy+rAkJhJMGz0vmsrt E7pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=odffH414; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id a63-20020a636642000000b00578a7f5a0b1si1485061pgc.393.2023.11.02.01.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 01:56:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=odffH414; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6AB5C80873B3; Thu, 2 Nov 2023 01:56:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344561AbjKBIyh (ORCPT + 99 others); Thu, 2 Nov 2023 04:54:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234811AbjKBIyb (ORCPT ); Thu, 2 Nov 2023 04:54:31 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F0318B for ; Thu, 2 Nov 2023 01:54:28 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56789C433C8; Thu, 2 Nov 2023 08:54:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698915268; bh=A7FoYJUUU5fM6KDQZG7+WD2UG90QXjzmTG48GuucSeg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=odffH41401if0nynpcNzmku2bPes9u+NXTnn3/94mJEdsp9QMJqQPk9qH5NKaxWsn /lSKcAaj1SO+piCDEqR/x3kPUJxK3KtKZYEC+bLhliNZVI62+ztUkNvVn0oaqc8npe NXexRyK5JnpWtGKEeUTTLuFD0Ih9tcrdTqPQkEDzNTmoKIXtHxESH/x882yPlE4twJ 5WjXMPZEdoAhJdKOdrmTEcgJCM8qDsf0snG+AQK0vAd86swQdWsh6SIIK8ZJ+7x3dM 43qflqT2U0FzRfEnoujJm1q9wO6HOGspX1uhiSLe8X6COkqrWaSxMawbfxtOcQfBTd aUGcv/nwmWSyA== Date: Thu, 2 Nov 2023 10:54:18 +0200 From: Mike Rapoport To: huanglllzu@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, Liangliang Huang Subject: Re: [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability. Message-ID: <20231102085418.GM2824@kernel.org> References: <20231102023710.13023-1-huanglllzu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231102023710.13023-1-huanglllzu@gmail.com> X-Spam-Status: No, score=-1.6 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 02 Nov 2023 01:56:44 -0700 (PDT) Hi, > Subject: [PATCH] mm/memblock.c: using judgment statement can reduce loop and enhance readability. I disagree. On Thu, Nov 02, 2023 at 10:37:10AM +0800, huanglllzu@gmail.com wrote: > From: Liangliang Huang > > Signed-off-by: Liangliang Huang > --- > mm/memblock.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index 913b2520a9a0..e48dea7144bb 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -655,7 +655,11 @@ static int __init_memblock memblock_add_range(struct memblock_type *type, > } > } > /* area below @rend is dealt with, forget about it */ > - base = min(rend, end); > + if (end < rend) { > + base = end; > + break; > + } else > + base = rend; min() is perfectly clear and there no change in number of iterations of the loop. > } > > /* insert the remaining portion */ > -- > 2.25.1 > -- Sincerely yours, Mike.