From patchwork Wed Jun 5 07:13:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13686249 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 AB4A1C25B76 for ; Wed, 5 Jun 2024 07:13:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D56B6B0098; Wed, 5 Jun 2024 03:13:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3834E6B0099; Wed, 5 Jun 2024 03:13:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24CBD6B009A; Wed, 5 Jun 2024 03:13:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 016756B0098 for ; Wed, 5 Jun 2024 03:13:52 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A54A8A1A1B for ; Wed, 5 Jun 2024 07:13:52 +0000 (UTC) X-FDA: 82195970304.18.7DFCA39 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by imf19.hostedemail.com (Postfix) with ESMTP id E4C961A000C for ; Wed, 5 Jun 2024 07:13:50 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Lx4mQ6A6; spf=pass (imf19.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=1717571631; 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=u/7kNVOQzPOn5VcsZFueGadWr2+w+eypobZ/GrNqpdU=; b=crcsdU46lAkzCY18SkeD/c7UqlBNN0z0i66wcC81cxFDrSxsuSySpIPT+t2S9/4dc41UTQ F41pmS7VbhfwzwLwd3dosk85U6OnkyXSL1XaHV1S8g087PpsxZHx9JhVBhLj86mCf9vX+n ty3O7WkyRdPwi3SLPl39NVP8reLMz1A= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Lx4mQ6A6; spf=pass (imf19.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717571631; a=rsa-sha256; cv=none; b=khFk4Tyf8zRegh9f5v1wTFmKoMq9zuaGWAsUugVG5OKJj4nUYWZfUatu+slodL23EuApvI LlPfrq3h9IpnnIc4V35Yqj65OGlrMXe+aDQmr+pUHFwG8Hjf4tilck7HNs1CTeHm5nmSh2 lQmgz8Oz/WhAQAA78MSsIR1RwKwFCDA= Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a68a4a9946cso439383566b.1 for ; Wed, 05 Jun 2024 00:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717571629; x=1718176429; darn=kvack.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u/7kNVOQzPOn5VcsZFueGadWr2+w+eypobZ/GrNqpdU=; b=Lx4mQ6A6ILNKNFw6KkTHuQL/8LsOEji1V1O4zZBJluAWDwQNreDc1FqommtvXdQNN3 WNMyAFDfLbc3ARrSs7sK9jCH0a26Wdvj6K++u7I1il/RV6qYROLSxu8CRSwnDwTB9na1 C60h2A4zmkY4JtX7w9eOcvcyjDS3gEQWIvbDok0Oll/yAHQblCPDSbfc/Oqw8AOiBpNn RUJURWW0kEEUOSkevgfSLigxiFnFK1gEzUSZZN7gmTZUBafWqGKiEqGTOb6Oym5MIu9j TvXdVIPWU1M7Vce+z2ioW1bhe6kX9XBvR8at0YnBZdRnjd/fmaFC4uknKk8lU7Z81AxZ W81g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717571629; x=1718176429; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u/7kNVOQzPOn5VcsZFueGadWr2+w+eypobZ/GrNqpdU=; b=m1UEVk2xOYsHIGVzNTpb/n8dI35rL/oWMVffZwpQyn7t9rdr5f7pJOZCCtqsmO4MqQ nN+kgswddPB8JpgbOGEfxxPX1rVR3QfRZgRWbdpjyeqSvT2GE9mEQCu9jr1At8aVcqXX F+AFEWThmpScxp9JAiusecdOJvnEhu68+jGbuXInJvtCwRBhYYXMCOaiFyIHseXTZs1Z 5ryT7gnSJfQpWLUvMxvIVTig2of5RlZklww1mEDQNrQiwSSKr+Qng6TQe8EKLcR6oCLa /qHahuhFFJZ8Db47X0H3UqeJc5YJ6EtM40kAwvA7O/2ZAXoRccUd9DqgiPaOvyUWlkSD FAFA== X-Gm-Message-State: AOJu0YxYeUAqj+c1fqZMNtGBii9CO4W4Dyc1upSPy9aIHlJLnkmaKdga 7qlOnpobCIKe4GaMcWTWCNqpxqS8H61oGYLS259DzH7Ga9G9+dAF X-Google-Smtp-Source: AGHT+IH9ooYOreg3MY06/0xk6BxTeBUA6mtCscQi7qczndVMugBtSAH1fqQ7AFohNVKodXkHO9X8GA== X-Received: by 2002:a17:906:fccf:b0:a64:e418:f93f with SMTP id a640c23a62f3a-a69a024ce23mr96209566b.60.1717571629119; Wed, 05 Jun 2024 00:13:49 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68f4191cfdsm473849466b.137.2024.06.05.00.13.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2024 00:13:48 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH v2 1/3] mm/mm_init.c: get the highest zone directly Date: Wed, 5 Jun 2024 07:13:37 +0000 Message-Id: <20240605071339.15330-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E4C961A000C X-Stat-Signature: 3wb6bnojozx6pa5cmpji51hxq8x7rcxc X-HE-Tag: 1717571630-417812 X-HE-Meta: U2FsdGVkX19OyJd2j5AobSQQb+46Px3a0uoz7RjY2qp0OBFujhdNy/dZadT656gGpRmzV8JlSSl1mFPGoQDxu/28/xiYUa1Qfj6GLca15WvvrJYBxvyAkz+7uO8RfTa4Us5/tuPrxqsqpo6DLsjki8nzMIZ+l0qorUrNowMK8Yvd0RDDue0KzYTK9QMAWPHZB84ELCXelGVlI5IzLKeMGayjrc5cxc8MRknjMsHEQ6VsCwa7TPqf3og3b66MuogNg0id6MNzyqqapUJ/EzlD438bZ1m65ZwlKd2BDuq2aRtVozO+pcYLU2r2a8XhBnWaafTEL2ZTSoXO1ZkCLGP+NG0VCZxr8Iwc84SkfOyxOrXp8hYQoKKtXgt7ZsA9QvMyAGPSGcEedugXFFMFOt8wDvr9dRPvZvaHBbFrr0TUHGJX+R5OXFMWXsrmhej2gu20rIhh5SMr2DD7ALoDD0P64tQ5Ww9K5/5ICbwBc7Q4sg89ZIcLSYQrsPHT8rWzYU7K5ZH533j9E21nKxJWO03YWQP4W4lcynrtBQXkpwcT9lZzl6HXvIrpRwmBwBOYBSCOL2BqtURIreR5sPIV66m9RBnHev+Xqd+bGC8nru3cP7D3vJdzUpcv0k6aReNOjtdfLH9C21dCRJXCV2xTzYzQzHPfNce/xgajR+I475Q/Ttlb4YZGlqWNkeYRTtI0v8kKLY+D2Lxt7g66EXvFwYS6IHLnaFHYMg3s9Q8BHkkVO2Xj8rQOdaY3hkXp0nmuUchAJnPx5lcbmNdxAul/6AjAr62mHGVg2TgZsdPPIObac80W1L6KcRZp/GJtadfBOTisJ0VupI0+RG87F8cXwexK9hfEpAOsjUVT/E6ejxR/czmd4RGVzyoMrQfdyMkhLNLlQ4UE9j64bgcT2O/2W9npD269SfSaQJNwrddNZ4HYxK4yONZoRAvGq2kaJx1a5UfPibXHh0Jm1cYFlD1cG6x VEbkmTCm malkvG27uQjfvo5nOi3jaJqGX6V+VtGnxLICDlwueskDy0DkXJPnD5euEMnN/a7vCf4Q1F2/pcFz6H3D3OZaieFtg5cupJ6WsIG7L8KogKTnl6BwhiWTAbuoxRuAMAp+etFjLvLv44Y3cpcGGcO/sNSrXnsglulYI7ifX9jVqgJMAR+VqGkqbrfYDokaBuvkSYhAkqZnAXB2ANfBAbUQxbKsJ5sLfMA/huzttiuev52i1mwDGtNXfD0mRICS4CyVaozSaseaEP3RdSrnnrJeV/zu+IYk14TIBsRI5aYVuMqInMl0FX7vD9TlVs3EWulFlwgfGvM1QYplVBDGmeqcjcMAwDAMF96fONm5YYCFQ6AYrTwTo9/yKDHNyvYCYIDOcOATPu1vdDMTr85p6NQUnv9pMVwCZQ3umu7OrtxIh89lCQOcrxtaGa7hz079hEDJO+uWG++EFCHvjviP9zMMZ8TvVZVrhZe54ymxlxLSxs4kFJkJTeT6/JC2Z3kXATdSeMQrk4awyRe5oQXMnhDe3m7MgBXti5ujX1t94XRd4WvlNqPRCQp0qUP4QMhTcx1CFGb5mdZbBful8lwSX8buk9ZJt4yAb48qynPfiEXadOiyK/EY= 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: 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 Wed Jun 5 07:13:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13686250 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 E6D34C27C53 for ; Wed, 5 Jun 2024 07:13:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A48A6B0099; Wed, 5 Jun 2024 03:13:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 754606B009A; Wed, 5 Jun 2024 03:13:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CF3E6B009B; Wed, 5 Jun 2024 03:13:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3D44F6B0099 for ; Wed, 5 Jun 2024 03:13:54 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E67F4141374 for ; Wed, 5 Jun 2024 07:13:53 +0000 (UTC) X-FDA: 82195970346.01.3C8DA54 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by imf26.hostedemail.com (Postfix) with ESMTP id 398C7140010 for ; Wed, 5 Jun 2024 07:13:51 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=lrIsWdPH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.45 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=1717571632; 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=H/b95r70FesOVKmFgvvHSUMKlDSyrPgwhWeZsaV/PzM=; b=0urvImI7+XK4b4jDVzdEAEGQwdhtXM09DmAr6Y3hEIp3B5SQg74nIrCyB2ZNsc78lqxfye hYguQHpaDrwkeWlYJm/caeupJQ1LA8bV0h/S/0GhP7IVAfxB+YII0fpbTR07l67q9QSJjf zA2KCbURTPMKAQv+CAsefcaUr3w8tNA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=lrIsWdPH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717571632; a=rsa-sha256; cv=none; b=N3VTLglMaLuU4vyDJVoD+SuPHBob+Apn8Pz/bijapTDpKlPQCCWGNQeo3NBq1QkiCPvW+J EwDvLLFUrTCOR4AND+qMNYbHY1un9QEuH1sETJrh8g2cEWY146PINffj51G2l84sgxx8JY ptKx6zZnMnlQQ1iD+a/+8B5+1k7LG+4= Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a69607c6ccaso180849966b.2 for ; Wed, 05 Jun 2024 00:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717571631; x=1718176431; 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=H/b95r70FesOVKmFgvvHSUMKlDSyrPgwhWeZsaV/PzM=; b=lrIsWdPHqbDpgokNIVz3bdRrzIHEIwRY7fSuJYS1s4ngshCOn6GdaVBZUHeunKSxVc vVXdnN4HJVMfxhhqN5jRy9xCuuoxMMd+sMOBCJZMUigZAU/okNV77LOaUy+b/wXArYHs 71k7BdhK6LSbqy2JgHdlkDSRGs18UM6pQ8NsrCOVwwCGc6g397cWT6Laujer28kY/q9P WobBRDyFfkC9xGtoeVW5sPMsn2D5OouxxjsyM1Pj0/Gdcvi3LoWXiCMeQXCCOkH3Kmhj oiQgU3lRsX4kcDHdVsHO/m4m1LhPRyc56/jQ/0QCdQCm5Z/qpDkTwFufDN6IwYYamCNe lvoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717571631; x=1718176431; 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=H/b95r70FesOVKmFgvvHSUMKlDSyrPgwhWeZsaV/PzM=; b=KN6zFrfiIJSj3OCYTP4Y2j6VHz5PbEgq91FyI+tF+jh99t5xJddUZhovsYL+8Hh95N U348ait2SStZ+En7MJNVSlBe/HkMn6irMGqFsimPAvBZDAosdn4xIwZDYwvXn/UMYRs9 AL03V6vX/zdIjjRqLNIY+/F5Ap1WnZxkBzEA+of28YMjpzCX9QaGxgv0f2aLQNjc5jdJ K3UNe3nVKj9OaiKV3zQXelyA4DkKIpMgSr5embsuSOFhrHtqb1C06IrGR6mLJSbuQcqh Gbu6BsF58KaroAIMulwUPdIi/3XhRxVm7r5moGJMaFdQlKEppm2BkAGKYuOzbGTAZVTz 3lPQ== X-Gm-Message-State: AOJu0YxYcxkoujTEVNjehmtqHJeKbFUkECp0aGd4hC9PeQIKjCOQwbaf nfaaOvQ42u/gJst9oYRV5AjmzOaJw3TYRyw/aaMpI2XknaUbEwtX X-Google-Smtp-Source: AGHT+IEWphobYmSuqPPBsUvpi4KB+lmbvzcE/2DdQdd0O31fG0Z19cBheV2kb9ksg6Pund/HxIPemA== X-Received: by 2002:a17:906:c383:b0:a62:cef2:5711 with SMTP id a640c23a62f3a-a699fab8c84mr81052566b.6.1717571630822; Wed, 05 Jun 2024 00:13:50 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68ee715f45sm491713866b.94.2024.06.05.00.13.49 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2024 00:13:49 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH v2 2/3] mm/mm_init.c: use deferred_init_mem_pfn_range_in_zone() to decide loop condition Date: Wed, 5 Jun 2024 07:13:38 +0000 Message-Id: <20240605071339.15330-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240605071339.15330-1-richard.weiyang@gmail.com> References: <20240605071339.15330-1-richard.weiyang@gmail.com> X-Rspamd-Queue-Id: 398C7140010 X-Stat-Signature: t4grwgooriptbx3mxt9ohw4f8q6e7u67 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1717571631-378045 X-HE-Meta: U2FsdGVkX19StQH+dbt2c9XzUXgjsc3eFth905V0F4/RzqRP7Dt39W7JjRXxB3I5cENquW5NPnqOba5XayL1eiYli/OIwX32zGAFjJ+9B5RF/T6zjah7GNOqNA7ybJApqTUSYl3l2R5TkpFJ+86WW+Y45Jxqzu0SqO8xlW7VVcw2/wAWBG/toUqeztY7OIe/hVqRTyOP8MfXJ663a6deS1v+3bxaZjwbkCGt1lNeZeCXNWN9uNPCaCx0ffmjn35jRRncSlseECBUiCc86MPWZXEathMlRMJaPfADSVyYsMP3RjTBUh3p1iu24dEk2fq9mRJGzNLSDsC/TrC3GA7O8mQbO/TbP35KUusYZoYc3wsZLTxClD0kZRqHqsGyKtSKBw8w5MPtsEAN89R123kpyGGlwljxHpoVb3oBxsdaPzHYOqsHkGABI+2xRJ/gC6PNjhnDxsmYpWz/qnEhs5JlsvjkkIS6P/+qbb0tIfmOYNUPrK1NdsRgEeZbPS+gLu/Ne/Iwc3g4aySG30flVsAu9VtQ6C4nA3bE2p87S2gukzdgkCaUvDjLofPAtPr9Vnaizf8V8fttpxhIC8nHeZbvnKz+gkFAcgO+RzuWovL4pXJ5oUo56B8Ned3sCR4tobjEl+L3diyI7NAQUG2fdu7wglJ9hbPz+jux6EINl1KbYVq/1U0ykBcobRCrV+3gAiXlc7y1HRD0AulG/Vl5poqzno7H9c6mUDeRhmGtLZ1VwTd43TQStyP6KAZgNpKg8W7jSBGqn1xmWFP9ARJbHGrzuBPiTgoUQAWzDo3EAfMiyTYvk4Gat+Pe1mp02cEiXutKWFiq2e9MvF/w+NXWowmVenTs5DskppJta1wQbNKQmUZ2ieaprrtkZuSlt7cdYKo+ZYjMLJcO1mrcoGpT9gO0JYv1d7s1xLRiX6UbNj9LV9bbmrN21dJO27/6c0AYQ4OxRVth9YzlvpjCHloMPjv No/Mfepu lPefMzzEH6rim8clEcfZXVKT/M42OMV6eEQpOLYhIAVwr6HdPqTrZNDObfJ777diTKmib6DsL5JIlUzzNT7KulRHAjFJae6+96eTRUgzPU8qIp5XJGLkGPFH2IDN+zsJMBBPSxbM4lswbhBNQ6x0UuJfTqFW7TmuVvv8mfd1Qg/DVfjRhtRrHzhFKNIR0tmh5k1Ayf9YUIPR9s4GeVUsyRm/4eGfsihTzOmuGJj2qe/dhettOMBtqbhkl0v7lIs1UtEe+vSddpapVed/MTUsvHfaXMAFz0CRErZ2keY6VJSDmjNhJZhIalmaSGd89F48Nk3+grU4H5NUN+nSZVKnDwVjXk9IfcSZqpi8M6oXzMLn3bW9N5yom0KFDfMLc61xsbziVte6yc+lAF4SS+vvO/DAbxnN5jn5hvzHxbnGGTgCkEj70kE2siKYB49foWuzpZZd1BOLeX0skzUGLqOoRrZwNacTeUQpnmLZbncwC9pdriYigUvtB+p7xEd8qORucKEH+aSoMIXeN31RrCVqZb3fXl80RsJJqnIPTIn+WJUKSOHxo+XqFda1VkwKYgvjD7WqYbFGBxnHiBoadmszvtEp0RD8X5ttP/Jj5UU469YWEp2g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000016, 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 Wed Jun 5 07:13:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13686251 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 E1295C25B76 for ; Wed, 5 Jun 2024 07:13:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66CE56B009B; Wed, 5 Jun 2024 03:13:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61E7A6B009C; Wed, 5 Jun 2024 03:13:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 449E16B009D; Wed, 5 Jun 2024 03:13:56 -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 1172F6B009B for ; Wed, 5 Jun 2024 03:13:56 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D103D810A7 for ; Wed, 5 Jun 2024 07:13:55 +0000 (UTC) X-FDA: 82195970430.20.1E05A15 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by imf23.hostedemail.com (Postfix) with ESMTP id 0D01214000E for ; Wed, 5 Jun 2024 07:13:53 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=PqrDB+cw; spf=pass (imf23.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.43 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=1717571634; 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=/ZhubvrjOrd+neq1ixpki3J5siuGrNaURm4tNFASJmU=; b=5LyBRGUHh3iT+Imtu4nn7/4oeeUaGmxF7AmZnS8zVcAZfjsA6f8L1ETY/zNXt44fsnbfel chJqdgZDMgIVwccFdgsUOdQq/W6snD57ZczUXrGktuiTKft3flQ49mWuipGlC5m+sb7ktB XO46Oxic4oV00hcFI/QmtNaF0WfzHSY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=PqrDB+cw; spf=pass (imf23.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.43 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717571634; a=rsa-sha256; cv=none; b=CWlpfIT/yBdO7RU3c2wep1ZC/ppCGVHCGu0ReR1KuKRwKlDSqeM0WMzLKbGFjC01rr0jrz 4Cq07EO0Em4lOXMc7QsROfzVyQgpxsxLs+8yFKy8ef+TS7kFbzY2yjdpkFhLxFn+07RRmg LBfcATww4mCraig4kkUZi+ypGiXku/c= Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-57a85cc2d96so1733358a12.2 for ; Wed, 05 Jun 2024 00:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717571632; x=1718176432; 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=/ZhubvrjOrd+neq1ixpki3J5siuGrNaURm4tNFASJmU=; b=PqrDB+cwhkOA1Z/CmYn12Dgu3c12CnNrksq/hHZjdo0ZTIuIwBCFDRxxq2oUkw06nY gm5/yT+mzO6AY30j/xd151OdMnWJqJhDm8sk/d/53w8l/gPbGsOHqwPQM2toKC/PdFSD TteIRqHXbxotl0oYQdu73HPgu0dWKHlUdvwJGumXD+Xu8l5ePZr1lpGAzawVaHaOuW6u /r9lE0OQkRvWDoITkC49x7BubuPXEpI1I/HUk8hAdTPksfezGqeAEDU5YX/1gOYjThO0 RB5m7wksY2ynrlGkinNCSmMvdXW5Ex7ie+KmJvh0bPwNw1BCY1U4SJ47CDtr4JxQbqc6 0f4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717571632; x=1718176432; 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=/ZhubvrjOrd+neq1ixpki3J5siuGrNaURm4tNFASJmU=; b=tB9Yq3LCyPIGkeUuf+tFAyQQBS8qmPhcfkp0J4Ivl+xJD0JRNRRguymLrUKekkd2Nw 6dsfMTzj+2A6djwRS0r2Z+W1uc88fP2qaJ9KHcOabq3DH4ty7kikY1V7t78dL7sHDn8b sQ296nTGDEHy/D/9GfE19LjAVFkgmsVJzHc8Xawtwo5kdNwsqMU9yM3xkaZfUnje8z/V 7lOTcsyjx+TXGT4uPEuf6mcXtJqBj2Wz1WdgHttV+9Kww3FTMLJdHsM9MDyogEwJGlGI cgrtKCEt0EUlBFdsq8ul8JpEmymRmN2fPQAPhhqS4nTgqiO9OOqwzOg9QLRb+8JAA5HJ hbLw== X-Gm-Message-State: AOJu0YwQZGilLkrb8nAXD2py8WdETm+MFhh7xYeMlS2fSgLqJ8TChAUs yz3W38ak/2sDVFvCHAVrmsXiQHZIgwPxHNoZNizQNYziEWRObL34av+WTw== X-Google-Smtp-Source: AGHT+IEuHDdxlkpY6TA0RZ/jt4/4oTi8idliiMfC1ShpZiTBs6KdvccaXIy0LsbLIV1zNG9Lgux7gg== X-Received: by 2002:a17:906:4694:b0:a5a:2d30:b8c1 with SMTP id a640c23a62f3a-a699f680d76mr98649766b.14.1717571632032; Wed, 05 Jun 2024 00:13:52 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a687cc4e903sm683702466b.216.2024.06.05.00.13.51 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2024 00:13:51 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH v2 3/3] mm/mm_init.c: not always search next deferred_init_pfn from very beginning Date: Wed, 5 Jun 2024 07:13:39 +0000 Message-Id: <20240605071339.15330-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240605071339.15330-1-richard.weiyang@gmail.com> References: <20240605071339.15330-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0D01214000E X-Stat-Signature: cqufzmo5ctcghpxdx7ff8ma9x117yppm X-Rspam-User: X-HE-Tag: 1717571633-56527 X-HE-Meta: U2FsdGVkX1+6H9g3TqHw4o9tGRrZHlDBpvXnU7kAtVmT2u+8GAB17D+lGHENlOAGec0jaJUHbkQalqIG7JAOzyh1jGUQ3U5A6NcJ+dWMXpgoM1V/dYGK9JY0JcxK0rqGoMlmhWhnwW4/Ol5qIdZFOOGm8lunMTukt+tdXe+yD3bBwjmb7XmFYOn4qMIlIpR+JeAhT5dvpowXWfwMFxCwMRyVru+CVxA7z65TAl9efZjlH4FrzTCbx8ZdvicYzn5YhGVw2TbVWSZpQHFTj6hqpBi5j/a/ZlXoEvxkmtDTUV5oe4KRsN83+6wLWW+Ev/B7XY9bFp94rlzVVcVakxv3JYvhRGd3yB3SReWQA+NMqPQU5GLDu+MxzUaGD7q8G7OtESnGpWc6va6IovWZZM9orqF9Hrr+GXzVmurS0bDbmYHi3zZngSyk56Gn7m6iuT0QMkxMbNfGYyQDzZjb894GyKchdnIpi2U9dOLSjBf+q3PTRypmUu3dBalILQnH5C7WJZa/QcdCDdWtaqo3LoQ3t5YcdWrJcdr0lzyw66o02PO9KEdkfrOUworG/wELPTrZcxQRF5q5VqmCk7jK/XdZNhI3l9TTAchU5ntkZ25TndjvsZSjR15OGsD34oMd75GsMKsDh6TKFbJ2XV9Iz4QoD+rRlZ2SOFDKdq7/6ugDA6jsD9p4JQPfmJdDGmYhwqZ5xGpodLWgImryCzQk/4vqIO7qZMCWUTDTfAcd3ipcblS8MU+O8BHFua/gybVKc54Md+7i0450JjqOAH4v9khHHyf/wTo63soLA69IscUI9mC4OEkWRPCxcJDi7ylpUW2Sz7IQSp+sEQzstCV+hQ4wwGMTTgbQIHuRoaA04tTBFO0wVOO4hOe5EZT7pdNIOCf8rHxfRxXnH8514XB5koMj5h2ZRIwhZo0r/EwhEWomU/DYK8kPhJjBP8jmQkKAfNZWMIwjY3kfogOWWfbPmX9 4I91XVLX w9hL6+nWokJCQLRJ8WqDc6169OT6QOb/JHOxYqlOlDX80zPNZNOIYNhMStQTh3r+FXODd/Ww+6J/4TYHALVsE8PQiKbfuSMnUzoZb29YlbeOmg14JrJnZERZuuktE4DtknbcMkH4eDuOnqmi95oY2EuEVbQdSKxRk4HbJ/kh0Q/zVuGjR4OS+KDogIGErBfaW2HlN/o09uplgPx68qnPaZvw5NoyeFVOQV0hwMT8XNUVyP7oQFveWLxcNF4TRTIe5adKYzwTFzUnxNC86lAan2mRq6hQ3qLLp5XfxSylrHaQBK0EPeAqiT4pjElj60JiRBYq3uMTCokGhgvc9AAu/cUU4gLJ3JLYt3r+vqQMkCXKgaQx/bQjsa0s18veMKp3EsFdFEFHrQh7cKno1NS1JsW88/odKixZIxAqVxuP3DPqjzTfLJ2XSeeiFIaFCrTo/QUfkeM9/ru0Aocs7yRWQshu7v8y06akS1eLkEnrE7xqSsEXNNsbVPXo/c7wXWjPTHzEIBK8xnCzy2LoJDcz3AwS8GRS1mLKOpasR+yOQ8GGfflI= 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. [rppt refine the comment] Signed-off-by: Wei Yang --- v2: update comment instead of rename function name --- include/linux/memblock.h | 19 ------------------- mm/mm_init.c | 23 ++++++++++++++--------- 2 files changed, 14 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..c152c60eca3d 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2017,24 +2017,29 @@ static unsigned long __init deferred_init_pages(struct zone *zone, } /* - * This function is meant to pre-load the iterator for the zone init. - * Specifically it walks through the ranges until we are caught up to the - * first_init_pfn value and exits there. If we never encounter the value we - * return false indicating there are no valid ranges left. + * This function is meant to pre-load the iterator for the zone init from + * a given point. + * Specifically it walks through the ranges starting with initial index + * passed to it until we are caught up to the first_init_pfn value and + * exits there. If we never encounter the value we return false indicating + * there are no valid ranges left. */ static bool __init deferred_init_mem_pfn_range_in_zone(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,7 +2111,7 @@ 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); @@ -2137,7 +2142,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)) @@ -2212,7 +2217,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))