From patchwork Thu Feb 25 13:21:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12104105 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 BE549C433E0 for ; Thu, 25 Feb 2021 13:23:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 357F664EF5 for ; Thu, 25 Feb 2021 13:23:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 357F664EF5 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 B2A878D0021; Thu, 25 Feb 2021 08:23:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADA338D0005; Thu, 25 Feb 2021 08:23:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 953E38D0021; Thu, 25 Feb 2021 08:23:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 7ED598D0005 for ; Thu, 25 Feb 2021 08:23:58 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4C1B99982 for ; Thu, 25 Feb 2021 13:23:58 +0000 (UTC) X-FDA: 77856858156.15.0FECB47 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by imf29.hostedemail.com (Postfix) with ESMTP id D5D4D139 for ; Thu, 25 Feb 2021 13:23:57 +0000 (UTC) Received: by mail-pg1-f170.google.com with SMTP id a4so3749610pgc.11 for ; Thu, 25 Feb 2021 05:23: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=ZRxLQEtAZMF7ynint68drnOS3AOgo+lUwQuMfO8HfyU=; b=bGWvFZrSNsgfHLr0ndyhmQ/W8MpRAjEhFK16bykd8rK0MPQMSNokOfsjdCXRosek+b BgQhCIjQRXjEL0D96Sl+/WL9GKQ+xSLO4g2eSz6Ps4Ox7p1wtAbpaQZNpLa6cTyIcx/A cF2IdS7GUwez0O2ziSwCFvuQuGj60r98Cinnj5FOTo0MKT2jG/k8/Sz4GjkZE58Oo/zk H5bJ8FtASUuYskjULgTa0DrjEq+mfIXLy3XPUlJbGNp/xcGqtDHTS/q5RMrO0Cgo/2ki ezGlWDRrD0HqmyBHu8YE8OLGrpbYfdQMXzW2f3CjtpS6RdcFmUvhKjGVpEw3yFkcoW9v Ow0g== 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=ZRxLQEtAZMF7ynint68drnOS3AOgo+lUwQuMfO8HfyU=; b=tGA26Y3EumxbNIjpa5Qxy0WqfzNGjfQryXH0bIVMm279rClRG5L2bYtzUuP8KaiZVC 5lpzpYs3tOr1JKo/uctYun5Kz5jCn1cu02B2Y6FCZ3QZVKcRRcWqnzrg+AQVsqH5Tmwp HV4Un68Y8neRbiz0rhTSPt3x6QHv9vVLYw8QMcbFXf4x7P3NgHsdKyHsFMsdxXldoZrQ YtVGq8aMS1wuzxVP7RYQjeGj1Y0hHcGNJHPezXFeY7x3iPoh6h+gRCaQxFdawRUtcNCo MOqGv1amH4xLrEp5PriRAed3h+uuOwTkLX4z5wWMIYRkfkdjw2g33GUDSHJC3O7CoQa2 kApQ== X-Gm-Message-State: AOAM530pQ7G/ZgnbbOIc6ID3827CT8Y8UxIica8vELKjTBpNHKQY7kuo d1LKXuzLOZwYK2X7Zu/1SdlLmw== X-Google-Smtp-Source: ABdhPJwFfKYHCSSTYgjRwYWqzJHWCMHhEBoS+v9+A+Fh/MnSpP9c6ac19THyCKs92XLKFiiS1L2msg== X-Received: by 2002:aa7:973c:0:b029:1ee:193b:6092 with SMTP id k28-20020aa7973c0000b02901ee193b6092mr2682444pfg.59.1614259436992; Thu, 25 Feb 2021 05:23:56 -0800 (PST) Received: from localhost.localdomain ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id x190sm6424676pfx.166.2021.02.25.05.23.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Feb 2021 05:23:56 -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, joao.m.martins@oracle.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 , Miaohe Lin Subject: [PATCH v17 2/9] mm: hugetlb: introduce a new config HUGETLB_PAGE_FREE_VMEMMAP Date: Thu, 25 Feb 2021 21:21:23 +0800 Message-Id: <20210225132130.26451-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210225132130.26451-1-songmuchun@bytedance.com> References: <20210225132130.26451-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Stat-Signature: mknbk6wj71a7uumw1dc347orrpyfxh5o X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D5D4D139 Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf29; identity=mailfrom; envelope-from=""; helo=mail-pg1-f170.google.com; client-ip=209.85.215.170 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614259437-727162 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 Reviewed-by: Balbir Singh --- 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 eccbcf1e3f2e..b5dcc68aab25 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