Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp592271pxb; Thu, 15 Apr 2021 01:44:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvTzL7DG++R7fj2aj3k0CGS73ySfB2fNPAnb2zfZpV23EYd9aCbgKcbckDOTalWsTAr/aC X-Received: by 2002:a17:906:4c91:: with SMTP id q17mr2331795eju.0.1618476273859; Thu, 15 Apr 2021 01:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618476273; cv=none; d=google.com; s=arc-20160816; b=JY1Vc1tZbGa/J/XIDEuUsUd/e4gQ7QCUNPHDsQRi9VyWFZPhJeq4qz7ZKYEXzxmVel mXu6kZUI8iMCVUtUJWauecPZHR4uOGkulmHBCcG9/M2Ql5gTphj95U0x8Pn+MlevsJaf EEZaSHByoKyJ8sraQ6aksjJuQZOq/+ytTMjmo5KYv0QC4pkriNUvMANUm7kZLV7LlX+i LSAW25tzGeLvxiZTDzfJDf/VD7qGeCvjymJiXYhpWh3VvU30jIT9VM/VYzQqk9vriZG+ bLSFCprjr2kC70CocMUOP0+jnRZobIV4CrKKTCO1Fzd5gLJhqxbtvuHiNSn8y6ZVunsJ Hhag== 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=SoZb++zfv4yAwjnBuF75FK8ZgZmHYksA4MNIPLiTWic=; b=n9hq6cjgh9DZLofhb1GOsmjKmNhyq009frVqoLWPxBFZdkJN2LQnASRkEBT1huzTHe RtCKWpNti5hrLSnrc+y333t93Vg8+z20NPfhVdCNV1bBLDeKxka1Gyy7GytjjOkmKyWr jXLIY9gHnvDH+BVurEXPP42bp6GjrXnqAgBlwT661Qn92o2qkoZeNQEU1UmJg0cAF2BX kerSh28ISq+1TTppiepK/5ZGmsZCuC7tRvhJi+tt87r+NU2btMxWE/ERzhjU9btzKksc 4HjxDM2fMeQVgw66RrErDNteB7uNprwrGIfgiMfyGoBLePhUulU9ui7BK9WyJ5ezuD33 wIfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=qb4x4kPn; 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 hd34si1707472ejc.197.2021.04.15.01.44.10; Thu, 15 Apr 2021 01:44:33 -0700 (PDT) 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=qb4x4kPn; 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 S231922AbhDOInK (ORCPT + 99 others); Thu, 15 Apr 2021 04:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231902AbhDOInE (ORCPT ); Thu, 15 Apr 2021 04:43:04 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FDCBC061574 for ; Thu, 15 Apr 2021 01:42:41 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id m18so9455588plc.13 for ; Thu, 15 Apr 2021 01:42:41 -0700 (PDT) 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=SoZb++zfv4yAwjnBuF75FK8ZgZmHYksA4MNIPLiTWic=; b=qb4x4kPnL1dlpXI/+d0gpkF9kwYzBftXjo9PWqIU+lemjVOupYoguZKtb3/kCWI/mA T9JH4OZFrCtydpvncc4zCUgGk6vtkX7DUfps28LPiF2CQjU+dSmQ8bBSEpkKk4ne6rhK 6yf9mefEVL7Mj17r33WvTPAvFZkVKDKuPHKB7BuJNleKt/82bfR+1hwlKwec4Ts2CFNY MnQNsL1wYBWXbPnU5p6kkIspVCmbqqzPWvgQXKAAh6qG2D5iOdz+Lx0iyqlBrHuetu1t OrInlgTR0i7KbWcXGiSWYs82WBbE93RYJV+Jgh4OIIg1mbtCwYiQyK7MckgrwHKEdUoe Df5w== 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=SoZb++zfv4yAwjnBuF75FK8ZgZmHYksA4MNIPLiTWic=; b=k7bgY1quVAeaRrcX+jLxzSQQd2IJIZTEWb0EJFc3nxOQ18gMxd/6ntaEHLmS97EdTz 4AbrsOEkaCEIfvFbC7jBiSoF6aXYP1WrcARwQUsi+NbYmPw+DYCohkEmPgKWE98GHxd5 z0rNt+IkyOGB86mCKxVvUDnBZ8D8YZcL1mMDAX59g4s++PnLynTmeIEja6GaTDTNCZ+N +cr5PDo9apvtq17HQAhrYkHi/4/n+D+Z1OBx5fpsCEVGaXbR8vCpZPQeyT+5EP08lWZA gp8bJRIYfOWdEn1ny9dCd3ho9B/jwUXtG/K7ve2hEo94ttLg80RBqZdAaqTvgA8UBaCA 5Z4A== X-Gm-Message-State: AOAM530Va4cRdpnfmfTjiS/ecnzpBRmKeiQ+L1R/qrSmBmmzbgAQO47B 0JR3qABsdIDmSH1TlP2ow+ePGA== X-Received: by 2002:a17:90a:6be2:: with SMTP id w89mr2653717pjj.130.1618476160886; Thu, 15 Apr 2021 01:42:40 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id e13sm1392365pgt.91.2021.04.15.01.42.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Apr 2021 01:42:40 -0700 (PDT) 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, 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, fam.zheng@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 , Chen Huang , Bodeddula Balasubramaniam , Balbir Singh Subject: [PATCH v20 2/9] mm: hugetlb: introduce a new config HUGETLB_PAGE_FREE_VMEMMAP Date: Thu, 15 Apr 2021 16:39:58 +0800 Message-Id: <20210415084005.25049-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210415084005.25049-1-songmuchun@bytedance.com> References: <20210415084005.25049-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. If config HAVE_BOOTMEM_INFO_NODE is enabled, the freeing vmemmap page code denpend on it to free vmemmap pages. Otherwise, just use free_reserved_page() to free vmemmmap pages. 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 Tested-by: Chen Huang Tested-by: Bodeddula Balasubramaniam Reviewed-by: Balbir Singh --- arch/x86/mm/init_64.c | 2 +- fs/Kconfig | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 3aaf1d30c777..65ea58527176 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1270,7 +1270,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 dcd9161fbeba..6ce6fdac00a3 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -240,6 +240,11 @@ 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 + config MEMFD_CREATE def_bool TMPFS || HUGETLBFS -- 2.11.0