From patchwork Tue Jan 17 20:46:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13105032 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 64C11C677F1 for ; Tue, 17 Jan 2023 20:46:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6B246B0073; Tue, 17 Jan 2023 15:46:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B1B476B0074; Tue, 17 Jan 2023 15:46:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E3356B0075; Tue, 17 Jan 2023 15:46:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8EACD6B0073 for ; Tue, 17 Jan 2023 15:46:24 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 591C314037E for ; Tue, 17 Jan 2023 20:46:24 +0000 (UTC) X-FDA: 80365473888.25.ECA74CB Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) by imf03.hostedemail.com (Postfix) with ESMTP id AF90520013 for ; Tue, 17 Jan 2023 20:46:21 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=kwox8c1r; spf=pass (imf03.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.217.48 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673988381; a=rsa-sha256; cv=none; b=pgIQsLmiTxTZyEuiX1PJ67JmSm1Kvr9dIBjsKMGW1cu3FzyIIwzcAOgvFRYpiTRP3TAUtE e0lIXpAYOb/D7iDdnDRHz7KsOjpu7+18647uvs/CijvOEIyZcXu/n+wcSI0fDpibfq41KZ c5er1C8YrN88RENj2jvOwZoJqE1irx0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=kwox8c1r; spf=pass (imf03.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.217.48 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673988381; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=ZmTkDMG76LtnP3d5zwBqn09xe+8G8F7vZ7HUcNnedBQ=; b=ZPx30XPJtVLGD1t9KfaYtk3SmT/MTFyqq3ZNxEZaZfbY04WPZ2ba54QVIQqRKhkPdV2zZw V0YiEAR2QE9v1zGQfd7PYfUJIRMFlucQ0auspyodBWqSdSTjHjB+9/FVeEFMw4oNv0ykrf r2vqb0qSD9YXyy8ucsUXbH/rujrri5A= Received: by mail-vs1-f48.google.com with SMTP id q125so21839226vsb.0 for ; Tue, 17 Jan 2023 12:46:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=ZmTkDMG76LtnP3d5zwBqn09xe+8G8F7vZ7HUcNnedBQ=; b=kwox8c1r6EFxK7FAaH08JtL7Sl+/rseUqoPyXySjH/FD6YBxd3eWCQ2WJcX6ENppUH BHgPzAdDWgK1Y2Gl7dpRbaR59aHLM1pJu0Rk7L4M+YDwt6c8yTimZCw0s4tdCy26SX5G 2nyvXIys5V6KiCuDK1KIpUOji0Yv6+X0vS2nbxS+lW0VWBsJFhDmrc24PahipoCmXxXK 1neoidWeSQmAZLUJRXZMwFzX2EVRfK+b0/fPRVgwPN3mlynfn6XFiy+BalH3Atv6gEwn Qzof7SVPDBNajsSH+SAbrC6MQnj2kU+JsGQjouOGRqZ1P6YRCL5s3V0cka9CJb9Lu9gW goVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZmTkDMG76LtnP3d5zwBqn09xe+8G8F7vZ7HUcNnedBQ=; b=pHr4h4ecX90mN7neYEnNByVVCw2C9QgOt3WfI1qRHHfnO329yNw6LTos5f8gh0fM1q 1AGCLEDs6AX3IUTNisA0p9fZLl6Dhsn0GScxfRFWtbFV9s2XavjLOfSUu1/pkLoZp/NG FnTnlWQESZynRyN/+uloWWl03THNbYhTTqALEInscO4g7c4dCx3Y4ZqpqkDnATPR4tB4 dzEHP1Im7hdZCHrL7ew5y/mNwvL9kbEGlx9xUJ8FekISJv19zZw8uofEK6sY91atuu/l IKZjQl8DlYQuWtfKWWNWqzt2ue/+y/2tdtADCkKwuqbneLsgZfOJrdzKb6HSeXCf+3yn 0jOw== X-Gm-Message-State: AFqh2krqoxo1bG9kL2DRG342o5+RZ1Na0/7E9xkXlLbytERkuGQM35xT 70JSOirngutGxy4gcLnwahEg3w== X-Google-Smtp-Source: AMrXdXv7HOGWMOYatLm5GB8kzSH2OsvxQTTpLlhFPjkZucKddcElWy5Fv+RF6Qc6ZjQAbtuZjCviKA== X-Received: by 2002:a05:6102:32c7:b0:3d0:a805:e6af with SMTP id o7-20020a05610232c700b003d0a805e6afmr2425156vss.15.1673988380818; Tue, 17 Jan 2023 12:46:20 -0800 (PST) Received: from soleen.c.googlers.com.com (193.132.150.34.bc.googleusercontent.com. [34.150.132.193]) by smtp.gmail.com with ESMTPSA id h18-20020a05620a401200b007064fa2c616sm6463581qko.66.2023.01.17.12.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:46:20 -0800 (PST) From: Pasha Tatashin To: pasha.tatashin@soleen.com, rppt@kernel.org, akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, david@redhat.com, quic_charante@quicinc.com, lizhe.67@bytedance.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] mm/page_ext: init page_ext early if there are no deferred struct pages Date: Tue, 17 Jan 2023 20:46:17 +0000 Message-Id: <20230117204617.1553748-1-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: AF90520013 X-Rspamd-Server: rspam01 X-Stat-Signature: 6qkciynqz8p169pjxidoaa1ngyd3p6dm X-HE-Tag: 1673988381-60917 X-HE-Meta: U2FsdGVkX1/IbyOSUNJWDA9cXO52PxklruI4qqSpOAEp6H1DNUZ/+oZ3RHqSzlp/viqWyUhLpKAaqDBvc5CbwF03oKsZIrUdRGe/Dieqhl0+GEMu9IepHQ8rHB/evpZu6TU02zmywHTi+eT6jHj6v/c+cQHn63z6mw+jNA7JtgWNCFcMwcu7iXFuKIMMvHWtkqKEB+/cWICBKuHvrhD0CR9+00YKUgM4WjLyUhcJ6hhs8XyqM+vHfWPvOFPSzez0G47R8oUZlJt3vZjQKs3tdEUBEPCoHAypL9ufBwIwL2kkiKOrf6wD20RyEUTIHf/hylzH7t+K1BrXTyqCIyfq/n/cpp4iEXZjh3PEIPTz+vU0EAgpUYBG+PuksGEy7s4NXXFgWL1tOJUtrQNYA2pSO1Jx9gdB/7c9cfg1sAQ3hjPhovOhx13ADjDuKu89cZvjcSUNbKJq/uaYQ8bNoqDmoEwtzq5+se52lT2Jc/ROlcLUoxmbdq5k1+t13/9sS7rncpG2kFzcCYxAjOCrILZaR1dI16uXAvIyO4Rvrmehyezqw5ZAtATc1jvGd+m2vtXsSjGjZq/VFynh7dn7A7glYxwis66jgPIWJhuOLz5WDkHXz6/ScOVoqqQfPCu/vnFKMtOj/j8TLWZRSKl5qxBDrXRHAjugCFPKoFm/QFBN/Lw9I3156ihJsGFDcQTOkVQY5GhlC0kG8aqFSkvf8lnRSMCrBkt61BkvESkjv7jWZiJvEwQ7Hc5yu+8qim2XHOxt1p9DzKrVnNVVrCTHllcuPLKbz9XbAVSNSz7dKfs+R71Gf4QfUMkq9IxwGff9LIAFRQfkIKEa6V4vwwCPuzdvckR2IuAeY6O58pCS7JkQdYNmfDU0xH2y3EpWw3DJO7E3npzakcrdiylps+A4BIWerfTtKxouxW2p80+5IZ/zCke8D2Pr//Vbdl2qIYmQ0X7LUstNIXjDAi8RsC1p1mF N6PxvHwt 7dkOGJUAVvt7u35e0v3q4iagwtVcDeTbPST6M/Hbxt77KOkR7XMGfbQRRPYattBs39wa9iKRIZjtGTTpFGKWwTspUm1R/2v9vuKrT8ovLQAJ9kXaNsARG8QaYPPFbTA8nPfsryzIJmTh6cuMZIBdrtTalRA== 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: page_ext must be initialized after all struct pages are initialized. Therefore, page_ext is initialized after page_alloc_init_late(), and can optionally be initialized earlier via early_page_ext kernel parameter which as a side effect also disables deferred struct pages. Allow to automatically init page_ext early when there are no deferred struct pages in order to be able to use page_ext during kernel boot and track for example page allocations early. Signed-off-by: Pasha Tatashin --- include/linux/page_ext.h | 1 + init/main.c | 6 +++--- mm/page_alloc.c | 6 +++++- mm/page_ext.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h index 22be4582faae..1e9bcc37a342 100644 --- a/include/linux/page_ext.h +++ b/include/linux/page_ext.h @@ -36,6 +36,7 @@ struct page_ext { unsigned long flags; }; +extern bool deferred_struct_pages; extern bool early_page_ext; extern unsigned long page_ext_size; extern void pgdat_page_ext_init(struct pglist_data *pgdat); diff --git a/init/main.c b/init/main.c index e1c3911d7c70..64cd2ff051c4 100644 --- a/init/main.c +++ b/init/main.c @@ -855,8 +855,8 @@ static void __init mm_init(void) pgtable_init(); debug_objects_mem_init(); vmalloc_init(); - /* Should be run after vmap initialization */ - if (early_page_ext_enabled()) + /* If no deferred init page_ext now, as vmap is fully initialized */ + if (!deferred_struct_pages) page_ext_init(); /* Should be run before the first non-init thread is created */ init_espfix_bsp(); @@ -1628,7 +1628,7 @@ static noinline void __init kernel_init_freeable(void) padata_init(); page_alloc_init_late(); /* Initialize page ext after all struct pages are initialized. */ - if (!early_page_ext_enabled()) + if (deferred_struct_pages) page_ext_init(); do_basic_setup(); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0745aedebb37..5a3e0f00f31d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -430,6 +430,8 @@ EXPORT_SYMBOL(nr_online_nodes); int page_group_by_mobility_disabled __read_mostly; +bool deferred_struct_pages __meminitdata; + #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT /* * During boot we initialize deferred pages on-demand, as needed, but once @@ -6761,8 +6763,10 @@ void __meminit memmap_init_range(unsigned long size, int nid, unsigned long zone if (context == MEMINIT_EARLY) { if (overlap_memmap_init(zone, &pfn)) continue; - if (defer_init(nid, pfn, zone_end_pfn)) + if (defer_init(nid, pfn, zone_end_pfn)) { + deferred_struct_pages = true; break; + } } page = pfn_to_page(pfn); diff --git a/mm/page_ext.c b/mm/page_ext.c index 4ee522fd381c..918e2e131ab0 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -91,7 +91,7 @@ unsigned long page_ext_size = sizeof(struct page_ext); static unsigned long total_usage; static struct page_ext *lookup_page_ext(const struct page *page); -bool early_page_ext; +bool early_page_ext __meminitdata; static int __init setup_early_page_ext(char *str) { early_page_ext = true;