From patchwork Tue Nov 24 09:52:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11927823 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 6E319C64E7C for ; Tue, 24 Nov 2020 09:59:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DBBBB20857 for ; Tue, 24 Nov 2020 09:59:10 +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="fuMUt74x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBBBB20857 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 664AA6B009B; Tue, 24 Nov 2020 04:59:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ED506B009D; Tue, 24 Nov 2020 04:59:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B4C76B009E; Tue, 24 Nov 2020 04:59:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 30CE66B009B for ; Tue, 24 Nov 2020 04:59:10 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A958CA2C8 for ; Tue, 24 Nov 2020 09:59:09 +0000 (UTC) X-FDA: 77518863618.04.ice17_4c14e0f2736d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 7C3D6800CE91 for ; Tue, 24 Nov 2020 09:59:09 +0000 (UTC) X-HE-Tag: ice17_4c14e0f2736d X-Filterd-Recvd-Size: 6774 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Nov 2020 09:59:08 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id s63so7134129pgc.8 for ; Tue, 24 Nov 2020 01:59:08 -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=RvROAgOOAQ4kY4iKE3ESPFWS7AbcyyeQezHTq1QFTAg=; b=fuMUt74xPel262JKZcWj7UdAWTy2xxyYGTNPRBO2ViJpSb3cOepUJiAuAL5eAr2ooz j2AHvTaxLpMpe17XuGaalenP6FFJcPzfpy9YqA23Bq2eUtD1M3G8z51lfjCSJya72zRY Cqsck+YkGPmh1FnH25pcEzUHMUjFjiVc3fm2OCsWimzfMVj9RcOe98i0MZLz6Kmym7e4 /K5gvmzeNjSQjb5v/FXLbtcDiHPYmOJUPWJlz1ldS8ljQO9iC0uEm2rIxpMCB8mcFTC1 7kQOBSiW05idLnK6y4kUUNxTqg1SlWoQCaGLWLXOnm4r0vJ38ZT0iZv8dgHT3KKv09NC vzUA== 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=RvROAgOOAQ4kY4iKE3ESPFWS7AbcyyeQezHTq1QFTAg=; b=qgDu8KOBgOgk4WWY70lncz+MZDXyV0wNoxbtVVmjz2xjLZrIzrsaeC3nGNBPZWxHgU 2kNmGGYKV89aY6RNDsp5ktmBZq1CJugS2yEFc3XbTvEsl/HbYR/gYZd8TEbX8xGr0rvc t703/PUCoCpEwnpWnoYmPW6orbm4tpUDmsu398Rf6SwOodyLUoo8/AioGUkks85Sw5GW R1fo/oieQUJPbiNSIOWn1QtMy6HD/+S4X67sly1aD2m6gduTsgix4y4ToUe5Lq4LZxXJ 0zc6gbGifCsDJliFXGsKa51SnuZndGhIwNRJVvjUFlSaKs7EZS48rD+Xmby4sHo7SWu4 hSLQ== X-Gm-Message-State: AOAM531PEX6loOnE/NOukVR7NsWAY41R0AfX3BjXvJgC0QTPhzq2Xco8 ow9YUEk66TqNRGzZk1VlGDyyEg== X-Google-Smtp-Source: ABdhPJxlanZ/RJAQaev8flwUs/w/EGF8DKrJNUyiGS3fentCZnvyeLaxGW2GOzpgkK7Q4Y0SmdGDQg== X-Received: by 2002:a17:90a:c214:: with SMTP id e20mr4154217pjt.212.1606211948164; Tue, 24 Nov 2020 01:59:08 -0800 (PST) Received: from localhost.localdomain ([103.136.220.120]) by smtp.gmail.com with ESMTPSA id t20sm2424562pjg.25.2020.11.24.01.58.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Nov 2020 01:59:07 -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 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 v6 14/16] mm/hugetlb: Add a kernel parameter hugetlb_free_vmemmap Date: Tue, 24 Nov 2020 17:52:57 +0800 Message-Id: <20201124095259.58755-15-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201124095259.58755-1-songmuchun@bytedance.com> References: <20201124095259.58755-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: Add a kernel parameter hugetlb_free_vmemmap to disable the feature of freeing unused vmemmap pages associated with each hugetlb page on boot. Signed-off-by: Muchun Song --- Documentation/admin-guide/kernel-parameters.txt | 9 +++++++++ Documentation/admin-guide/mm/hugetlbpage.rst | 3 +++ mm/hugetlb_vmemmap.c | 19 ++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 5debfe238027..d28c3acde965 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1551,6 +1551,15 @@ Documentation/admin-guide/mm/hugetlbpage.rst. Format: size[KMG] + hugetlb_free_vmemmap= + [KNL] When CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is set, + this controls freeing unused vmemmap pages associated + with each HugeTLB page. + Format: { on | off (default) } + + on: enable the feature + off: disable the feature + hung_task_panic= [KNL] Should the hung task detector generate panics. Format: 0 | 1 diff --git a/Documentation/admin-guide/mm/hugetlbpage.rst b/Documentation/admin-guide/mm/hugetlbpage.rst index f7b1c7462991..6a8b57f6d3b7 100644 --- a/Documentation/admin-guide/mm/hugetlbpage.rst +++ b/Documentation/admin-guide/mm/hugetlbpage.rst @@ -145,6 +145,9 @@ default_hugepagesz will all result in 256 2M huge pages being allocated. Valid default huge page size is architecture dependent. +hugetlb_free_vmemmap + When CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is set, this enables freeing + unused vmemmap pages associated each HugeTLB page. When multiple huge page sizes are supported, ``/proc/sys/vm/nr_hugepages`` indicates the current number of pre-allocated huge pages of the default size. diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 509ca451e232..b2222f8d1245 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -131,6 +131,22 @@ typedef void (*vmemmap_pte_remap_func_t)(struct page *reuse, pte_t *ptep, unsigned long start, unsigned long end, void *priv); +static bool hugetlb_free_vmemmap_enabled __initdata; + +static int __init early_hugetlb_free_vmemmap_param(char *buf) +{ + if (!buf) + return -EINVAL; + + if (!strcmp(buf, "on")) + hugetlb_free_vmemmap_enabled = true; + else if (strcmp(buf, "off")) + return -EINVAL; + + return 0; +} +early_param("hugetlb_free_vmemmap", early_hugetlb_free_vmemmap_param); + static inline unsigned int vmemmap_pages_per_hpage(struct hstate *h) { return free_vmemmap_pages_per_hpage(h) + RESERVE_VMEMMAP_NR; @@ -322,7 +338,8 @@ void __init hugetlb_vmemmap_init(struct hstate *h) unsigned int order = huge_page_order(h); unsigned int vmemmap_pages; - if (!is_power_of_2(sizeof(struct page))) { + if (!is_power_of_2(sizeof(struct page)) || + !hugetlb_free_vmemmap_enabled) { pr_info("disable freeing vmemmap pages for %s\n", h->name); return; }