Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3711395pxb; Tue, 26 Jan 2021 02:47:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzG3HzDUfMzXiI09hYVdrXmqnX2cSqwW8izmsxreX0xpoqWHQMi476misCsvJhImOWWqHKI X-Received: by 2002:a17:906:409:: with SMTP id d9mr2967804eja.70.1611658047972; Tue, 26 Jan 2021 02:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611658047; cv=none; d=google.com; s=arc-20160816; b=FMR8WI4JCCv1vVrNT8/HWSAFbkzPAfAXwsmWpXqnq6lh5K97XvVJ+LlZhXk4LrWT+o DE7Qizz78knYlBpu6l9nwUMoWIpp+lUtIh5Qi/YcuexZ3/o7pbo1PtcJD7+d0hEfTHHN 5w6VQKcl6kaMMpZuDBsW3LMbDRVIkMVj6tgkd86LTm3SC71WrMpjjodaSTQ3Ntj750Hx SKSrqDEEp8YejrcRIoUf3gO95XKLW+R9g2ZeBxytwpAModCY8tLKPb+evaum8OOj11xV GJ+NIq57DJBZq/IrHr2an/ZKNo19A2owEcJ3QocnTWMpCG9wH7figDDGeR7+0un5oDzJ wroQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=gB8grb2B1oUDWyRRCssaxFw3EOzokVWQD1fRBFYa1d4=; b=N4FyBWxyIZhtC54s8UJO1os3lNB/JrQltneXEquLDgSb4+D+KmHqBz+4+VZddlSd/1 x+y5kppxPKfeZlugEgq/WBOGutfx5NpuKAoBqFAq8+nbCAk9chdAJ2+JIFsQn7elvoSL LtoZYJlUJ3ax4mTWJ2KUOqPCWgLEvaLr/2T/cGTu3fM3y5UxytoeL7C8Lq79uh3AcCl3 6kT3REp+s84YVuLWYCEXqL/rwZutu2Mgk13r3lVHd2UT+WUazB9CecQzOjkMaRZbTZJj aaNzQnMgz1HYW6XLt7/rAtQ4rDNkHbE02oQAmG8k8FFmiM0ujbUoVFPFk8Gy3R88kLvl AiPg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h16si7067738ejy.432.2021.01.26.02.47.03; Tue, 26 Jan 2021 02:47:27 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732167AbhAZKpZ (ORCPT + 99 others); Tue, 26 Jan 2021 05:45:25 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:11876 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730651AbhAZCIP (ORCPT ); Mon, 25 Jan 2021 21:08:15 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DPqpT3CBsz7ZQW; Tue, 26 Jan 2021 10:06:09 +0800 (CST) Received: from [10.174.179.117] (10.174.179.117) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Tue, 26 Jan 2021 10:07:11 +0800 Subject: Re: [PATCH v13 02/12] mm: hugetlb: introduce a new config HUGETLB_PAGE_FREE_VMEMMAP To: Muchun Song CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <20210117151053.24600-1-songmuchun@bytedance.com> <20210117151053.24600-3-songmuchun@bytedance.com> From: Miaohe Lin Message-ID: <474cca65-c184-293a-a71d-b373aae4dfb1@huawei.com> Date: Tue, 26 Jan 2021 10:07:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210117151053.24600-3-songmuchun@bytedance.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.117] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi: On 2021/1/17 23:10, Muchun Song wrote: > The HUGETLB_PAGE_FREE_VMEMMAP option is used to enable the freeing > of unnecessary vmemmap associated with HugeTLB pages. 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 > --- > arch/x86/mm/init_64.c | 2 +- > fs/Kconfig | 18 ++++++++++++++++++ > 2 files changed, 19 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 976e8b9033c4..e7c4c2a79311 100644 > --- a/fs/Kconfig > +++ b/fs/Kconfig > @@ -245,6 +245,24 @@ 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 > + help > + 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. > + > config MEMFD_CREATE > def_bool TMPFS || HUGETLBFS > > LGTM. Thanks. Reviewed-by: Miaohe Lin