Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1224003iog; Tue, 14 Jun 2022 01:37:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uINTpKXaDZvArpQPWUt3KicUJbvvhQd1kVHVMLZchJt6R/yrfp8scgDbCYiL9qbJU2/KiP X-Received: by 2002:a17:903:2c2:b0:168:e323:d471 with SMTP id s2-20020a17090302c200b00168e323d471mr3252511plk.147.1655195829470; Tue, 14 Jun 2022 01:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655195829; cv=none; d=google.com; s=arc-20160816; b=BqHUL6cMBiAImZNmbJAEi9kZ8sm/ZWKldvJtCJKAZxHXe3q6sMRZ9ArUdMszh6hwKg 7EYKJJmImz7bAowAnU9ZxtzHwgtRxpQv43aWxtcI7b7wHWQuVOJJnTfDVbF8wYYZKJEH +MPIX4XaGEXiliHCA00MO3gGhmeh8oXQ6YgRk6DBVHFZcHJErx7KNuB3Wj/rO40sqILv RAwJdf+lkbGr5C+CyDqybVsoDu+hc+pZPDEHJ2YmDM0yP7klnxMTPV3xyQqLlsUJtemu UQQdQLuNzeQUUZi7o1ia2uD6K4TsBrQ28+Za91LlJKI8qjjZI7SRrp6PQ832Wf9Z7U6l zrFQ== 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; bh=UvrxaRhhhLleS2coheY6zUyurZeEXi35BZeBQqc0VWc=; b=K+fRtxtf1CXXIr4w4jVdxRHa3PalEIZ+BVF5lHHnLICzPEByUvNnB+diUDk1iareB/ xNSQomhZGJCfE4fjiJVzhxNHPw3R5WGSLaXqhboXkjNzW9Lj2lzwYtGVRK/9X2OOtRKz 51i44xr2T4v26js+pnRVB1BvSz89hgKXGIbHt5EDW+3yL+PCQecKufPZ05GOCddsZ6mS vLs9Bl7aClB7FL1qtkfivm3DZMJI5RscbbCpDoIbjWDzlmWTpq3JtKZXP3cMod5V4o4I 11Y/x921iiMxzM2YbgOroyKsC7LAnQJUqQWwkR5C4LSjV2lKYdGSWEmCpKzb5d/9IO7v fSbA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rj13-20020a17090b3e8d00b001e350ed011csi10369178pjb.175.2022.06.14.01.36.56; Tue, 14 Jun 2022 01:37:09 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355377AbiFNHyF (ORCPT + 99 others); Tue, 14 Jun 2022 03:54:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355884AbiFNHxl (ORCPT ); Tue, 14 Jun 2022 03:53:41 -0400 Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAF2641F9D for ; Tue, 14 Jun 2022 00:53:02 -0700 (PDT) Date: Tue, 14 Jun 2022 15:52:48 +0800 From: Yixun Lan To: tjytimi Cc: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] memblock: avoid some repeat when add new range Message-ID: References: <20220609024122.6679-1-tjytimi@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220609024122.6679-1-tjytimi@163.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,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 On 10:41 Thu 09 Jun , tjytimi wrote: > The worst case is that the new memory range overlaps all existing > regions,which need type->cnt + 1 free area of struct memblock_region. > So if type->cnt + 1 + type->cnt is less than type->max,we can insert > regions directly.And becase of merge operation in the end of function, > tpye->cnt increase slowly for many cases.So this patch can avoid > unnecessary repeat for many cases when add new memory range. > > Signed-off-by: tjytimi Can you fix the author/signed-off tag with your real legal name? https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v4.18#n460 > --- > mm/memblock.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/memblock.c b/mm/memblock.c > index e4f03a6e8..243cd7de5 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -602,6 +602,9 @@ static int __init_memblock memblock_add_range(struct memblock_type *type, > base = obase; > nr_new = 0; > > + if (type->cnt<<1 < type->max - 1) > + insert = true; > + > for_each_memblock_type(idx, type, rgn) { > phys_addr_t rbase = rgn->base; > phys_addr_t rend = rbase + rgn->size; > -- > 2.32.0 > -- Yixun Lan (dlan) Gentoo Linux Developer GPG Key ID AABEFD55