From patchwork Thu Feb 4 03:50:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12066233 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 C9532C433E6 for ; Thu, 4 Feb 2021 03:54:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4295564F3C for ; Thu, 4 Feb 2021 03:54:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4295564F3C 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 B15A76B006E; Wed, 3 Feb 2021 22:54:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A9E786B0070; Wed, 3 Feb 2021 22:54:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F0946B0071; Wed, 3 Feb 2021 22:54:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id 72CE36B006E for ; Wed, 3 Feb 2021 22:54:19 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3A69C1EE6 for ; Thu, 4 Feb 2021 03:54:19 +0000 (UTC) X-FDA: 77779217838.01.wing17_30001e2275d9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 1D98A10047E06 for ; Thu, 4 Feb 2021 03:54:19 +0000 (UTC) X-HE-Tag: wing17_30001e2275d9 X-Filterd-Recvd-Size: 5866 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 03:54:18 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id q72so935920pjq.2 for ; Wed, 03 Feb 2021 19:54:18 -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=rbaYTNYcnNCF5suT1Rnzl4fKBboUgz5smm7iB2s2QLo=; b=BZ9xMp3YtuJbJlv/cWJQps/Tpdxkv3meqtQufoGBj7IPb11hqwXzbvaTSBp0UqKg6T k8PmO7u00wNYkFfNARE+khYCQBrgi9HeU4C40Vbd+k32LaDwwZzikdIIG/JMfQzN62Nr zbCTYPTS8JL3WQZq711tY1VUMY+jriby99Ae6nDbubzItBcSfHUNHogoAY6b+VlW7qBe thr/geWt1x6v7paRRP8bU2CvSpyC4Bg4FrOjTlJ7aGZBZvWv3Tjfbn5BNyHVlW9qCxdI nBKpLmddjx3rW4/khv0BFx8cTDiBZcikuDSB+O64S71OFfgJwCl8ISRrjWStLnYLlM6i tevA== 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=rbaYTNYcnNCF5suT1Rnzl4fKBboUgz5smm7iB2s2QLo=; b=rbDY5kvT3dJHYnMrusUKcpmWFb/wH87sFACw52tG9c43ZxF4HfkA8G+yk8f3EV4gS/ 7TTngyFezqedJTKn63bKPZnsM4W6lcjr3pSrpnf/SCHq7mO4IbyYQ6mymxhBnYRsOuJW Ox/cdHvdO7BtNjN5iUYaAGTf+S8Ai3ZNrj0tsqxM79sPdP5CRq+YWR0JkjN8H0LsCd29 qgFy1/15NJCiDKkQzxc2ms1LW7/9SN8XutPglzDQ70b6hMrqVTdBPaZ7txtcU4MFISn7 rBZYYLsX+qjGSDpMHNV4yd4c2N9SzVaXxHk8/D72ZlMjdNDdSd3DBX/xPo4gPf7fq4Op 3PoA== X-Gm-Message-State: AOAM533AseCXQipN8Iq4/jBksUtVzDDIAVaLlq0tRXqaq5HoDR46xsyD VwrZ1xnXaXNob4p4iHntiuaqRg== X-Google-Smtp-Source: ABdhPJwYg71Pe1QhU5oYCWBRke57VHrFd8GAEfIocOsjtaS43HRiEMVdR+bZjyHFtv6psvkU3njfNA== X-Received: by 2002:a17:90b:3886:: with SMTP id mu6mr6231566pjb.153.1612410857508; Wed, 03 Feb 2021 19:54:17 -0800 (PST) Received: from localhost.localdomain ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id 9sm3747466pfy.110.2021.02.03.19.54.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2021 19:54:16 -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, david@redhat.com, naoya.horiguchi@nec.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 v14 2/8] mm: hugetlb: introduce a new config HUGETLB_PAGE_FREE_VMEMMAP Date: Thu, 4 Feb 2021 11:50:37 +0800 Message-Id: <20210204035043.36609-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210204035043.36609-1-songmuchun@bytedance.com> References: <20210204035043.36609-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: The option HUGETLB_PAGE_FREE_VMEMMAP allows for the freeing of some vmemmap pages associated with pre-allocated HugeTLB pages. For example, on X86_64 6 vmemmap pages of size 4KB each can be saved for each 2MB HugeTLB page. 4094 vmemmap pages of size 4KB each can be saved for each 1GB HugeTLB page. When a HugeTLB page is allocated or freed, the vmemmap array representing the range associated with the page will need to be remapped. When a page is allocated, vmemmap pages are freed after remapping. When a page is freed, previously discarded vmemmap pages must be allocated before remapping. The config option is introduced early so that supporting code can be written to depend on the option. The initial version of the code only provides support for x86-64. Like other code which frees vmemmap, this config option depends on HAVE_BOOTMEM_INFO_NODE. The routine register_page_bootmem_info() is used to register bootmem info. Therefore, make sure register_page_bootmem_info is enabled if HUGETLB_PAGE_FREE_VMEMMAP is defined. Signed-off-by: Muchun Song Reviewed-by: Oscar Salvador Acked-by: Mike Kravetz Reviewed-by: Miaohe Lin --- arch/x86/mm/init_64.c | 2 +- fs/Kconfig | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 0a45f062826e..0435bee2e172 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1225,7 +1225,7 @@ static struct kcore_list kcore_vsyscall; static void __init register_page_bootmem_info(void) { -#ifdef CONFIG_NUMA +#if defined(CONFIG_NUMA) || defined(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP) int i; for_each_online_node(i) diff --git a/fs/Kconfig b/fs/Kconfig index 97e7b77c9309..de87f234f1e9 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -237,6 +237,12 @@ config HUGETLBFS config HUGETLB_PAGE def_bool HUGETLBFS +config HUGETLB_PAGE_FREE_VMEMMAP + def_bool HUGETLB_PAGE + depends on X86_64 + depends on SPARSEMEM_VMEMMAP + depends on HAVE_BOOTMEM_INFO_NODE + config MEMFD_CREATE def_bool TMPFS || HUGETLBFS