From patchwork Wed Jun 16 09:49:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12324695 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 EC32AC48BE6 for ; Wed, 16 Jun 2021 09:52:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D4706128C for ; Wed, 16 Jun 2021 09:52:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D4706128C 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 40DCA6B0071; Wed, 16 Jun 2021 05:52:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BDAE6B0072; Wed, 16 Jun 2021 05:52:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 210626B0073; Wed, 16 Jun 2021 05:52:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id E33FB6B0071 for ; Wed, 16 Jun 2021 05:52:37 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8BF3A10F6B for ; Wed, 16 Jun 2021 09:52:37 +0000 (UTC) X-FDA: 78259122354.31.43567E2 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf18.hostedemail.com (Postfix) with ESMTP id CD70F2001086 for ; Wed, 16 Jun 2021 09:52:27 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id k6so1743274pfk.12 for ; Wed, 16 Jun 2021 02:52:36 -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=cStPclh9XG3RxOFyVxsu9zTH21TiQql+7187dLUWbK8=; b=sYSNoTU43Ix6OsZTUORxb3rzT9NRRaz/6B8uMNVYNKewRmZY4telOmLIZdah47riHS yJFl3hoXYNc+zEC6lOIiqW2vZHa8BpPJE5qOZ5feQC9BG0wk/Xwuh7wNmb/hb/Bn8r60 yx8xA+AXdOMesVqkl7E36Gm8pR/crs3X34YHNf6lRIt7+HRPJikEtXVR4yZRz9T6KgTT Q4XXbhkOKzYxQr8eKzkigqTxzChomgUAdakUWNxMt8y1Oh8+9+ljdJ+iZ3RDy9MXaWWq v8PglxPX9txjmUQ5woJm7ZPdOgU6m3/kJ8CfJBF4y/W1tLgxPjKDgmOQfXKy5rBEKVao pHig== 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=cStPclh9XG3RxOFyVxsu9zTH21TiQql+7187dLUWbK8=; b=Y8ZTg7E6RNVFER3wg5p+N7K2mdRqsRfYqZkD4xMEv5oOFY5b+k97kP0lylat425VB8 /bJbd/CUJwc2LlWaXzvu659gx/NhrjQIWm1QDuksWfvLWviMZigHHrTdApqvGI+UDeeG yOXSYv9n46sDSaF9c/tdLypLMozb+0JfzJQiE1mRXYhduem7ZcQq8TWPmOfGZ/83K33E yqZ0uR3RG1nvShkkhUxBhs5h/HFaxGPeNKw+RILoMrW39NomoQHIaISZRvfGLKVpPsiX bJC8wKrSi7ngv1T/YRK22cpW2k1PEZhTJhrk7cNNrV4UOo2mVqvb8YuuE5AcBEOVvmcH kZbg== X-Gm-Message-State: AOAM533DtxkOiVAffmuQ83Gr5RmnNnkvReegRnLqMycLsGeHDYXk6K61 6Zlj0p48kGpVrZFq2ts/G9oSsA== X-Google-Smtp-Source: ABdhPJzGmh1DPcZnjuy13NT9spKbX8eIhbJOKLSzvyG8u3OumKYilIfOiIwI+2Bl5SHqqQiGtiHlSw== X-Received: by 2002:a62:9290:0:b029:2f7:64c4:b5f4 with SMTP id o138-20020a6292900000b02902f764c4b5f4mr8714444pfd.47.1623837156316; Wed, 16 Jun 2021 02:52:36 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.246]) by smtp.gmail.com with ESMTPSA id a20sm1744222pfk.145.2021.06.16.02.52.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jun 2021 02:52:36 -0700 (PDT) From: Muchun Song To: mike.kravetz@oracle.com, akpm@linux-foundation.org, osalvador@suse.de, mhocko@suse.com, song.bao.hua@hisilicon.com, david@redhat.com, chenhuang5@huawei.com, bodeddub@amazon.com, corbet@lwn.net Cc: duanxiongchun@bytedance.com, fam.zheng@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Muchun Song Subject: [PATCH v3 3/3] mm: hugetlb: introduce CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON Date: Wed, 16 Jun 2021 17:49:15 +0800 Message-Id: <20210616094915.34432-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210616094915.34432-1-songmuchun@bytedance.com> References: <20210616094915.34432-1-songmuchun@bytedance.com> MIME-Version: 1.0 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=sYSNoTU4; spf=pass (imf18.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Stat-Signature: 3is3a4a7raukho14r3133pdk41afkjr6 X-Rspamd-Queue-Id: CD70F2001086 X-Rspamd-Server: rspam06 X-HE-Tag: 1623837147-16939 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: When using HUGETLB_PAGE_FREE_VMEMMAP, the freeing unused vmemmap pages associated with each HugeTLB page is default off. Now the vmemmap is PMD mapped. So there is no side effect when this feature is enabled with no HugeTLB pages in the system. Someone may want to enable this feature in the compiler time instead of using boot command line. So add a config to make it default on when someone do not want to enable it via command line. Signed-off-by: Muchun Song --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ fs/Kconfig | 10 ++++++++++ mm/hugetlb_vmemmap.c | 6 ++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index a01aadafee38..8eee439d943c 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1604,6 +1604,9 @@ on: enable the feature off: disable the feature + Built with CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON=y, + the default is on. + This is not compatible with memory_hotplug.memmap_on_memory. If both parameters are enabled, hugetlb_free_vmemmap takes precedence over memory_hotplug.memmap_on_memory. diff --git a/fs/Kconfig b/fs/Kconfig index f40b5b98f7ba..e78bc5daf7b0 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -245,6 +245,16 @@ config HUGETLB_PAGE_FREE_VMEMMAP depends on X86_64 depends on SPARSEMEM_VMEMMAP +config HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON + bool "Default freeing vmemmap pages of HugeTLB to on" + default n + depends on HUGETLB_PAGE_FREE_VMEMMAP + help + When using HUGETLB_PAGE_FREE_VMEMMAP, the freeing unused vmemmap + pages associated with each HugeTLB page is default off. Say Y here + to enable freeing vmemmap pages of HugeTLB by default. It can then + be disabled on the command line via hugetlb_free_vmemmap=off. + config MEMFD_CREATE def_bool TMPFS || HUGETLBFS diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 06802056f296..c540c21e26f5 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -182,7 +182,7 @@ #define RESERVE_VMEMMAP_NR 2U #define RESERVE_VMEMMAP_SIZE (RESERVE_VMEMMAP_NR << PAGE_SHIFT) -bool hugetlb_free_vmemmap_enabled; +bool hugetlb_free_vmemmap_enabled = IS_ENABLED(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP_DEFAULT_ON); static int __init early_hugetlb_free_vmemmap_param(char *buf) { @@ -197,7 +197,9 @@ static int __init early_hugetlb_free_vmemmap_param(char *buf) if (!strcmp(buf, "on")) hugetlb_free_vmemmap_enabled = true; - else if (strcmp(buf, "off")) + else if (!strcmp(buf, "off")) + hugetlb_free_vmemmap_enabled = false; + else return -EINVAL; return 0;