From patchwork Fri Feb 19 10:49:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12094989 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 0948CC433DB for ; Fri, 19 Feb 2021 10:52:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 821ED64EB1 for ; Fri, 19 Feb 2021 10:52:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 821ED64EB1 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 026EF8D0012; Fri, 19 Feb 2021 05:52:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F19EB8D000A; Fri, 19 Feb 2021 05:52:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE06C8D0012; Fri, 19 Feb 2021 05:52:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id C2E8A8D000A for ; Fri, 19 Feb 2021 05:52:21 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 82CA2181AF5EA for ; Fri, 19 Feb 2021 10:52:21 +0000 (UTC) X-FDA: 77834703282.19.DEB5639 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by imf08.hostedemail.com (Postfix) with ESMTP id 2272B80192E2 for ; Fri, 19 Feb 2021 10:52:13 +0000 (UTC) Received: by mail-pg1-f182.google.com with SMTP id t26so3781623pgv.3 for ; Fri, 19 Feb 2021 02:52:20 -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=/z4/inaUQyi6A7ziFBiSuphvc4zlbtBFhhYbLAw/G34=; b=dTHGW2GrZQlpZCCgS5ZGbbONBlwQ67ce+8mCMu/g5KK3ueEVcctzYjxaprsXTtbPGJ Yq9NXwoiKFoDETUkpr+m96ZD2lg7P1WqXsUavgtl2ohvjVdJ9cfbsGBovwDhldFU91Cf +1OUoo4ftVwOJpwt0oWmAc6yldLkuY2HEdz5TGqzKWHCSk3LKNruRlqm4EIdkzbc6xEP 9GZt9M9HlBL16qyEF49t82HbU+nV60t7h5e26EDBC5VhON1kDSQEXXizdaQB154IOWDN piK3eDp6mKC45Z0WnuMNi/vpyTQC7h4JIzSMJvoDIA0InFn+88jIfH/kI11xEyB76OnD nc5w== 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=/z4/inaUQyi6A7ziFBiSuphvc4zlbtBFhhYbLAw/G34=; b=pHsQ4bHRbLcWE03DZg0pnp6qTeMhWXp6X+w6r1gLyX3y4ZwZX4lDKDhil639JJl5+E rXksMsiXaAV+TDJTrWVFgTNt/ZauYdGnlsXDyrE7NjGgdV9F5omI1pXwGGbDf3D5HPaT mC0WB5kxH3hYoGRmruDjzH8O0FrraDi4D/EPARh+tQcj9mqaP5nIVSynTzJjuixgQx4X okqk9BgQH+0zlPXIrhnajdxYzLm5jZjq/t6377xSGjWUiKZ3Dkw4taQFMPaSqc+9O4lI ZDFn4tjbqb3BuiyAU6EbV+ExDbk1ZvYONRe9ZBLa3uVfiHdcSWyZMKbLOfejl25RZK4a XP2A== X-Gm-Message-State: AOAM530bUosLgj3DTieal/gc2CyxmiNDZVofItweSyYEBiZLnUU2hmoF wZSWbaV+PoSwEmu6+67l4LzHfA== X-Google-Smtp-Source: ABdhPJwOmS9HqudSELeMjO7sH1YZWGFBDRQ+Usrfu04u4QL8cAeQ4UBBNVPlDp0EZzgLb+Zm8DkQIQ== X-Received: by 2002:a62:8fd4:0:b029:1de:d484:e1f7 with SMTP id n203-20020a628fd40000b02901ded484e1f7mr8781404pfd.78.1613731940261; Fri, 19 Feb 2021 02:52:20 -0800 (PST) Received: from localhost.localdomain ([139.177.225.250]) by smtp.gmail.com with ESMTPSA id x1sm9662193pgj.37.2021.02.19.02.52.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Feb 2021 02:52:19 -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 v16 2/9] mm: hugetlb: introduce a new config HUGETLB_PAGE_FREE_VMEMMAP Date: Fri, 19 Feb 2021 18:49:47 +0800 Message-Id: <20210219104954.67390-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210219104954.67390-1-songmuchun@bytedance.com> References: <20210219104954.67390-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2272B80192E2 X-Stat-Signature: deahgtux5rxra7qpxsoax49s7wqywud1 Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from=""; helo=mail-pg1-f182.google.com; client-ip=209.85.215.182 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613731933-335561 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