From patchwork Sun Apr 25 07:07:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12223033 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.5 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=unavailable 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 13024C43460 for ; Sun, 25 Apr 2021 07:13:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 91E666161F for ; Sun, 25 Apr 2021 07:13:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 91E666161F 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 2F4F26B006E; Sun, 25 Apr 2021 03:13:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2CACA6B0070; Sun, 25 Apr 2021 03:13:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 147BA6B0071; Sun, 25 Apr 2021 03:13:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id EBB476B006E for ; Sun, 25 Apr 2021 03:13:10 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A84E76C37 for ; Sun, 25 Apr 2021 07:13:10 +0000 (UTC) X-FDA: 78070022940.08.62C06D5 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf18.hostedemail.com (Postfix) with ESMTP id 625342000242 for ; Sun, 25 Apr 2021 07:13:12 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id j7so28636473pgi.3 for ; Sun, 25 Apr 2021 00:13:10 -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=1bTV5nlan8MWSy/nxj3eASEhGZQ0KgaptGQnSI4jeHIJoKISCdIAIfXYgMXuR8w6Qm whcjZTBlqfrQHnqAkLtAmFI/s/iVKboYu8prKLL2RESUL/0F8aqxYDsK6BwhCAfn9B7M 6aMckk8KY7N5FtmWr4s+4SkZneSWlGLPAdmhPrIimCHVCX6xGtTb3PUr6wByNhQt0Fv0 xo19FtUwBs++wyhnN5YNeUOU68UJe8qCYgEwFnr8reliOTEseI2qhXqSVe3we2fqlN+M NscD3hOSHmqVdWqSdtx855l7rBfO+o6QFlcRwZQJ8Jeahk39bpLL/rBchITeD9qP9o8/ 9i9A== 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=o5V56khFSxz5K/LjCrdg6fxlS9rq62AKYhWVxW1asP83TSN3dpWgX8eSxHewgqQWl8 QUhYGr9QNL0gSa1sLgznrYsaYwacd0Ck13CX545YULHZpvbpvZbvs9VcAIaZiL2anGuX /DxGcnTUqAzT3dd+kFoL1HgJ5CkTGYqMB+j8aoz+gw/UZAALOI9oEIS8e+fv4NIxv7Op gIJGBBHb0urw5r27kO4fMqdeVkWxp/SPRlX00PQkj1qxCpGxrgB03my+k7sq+aj8ul3E Ckj2Q/AcU1mlmlibfaAVhxbgQiPQKnbm76djYa09YPSgkn9BHtw8mkoaUoEvThPPW866 P/QQ== X-Gm-Message-State: AOAM532nguzvNAKwNOTdRxAfhncWA/nE2u1Ete7u7nrGU7BN8Ot/HuxV jXS+EN3DwxhIV+7XyKqJZ2VNiA== X-Google-Smtp-Source: ABdhPJyXeVBx1my+A3dIYD92sTzDNr3ovIrz5cTjVTbBWqptlQztvOxxOJgEOP5gZ0JNR7axJrRZ/A== X-Received: by 2002:a62:e315:0:b029:263:8436:e784 with SMTP id g21-20020a62e3150000b02902638436e784mr11318972pfh.69.1619334789431; Sun, 25 Apr 2021 00:13:09 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id h8sm8767125pjt.17.2021.04.25.00.12.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Apr 2021 00:13:09 -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 v21 2/9] mm: hugetlb: introduce a new config HUGETLB_PAGE_FREE_VMEMMAP Date: Sun, 25 Apr 2021 15:07:45 +0800 Message-Id: <20210425070752.17783-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210425070752.17783-1-songmuchun@bytedance.com> References: <20210425070752.17783-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 625342000242 X-Stat-Signature: gnnkifpzfh55xyo4oojo1qazkicmdgrq Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf18; identity=mailfrom; envelope-from=""; helo=mail-pg1-f178.google.com; client-ip=209.85.215.178 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619334792-623684 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 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