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)); From patchwork Fri May 31 00:26:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13680970 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 B7305C27C44 for ; Fri, 31 May 2024 00:26:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 364536B0095; Thu, 30 May 2024 20:26:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 315D26B0098; Thu, 30 May 2024 20:26:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B5636B0099; Thu, 30 May 2024 20:26:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DE3FA6B0095 for ; Thu, 30 May 2024 20:26:36 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8212C140F2D for ; Fri, 31 May 2024 00:26:36 +0000 (UTC) X-FDA: 82176799992.16.85765D9 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by imf12.hostedemail.com (Postfix) with ESMTP id BD52E4000F for ; Fri, 31 May 2024 00:26:34 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=P56Q+7EM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.128.49 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=1717115194; 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=kprjUC9pNkTVXwxtCvvhiLMuG15dqqeAtcDIcjJLuHE=; b=hFT5fYdla9opmeSjaR5AV8Svtd5eOhUX0Vy36x+vPvf+TJdz3x/LaWstfIsVmIo3tcmCwt A4/NxK1Cmt7zKvfmbx7ZIKsK35kIgx5lgfnGJMfoSn9OL2Bqvp3oommLC+PqFGzCInAL8R 3MGY9faSUDFiqTqXPse53PQ8bAP+15A= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=P56Q+7EM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.128.49 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717115194; a=rsa-sha256; cv=none; b=oPPvg+qjoUcWfpjet/IMr/X1/am+ye2vpGWHgoCSy/8DC2ukAWWMp/JHrAR397MbhzXY+K p4nId4l0A8CtpQkWrq3VloBGbc8ZYps+L8sybqwsG/7yhx7+1vbvxUOQJKUbApjppo1HYU oltr3qvZnd0wPDLUMaUk5XQr3zqHZ4I= Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-421087b6f3fso16310205e9.1 for ; Thu, 30 May 2024 17:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717115193; x=1717719993; 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=kprjUC9pNkTVXwxtCvvhiLMuG15dqqeAtcDIcjJLuHE=; b=P56Q+7EMmTSP4sj2T4mREjOJdXF+0lUIq59Up2x4GXIMnAJNbo8gMhL6qcQ3WHVDxA hfgtmBzeLGjyVlyYlr5KocMHF3dxtQfVb7TP8kKKtPu6WqATXu0gHUJXkW/BnLkb2tkq UJoeDFpouunQd3W4ICaZWoIlugezU20tUnZUpxbOwIdyikyNMTeQzhFDMGqRzGXwJixd G3e6AF7mLwHKQsmZZ2nb9JxyWYt9QfYppDEhw157SrA4ycrdZ27YUYO/BGFQtqcdAMBZ o2OvdWCN6P10Bl058fsa731EiDLdxtYCcUbdbAHj34oqJ4whce2CVIGoaKbncrAoukUG 7Xfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717115193; x=1717719993; 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=kprjUC9pNkTVXwxtCvvhiLMuG15dqqeAtcDIcjJLuHE=; b=oc38AerIQfeMRb+luZ1biV/JwA9/GihRx1ea5Lb5xEWxzhhr0wEeN8PVX6mR8qneME Rxb9f83+Xb5XsWAc35CSY4f0AHvoXtNr52KtAFu8cUf2yc4MkxGsT+kcZQCbVdEyzbJw 1ral0ayWhiQT7zGOLCnRxS/j4sSQ3N0K2LH2axYSN7SAhbG7TMwRev22I+1JwjokJhgF 6aMgcAWAigIyc5sIhKaXMVC0sm/nonWAI5K5fEUUG+khB4Q2Z/2SoZZ3XV13nMy0mGNb bBwhPuvvMnYX+8Z01OQiwCSR3zDUTtJjZai6JPr7sSl0IE/ri8jU4UKzfNoKbqNj1nA2 ovLQ== X-Gm-Message-State: AOJu0YzfZQM/lz8W8Nr27BXGOkDhaU8hA1ALMy0G5n9duR1CYxUV8lFs 4jAK94PH1DuQL+8D9N8s2q+ROW7yeE9oVfCNvUmRHCg7JFAgLIN+ X-Google-Smtp-Source: AGHT+IEPJkPxNdetDTpgEMsMKkXKGVb0seTe6ZrwCSmdzFW1nR19SAZkZbAvnnnu1cz220mz7flb7g== X-Received: by 2002:a05:600c:1c24:b0:418:f5a9:b91c with SMTP id 5b1f17b1804b1-4212e0bd8fcmr2064715e9.33.1717115193040; Thu, 30 May 2024 17:26:33 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57a31be4c7dsm370889a12.50.2024.05.30.17.26.31 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 May 2024 17:26:31 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 2/3] mm/mm_init.c: use deferred_init_mem_pfn_range_in_zone() to decide loop condition Date: Fri, 31 May 2024 00:26:12 +0000 Message-Id: <20240531002613.5231-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240531002613.5231-1-richard.weiyang@gmail.com> References: <20240531002613.5231-1-richard.weiyang@gmail.com> X-Rspamd-Queue-Id: BD52E4000F X-Stat-Signature: asoq53qd91tuw7ty3dr9meuiwracdyiw X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1717115194-219434 X-HE-Meta: U2FsdGVkX18FU4gNYsPyMqNBQpYxgvNgqPVLQBJb9VZ2HU6ATOsKgskf662YSnNgofZz8B8IWzM0rXjD56YfaLuxL45bK7aw/fqeRmhyEpZGyLoNWJyR/s7eN9+gLdAmkBPJEiIJAAvv1dIRuOkXIEW9ZK2yhZOPux7CEfvCLlmI5zGYlHGC5XPCBfwwMOl+XkhLkMMro90cJG1/bHKjWQePtfV1ZOgjkrQGBGBr1Kvwx/gxyXoH84CTIQqRRlqIKObJptfoZKgBcF1+kWJpb5PLOfvM17/cMbaGMwEClJf5lQuI3CMU2BMsErrpEasiSx2HatIdfMCdEKWfmPBPH3CvqSgvqzXVzfWshsWdfkakW+7HrU0lDqAupiTBsV+PvnYUoFbLOKnihaleASV9PnV1WEkx1cPYE7RsRJcAQBjwEu/D28kBABWUyV197u+7UkcgmHO25W7VXmcnC5N6hiGaMDVo3WN1W4NE6GuIex9VYLSxlTrkwVJ0TQgjmeqrfoUWao5V+8pJcMDFS/loZrSlSsVLaG7u7UC/1m0fy6KMfSWOhjycKTf5qZXkaGdWfxZRL5sZ1FFxMOR07JIdcecX9gpIAQWftVz93EG0Xv4v6KhQloao2jigY5BQpXSkDkXzNH8h9mPn4lJTHdFuHlvE+pO3np06eM0GZFGqnQXV27CC8V59gUkw1n9RZiutylrLLjJg7vuKJWhBmUWciCQ+XcFnTmpDLbpneVSxxtLv3KMrlvEwUFsLjFmidVdKuVRj1iPMSeu/DNzsg8PQJv9Ja7D2GOTwzMD8cYFMuhhN4J+yn1mYO/vW5GYnuSrh6nQkEIIR4sgAQgMbpRkYIjqudgxtEsZSkc4+c1Rij3DEoPSXmcuofE4QCjpRgqh3wMj3sWM6MVJKu4PAMjGMDQSMejy9JMr4kDLTNLK5q3V1h58HyCDL8Ci3qZtQWiaBAvdj6cwGrU48EnugxxO 8xQa2N0a AW5KGrRVlY95/1odKM0s/UFeYGQ2paf178sSrqpyobv1pexJ52dIXNygGmPuyO8XSbx/FfUjnxMGRZOvovOn5ox+twT7qs12gurfVRdYppCH24w40t5/j3FWSjsqJmdRPpOE8F761GCZe6InrWb3H3IvfziTP2FtOfWkbT4omMPZIoZyzO8ZnKVmkF1wVAup5ri/qM56RaJgHj3dpytkSVM0oKuzf0TkluhzA/Me0Vge1rYY7tbEuPRnvE0lbqyUTizdIRHZzybaWoYzRIbdOCmeGe6fkjrOxsuHlzJHFNPP8kBBpCwJvX0JSWGlFGumrPs9Ji5n1pWks2rbFKO9UG82ZdhW9VhhAWK/AtQ/LZ94guNO3Bp10KiMsxnpBCJKpZprLRHPQsQ0FRO4pSh0pr252fwNs6B04VxWc95nRszOukpMGUc4WHtuL8ZIIeNovVLJyHraR39u3DPRZ9eJ78zPXp3ZyYzbDvg1eayNxlydkYg8B93PqV2IAeh0oGUWfqu4tyWQxxtf3QmBwSBF1FwbhidD9UbZWx+MTzJOxQXTjZpc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: If deferred_init_mem_pfn_range_in_zone() return true, we know it finds some range in (spfn, epfn). Then we can use it directly for the loop condition. Signed-off-by: Wei Yang Reviewed-by: Mike Rapoport (IBM) --- mm/mm_init.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 2bcf87eab0c6..d05a4c38310f 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2166,20 +2166,15 @@ static int __init deferred_init_memmap(void *data) /* 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, - first_init_pfn)) - goto zone_empty; - max_threads = deferred_page_init_max_threads(cpumask); - while (spfn < epfn) { - unsigned long epfn_align = ALIGN(epfn, PAGES_PER_SECTION); + while (deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn, first_init_pfn)) { + first_init_pfn = ALIGN(epfn, PAGES_PER_SECTION); struct padata_mt_job job = { .thread_fn = deferred_init_memmap_chunk, .fn_arg = zone, .start = spfn, - .size = epfn_align - spfn, + .size = first_init_pfn - spfn, .align = PAGES_PER_SECTION, .min_chunk = PAGES_PER_SECTION, .max_threads = max_threads, @@ -2187,10 +2182,8 @@ static int __init deferred_init_memmap(void *data) }; padata_do_multithreaded(&job); - deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn, - epfn_align); } -zone_empty: + /* Sanity check that the next zone really is unpopulated */ WARN_ON(pgdat->nr_zones < MAX_NR_ZONES && populated_zone(++zone)); From patchwork Fri May 31 00:26:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13680971 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 B7A47C25B74 for ; Fri, 31 May 2024 00:26:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 142D36B0099; Thu, 30 May 2024 20:26:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CDF76B009A; Thu, 30 May 2024 20:26:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E39786B009B; Thu, 30 May 2024 20:26:38 -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 BE0466B0099 for ; Thu, 30 May 2024 20:26:38 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 701501C1E43 for ; Fri, 31 May 2024 00:26:38 +0000 (UTC) X-FDA: 82176800076.13.AF17244 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by imf17.hostedemail.com (Postfix) with ESMTP id ABA324000E for ; Fri, 31 May 2024 00:26:36 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BZ+7uJsh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.52 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=1717115196; 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=MZBE41AChCp0m8HAgfoBpLE+uoE/yknDqU4N2DO/2Os=; b=w+U6X/+YS0UUttOJYrjLqThelunSVgH3YM3oxDX5o3QoCT0UUPro8b76XY5yiGaEsZhzdj ohGcUUGJDBfzF4be9jdI5ByK6BCbIXj+h2KdPbbvLKb7yfEuRRCTJJBLHHkW7sJ6hebiNj fYz/SbvNrzBM1IJuhMgfoqWow/Rfxas= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BZ+7uJsh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.52 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717115196; a=rsa-sha256; cv=none; b=wsPsIhSMtifWZs191sNlx7lV9fEa/5WXp/e8TaD7TcQIbmobTnk5GED9VR/f+73oD3yxuh kbgvhCl8NJ7C6Xh6RakkpCsWpHD/qfPqO9bB3lk5WKcum7W2pIxd9OBJELlZggx+Q8+MuA BhK8KGdMWk1KmfrHw3gGU18A0ihtFVo= Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a62db0c8c9cso146671066b.2 for ; Thu, 30 May 2024 17:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717115195; x=1717719995; 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=MZBE41AChCp0m8HAgfoBpLE+uoE/yknDqU4N2DO/2Os=; b=BZ+7uJshi5rRZ/jAARKOZaB/w4aWxEIETxxwCdkq7B1MVcAFKSMjXYv7ceUlFZ7PKF F8CSbNmLGTUbu6hRBQgwXvXtrogsBWlV1UorWZ53mln0twnZW3mqn3IdJT4k97YcAt1J X+IGEs8VykIty//dS9452GpVBQREm9WanrYwEy6CxFeHYWIHularVvDFjKI57aOlD7E0 952PvscZO6LWIeILgDQ2KxPOCibs0Uzrz/5Z4wqhpk8vEbplzG6nj17bZTm4erCgPhG2 7vZSA++Z7nX05jecjj5htUcNgTX/TDkdlwaKuJSk4/CRVbjvk7c88TYzep2o/q5pPYRw bmow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717115195; x=1717719995; 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=MZBE41AChCp0m8HAgfoBpLE+uoE/yknDqU4N2DO/2Os=; b=GE0SFD3dxd3B/iOZKV2E0scnzeW0lMt4lyeO46LHkdnCRI7u4xbTXf4yRsgV871CK3 hc1Ji7TpjeE91uZ9fnLdmAjAMW9+sXwmbvMqnY7NrTh/ThtPqmzTnHeXFGbZLr+F0g3N 1nBJsct26uO0PrzyZE04aFH8oPdqQoDDB60xCMZSgRtTz+FTPOEhvS6EpgTjkv4Nx1ih QzrO/xPXSURLOSjNP3S9aXnlOGnMTlCcdLzstR3ikUmYr7BsN1G2rrGfvfSuzRzdydu4 O/Sobfju8JvR4O8cJ41ov3MUTHMwD4lECNr+3S3QIXAjuodzGD0Ymx/OI0twtpM72XYy eS8A== X-Gm-Message-State: AOJu0YxlnTErSrS3c/O5PEYldUvvg+IBtMHmK10vhVGhfS8wTA5W2AiW C0zAHxrHEAlTbgUxbCAuOMJsV/Bs08lHc6AlFbIZ29jqM+jkkAZT X-Google-Smtp-Source: AGHT+IGpmSdbdFUNJHYiOkwm2eAOghZCZ6bPZb4wH7CNYr6cx7s8fjnBQMvxxMM5Gr99XIwnAHA/6g== X-Received: by 2002:a17:906:1e12:b0:a62:c238:b229 with SMTP id a640c23a62f3a-a682234b700mr25526366b.74.1717115194940; Thu, 30 May 2024 17:26:34 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67e6f030f7sm29807666b.10.2024.05.30.17.26.33 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 May 2024 17:26:33 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 3/3] mm/mm_init.c: not always search next deferred_init_pfn from very beginning Date: Fri, 31 May 2024 00:26:13 +0000 Message-Id: <20240531002613.5231-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240531002613.5231-1-richard.weiyang@gmail.com> References: <20240531002613.5231-1-richard.weiyang@gmail.com> X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: ABA324000E X-Stat-Signature: jrxisu1e5sznimkng16ixwniw1uqomdp X-HE-Tag: 1717115196-454382 X-HE-Meta: U2FsdGVkX18HgFO85nSXcUxFdG9aIH5kE1VO5Qmja4kIiRs9mgtg8lxuqrw1BlBYrmYL2Rh72TqYl+cjYy1LDcNARNl1WhQWHPI81JPdPmpV7vFRsOOUXjpTH9YKbY6siPhLN2NI+s3Got1G4TOSHhFsjfirBUwqHIajVnBbWu2chG5ESe18dCyY+Zu4WW+3T9jIEqnj+IlJImv04nhtt2w05/lT2Qyw7kaQma/px8VUSvTDXMz9E30a4OkOIilClhANrIL0Hy9V0OPhwMjx7Plll3KXLp4Z4E3ONb89IoKeHVjA6njsgSLpVfJz/cKsmfc/VUcHf4vNZHwbfcS5qv6VqurdSraaJc/wmMvOy0ZiIuYJ58AP1Yk6XjNt8Fo3/noKWB1R3AUw7FjxNwjoULd7j1cDFpk8q0e3GXWtJOKzlCsabRjyZ5JlmRp6hJiEBLjt3wq4/C5PnZOaIBF0XuOI6rF812Kj4FTxlLLvdtzSLsf49A8ARbD8NcvXuARvBdR9GE7stnykuNCIUf0ZBV3E1XhPwgWNLktb7mgTK2RMwNPLsmCm5B6Q8Ae72eKd6+6hSnzQo3OAd+Vwe+JFLYY0ko0oJQYmRHGuaYMDaTnLLgI7YV4R+Z6F2LfvrAYJYoec3923IxFgEIWHpVx8crNxmxWAy2L0aQAPRYXSBrRY0wokfrmJLfVJEn8AQPUxlvn547EJKEq22OdcTCBdpelx8aRGDJsIPbF58UiGp8VVUgy069Ljd+jJiPxMxBgyuQCEP5m9RuFozB8HYqnpAFJAiNfF+MdNlvg/bGVfYQFosiv6YXna+TcNFsbdArbgxqhFXeVwQZiU9V0gswflDBtw9B/PGWdiotNAp0Y32rZG+uGpOcyZejcEmm+GHn8txHL+ZhAohTwSbk1AnnhDNhjmn6Kb8mnQSA2tIkq7dAEEQcEVb0ojOuVQgTtUlJNsWofLB2uDB9iETKtRr5+ TWT4QSm6 vL3Da7ANed1B81k2WYv+8RvxWlzzZi9fGKOLR5+aOXhZzRRPF5j9PskRRd1MLL916gRTQYpYZumjWXaYZebtXdcoZiYJEt8btwnL50kMruEkVK5glLl9Wc6tKAui+oZ8PYvbr/RqKCdllj+zFFwDSZXH+7gGhLV0eNPpM7VIqQISDHQp/FFrGIjOJDUFImdpb3ICvlSZWi7PyyWPzgry7QFzby/bioSWldqk3sGI8P0o56g1OKQIJB6fSAlSF6qnSIaeb9PqKFNrdIgHEfiIoT24fumL8v1DCDx3iZ8dXkVLe/0gs5enMQVraFaDCPe8TeD9ZsoJnohcMMcVyZSxkdgDU5EEignNmsD802s7tb34HcdR49vT6BmngQXBuah/SdGoAH34PpZl5CK7qPjSwo2IO5KfT2CsvkLDSKAzQEw+GNttL2IHA0JZkd5eb33Or2pH/uDAACkeSHYrdTGDwX85RQqgRXmjYyu5xyU0luwdntR9Sgnpbg+pvctfgVbN5iZk0s2KG8TCp56567foIf3GgPnnB74LfPyfgjHR4Fo2nS0E= X-Bogosity: 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: In function deferred_init_memmap(), we call deferred_init_mem_pfn_range_in_zone() to get the next deferred_init_pfn. But we always search it from the very beginning. Since we save the index in i, we can leverage this to search from i next time. Signed-off-by: Wei Yang --- include/linux/memblock.h | 19 ------------------- mm/mm_init.c | 21 ++++++++++++--------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 6cf18dc2b4d0..45cac33334c8 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -299,25 +299,6 @@ void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, void __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone, unsigned long *out_spfn, unsigned long *out_epfn); -/** - * for_each_free_mem_pfn_range_in_zone - iterate through zone specific free - * memblock areas - * @i: u64 used as loop variable - * @zone: zone in which all of the memory blocks reside - * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL - * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL - * - * Walks over free (memory && !reserved) areas of memblock in a specific - * zone. Available once memblock and an empty zone is initialized. The main - * assumption is that the zone start, end, and pgdat have been associated. - * This way we can use the zone to determine NUMA node, and if a given part - * of the memblock is valid for the zone. - */ -#define for_each_free_mem_pfn_range_in_zone(i, zone, p_start, p_end) \ - for (i = 0, \ - __next_mem_pfn_range_in_zone(&i, zone, p_start, p_end); \ - i != U64_MAX; \ - __next_mem_pfn_range_in_zone(&i, zone, p_start, p_end)) /** * for_each_free_mem_pfn_range_in_zone_from - iterate through zone specific diff --git a/mm/mm_init.c b/mm/mm_init.c index d05a4c38310f..ec17bf93f946 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2023,18 +2023,21 @@ static unsigned long __init deferred_init_pages(struct zone *zone, * return false indicating there are no valid ranges left. */ static bool __init -deferred_init_mem_pfn_range_in_zone(u64 *i, struct zone *zone, +deferred_init_mem_pfn_range_in_zone_from(u64 *i, struct zone *zone, unsigned long *spfn, unsigned long *epfn, unsigned long first_init_pfn) { - u64 j; + u64 j = *i; + + if (j == 0) + __next_mem_pfn_range_in_zone(&j, zone, spfn, epfn); /* * Start out by walking through the ranges in this zone that have * already been initialized. We don't need to do anything with them * so we just need to flush them out of the system. */ - for_each_free_mem_pfn_range_in_zone(j, zone, spfn, epfn) { + for_each_free_mem_pfn_range_in_zone_from(j, zone, spfn, epfn) { if (*epfn <= first_init_pfn) continue; if (*spfn < first_init_pfn) @@ -2106,9 +2109,9 @@ deferred_init_memmap_chunk(unsigned long start_pfn, unsigned long end_pfn, { unsigned long spfn, epfn; struct zone *zone = arg; - u64 i; + u64 i = 0; - deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn, start_pfn); + deferred_init_mem_pfn_range_in_zone_from(&i, zone, &spfn, &epfn, start_pfn); /* * Initialize and free pages in MAX_PAGE_ORDER sized increments so that @@ -2137,7 +2140,7 @@ static int __init deferred_init_memmap(void *data) unsigned long start = jiffies; struct zone *zone; int max_threads; - u64 i; + u64 i = 0; /* Bind memory initialisation thread to a local node if possible */ if (!cpumask_empty(cpumask)) @@ -2168,7 +2171,7 @@ static int __init deferred_init_memmap(void *data) max_threads = deferred_page_init_max_threads(cpumask); - while (deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn, first_init_pfn)) { + while (deferred_init_mem_pfn_range_in_zone_from(&i, zone, &spfn, &epfn, first_init_pfn)) { first_init_pfn = ALIGN(epfn, PAGES_PER_SECTION); struct padata_mt_job job = { .thread_fn = deferred_init_memmap_chunk, @@ -2212,7 +2215,7 @@ bool __init deferred_grow_zone(struct zone *zone, unsigned int order) unsigned long first_deferred_pfn = pgdat->first_deferred_pfn; unsigned long spfn, epfn, flags; unsigned long nr_pages = 0; - u64 i; + u64 i = 0; /* Only the last zone may have deferred pages */ if (zone_end_pfn(zone) != pgdat_end_pfn(pgdat)) @@ -2230,7 +2233,7 @@ bool __init deferred_grow_zone(struct zone *zone, unsigned int order) } /* 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, + if (!deferred_init_mem_pfn_range_in_zone_from(&i, zone, &spfn, &epfn, first_deferred_pfn)) { pgdat->first_deferred_pfn = ULONG_MAX; pgdat_resize_unlock(pgdat, &flags);