From patchwork Tue Dec 22 14:24:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11986755 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,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 356A9C433DB for ; Tue, 22 Dec 2020 14:29:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C59492312E for ; Tue, 22 Dec 2020 14:29:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C59492312E 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 08BD06B0087; Tue, 22 Dec 2020 09:29:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 015466B0088; Tue, 22 Dec 2020 09:29:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF7CB8D0009; Tue, 22 Dec 2020 09:29:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id C58036B0087 for ; Tue, 22 Dec 2020 09:29:54 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8C484181AEF1E for ; Tue, 22 Dec 2020 14:29:54 +0000 (UTC) X-FDA: 77621152308.17.coat30_020e25627460 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 77070180D0781 for ; Tue, 22 Dec 2020 14:29:54 +0000 (UTC) X-HE-Tag: coat30_020e25627460 X-Filterd-Recvd-Size: 6112 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Dec 2020 14:29:53 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id t8so8564922pfg.8 for ; Tue, 22 Dec 2020 06:29:51 -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=ntojA21L7AWHHQRUBdhZHwBioWXg1bVrcDP2ArBhkkY=; b=XTTONU2KZyeFIIukV/BEYoa3ybU4lZ89lYtgBqJ1YEuOA9kkye11aJ91ssriUtJ4F+ vXAfW2eN15sPIGPeOX8NTzTs0K8/CGg8oaTVLSCpaNQ+BlYuHMhjWi3dIlkbgPQPOOAh 9NWYI3ZLds0WcSf53RD5hHHtXjxQRUMwXlt4231q+ReNs7A2XyIa5qlL5yf1IFLGazvU jV/vu6/OwgYhLa93+DACagHBc6EOIrEMG5CZUVLC5UlbhalmucW6ugVkhQ9rEtqHzPMu wGFC9fy58EIrm0sitEf0aJ9c9PaEKeyWDUPqB22b2HqSBL9gSH/XiCbGcYcb1eTUuOUi Y/bw== 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=ntojA21L7AWHHQRUBdhZHwBioWXg1bVrcDP2ArBhkkY=; b=Sgl2JKQY8Y8c++lXs/oSneWa7el6mUIpHi5N8MLnNtRMCDOSoG7rdD37azVy/KfxcH J99xoMNDSMvU0e8MF5ff/bK0T3IaJa/13duUptC5fGnzycoecMZLiFilaa2Nv3Kos15c Z+QUqB9XVw3ZSmJ6Lz+A6Lh4GE5EWxc8wI/nawzFh6p59eCfAbsU8P4o0lv436oiocp3 d9JgyNVbyYOXtQ3BrOkMLZt1vroIH0fqmV6E3EyxgwoKEoRfrHv8QePUTC5+3qyRV2Hh d15k6MBeMcFbNasxamSy70HEM5SR0i0oPbk5jX8bibtDjwfzZfGwwGTtw1mDeWDxXzPJ GEyw== X-Gm-Message-State: AOAM533U0fq5jEy2ujmLIrfXVP1NY1C/Rn7864QhkOqe8Hxxa2lZnlm+ fOu1ydRLHqf5h7oLUdIGdNg4aA== X-Google-Smtp-Source: ABdhPJzCUCmTavcCtYy0Cgeu988bfVe0mdBav9lSJTTmQ2B5meYZqqFRw1PChtjMNZxchKxCfkqcwQ== X-Received: by 2002:a62:8683:0:b029:1a4:4f3f:7e75 with SMTP id x125-20020a6286830000b02901a44f3f7e75mr20092143pfd.68.1608647391128; Tue, 22 Dec 2020 06:29:51 -0800 (PST) Received: from localhost.bytedance.net ([139.177.225.247]) by smtp.gmail.com with ESMTPSA id a31sm21182088pgb.93.2020.12.22.06.29.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2020 06:29:50 -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, david@redhat.com, naoya.horiguchi@nec.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 v11 02/11] mm/hugetlb: Introduce a new config HUGETLB_PAGE_FREE_VMEMMAP Date: Tue, 22 Dec 2020 22:24:31 +0800 Message-Id: <20201222142440.28930-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201222142440.28930-1-songmuchun@bytedance.com> References: <20201222142440.28930-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 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. Signed-off-by: Muchun Song Reviewed-by: Oscar Salvador Acked-by: Mike Kravetz --- arch/x86/mm/init_64.c | 2 +- fs/Kconfig | 18 ++++++++++++++++++ 2 files changed, 19 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..e7c4c2a79311 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -245,6 +245,24 @@ 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 + 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. + config MEMFD_CREATE def_bool TMPFS || HUGETLBFS