Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2229844pxj; Sun, 9 May 2021 20:05:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjW4UFnt7/s72Nrp0AE+qmxg2EUiuvXv9NqnhxZLuHkJBZoFCG6sZ6MIxfj0OVal6t49In X-Received: by 2002:a92:c746:: with SMTP id y6mr20100320ilp.30.1620615924677; Sun, 09 May 2021 20:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620615924; cv=none; d=google.com; s=arc-20160816; b=Z3WBfDW59l0KgtkPbcNAig4v0AeHQEtLXmdVjyFYYF4/RtOr6u3YTgE6tLyv2DqzoL ixr82nNE8zX8XEhYbILsmXQtiyNmTqiXVeRUqPgvEalhAwILn4YvPVi90VG8T+g6XEED Zt9nOAfm1m+Q0TVf1MkmtNn/79gYJq4ACfvZi69XsK/JTCUmmsfpjcAaFOHavd+nBO4S GDA7WKBkK1cCpzy8VHVn1sYHM6H+E2INjTFfadmsMD39oIc3QcrJp7Odn9bEQpm320so MY/6iDb/Roocj4qmcrqP9Cw6USDkZWuuKgODVVZwsntyVyXNOvG5SXJbWuJ7v9VCLj+c q2qA== 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=wKelYap5ZqtStFBa9TtsHHfojKiS3Hglicls/a2/J1GxzkUwjq9e3bUbJHs2Kn73gb Cyi/KmN3JfDeo7p/sCu/97apd8XetXerLg9Elj28HBPxp+4ZTG/oCc/dbeKusMKSpWs0 RkS6uNoFfTubDUJSF3Qjbv30/sXcTJn6kqw7ewX5FTMrWxP1G3DpJZcY2uOi2F874soi Qeoe8LA1gQGtShU0xPMXk3tHza+gQpv1rAzBmyHLKdgT2O+UCFLpAJvYv1O8AQ7Cv4vA 4fEMzpywEypztPMsfKj4Cv+Yuh/YMaYBq+WFifWXgnYmwG6BuNYjKv12MSZe2+72iSHU EN4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=se6vvw+Z; 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 k26si3440202jap.39.2021.05.09.20.05.12; Sun, 09 May 2021 20:05:24 -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=se6vvw+Z; 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 S230245AbhEJDEr (ORCPT + 99 others); Sun, 9 May 2021 23:04:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbhEJDEq (ORCPT ); Sun, 9 May 2021 23:04:46 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFA07C061574 for ; Sun, 9 May 2021 20:03:42 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id 69so3807649plc.5 for ; Sun, 09 May 2021 20:03:42 -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=se6vvw+ZxXlajwG5sizvmAQHljY9gpETC9t2m8A8d0Y9HfYbApkE78gIC+V1qB9Vot ywsG1i2raBCCIQsCtzqFwtFJdWe0MimiHP0FJjTuvvwzSnPucHPo7Nk+l9UrFa9FhFkk 0JWkLo4Aw2V1BfyM+7d7D5kOXihO99OFcVtOtv/XRCY7TNe8E+xgR4A0eawa4YpCKX24 Js9XK0bAyW72BRD19Y94mn6l2p+kx6rZnoEuSViOzvpl40ZPe9vJeUQBYCCKGu6rW3uv 3VIj9a4PB0zRqpxWp2z0+cDaojmyIft9Jhvx1ATYQ6Lqi6xvxBsaJUalBSXkV6ee92+s tucA== 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=Y7Qb+in6LNR7JDEQTqSSQRKQQp9GBnzNv36MnkPwIAfYRKf9YEKUylx4lK1vOzDXap c0fH9Ihdr/yob63/9uJ5ihiI9Cn3GgY8Q98QXsY2CR7C0EOU18uTCf7jtD8pZWoVyrf1 qd3cs99/cLACrpdE4LBMZThuGiVArE078SCmVkhSg1fu9t7V8RpbaPgcJNelswz4TaH7 RyNtl27EHCQkIvws9MQvBxxtq8dknjXlVA8DUUhGilMKkeWB6dq3X4fleiaO4fBzm4di y3B650/3cZmBqUpU+i7w6BF2bb3nSoXXzfFibsy8pRM+NCPaAU7hrumkPUbD3XD2FfbM VRKQ== X-Gm-Message-State: AOAM533FvkaT17ZI6DajwSHgXwM3ntQTw6jO2AE5EsC2q0/ViU8tgexP gNmvACAJih/qggDkA/fLDFZtTA== X-Received: by 2002:a17:902:bcc7:b029:ed:6f73:ffc4 with SMTP id o7-20020a170902bcc7b02900ed6f73ffc4mr21980606pls.1.1620615822268; Sun, 09 May 2021 20:03:42 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id a128sm9777003pfd.115.2021.05.09.20.03.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 May 2021 20:03:41 -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, zhengqi.arch@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 v23 2/9] mm: hugetlb: introduce a new config HUGETLB_PAGE_FREE_VMEMMAP Date: Mon, 10 May 2021 11:00:20 +0800 Message-Id: <20210510030027.56044-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210510030027.56044-1-songmuchun@bytedance.com> References: <20210510030027.56044-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