From patchwork Sat May 25 02:30:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13673886 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 8BE62C25B74 for ; Sat, 25 May 2024 02:31:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AD046B008C; Fri, 24 May 2024 22:31:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05D166B0092; Fri, 24 May 2024 22:31:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3F5D6B0093; Fri, 24 May 2024 22:31:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C13326B008C for ; Fri, 24 May 2024 22:31:04 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4D1F61C1891 for ; Sat, 25 May 2024 02:31:04 +0000 (UTC) X-FDA: 82155340848.15.60523FE Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by imf05.hostedemail.com (Postfix) with ESMTP id 6CC4B100006 for ; Sat, 25 May 2024 02:31:02 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SvIKzWNK; spf=pass (imf05.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716604262; 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=FiBCELuE62C2faXPcJ+beB9jxHLe1JTI96VohTYJ0eA=; b=I9FbbZ1FU64dABrx+0L/mSDiylUIwy5PbZeu+KGQjYTuDSCKUXES8LMd7on4ZU0d42YqvL jUkZA8r3K3bIewBSz2wEno/PiSPFAHgRoryZWgwqzDUn75JnEHqkVOcxCqLJ0vbgyT6v0q Wf178V0QrTvpbMIcRUjiFENsx4/IYNA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716604262; a=rsa-sha256; cv=none; b=lEidH4YdpYZMiPoYzah0ZVGaDHMfYJ6HJnzL7Je6Pkj9dZi3r0ZxjyFmYtCtlWSUbsbejB ct/vvPYo9KtfPwxY0UwT5MEAAbGjD3djy0zQvpllIr9jxKvlNEUkDNknJYKAJs7oX6g++h WwBRSedI8trttOyKvtNHIqbLekSZbHc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SvIKzWNK; spf=pass (imf05.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a5dcb5a0db4so881730666b.2 for ; Fri, 24 May 2024 19:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716604261; x=1717209061; 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=FiBCELuE62C2faXPcJ+beB9jxHLe1JTI96VohTYJ0eA=; b=SvIKzWNKyDAbVHawAPPhsjcbxPCkzfGzgIq+ARQ1AYF0NOCLK2ALVDP57EBh3seJbt 4VCtsJwmYaRBABOesl8BJYEgTn/raHhOkYdCJ3ub4x0JXhhbKD5n5zTDfXzF/QaoRJ/+ 0IjtQ5jQH8zQRiLiZokC6nz4DYFGnBnxgTohzOOiCE+tgnrUblqNtwXE4yt3SeyaME85 Cz+ahfuYHe56O9Dc750tOlOh4J5DfZEjWjujtEyMbWqQBKQ49oZ+BI6Ns8eeaCag9/XU BRjY2GCPjKiG0ExQG58T9dGL+ieXAkEZJpppO9ISHQ6YiS60zaUPD2HReDkWpcYqReJO kIKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716604261; x=1717209061; 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=FiBCELuE62C2faXPcJ+beB9jxHLe1JTI96VohTYJ0eA=; b=QA8LlOmJwax/kUj1ogX762X6/ZbUBhCrZ8bfnVGvcVztulceT9tKZSDjQbzs634RNv 9ffXBUl2AMA9nsXFfmIZXCk0lX/Rl0QIHg+92wb1wn3DIRf8tjDlwsMMiilHqA6Gx7JT vjwNM2l8zqMRGsnPsz2NGqjG4Dc/e7Mqbgo9NkUiKofNYViT/5y81LSaFX+NWSi+AE5+ h7a7MGrEkAWAxy2swxOFzNZ4IZ5ZxBbqGtLYid4JS+NDvxPuzqU6VT9KGsgRVItS2oT9 VktvoGAt2G+mlmYgNkIU1vb8HvzcxCoXF2BkztGjXq1ji7nbgLCNgEVLOfmVgYbLE1wC DjxA== X-Gm-Message-State: AOJu0YzLiYxXC/umNKJwbE+nZrsUryX5tObhmOaE6zJpzb1iD1olhssf EbFNMi+GB1mj9wVP3QsWllwp1T0eBMx4atX/iLnpsrTGcsUbxRLssjlIrw== X-Google-Smtp-Source: AGHT+IH/CzPBWmgzhHi/RKf2klij+na6TNhXVsLZT/2bL4q5IUEkph/I9m1D7HtgD6csXjwRXW5OaA== X-Received: by 2002:a17:907:f90:b0:a59:ad6d:26e2 with SMTP id a640c23a62f3a-a62641deb55mr241220166b.22.1716604260646; Fri, 24 May 2024 19:31:00 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a626c818139sm205376166b.35.2024.05.24.19.30.59 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2024 19:31:00 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [Patch v3 3/3] mm/mm_init.c: move nr_initialised reset down a bit Date: Sat, 25 May 2024 02:30:40 +0000 Message-Id: <20240525023040.13509-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240525023040.13509-1-richard.weiyang@gmail.com> References: <20240525023040.13509-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6CC4B100006 X-Rspam-User: X-Stat-Signature: pbuda7bkwxxfnfimej63ubp94q6dizr8 X-HE-Tag: 1716604262-689231 X-HE-Meta: U2FsdGVkX19brASStdYRkrDIa2eNJ6iALDWuWxxOQsxvkAR9P9F1ntmdmHYEx9TPW5yG0tZEUdmc7BUtSnOyz7N7GbCm3YsPerNHkkydKOsZ6MA/HeEq+FV3MH1nDgy4vgEHDH7Nv0gVyjQlTH6zWAYLsQrcmODq4IGodITzWX4Aqo/FaEaq9cYVELFDpgPx0NhFrCJefHbJEq2kx2h447eWAghTf094ArcFQuIzv78ocxgVSvrmP5nX2s5R1BCiQYDCkrID0Sqhwykz2auJqf+nCRWdOv+lEXTtIN5VbPmbpKCxnZX7wVZSipCEO9Wc5ZAtzVfQtlzPTrYlZIIz4dhIEVzAZ+lPxhHtGd0p01NmwPigAXCBnnZA2ofDThgk8XRj+5aw6W1NZNSa1lfLVesv2fnTNOVCXBO2txycX/wlOJGtHAUq0RD/Ylu0x49RQpsa5PD9HCdYDrad0w70py6XoPpDHoyaDOP73vepaWEu/9m8de8D+pamRDlE/af14sT2A1iTSvUOa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osity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We don't need to count nr_initialised in two cases: * for low zones we always populate it * after first_deferred_pfn is detected Let's move the nr_initialised reset down a bit to reduce some comparison of prev_end_pfn and end_pfn. Signed-off-by: Wei Yang --- v2: move it after first_deferred_pfn is detected per rppt's comment --- mm/mm_init.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 2dfb87841fdb..bdbd800b0436 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -676,6 +676,14 @@ 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; + + if (NODE_DATA(nid)->first_deferred_pfn != ULONG_MAX) + return true; + /* * 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,12 +693,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; /* * We start only with one section of pages, more pages are added as * needed until the rest of deferred pages are initialized.