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+gL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ttP/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));