From patchwork Mon Oct 26 14:51:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11857501 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A44A592C for ; Mon, 26 Oct 2020 14:55:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 664E5239D2 for ; Mon, 26 Oct 2020 14:55:47 +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="ieYl9GrT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 664E5239D2 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 9120E6B0080; Mon, 26 Oct 2020 10:55:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8C1B16B0081; Mon, 26 Oct 2020 10:55:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 715E26B0088; Mon, 26 Oct 2020 10:55:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 416576B0080 for ; Mon, 26 Oct 2020 10:55:46 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B46323623 for ; Mon, 26 Oct 2020 14:55:45 +0000 (UTC) X-FDA: 77414375850.14.size27_0f1775027274 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 8AA9918229835 for ; Mon, 26 Oct 2020 14:55:45 +0000 (UTC) X-Spam-Summary: 1,0,0,5dc0eb45254ecf59,d41d8cd98f00b204,songmuchun@bytedance.com,,RULES_HIT:41:355:379:541:800:960:965:966:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1543:1711:1730:1747:1777:1792:1801:2196:2198:2199:2200:2393:2559:2562:2693:2731:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:4117:4321:4385:4390:4395:4605:5007:6119:6261:6653:6737:6738:8603:9036:10004:11026:11473:11658:11914:12043:12048:12114:12297:12438:12517:12519:12555:12895:13894:14181:14394:14721:21080:21094:21323:21444:21451:21627:21966:21990:30029:30034:30054,0,RBL:209.85.216.68:@bytedance.com:.lbl8.mailshell.net-66.100.201.201 62.2.0.100;04yfnnjrozpbmy11i6ygufyz55r3pyce3n6bc8c9pdzp8dytw96r8jz5bcbrcwi.kpaynwo9ggu9m5i9cmmjrszn9wh5d7zj1eygcareep1qutwerutfefny87wuyyn.4-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: size27_0f1775027274 X-Filterd-Recvd-Size: 6959 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Mon, 26 Oct 2020 14:55:45 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id a17so3379305pju.1 for ; Mon, 26 Oct 2020 07:55:44 -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=gyW32MZ8OSoinxuXp8kqgHUjIwxNZICw8FuoRY/UD9c=; b=ieYl9GrTxm18tKLd3e2GEkSyzB4fgJBpLTwzGnog8ojgx+bj/xGHpgf7e43ffusvjh QuDW0AT5ukd+yNgI4Q13wVET7huAibAY/PXl7lJpT9r9FC++G1sh+tWQLFrD31kk1Ia4 TkpI6GvCoMdCpKLLMb5l1crJrCbhHcX8kjWD3Em5jxJXVRUO1PvW8MQiNqADdRPPzZx1 UbofYIoYpINsiRUNxM+g9Q8qAkDf68EGkIVssPlhhil9lQXjEMARYEHRrmAOBgv90Skz M2WmiXIS+1b2I+AOVkUWzrKloLm8yykJjjRjr9chMd1nQRHV9z48E3R7U9Zaqk3oMKYp rhIw== 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=gyW32MZ8OSoinxuXp8kqgHUjIwxNZICw8FuoRY/UD9c=; b=SW+8DW52UHs8jDrLPQ91TT2O3rH5OoMmM6eGKYAcSjr8I08YiCcFK/Gau9GRuBzuEG Dt+/Ll8PKO3ppX55x6mIxvB/Kz7jY+au0pmqqDOVVxIup9GP/27IC7XKP88J/gH0EPVd /eNdz5Ysp9TkUdeqgxrc0yrdY0HrKmT3hDqGyxw64sLTxMzuISKo88ndpoIPNJdK0It8 OnQ9gNkvC2UVkK7/cLz4E83GWJUbcrG8GwHEVYBV+nLeHba7RgUaSC9tFeAFUmnd+mt3 VkpfhfntF1tLlpr6B1jw1na1ctURbMqEzGQFLaHEAeN4iEHfDGGGKHLI/02bf/fUijXu qSzg== X-Gm-Message-State: AOAM533zX4IBtCCNO7Xe8t6Flekna5DbhofLsssbHpJQ68+DG4uP/WfK HDNNalXFePHStUzffxl+m0KU9g== X-Google-Smtp-Source: ABdhPJxXsam/XlOPzz/Gp1YN2pMJT1VPNjBUP5H+XZsosKWY9Qb7CNr3fa9M+5hmN9nFhz9dzpvY+A== X-Received: by 2002:a17:902:c383:b029:d3:d17a:1de with SMTP id g3-20020a170902c383b02900d3d17a01demr8417074plg.84.1603724144004; Mon, 26 Oct 2020 07:55:44 -0700 (PDT) Received: from localhost.localdomain ([103.136.220.89]) by smtp.gmail.com with ESMTPSA id x123sm12042726pfb.212.2020.10.26.07.55.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Oct 2020 07:55:43 -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, 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 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 v2 16/19] mm/hugetlb: Add a kernel parameter hugetlb_free_vmemmap Date: Mon, 26 Oct 2020 22:51:11 +0800 Message-Id: <20201026145114.59424-17-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201026145114.59424-1-songmuchun@bytedance.com> References: <20201026145114.59424-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 --- .../admin-guide/kernel-parameters.txt | 9 ++++++++ Documentation/admin-guide/mm/hugetlbpage.rst | 3 +++ mm/hugetlb.c | 23 +++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 5debfe238027..ccf07293cb63 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 (default) | off } + + 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..7d6129ee97dd 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 disables 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.c b/mm/hugetlb.c index 509de0732d9f..82467d573fee 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1310,6 +1310,8 @@ static void __free_hugepage(struct hstate *h, struct page *page); (__boundary - 1 < (end) - 1) ? __boundary : (end); \ }) +static bool hugetlb_free_vmemmap_disabled __initdata; + static inline unsigned int nr_free_vmemmap(struct hstate *h) { return h->nr_free_vmemmap_pages; @@ -1457,6 +1459,13 @@ static void __init hugetlb_vmemmap_init(struct hstate *h) unsigned int order = huge_page_order(h); unsigned int vmemmap_pages; + if (hugetlb_free_vmemmap_disabled) { + h->nr_free_vmemmap_pages = 0; + pr_info("HugeTLB: disable free vmemmap pages for %s\n", + h->name); + return; + } + vmemmap_pages = ((1 << order) * sizeof(struct page)) >> PAGE_SHIFT; /* * The head page and the first tail page not free to buddy system, @@ -1826,6 +1835,20 @@ static inline void clear_subpage_hwpoison(struct page *head) { set_page_private(head + 4, 0); } + +static int __init early_hugetlb_free_vmemmap_param(char *buf) +{ + if (!buf) + return -EINVAL; + + if (!strcmp(buf, "off")) + hugetlb_free_vmemmap_disabled = true; + else if (strcmp(buf, "on")) + return -EINVAL; + + return 0; +} +early_param("hugetlb_free_vmemmap", early_hugetlb_free_vmemmap_param); #else static inline void hugetlb_vmemmap_init(struct hstate *h) {