From patchwork Fri Jan 13 08:26:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 43072 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp152487wrt; Fri, 13 Jan 2023 00:32:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXtY6ed55dV57G/LVes4kl/nVCoip6/fv3XRkbE0OhCwv1IrZEXyQliXhZKeqjDh3zvO+Hd0 X-Received: by 2002:a17:903:32d1:b0:191:3b7b:3c2c with SMTP id i17-20020a17090332d100b001913b7b3c2cmr13363422plr.22.1673598724607; Fri, 13 Jan 2023 00:32:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673598724; cv=none; d=google.com; s=arc-20160816; b=leBXI/rzXq8d6iCdPoJVcrNATDXNFSrlowAM6n5jCuw7SqIKZvjjs2vJt1TCYgMwjy hJddcw/pIuuei+hIMildCqZWbk8IzWf7T1ulyUgp/mcUS7HsBy64HL4aDtzdsbxnTqM6 FqXKkpGC/hgE0hrztq/tYLAaNygsUH+WQ6hBpI0rYPRC3GF1sZXq0SEyGO4o/9ngHGkV QNOEh1kmSOvAPSt9KW7oQ1iMw5+307gHqwzdQ602qvOiNK8Y/Vq+C3lyIdAzF9BUoSar vrZ9RL1TJbw7AKsM+hb3Iofz1YsRBsHgq8A7JHZkDuqTg8RkeWpcihHwV94YJSEgk2Qh EO8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1iTd5byfBOgh9LVNuYuoOV6hXCYzXq9gAf1csxesg8Y=; b=WCrDAsUjI5GBIWToUxc5J1HfSkgtPjghioI63i1vWh9by+Tyy8XvRNWENiHXQAsWkb /xXchQJig9KepkP4iO8dKtN/EidSYpOo2kJEW0ZJ4ZYT7zdJThxd/hCOlNkvyYxsBlTK Nh4lAJFAo1U0itL6vkQMXyx5ha6VNAaQemqK9mp9jcolo6clES8wv8KSzPJ+1WiHcOCs 7n/pnDmGA6cIHciL860O6WamBnqh1UfisigZh+uRmNGRLJ53ziAILh1hObGAwqhAgLV/ hudk5AAMucbmtr9W+pKG3fHiwiZVyNvT4lw5DNspVxi6+zDoQk3X0vGGCZZZBR6vNZOK vbzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=f4WyK3Xl; 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=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x14-20020a170902ec8e00b001925dbac333si9581278plg.312.2023.01.13.00.31.51; Fri, 13 Jan 2023 00:32:04 -0800 (PST) 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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=f4WyK3Xl; 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=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240835AbjAMI15 (ORCPT + 99 others); Fri, 13 Jan 2023 03:27:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240676AbjAMI1f (ORCPT ); Fri, 13 Jan 2023 03:27:35 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE32A55652 for ; Fri, 13 Jan 2023 00:27:10 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id 7so14515584pga.1 for ; Fri, 13 Jan 2023 00:27:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1iTd5byfBOgh9LVNuYuoOV6hXCYzXq9gAf1csxesg8Y=; b=f4WyK3XlBgkV1829d+TSRcqYiXtgsgVc0lzyFga2JdKfICjv+2pvnWx/fysrvWeeqp 4g4zEITqfzVovBMOaYMAZfTvSO8H0c30bfGjbfVneHfX96pffYg/4NNwdDubQkeAXGF+ NXmTN8SrCcmw3gbQvFXSjxxTysiPyVQmreTuYBlhfVs9xmkwxs4MkOfz4DJBkJC0m96G 9NAYz8PdGTXGdRsRIKvcQmaKr69fppmU74LXLcB/u1qvpzBHYeMFSGM7lViEsSM8g4UK Z+Km4VvT4nxgGfATWUcbqR40opiVVYy4VerfXH1aB0dTKhgNsB/JAyzzeVrL9rENC0lA U9eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1iTd5byfBOgh9LVNuYuoOV6hXCYzXq9gAf1csxesg8Y=; b=qwAAW5MOdg+KA3x4fS/11OJdgn/GhJlB9f9Ut25ZcpXbPUcrsQc3kIl5WvJlYJvoSF cvzghw9vIJOtqoj7Q9ht3NfhCZBSGB8B/MWtVNSRteOS+AO4unlufBNbU50FsKq3xS27 vuvfiAyucAlDX2N/TrmyTTCfuVoC75ZS+VBPanjNO1xY/HhhjT8qypkF1ZjTqh1JReeq 852EPBXkgCUg2LoXFEqo3VYATs347qPudwhauQe5dkp0m92MUhjFY4FLqh4ZemjCrrxb f8vnQGQjY6YHW1gjjiOFTsexLHBRQcpIC9SA+gzpDtaAMZDZbqzvezMrXQt/6HCaALf6 HTmg== X-Gm-Message-State: AFqh2krThuUM2lP3d3sJ9zU1aDjFhsLNcg+EtLs0GXCD0OyV+9OISkel 7cCQvufD3WxlBeceE1AL2AgOIw== X-Received: by 2002:a62:e703:0:b0:577:7cfb:a896 with SMTP id s3-20020a62e703000000b005777cfba896mr9537441pfh.31.1673598430465; Fri, 13 Jan 2023 00:27:10 -0800 (PST) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.251]) by smtp.gmail.com with ESMTPSA id l123-20020a622581000000b005818d429d98sm13092738pfl.136.2023.01.13.00.27.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Jan 2023 00:27:10 -0800 (PST) From: Peng Zhang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Peng Zhang Subject: [PATCH 1/3] memblock: Make a boundary tighter in memblock_add_range(). Date: Fri, 13 Jan 2023 16:26:57 +0800 Message-Id: <20230113082659.65276-2-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230113082659.65276-1-zhangpeng.00@bytedance.com> References: <20230113082659.65276-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754895456041413743?= X-GMAIL-MSGID: =?utf-8?q?1754895456041413743?= When type->cnt * 2 + 1 is less than or equal to type->max, there is enough empty regions to insert. Signed-off-by: Peng Zhang --- mm/memblock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index 511d4783dcf1..6eedcfc5dcc1 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -601,11 +601,11 @@ static int __init_memblock memblock_add_range(struct memblock_type *type, /* * The worst case is when new range overlaps all existing regions, * then we'll need type->cnt + 1 empty regions in @type. So if - * type->cnt * 2 + 1 is less than type->max, we know + * type->cnt * 2 + 1 is less than or equal to type->max, we know * that there is enough empty regions in @type, and we can insert * regions directly. */ - if (type->cnt * 2 + 1 < type->max) + if (type->cnt * 2 + 1 <= type->max) insert = true; repeat: