Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp303477rdf; Fri, 3 Nov 2023 00:36:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFHXzk9BFHSRjsR2PJkxm81r6Ubp226A0IDmTnMYZchjGHViDn/3bBx30USjpKLttLeU7+i X-Received: by 2002:a05:6808:7c8:b0:3b2:ef9e:45af with SMTP id f8-20020a05680807c800b003b2ef9e45afmr22176458oij.13.1698996999892; Fri, 03 Nov 2023 00:36:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698996999; cv=none; d=google.com; s=arc-20160816; b=k/rfykO9xHr05jcSBgezjS5FK0OzMMKfBPyHCekjnaYH/5bHPC7YdiS4kSvivCtGmC VV0TWHGRM+0BgzH7Rj7iOuO0Vn63NXi90oITrikJthCuMyiwupOIc+rmBGb1m8XWfAUt X2BUm5hk/FdK4aQvs+s6YQatMBtKjfNisGzYl7FHlJ4fnPZhxVPPuev3x+WvhG9Lymp/ 5iKZY2mDCYWBkXHyNxZupnW5KyASJuE/y2PWHkCfhP3ZDO3F0K4b9kh0xvMpU8JObybv cCWLHp4T5oOJy+I+SjBqeAGw9/yXWxQNvq7iRp1uXbuyfmIfKjDzCCmXjqrSPQPk6x5R nkVQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=c+HlHAujwXryt3cM+WgmhddL2hT01A0F+Sb2FRDQ5TQ=; fh=eDdWd0WSiogwuznaGRbwfhSfGzVaimWl3yQxHFwVDto=; b=KMfzZ4spAMsJ66hDsAumeo1m2tRCTtjL4VyuCtRhwSdRmBbmCebw19yrE6A56hqLcV JXJDioE1xwobldAO+o5Ww2x2BwETva4q3bAbNJtfGacnxsNIx0fzQipp3KKwqAhfRa36 ZJT76UBKM6Dzow9lKxQGWAEtoo6yuni5rPUB26p5m6js9PhZ9OXbszim31cYHyQqdkNu x87RqpyiY45m0oeq+SDALoQ8PfNjQNnSF1N4ppNS2t/LNElrDetOz5Rsq06SFqsJbWqz yWRGcvYMyImmpdwWbb5faKfwdNdIOpIvffOZzunu1s2zxloikStbrtJs1WzLhl888uzj ejBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MpQvfuD6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bh14-20020a056a02020e00b00578ae22988csi1160555pgb.327.2023.11.03.00.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 00:36:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MpQvfuD6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 8ADC780699E6; Fri, 3 Nov 2023 00:35:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233470AbjKCHfQ (ORCPT + 99 others); Fri, 3 Nov 2023 03:35:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233216AbjKCHfP (ORCPT ); Fri, 3 Nov 2023 03:35:15 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36413CE for ; Fri, 3 Nov 2023 00:35:12 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0629CC433C8; Fri, 3 Nov 2023 07:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698996911; bh=OwYraiWkRGh713mFuBYUkMG66+APMALaM2UA9/OPM4Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MpQvfuD64rLyAZYkNj6bZGqNDUHXaBufxMYO7HTTllrrdXkiY5fSmEKrzDlJtpMJ+ TG1it3u/4YTXqyVqHba3o/03rXvIiokvctVSUrIGRSf96MBWBvF+msAvFoznrhdkGF E4mIRx3hAru3EaujSHaWm+Fk3A+OuzouKtd3TBn2vKqQ/9h0fZlBrYPNA4Kj97kpyT 0tLQlqje7tlZCTHJPaGtgN4CC0KJo6W8FncdU0Hwea2w1zGXrZdMOgpmx75YvKeUDD +EF+jkYlw+t0BI+zLRgcsjk+O3CmBcbwkWnShoG108n0UQ8VY+bgX71sYj61uTS737 lh1CSEprMLS2A== Date: Fri, 3 Nov 2023 09:34:59 +0200 From: Mike Rapoport To: =?utf-8?B?6buE5Lqu5Lqu?= 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: <20231103073459.GN2824@kernel.org> References: <20231102023710.13023-1-huanglllzu@gmail.com> <20231102085418.GM2824@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 00:35:29 -0700 (PDT) On Fri, Nov 03, 2023 at 01:30:21PM +0800, 黄亮亮 wrote: > Hi,this patch can less loop once in this situation: > base more than rbase and end less than rend. >                 base           end >     rbase-----|--------------|-------rend >       |            |                 |           | > --------------------------------------------------------> The loop won't be executed anyway because there's similar condition in the beginning of the loop. Next time when you reply to the kernel mailing lists, please don't top post and make sure your reply is text-only. And there is no need to send 4 badly formatted replies. > Mike Rapoport 于2023年11月2日周四 16:54写道: > > 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. > -- Sincerely yours, Mike.