From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 1CEBCC4361B for ; Wed, 16 Dec 2020 03:25:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4EBCD20700 for ; Wed, 16 Dec 2020 03:25:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4EBCD20700 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 6F52B6B0036; Tue, 15 Dec 2020 22:25:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 67DFE6B005D; Tue, 15 Dec 2020 22:25:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 520C56B0068; Tue, 15 Dec 2020 22:25:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0031.hostedemail.com [216.40.44.31]) by kanga.kvack.org (Postfix) with ESMTP id 36A2F6B0036 for ; Tue, 15 Dec 2020 22:25:01 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F07B8180AD81D for ; Wed, 16 Dec 2020 03:25:00 +0000 (UTC) X-FDA: 77597703960.14.tax71_3e1632927428 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id D362718229818 for ; Wed, 16 Dec 2020 03:25:00 +0000 (UTC) X-HE-Tag: tax71_3e1632927428 X-Filterd-Recvd-Size: 7780 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Dec 2020 03:25:00 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id lb18so721221pjb.5 for ; Tue, 15 Dec 2020 19:24:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DnjH3+59C2HesEkci6o2tYhXJ5O1oMeATLk3gN2lfbg=; b=H/9T2Di4Pe5rI0y2nVUFZ3UMm216WYTE9Xf04MP8zhn5RjRWrRdwoQPP1ZdIskjwCa 0ctDKAtETaY9G7isbgjYkIf5DYftsCeExeXvEWyNO5KUVqgo0FsoVIt5n4206Rh/C1u3 DqrTfdrwwQoXKUZvKWIIr6CuET9zfMcIsDN9AZv8SvCEG35pGKfGKjWKmZP/pixw/aOG if41hwRtBpC4dNX4So5hbysvkAwWwPRHRzK7k2eYLR5LDq2FZmNmf4Gb/fxa/kxDvQ+O 2ShBjFsGiYuYQU9JDfwPuZ2ZvWwbw1cnSGm5uEKy8+68QBRgPp3z8jjVRV+BB7v3RsIx gzFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DnjH3+59C2HesEkci6o2tYhXJ5O1oMeATLk3gN2lfbg=; b=ifhJUFuHFxmKx0UsGpzsk1G4OhrotNpuRmbI/8MG4wcGIP4kcJ5qpM40Zq95oL+yui ahObaQDaztTpLlrPjCEUysOMGufwAVY/yOJkhLyDoKAhtRRT7FGujnrHzxr4nIIGgmMY frR+w7EuRtIv9dj3e1UavK99Cp40VQNcvI89Vt2VSRt7CgPRZJmUKMFhf6PoTQ1Rb3vY ZlAhzO+iPc66X3ycH/x1xBLP0moafJWDF9mLorgG0Cl4jbc+3ABtC8fgBQiCyRpYYBk/ uLkMYf3Egj0AjOrTvAWmUccH7JBSeGqg7fDrgEPZ5RjACMT0t35wYs8ZD4XcqyUTN0o4 eiQw== X-Gm-Message-State: AOAM533CWtMTZCSIsIzL118lhYwXOi2yW5tYhRmEkRkQW/twLXBGOIQw bLnS8wRpHLCUD4U+t3dz9+1Ka4bnQVFx42yBJlaV+w== X-Google-Smtp-Source: ABdhPJz0vnVdzRo2r8SFm69RR6xf0plpTm8e0X2u/aZgJ2No7jCV4ESWSR3kVc3lFpAv+GCLKBDYBT07o/8XH1oEPrA= X-Received: by 2002:a17:902:ed0d:b029:da:c83b:5f40 with SMTP id b13-20020a170902ed0db02900dac83b5f40mr3476341pld.20.1608089098795; Tue, 15 Dec 2020 19:24:58 -0800 (PST) MIME-Version: 1.0 References: <20201213154534.54826-1-songmuchun@bytedance.com> <20201213154534.54826-3-songmuchun@bytedance.com> <7cfe44aa-3753-82d9-6630-194f1532e186@oracle.com> In-Reply-To: <7cfe44aa-3753-82d9-6630-194f1532e186@oracle.com> From: Muchun Song Date: Wed, 16 Dec 2020 11:24:22 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v9 02/11] mm/hugetlb: Introduce a new config HUGETLB_PAGE_FREE_VMEMMAP To: Mike Kravetz Cc: Jonathan Corbet , Thomas Gleixner , mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, Peter Zijlstra , viro@zeniv.linux.org.uk, Andrew Morton , paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, Randy Dunlap , oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, Mina Almasry , David Rientjes , Matthew Wilcox , Oscar Salvador , Michal Hocko , "Song Bao Hua (Barry Song)" , David Hildenbrand , Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel Content-Type: text/plain; charset="UTF-8" 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: On Wed, Dec 16, 2020 at 9:04 AM Mike Kravetz wrote: > > On 12/13/20 7:45 AM, Muchun Song wrote: > > The purpose of introducing HUGETLB_PAGE_FREE_VMEMMAP is to configure > > whether to enable the feature of freeing unused vmemmap associated with > > HugeTLB pages. And this is just for dependency check. Now only support > > x86-64. > > > > Because this config depends on HAVE_BOOTMEM_INFO_NODE. And the function > > of the register_page_bootmem_info() is aimed to register bootmem info. > > So we should register bootmem info when this config is enabled. > > Suggested commit message rewording? > > 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. Thank Mike. Will update. > > > > > Signed-off-by: Muchun Song > > --- > > arch/x86/mm/init_64.c | 2 +- > > fs/Kconfig | 15 +++++++++++++++ > > 2 files changed, 16 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..4c3a9c614983 100644 > > --- a/fs/Kconfig > > +++ b/fs/Kconfig > > @@ -245,6 +245,21 @@ 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 > > + When using HUGETLB_PAGE_FREE_VMEMMAP, the system can save up some > > + memory from pre-allocated HugeTLB pages when they are not used. > > + 6 pages per HugeTLB page of the pmd level mapping and (PAGE_SIZE - 2) > > + pages per HugeTLB page of the pud level mapping. > > + > > + When the pages are going to be used or freed up, the vmemmap array > > + representing that range needs to be remapped again and the pages > > + we discarded earlier need to be rellocated again. > > I see the previous discussion with David about wording here. How about > leaving the functionality description general, and provide a specific > example for x86_64? As mentioned we can always update when new arch support > is added. Suggested text? Good suggestion. Thanks. > > 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 before remapping. > > -- > Mike Kravetz > > > + > > config MEMFD_CREATE > > def_bool TMPFS || HUGETLBFS > > > > -- Yours, Muchun