From patchwork Fri Nov 20 06:43:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11919567 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 61674C56201 for ; Fri, 20 Nov 2020 06:46:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C7D4F223BE for ; Fri, 20 Nov 2020 06:46:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="ddlgsc9a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7D4F223BE 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 213B76B0072; Fri, 20 Nov 2020 01:46:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C2EF6B0073; Fri, 20 Nov 2020 01:46:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D96F6B0074; Fri, 20 Nov 2020 01:46:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id C91526B0072 for ; Fri, 20 Nov 2020 01:46:39 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 62A10180AD837 for ; Fri, 20 Nov 2020 06:46:39 +0000 (UTC) X-FDA: 77503863318.19.nose57_3a09d9627349 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 48B141AD1B9 for ; Fri, 20 Nov 2020 06:46:39 +0000 (UTC) X-HE-Tag: nose57_3a09d9627349 X-Filterd-Recvd-Size: 5271 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Nov 2020 06:46:38 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id g7so6941681pfc.2 for ; Thu, 19 Nov 2020 22:46:38 -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=HbZE3hLPN+y4fZ+XDemkVZGrMn++MM+PXc+bcKxkyTw=; b=ddlgsc9aJsqPVq5fGeJt+X/ZQDQwAN5aZciP0XGHarhI6Nw/kv2uYbf8pALflOPDng NlHcU4f7e6w+J7m5KV07mvu6AWmk3bFVO2ZiH13JRIR04zcMF0SYwHKCN+48MZj2d+6X CFRtJzAwC9PpdgLDHOzJsVovdSdoByQtLk3NuNZY8tSHaBjkFhnCSBiIbgIZytARMijD +TEAHTXGjLuO8DrcIfZZQsESQXaE2wlc76W0xFNwSnh0ntthmym0fyZWvgYm4iBxkevy Ly6rL9wS7cDAvGp6z05ix/wjT46BCMjRj9a43QVrQ01leZmx90byJCQ+Qe74wu6mFqZp Sdfg== 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=HbZE3hLPN+y4fZ+XDemkVZGrMn++MM+PXc+bcKxkyTw=; b=acDZEEpJDu3A48u1ucev1mgtJSYDWW2uUQYNyfRj8PvjoB8HUZuqrm6yvFPpb8ouEI qXwGZYA3qtY/7/iUaFSHiQjPlp5QYUvUbnce1LbSvl4Uq66Od2zm236K6NVqDGESLZFx mLLpu248nYP/GpvySIjXYgdu5lOFug6VUmEmsgq4uCcC+cipTXXokSMeSWY7kvVtW1ZP DP91LUHnSFEh9mrQ2QDR/j697AWTqTRYOmPKI0ZpbkNIOoFcp6VbFvoqztBwJv31Uwht NlOcbkeapkHPc1/MrAFsAG7dFPcYjjj67OfHhjXOUj5xotMtOzzleNVwnuWtTPsYyXVL xacg== X-Gm-Message-State: AOAM5315N5PjNcrYv2L3BLA1xlKwZurVVbn9zeMaoiF7mDwlaNqiMFgH pXiM20bBO9wvHgr1thf5n+S1NA== X-Google-Smtp-Source: ABdhPJwrv3QKWbdRQidbZcDMmub+4jw1ViBixLnsgA9kLSF0wXLcGC+wV5JBbDHtGxKTMQPT1ZHxvQ== X-Received: by 2002:a17:90a:4dc8:: with SMTP id r8mr8278165pjl.1.1605854797793; Thu, 19 Nov 2020 22:46:37 -0800 (PST) Received: from localhost.localdomain ([103.136.221.72]) by smtp.gmail.com with ESMTPSA id 23sm2220278pfx.210.2020.11.19.22.46.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Nov 2020 22:46:37 -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 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 Subject: [PATCH v5 03/21] mm/hugetlb: Introduce a new config HUGETLB_PAGE_FREE_VMEMMAP Date: Fri, 20 Nov 2020 14:43:07 +0800 Message-Id: <20201120064325.34492-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201120064325.34492-1-songmuchun@bytedance.com> References: <20201120064325.34492-1-songmuchun@bytedance.com> MIME-Version: 1.0 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 purpose of introducing HUGETLB_PAGE_FREE_VMEMMAP is to configure whether to enable the feature of freeing unused vmemmap associated with HugeTLB pages. Now only support x86. Signed-off-by: Muchun Song --- arch/x86/mm/init_64.c | 2 +- fs/Kconfig | 14 ++++++++++++++ 2 files changed, 15 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..4961dd488444 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -245,6 +245,20 @@ config HUGETLBFS config HUGETLB_PAGE def_bool HUGETLBFS +config HUGETLB_PAGE_FREE_VMEMMAP + def_bool HUGETLB_PAGE + depends on X86 + 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 2MB HugeTLB page and 4094 per 1GB HugeTLB page. + + 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. + config MEMFD_CREATE def_bool TMPFS || HUGETLBFS