Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp318850rwi; Mon, 31 Oct 2022 01:34:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4vXHSzbkXbaAWXO29H5Kc3bZLiK6reMDBU68eF9YQoTjSayOlFt24cFb5jLWrzNiJfklDm X-Received: by 2002:a50:ee0a:0:b0:463:4055:9db4 with SMTP id g10-20020a50ee0a000000b0046340559db4mr6308682eds.421.1667205251853; Mon, 31 Oct 2022 01:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667205251; cv=none; d=google.com; s=arc-20160816; b=RsGdK2jiIm+MhnBjXBsD+kMhTaDeG4VkC/8KFMynQDxgzkQGtcC/qiDhIeTFysSH/D GiBHKMBQImL3+JpjKn5pz0D03XiA6FEwt4Q9tKKICfy6+l2LTVQZ1fY4DFO8f5mZYhLm 2lOz0c6XY3zlHkJyEcxEbT3wEh5hVaVqIidCwPqaLyYB7cHqqjzXEZxe0r7uuH3yoqZI A8wwK94u9gz32N+80vNXg87155ETFbz9/MnUHzxzMj2+cP8oCoK4KZh5EXD8581N6g5S M0E2I8Qwlg4TFnUGR/5tHvVnlmXUi44JzWh/RFL+mySorqqcXlF6jyS5IARONNaTyj9I nefw== 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=UPxd9YIcwKoWFvFO3Ziiw65Cff8xvEY90OLdTe087Bs=; b=KdnpXjQ5T8UM+7jkUWe+T5BxnogM+i0RmSHWOjrZMwChi2W01YEW+dOBXEOd0LJ2qW ZiQsen1a1mU83fzdLqQkjV6hi1kMyKxEI+pWy8oFVQ6gu2YVeNqMrPBClcmgemroDl4p 8KRlhLKVrB/gbUyr5e5jj2l8O5Nr7bLGXmJkTklS7QM35S/LKfon2kewmT5WoHyp4b5P PCF+LZ3fMMkUaFpj+gRtigmQOjZa8Lg40nx69OaQ/tw9ZXuf9v6ueqB1QuD50+knYzT3 SxigLbffnXfK4LgHNcncRGGWVZkN0Ww8nhgP4ZPd8bIsTrYF/dGbbZp1JUtmFTPUIy0u I+Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gtizLyWT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id my15-20020a1709065a4f00b00781cde43588si5951834ejc.58.2022.10.31.01.33.44; Mon, 31 Oct 2022 01:34:11 -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=@kernel.org header.s=k20201202 header.b=gtizLyWT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbiJaIRH (ORCPT + 99 others); Mon, 31 Oct 2022 04:17:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbiJaIRF (ORCPT ); Mon, 31 Oct 2022 04:17:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FA7865FB for ; Mon, 31 Oct 2022 01:17:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CC27461031 for ; Mon, 31 Oct 2022 08:17:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66D6DC433B5; Mon, 31 Oct 2022 08:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667204224; bh=URxGX3rN0t4vDzNmnpRLGdtDfedX1xDpndmmWDxKjO8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gtizLyWTlicoIYLxEUip8appSngpFlGx70dK3zqlq3RovHYO7gKMpOQ4Mh5qXatxT LxEjp3/8Ndfqq6sCyMkIMc+2pk6Ds24u1eP0qb+/sHcWOTnq6kqFPeI1oUXN4ll+Fe vnMIUqPTjV6MzSAw5o0wMrNbEBEVPA0g+V2YbzqkF+KJa1AuOO8OPTt+Edd6K4Cgoo HB/ayGS9vDJnW5BIF9laUa8v6ZlPvSSO2hdCg6Cfk8VR89TPEfvu+bSwcEbIRbTWsd CokEf+FfcdErmqBzG3zdHwUSdBEnxzh1yY7nze9g4gzDI13JP4WdXp1D6MUCtakIEF Ex6+5XlAdWysQ== Date: Mon, 31 Oct 2022 10:16:51 +0200 From: Mike Rapoport To: Yajun Deng Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] memblock: don't run loop in memblock_add_range() twice Message-ID: References: <20221025070943.363578-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221025070943.363578-1-yajun.deng@linux.dev> X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Tue, Oct 25, 2022 at 03:09:43PM +0800, Yajun Deng wrote: > There is no need round twice in memblock_add_range(). > > We can call memblock_double_array() to extend the size if type->cnt > greater or equal to type->max before memblock_insert_region(); otherwise, > we can insert the new region directly. > > v2: > - Add a comment when the allocation is required. > > Signed-off-by: Yajun Deng > --- > mm/memblock.c | 69 ++++++++++++++++++--------------------------------- > 1 file changed, 24 insertions(+), 45 deletions(-) Applied, thanks!