From patchwork Fri May 31 00:26:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13680969 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 CCEB2C25B74 for ; Fri, 31 May 2024 00:26:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44EF06B0093; Thu, 30 May 2024 20:26:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FE2C6B0095; Thu, 30 May 2024 20:26:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C6876B0098; Thu, 30 May 2024 20:26:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0CEA36B0093 for ; Thu, 30 May 2024 20:26:36 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8A1031C1DD1 for ; Fri, 31 May 2024 00:26:35 +0000 (UTC) X-FDA: 82176799950.26.76F8C70 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by imf24.hostedemail.com (Postfix) with ESMTP id E85B8180006 for ; Fri, 31 May 2024 00:26:32 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aVpLgosX; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.128.43 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=1717115193; 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:references:dkim-signature; bh=rx3yGTm6VHYztg7vBo9WFnogEPOmrsfdWClh4QN61W0=; b=bcfRQdSY8i7O78n4TChRMj1Tghq8z6Q7FF847GLhHWfsUrTjlGVdBOwgYThrDOUxKUKI/z HmP9btHiPPptRkIU1X9Qo57/h3fFQLE/PFekKmXmzM8+Pf5oq+zjolzVLCHYi5ZWMvmKfo SingmvHh61s/NapQOSertaeZahUb1WE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aVpLgosX; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.128.43 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717115193; a=rsa-sha256; cv=none; b=jrX8cLo3OMfBEb5mZ/UK2b44iWfYLedct4LZkDvGGXxrqK/sSyrGQwDPx1+XJAOMgimkD6 fNxMPOrwOFpjMpxCvSdkyu8pNOcl6p9Ad8R6nABOKNynC5u91CoOvEXKx3NvKvOB7POFTi IwFELf3o2fdEWy2OhTD9Nxt3GmVkQcs= Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-42120e3911eso15089735e9.0 for ; Thu, 30 May 2024 17:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717115191; x=1717719991; darn=kvack.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rx3yGTm6VHYztg7vBo9WFnogEPOmrsfdWClh4QN61W0=; b=aVpLgosXAkbMeFXOV0Vz6EJsy5qjOFfBThP7x2WOaAkupL3QxRa2Nvcei2vm0t1gM/ tJA/6n++Ms6phqI989qVj2k9Wh2NeoN4dQOFWnWyWrPKBnZkNI7VAnlWzJ0Ppxf32Yvi krSAaCfQqt0JnFPenNlcSHsHftlbZP9QJdmNzSL32hfA3e6sxYeTLSAxhP+8sexJroCc 2IokLcpFdZRuSx8ZEKJi9XfL7imD+UhiZ6C8s1y6W2Yl4snQZX1msSnkk+CtGNX5TWE8 vORisppCeDxK2nGSBOyr2G1b2bgVaLexZhQTTP42o7yaPsJw0wZZCuv8bxrRGNorCEfd gxKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717115191; x=1717719991; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rx3yGTm6VHYztg7vBo9WFnogEPOmrsfdWClh4QN61W0=; b=Zux13ZB/EA1hf7rEHO9msUJLBMz1tF4vTSn/EFRo7TK3my/dmHqnZ3TzpuBwWm9kyH gjRIHunx26JxZvEFZMX4sgCTCuxBUe2EaJoP+mGpCWTdSdJiycdaKvQnR30vC3KdSTsB aHXZA+CxqQfSYrW6ojPE5bWQApm75qHctunMsgsYhwnIKJH3fmu6nbVBtGZsx+XHsLML 5f7e0+13utr7CfmZP2gCoEL0Qzkdx5qUvblj52tSACi5XzeFWoiKoOiafoqlaCFyXcyG GCkaOfXmL33/aKuUFDUhrFIUDHFPwmC4Fx19apPSueP2qqZZNNFRkhEFhyvldYgn2b1x o9wQ== X-Gm-Message-State: AOJu0Yzj+0WGH3OfeoGkPBIAur8A4uVhmnSXznyPPMZtv21EJLJWDd70 j2v5qTbkn5EoJW+d3tT1phhlQlXMiHixiHHiKK3VtyQPIW+olQJ9 X-Google-Smtp-Source: AGHT+IH55cBdsEXTDkEKad2IrXQ97/XSCRqaf+nkITk5IX+W0AZMpRhadjZKiJZhy2df3u+YcRR1Nw== X-Received: by 2002:a05:600c:3483:b0:41b:143b:5c2d with SMTP id 5b1f17b1804b1-4212e0a5389mr2137675e9.28.1717115191075; Thu, 30 May 2024 17:26:31 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57a31c6d444sm367667a12.64.2024.05.30.17.26.29 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 May 2024 17:26:29 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 1/3] mm/mm_init.c: get the highest zone directly Date: Fri, 31 May 2024 00:26:11 +0000 Message-Id: <20240531002613.5231-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspamd-Queue-Id: E85B8180006 X-Stat-Signature: xz73s5ycb9tco6gy6jgcaa5dgj931kd1 X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1717115192-720487 X-HE-Meta: U2FsdGVkX1+PX21hpoBbt9JlVh/N7B1+sv9z3RTzw9bUr79PYl7acmUuTGwfWUosnui9nCMjgOYRMUDmLLuft4Z4PQFGrMAv8tuEho2Ee2dTG4zlGFBGDK7eqH6RcZ5bhvDpcCN3uZ+AZf5ptusv4B/vxw5tHkBXWUrGZlXHtxpWqddtIga66BvL0udHBxIVKcr+Q7O0sLUHXscPxatYT8IBb6vfw+pcxszI4HFHN6i1JXCWtR5ASsraXWjo4AK5mprjKwS2uexum6OziilGjauZQTIwk+237sBIz76aUOAD7ba/lPP9DhiaMrBxSbz1JQgC7O397LkNw8syQGSVM2Xxut6oZT3CbBeu0ev9o7JQdJJnbpJnaI8hMEuh8R8Oy8Ze2Db0rCo78rV44nVdDL+sVMO2Beb1lx35cIC2gE+cXqyh3LawKYmi9gAsztUCYq56uAy/lprenYJO6sQC1Hmv0FSSzDvWAhlcFOiCaMz+ZJopq4OL0+tOboOb6Puy3cDw4OCNVnXLO0/VBSY31PoV0pnp896RVHSurVB9syiMvha83gIkoOG/5rkacdoa/AUO0kJZj4Y19msQD3lYayBFhexSJr2A+8Jy5A9h0A0RWrFgxRov7wF9+knihKeKx8mmorLWzE+4LPL6su4FR/Y0K6RWfpbP2swXo6GraZABbmaols1o9CacBRtjEWpoBmwCT7NWapcT1QhqV4y0fqOlHWJmS+zn1JW+Uo0aZHkCOq1VjUA5C6oBZX+V2BmNB1nWNun67bkMtCF41kUyVeNFmf5FhWz2VEqUYsCC1iZJAbWcgBp6O623KFOGQBAS4oEet1njOHZbw8kHOhbq8ZxSyh9i3cmrvQtMY0Tc1LRvHiRxxQu+1sw45TqyuNC3loyzWIUWLNx/YbC33cXB2hap5EHv9XGskuF78LQzYTA8TtBh98cyz/HxYRaxX2dB9AjQXZKO1GlPCgTYHyt smrQN8eU dma+3QXt59Py8L5Mi3hyeLOFoHvcV3uC+dQ0WFOyidgQOwjGg85u4/eDKr3MZPxrITP1hZ4QbYQUG0btm3qgwKe6lIwQGADrcAo8xqAPlWZ+JZPcRLTH9gnWgKJN73FeVCXUnMue28aKNlNLdBLVb1yQa+Ak5hsMzJybeQaKopZm1mi0Wd0j7jQSQ2DmccvRzxO5TLpey5FKJOM6uW0QJkABvElhdfCHpDwsQsIRBMV3dXJCFgiZsmzavXYbhBl6/OaDp8zZXbEd/FpnAXI/lDOgmvqTUb4mjuKRvMQbnjsr2rJVOSiZ5GeGDcisRf1g6724V5//twg9IkIDETEzasuaOriRoEdXtSWzDNd/iM5z+ohaj/OorrsLX0PQX5WrTHBn/QdsQ9njbG79zB3pQgP++gl0sHX+oheoX6pVQEzjloXIca2M6Eo9KdZ2IG5m8CQOjlPP5F+TladYJmNQe/bm67MfSD8xq1DjRxgODA7xd0R9x/St5lN2ca73x22iJRQfuQURyk2vRYKLnOdIpnz9SErSKpmYtEKdCsaFD0TbSAJ8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000008, 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 have recorded nr_zones in pgdat, just get it directly. Signed-off-by: Wei Yang Reviewed-by: Mike Rapoport (IBM) --- mm/mm_init.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index aa83105b3a1b..2bcf87eab0c6 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2136,7 +2136,7 @@ static int __init deferred_init_memmap(void *data) unsigned long first_init_pfn, flags; unsigned long start = jiffies; struct zone *zone; - int zid, max_threads; + int max_threads; u64 i; /* Bind memory initialisation thread to a local node if possible */ @@ -2163,12 +2163,8 @@ static int __init deferred_init_memmap(void *data) */ pgdat_resize_unlock(pgdat, &flags); - /* Only the highest zone is deferred so find it */ - for (zid = 0; zid < MAX_NR_ZONES; zid++) { - zone = pgdat->node_zones + zid; - if (first_init_pfn < zone_end_pfn(zone)) - break; - } + /* Only the highest zone is deferred */ + zone = pgdat->node_zones + pgdat->nr_zones - 1; /* If the zone is empty somebody else may have cleared out the zone */ if (!deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn, @@ -2196,7 +2192,7 @@ static int __init deferred_init_memmap(void *data) } zone_empty: /* Sanity check that the next zone really is unpopulated */ - WARN_ON(++zid < MAX_NR_ZONES && populated_zone(++zone)); + WARN_ON(pgdat->nr_zones < MAX_NR_ZONES && populated_zone(++zone)); pr_info("node %d deferred pages initialised in %ums\n", pgdat->node_id, jiffies_to_msecs(jiffies - start));