From patchwork Wed May 22 07:29:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13670517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEAC4C25B79 for ; Wed, 22 May 2024 07:31:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AEC36B0085; Wed, 22 May 2024 03:31:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 35D5D6B0088; Wed, 22 May 2024 03:31:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D64B6B0089; Wed, 22 May 2024 03:31:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 028636B0085 for ; Wed, 22 May 2024 03:31:17 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id ACACF1610A8 for ; Wed, 22 May 2024 07:31:17 +0000 (UTC) X-FDA: 82145210994.25.D3EA3B8 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by imf06.hostedemail.com (Postfix) with ESMTP id ED56E180014 for ; Wed, 22 May 2024 07:31:15 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=c56m8oN2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.51 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716363076; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=I9LNlp7Vr9e2XNcPJ8n7JHk//I1lYT3ZDoZEKcoYIV4=; b=DFv66oznHpzcEV9A3kXbZ5+QhsU5N013Ga45hWrL0gS0GPBJ3QINhwXQXqioGNjbml9ooI kinkBTtYtaOPdxuTDA9kVt9V4gKMODyLzHKBJgvbqscb+G2vxxDG6ISboRap198xmpf6EX 3E0+VPqZNsETaOvm561GYkby0tzFjp4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=c56m8oN2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.51 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716363076; a=rsa-sha256; cv=none; b=mHvzpiKnYxuaAvTLWW07+Pu/+0M30bdi00KylGY54M2AS4Godn4S+HY6kHEdjdW/ADqtPo nE5DLW4Xo8jmYNBHLPHCM+Q/AdQYoV24yDtXx6YInJxJ3A+ZoUTooqF6zhPZMhLQ5wrBTE BItaGRTUtptLKV1c+Q/xWssbVqbvNNU= Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5755fafa5a7so4876193a12.1 for ; Wed, 22 May 2024 00:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716363074; x=1716967874; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=I9LNlp7Vr9e2XNcPJ8n7JHk//I1lYT3ZDoZEKcoYIV4=; b=c56m8oN2cfx3xLDGA7UogQkh/P4C2cUlW/9Kn4IEvTBuhqSEiKg2pwH32Moy3oP4Ch N6V6UT4PALoAAvHJNp67/NdYnzEXNBrxcFvQ1TpiWQ04DbcgXQT50vQvzFI0rWz0MjDQ h7x0Y3c0hU0CB6vYoIJfg7LAn90jyFfM+QP85ZfrFCedQEO+B2dAsSJdM8vleBd4pB8E nQcxzCKZdRV+SQFTyhfGMw5y5P6k4OFInpko9dIGJj8dDERXGjQwgrSCO1Ban+4yJf2C laKk4Pa3WAdM6zCVfgQm2wnQ+lystQK83IIpgSxjoUfmxhBqTBryacvZg7BCEi51yZ+p 9HsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716363074; x=1716967874; h=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=I9LNlp7Vr9e2XNcPJ8n7JHk//I1lYT3ZDoZEKcoYIV4=; b=LEkmiXklRQ78LwO0+S9PA+i5jQugDo1n/BWRbxX9BvB/oLs4jKnqn3Y0PgHtA4uTxW ahGAAIcSH5KxaTMRzaF1mp6MxUb0WkrtbSkXWw28gpoL8LCLMOS/vadWB7ahA67prWe7 Ii71aa6IWSvyI25FXERGRHIxhauxuRPnFwYXINaMKmHa+gPejFfpY6BohIBzfvuUren6 hFMfLD9Z+nMLQjfosXfveZ80OkPVsW6/wwcD0xbGtvVrP1gh94TYyD4BW8V1VLtJyu0M G2dkaZhAuUdmU+MLXIqlZHZha8YJk/QW+LQGy16L/Tv6uLYVbxucKOlCFefexvmKj8XQ 7sEg== X-Gm-Message-State: AOJu0YwPBVbnUCisv0cV3TeHlteYNem+UPVqvM3xIaEpCiImK7lNSaXP YcCEFdY/xFRohYziOQS0ZIywUagP/qZ5Tly+CGDBb588mLsibDQL X-Google-Smtp-Source: AGHT+IH1mFLdjD7DWiwZUxeY3gF38EWviW3maXIl052pNZl+HIaqf73KzoCPPXwJ/XDvX5ce1KoIJA== X-Received: by 2002:a17:906:6bcb:b0:a61:9c28:f172 with SMTP id a640c23a62f3a-a6228198c0dmr65743766b.51.1716363074397; Wed, 22 May 2024 00:31:14 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a17b015ecsm1757119866b.177.2024.05.22.00.31.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 May 2024 00:31:13 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone Date: Wed, 22 May 2024 07:29:59 +0000 Message-Id: <20240522072959.23741-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240522072959.23741-1-richard.weiyang@gmail.com> References: <20240522072959.23741-1-richard.weiyang@gmail.com> X-Rspamd-Queue-Id: ED56E180014 X-Stat-Signature: poxjof1m9pni4apikhjxu3t35937nqxc X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1716363075-939241 X-HE-Meta: U2FsdGVkX1994gK+B8xS4bppt4H0ArL+t5tv0reX1a1FepD4W4sZpIuQPHwaxabUMjYbNMyt4WlcpZY53OWgwQIZMZQBpA7G7pfWU7V4TtjwmbGRTQIe9IkuTB1gdMA5+KRFs04uRgz1cBL1LhepATgHoK5QmLdJYg++67dWE19ev9IV8QkZCfFrXKc5h2yXG0dQSFJBYqlXr0USWDUvFIvhnkwvDsAwU+U2nKPioDWTdxqrn4AdADtwk+RB1o6PVXe4OIlcDQS/FBLMWwfKf0iX71VSBkUW153akgfFj1i+Pxfc48bnIwH9o6jEqvkVitv7wJEy1+c3YoYgfnxdcwaoySvsigjngKlFSx6QqCFf/mIXFAMcx/WlAvzd+YU5EYpUwQxluBXsLDslRlaI4n/On5T7uAjTQbzmupEkvjTUgxuLtaQJ30+rsZWpnI5NwsemFArrIu7RDJ2fTg37wBHPcy+J34+xuUwsFq3j7Rip3UGZp5tNX0Le7Aw5eBDYUGbpEGREAYDqm+cUR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Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since we always populate low zones, it is not necessary to count nr_initialised for them. Let's move the last zone check ahead to skip the nr_initialised reset. Assume low zones counts for 4G, this change may reduce 1M times comparison of prev_end_pfn and end_pfn. Signed-off-by: Wei Yang --- mm/mm_init.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 2dfb87841fdb..4cc627b4ebfe 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -676,6 +676,11 @@ defer_init(int nid, unsigned long pfn, unsigned long end_pfn) if (early_page_ext_enabled()) return false; + + /* Always populate low zones for address-constrained allocations */ + if (end_pfn < pgdat_end_pfn(NODE_DATA(nid))) + return false; + /* * prev_end_pfn static that contains the end of previous zone * No need to protect because called very early in boot before smp_init. @@ -685,10 +690,6 @@ defer_init(int nid, unsigned long pfn, unsigned long end_pfn) nr_initialised = 0; } - /* Always populate low zones for address-constrained allocations */ - if (end_pfn < pgdat_end_pfn(NODE_DATA(nid))) - return false; - if (NODE_DATA(nid)->first_deferred_pfn != ULONG_MAX) return true; /*