From patchwork Fri Nov 13 10:59:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11903019 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 4AEF7138B for ; Fri, 13 Nov 2020 11:04:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EDA512224C for ; Fri, 13 Nov 2020 11:04: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="QulP4xf/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDA512224C 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 104696B00B9; Fri, 13 Nov 2020 06:04:10 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0B45B6B00C9; Fri, 13 Nov 2020 06:04:10 -0500 (EST) 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 E94806B00CA; Fri, 13 Nov 2020 06:04:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id BCF8B6B00B9 for ; Fri, 13 Nov 2020 06:04:09 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5E5A98249980 for ; Fri, 13 Nov 2020 11:04:09 +0000 (UTC) X-FDA: 77479110618.06.dress38_090c9472730e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 346C610047A02 for ; Fri, 13 Nov 2020 11:04:09 +0000 (UTC) X-Spam-Summary: 1,0,0,b3ebdc7c4e10777c,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:11232:11473:11658:11914:12043:12048:12114:12291: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.215.195:@bytedance.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201;04yf1r5xjqpnbd6qo13gfj891j5mfoc13zqbd3upugy335ffgeerxzh88d7azu5.kmr448izshky8pog5jdocwyz6gzftzsyjuykbfxdx6ajcn9jcehgd4d8ghuoef9.n-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:70,LUA_SUMMARY:none X-HE-Tag: dress38_090c9472730e X-Filterd-Recvd-Size: 6739 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 13 Nov 2020 11:04:08 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id f18so6802266pgi.8 for ; Fri, 13 Nov 2020 03:04: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=fI+ffyIJ/lWFcSPqbFf/SmboYz3zeHAfd7luhLQKQ2M=; b=QulP4xf/F6bZj2Zxu1813MvOIxpc2rFiP4TBkEPNGz0cA8cZfezugMTjZ1JRHyAQPK +YUUWrYNgbVdX27QXnFjI6qj01jwtydS7G7T061gSxs//krrWqRIAABtWkIYNR0lykl5 TdLs0L4qv6nPhkfMKYbDMbbPWCIHbDIohnT86/1voKVq0HpLeRh49n5lPp4FwnlRjWhy qM+1w2MIzt6mat1Ecs5s8/gbvmVB3nSl3JyAq2dMBiV187YaVB+wTY+OFHRBNibHqweP ztz7ULVEjVJpEVz5+uq+rgoj7N1H9erXAjIw1ObKzX+WeTY033M2B0NZRD5OWfuRcTGQ hp2Q== 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=fI+ffyIJ/lWFcSPqbFf/SmboYz3zeHAfd7luhLQKQ2M=; b=Wp+fSyre0uMcL7FIuY+tgarT17U6msRUuSiBpLQ8rxgC0LGf/uF9gOXxpuC2yiO6Ig FUxyknw08U603N3A6Qyjon1tyPmMkdCh1sqabY+qGzxDKQicoQLyWKsf/Ub4Jr23OIwh L6DycVk3ExNFZ42dXhtmm8IwFl9Q4m0oXwF8fANMDMLR+yI6NM9rIZgluJyDYfKXIwND Gv7x23fncT6EJT3znwtcUGYJigskFVA6237WrXQTRNy1to5Lm/qanuBLZabNSCnvs6uR JUsXbV86PO8wXjokSsLodyVVkT320RZRQKzy+oQpQKydTQDBfEv8hnardhaVlVXirfyO hScg== X-Gm-Message-State: AOAM532afGCRp+SatSpZm3/FN7cihszGgfuPWza7KPu//F2Br3hKhETP aqFPnmMDIWiRAtvvDmqKNzjLDA== X-Google-Smtp-Source: ABdhPJycK8Y8+LhZZx+UnepZGWXv3ZrX0BXb/re7wsijJy2j7WEjgUHiRaeIGY1XCDVXSaWuN3Ls6w== X-Received: by 2002:a65:56ca:: with SMTP id w10mr1741133pgs.204.1605265447958; Fri, 13 Nov 2020 03:04:07 -0800 (PST) Received: from localhost.localdomain ([61.120.150.78]) by smtp.gmail.com with ESMTPSA id f1sm8909959pfc.56.2020.11.13.03.03.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 03:04: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 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 v4 17/21] mm/hugetlb: Add a kernel parameter hugetlb_free_vmemmap Date: Fri, 13 Nov 2020 18:59:48 +0800 Message-Id: <20201113105952.11638-18-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201113105952.11638-1-songmuchun@bytedance.com> References: <20201113105952.11638-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 | 22 ++++++++++++++++++++++ 3 files changed, 34 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_vmemmap.c b/mm/hugetlb_vmemmap.c index 47f81e0b3832..1528b156920c 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -118,6 +118,22 @@ static inline bool vmemmap_pmd_huge(pmd_t *pmd) } #endif +static bool hugetlb_free_vmemmap_disabled __initdata; + +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); + static inline unsigned int vmemmap_pages_per_hpage(struct hstate *h) { return free_vmemmap_pages_per_hpage(h) + RESERVE_VMEMMAP_NR; @@ -505,6 +521,12 @@ 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("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 are not to be freed to buddy