From patchwork Tue Nov 24 09:52:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11927809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CA7AC56201 for ; Tue, 24 Nov 2020 09:57:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A65BD2076E for ; Tue, 24 Nov 2020 09:57:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="B7s2QSZd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A65BD2076E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 30DB56B0083; Tue, 24 Nov 2020 04:57:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BAD06B0088; Tue, 24 Nov 2020 04:57:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 135A76B0083; Tue, 24 Nov 2020 04:57:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id EB4E06B0081 for ; Tue, 24 Nov 2020 04:57:57 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B1DBB8249980 for ; Tue, 24 Nov 2020 09:57:57 +0000 (UTC) X-FDA: 77518860594.15.eggs12_171017b2736d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 907B51814B0C1 for ; Tue, 24 Nov 2020 09:57:57 +0000 (UTC) X-HE-Tag: eggs12_171017b2736d X-Filterd-Recvd-Size: 5240 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Nov 2020 09:57:57 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id l17so6551805pgk.1 for ; Tue, 24 Nov 2020 01:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oSUrQajIlhHrZQJhWJQy1InopKyNlwdkkxQ0BvZwQN0=; b=B7s2QSZdwKs6D656MgfnkoLqCCJ2k2pYSfIOnNWNNwqAEh9uEpIuiX6LDtbE178WrC jjuUSq3hI3hM9sGyUKnOwI2f/d9Q40hQClsq9HYgFoO3ChJdL6Qx7I6vsp2nbvr1gRts qcBkPfLQu3qC95KdnFaki+XdTFWPz/K1bW75zQR8DP+pwj+gpuQifRbQCErRjYqaOurf KXWOnmuvUSM50zWK0gtccC3PATob4pad+REin14akFJ0RKcNtv2Fap12YEtyFV5pE4bc jwRhZFLQOH/bxopGPWardMumil0DeJldoqEwMI4vR86WvTDOOwS4e5JZPH+pDNUxWuEv wO0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oSUrQajIlhHrZQJhWJQy1InopKyNlwdkkxQ0BvZwQN0=; b=SP6dS1h2W2sXMcxuWT13auravHu/AEfQ16Fe/I+dtbJY4M5X+CtkG70IutHkD5hoJU 021usXsH+CnHWhbIQ96OY/hwbWgU6HVgmFxy8j7mqR5Ji7ngpQ9NCooHYRPAXbZeeJqr KSKc2cTgG35z5HjfEVDj+CiZLONdbZXZmmqgIyG+hwdFHslXSPsEs3l9GHSzKD5cP5xG U1C3UpnQpGeUgtiFzG8w1d8cQT/70tZ001K0Vv3T1nVcMPgigC46eSeaKGq5oa7C/dCp +7DmAV3wA7xaKXPM/ctSMOnqifhlR+BnBrDb3Pwojc5zSB/rzzeMg29YkzIrP//B6RJx 0sGQ== X-Gm-Message-State: AOAM533TrAH0ZIPkHJg4uEpakSbaqzUv9SIG6woghtG6TPVS5iZ8WBtp 8PEJ7f9WFivEx4AzCAllI5aBmA== X-Google-Smtp-Source: ABdhPJyMrb78F1w9ZubIENSfiY4yzl9F3+dQeY4OKhrOsOuJH8YxUhUghcDgoJFYUmMbp5zY3YWt3A== X-Received: by 2002:a17:90a:f406:: with SMTP id ch6mr3827991pjb.134.1606211876417; Tue, 24 Nov 2020 01:57:56 -0800 (PST) Received: from localhost.localdomain ([103.136.220.120]) by smtp.gmail.com with ESMTPSA id t20sm2424562pjg.25.2020.11.24.01.57.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Nov 2020 01:57:55 -0800 (PST) From: Muchun Song To: corbet@lwn.net, mike.kravetz@oracle.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, rdunlap@infradead.org, oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, almasrymina@google.com, rientjes@google.com, willy@infradead.org, osalvador@suse.de, mhocko@suse.com, song.bao.hua@hisilicon.com Cc: duanxiongchun@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Muchun Song Subject: [PATCH v6 07/16] x86/mm/64: Disable PMD page mapping of vmemmap Date: Tue, 24 Nov 2020 17:52:50 +0800 Message-Id: <20201124095259.58755-8-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201124095259.58755-1-songmuchun@bytedance.com> References: <20201124095259.58755-1-songmuchun@bytedance.com> MIME-Version: 1.0 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: If we enable the CONFIG_HUGETLB_PAGE_FREE_VMEMMAP, we can just disbale PMD page mapping of vmemmap to simplify the code. In this case, we do not need complex code doing vmemmap page table manipulation. This is a way to simply the first version of this patch series. In the future, we can add some code doing page table manipulation. Signed-off-by: Muchun Song --- arch/x86/mm/init_64.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 0435bee2e172..155cb06a6961 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1557,7 +1557,9 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, { int err; - if (end - start < PAGES_PER_SECTION * sizeof(struct page)) + if (IS_ENABLED(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP)) + err = vmemmap_populate_basepages(start, end, node, NULL); + else if (end - start < PAGES_PER_SECTION * sizeof(struct page)) err = vmemmap_populate_basepages(start, end, node, NULL); else if (boot_cpu_has(X86_FEATURE_PSE)) err = vmemmap_populate_hugepages(start, end, node, altmap); @@ -1610,7 +1612,8 @@ void register_page_bootmem_memmap(unsigned long section_nr, } get_page_bootmem(section_nr, pud_page(*pud), MIX_SECTION_INFO); - if (!boot_cpu_has(X86_FEATURE_PSE)) { + if (!boot_cpu_has(X86_FEATURE_PSE) || + IS_ENABLED(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP)) { next = (addr + PAGE_SIZE) & PAGE_MASK; pmd = pmd_offset(pud, addr); if (pmd_none(*pmd))