Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7922954pxb; Fri, 19 Feb 2021 02:55:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwejKTwIgZTXcKvUPs7jfzYezAp3f51ozgaLTTJXjNoj4ApSnOuQv8TRsd578rU/h8P2HdD X-Received: by 2002:a17:906:70d4:: with SMTP id g20mr8359437ejk.361.1613732158992; Fri, 19 Feb 2021 02:55:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613732158; cv=none; d=google.com; s=arc-20160816; b=sVF2IHJ6VFtZdxCRvc0Z/GtEol9nKfGNz9PNdBjXMLB5Zw5mBPfGZcwfHUyHes5SGm uPlVL5jU9XjyF7j9z+dgdxiUTLsuYce2TpAOK67b3bwJ1WjrCgvYbqfawqlI2jbCPSP7 /6Hr94YHISbMfPcOHyGrR8oy9+9Ngp5KBkVj+AV/mSUW5JuWazl1JCWq5XfuABIlzmqT 2dg5XWI+MNTOxOC9XgCoDT/q32Wx0bXoU7tKnFoFDZ2mrpYEEV79RdOLDrH8MfAcp23z 12aSf2MatXUJRF73zuOzkAR3FQetI0+O7AAw5FYo5wVc5z1EmfDktJKIuD/7SsUmlS9N wZ9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/z4/inaUQyi6A7ziFBiSuphvc4zlbtBFhhYbLAw/G34=; b=ydBgHAmQhVMFKkM3sOpdm+L6+8EEnexa/CWA09afEYXsaHQSTkVsc9YYRBNOIYtjhR TyV+AFDWlzvQWfUjHn2sXQ81BydNjgmevhCPl1e/kWSQsWajaUMRg9Is2cKSDHCxXwda PWRy5/6PMuOY/GmDxj8JhOR+sYw9bDAX/FCWdSgpbiTbDWbjSJYYK7AJ4iQRqdR5riPS ChsyW/JOJr8v2tjxN1vbBm8EBGb7NBSR1UEabuWFR7MAd4ovgERX8pDQMyZHMCKNnreT zeV+Tclmwob+qZCS8mJB0AgiIiURh7/Fd+2AhjuLTbUufsPJWh6AAv9hyOKTUU4Orv7u d3Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=dTHGW2Gr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ca25si1745890ejb.9.2021.02.19.02.55.34; Fri, 19 Feb 2021 02:55:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=dTHGW2Gr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbhBSKxg (ORCPT + 99 others); Fri, 19 Feb 2021 05:53:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbhBSKxS (ORCPT ); Fri, 19 Feb 2021 05:53:18 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC5D7C061793 for ; Fri, 19 Feb 2021 02:52:20 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id o7so3778413pgl.1 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=SoRjuok5QFBvJJqUrm/F+IoCPvqiMrDC1Lsz9uuaTTulFayYMc1Nd7+k7qR5ykR8Xh Vckfjqts3dLm+ADCgR0rCk93IUYvKwFUX2U/kvyyfh7CE4+yT8VeU11TMJgKDsUGXNmA UoeYnmWPsnT9kuryCCovcnSRZPVvFshsh9WyhorKaW0ej5DboD8Qq89PvmEYxB5e4cE3 x3gq/3Yw+4B9t+RyMMtSsRmtYObmxynlcS8rb/c2xeiRydv5FRhuDTyT5uQ3/tFf5kBG gRcl25gswPEGQqy1tW4/tTaxX6Y76Tr+Yz2Oq78q1BAbs4oHDhDLG3LGoRKgeiMWqUIz SQ1g== X-Gm-Message-State: AOAM531MDvHi5DtHuHuclixMN6MC6jT+t41B4iXDDjeVYLxILqkOy+Rg O5oVeeBWtZh9UIIa399O3UJFMQ== 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.11.0