From patchwork Sun Nov 8 14:10:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11889595 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E5CC139F for ; Sun, 8 Nov 2020 14:12:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 31CD820B1F for ; Sun, 8 Nov 2020 14:12:16 +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="o0HEIRih" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31CD820B1F 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 641516B006C; Sun, 8 Nov 2020 09:12:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5EE936B006E; Sun, 8 Nov 2020 09:12:15 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46B3E6B0070; Sun, 8 Nov 2020 09:12:15 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 1AB8E6B006C for ; Sun, 8 Nov 2020 09:12:15 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id AD3A3362A for ; Sun, 8 Nov 2020 14:12:14 +0000 (UTC) X-FDA: 77461440588.05.wren11_5a14a85272e4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 804D318016125 for ; Sun, 8 Nov 2020 14:12:14 +0000 (UTC) X-Spam-Summary: 10,1,0,88ef75af582c5fb9,d41d8cd98f00b204,songmuchun@bytedance.com,,RULES_HIT:41:355:379:404:541:800:960:965:966:973:981:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3870:3871:3872:3874:4250:4321:4385:4390:4395:4605:5007:6261:6653:6737:6738:7904:8957:10004:11026:11473:11658:11914:12043:12048:12114:12296:12297:12438:12517:12519:12555:12895:12986:13161:13229:13894:13972:14093:14096:14181:14394:14721:21080:21094:21323:21444:21451:21627:30054:30075,0,RBL:209.85.214.194:@bytedance.com:.lbl8.mailshell.net-66.100.201.201 62.2.0.100;04y8oyns4u54tfume3fehbccw51q5yp6trgpyhbg7q5bee7czi8mdzcqp63dmkq.oni8u141yxu5sas66fpyffw6zwto3pi4n3q3e849oy5793sboh36z6p4fwrnyhi.6-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:68,LUA_SUMMARY:none X-HE-Tag: wren11_5a14a85272e4 X-Filterd-Recvd-Size: 5825 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Sun, 8 Nov 2020 14:12:14 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id t22so3254435plr.9 for ; Sun, 08 Nov 2020 06:12:12 -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=7V5l6iVptpyNChOEqgaC9UYBunmQshAPJJMGH6oVOO8=; b=o0HEIRih4qIk8FKiaCrU/8jPPZ5TYT6PQWg9ap++vRxQ08ObrhpaevX4214Ob2VCY2 bHwFHgK7NR9A1or3FsJjDVthim8iB3WkhekAJ3nEByhI9pBN6luYwVbGAUs/2G+uay5s gooJjeKFBKWzlkf2GamyV+vc4R6VeS43+OqoTKNV73tC1vCFejqm9W4GiKyrG5+yHeM3 xd7pwh2QL62pQA13zHEZhVG27MtZ23E0H1cdnwbg4gAxNqun3pYYuoLtce5HF2bN6yCH HE4blj+ArUxxMH33jBUNT0HzpGNcmth0I2XO7RFjfCMZqNitjz16k+F4CXTTflMWN6uF mbGQ== 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=7V5l6iVptpyNChOEqgaC9UYBunmQshAPJJMGH6oVOO8=; b=Vqk7GhwXzgXMmRb3kwzOna6b5MODM31GZFSFyhVX/fczeFUgQZbHjxmNuSeGjFyX1k M874JZYEYTyvQ8j07cZbTRGyuenMcYoBQ4pB3Er4kryj545Q1o4dH2Lf75XlXvoh/iGi WJELl7syAToaCLxfhtVexbCH1gNd2hZ2+Yyxq2fx04bOlzBNZWNh4ZSSDi4UopkBTMZV vUaTJ33XlMr8awlnTZ+CzNJQacFrf2wiyZqY4kHUes58M0rvNErqTuT/amOPppIp+Wtr 9Z1rvR7WROfqUPhKIh8GxIF6yrYgXSr+U3wBOe4goHqHJ7JRHA8pWptckGQl2ewEzkyH 9h1A== X-Gm-Message-State: AOAM532MJdkVkBnsi9G9/USK0yr1bEB8iklhh59Z1cE48mOnWY1BHXdm FTha20vddhZgCdGC4jDYvfPVow== X-Google-Smtp-Source: ABdhPJwKM/CCRKYOI1UvT8sA6mZlrIw7idUpNoiTVHntW3fTsKokmQ5P/+hpT6dCP1V9Wu+5WLqwkg== X-Received: by 2002:a17:902:7049:b029:d7:e413:8aba with SMTP id h9-20020a1709027049b02900d7e4138abamr284690plt.30.1604844731474; Sun, 08 Nov 2020 06:12:11 -0800 (PST) Received: from localhost.localdomain ([103.136.220.94]) by smtp.gmail.com with ESMTPSA id z11sm8754047pfk.52.2020.11.08.06.12.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Nov 2020 06:12:10 -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 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 v3 03/21] mm/hugetlb: Introduce a new config HUGETLB_PAGE_FREE_VMEMMAP Date: Sun, 8 Nov 2020 22:10:55 +0800 Message-Id: <20201108141113.65450-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201108141113.65450-1-songmuchun@bytedance.com> References: <20201108141113.65450-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 | 16 ++++++++++++++++ mm/bootmem_info.c | 3 +-- 3 files changed, 18 insertions(+), 3 deletions(-) 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..21b8d39a9715 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -245,6 +245,22 @@ config HUGETLBFS config HUGETLB_PAGE def_bool HUGETLBFS +config HUGETLB_PAGE_FREE_VMEMMAP + bool "Free unused vmemmap associated with HugeTLB pages" + default y + depends on X86 + depends on HUGETLB_PAGE + depends on SPARSEMEM_VMEMMAP + depends on HAVE_BOOTMEM_INFO_NODE + help + There are many struct page structures associated with each HugeTLB + page. But we only use a few struct page structures. In this case, + it wastes some memory. It is better to free the unused struct page + structures to buddy system which can save some memory. For + architectures that support it, say Y here. + + If unsure, say N. + config MEMFD_CREATE def_bool TMPFS || HUGETLBFS diff --git a/mm/bootmem_info.c b/mm/bootmem_info.c index d276e96e487f..fcab5a3f8cc0 100644 --- a/mm/bootmem_info.c +++ b/mm/bootmem_info.c @@ -10,8 +10,7 @@ #include #include -void get_page_bootmem(unsigned long info, struct page *page, - unsigned long type) +void get_page_bootmem(unsigned long info, struct page *page, unsigned long type) { page->freelist = (void *)type; SetPagePrivate(page);