From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,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 9001BC2D0F6 for ; Tue, 15 Sep 2020 13:03:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 124E220684 for ; Tue, 15 Sep 2020 13:03:51 +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="EOQN2yWH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 124E220684 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 8F0F3900048; Tue, 15 Sep 2020 09:03:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C845900041; Tue, 15 Sep 2020 09:03:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B98B900048; Tue, 15 Sep 2020 09:03:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id 632EE900041 for ; Tue, 15 Sep 2020 09:03:50 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0C95D8249980 for ; Tue, 15 Sep 2020 13:03:50 +0000 (UTC) X-FDA: 77265313020.13.wash50_1407f8927111 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 3DE6018140B82 for ; Tue, 15 Sep 2020 13:03:44 +0000 (UTC) X-HE-Tag: wash50_1407f8927111 X-Filterd-Recvd-Size: 6908 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Sep 2020 13:03:27 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id x123so1891043pfc.7 for ; Tue, 15 Sep 2020 06:03:27 -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=mOJhqJtv+UWYoFjqXwWvBe8sB0f2lCBZ6nqED2fuMHQ=; b=EOQN2yWHyRuPAk9Gq+vMMRCScrOmbSFwQ3n+S9wZYYojswi6k8MztS4cheCz/qacPa JQH4e+xWH0J27Q2IH3NK20OWrmxC6SH8QTl8gW2KyP1R6iauFKSbXnW6RCyse/SaZqzu H5/jC1r63VISpnzqCqjZbh1KoHJ8PUp5VnvAh87TKRUVm6FgYuM/2IBTVSCqs/moqLOl vDTfbMz93M8Af8EBdTZK3i8xzTOrHp7cqmo+zrubXB95j0mPnK2Jy/6skjemTyoOrdlc VOcBpmuITOubgjyoOWCxAvFXusRUf0Wsf7a9t97nrU1k/gEkmQpssTuulsmZPnh6+CTw /bxQ== 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=mOJhqJtv+UWYoFjqXwWvBe8sB0f2lCBZ6nqED2fuMHQ=; b=ZupODhDMSp+wFs3Zh28JSna2aAsxg3d8Q+RMuFHbYYy96287E3Qi6RONkICbkCx9Fl OeAecF13LL00y7U5WHhkSa8yZzImMIDkg4vZYXFhohwXs2mPkUOuOYXbGhZj8v/JUn4f UK0xeekJDoq1iMGP1TykeETiKebXK4Zcf1XuW8x4d1L7Ctic90PVZD8y3nQhGx2qeytD pp0PvDUGSZJhDAYhfaxp5n7Lr97hXyEmSHFiFmzz/irzyj0Wf8HHqgTEQTjBbs0lvM9x uM08806t3g5M+UjRm9cczUPlou0rO49cL23iT8HOrPcIdXuh8ViObUwnscxvgYfg0B9A guxA== X-Gm-Message-State: AOAM5332F+CcyIjK7Kb1+gJm/ETyNHd+0HqjRVKf4ei9O7LCVdoJq1aO d/PhsVqA1PTLkBAorC/cTJVyew== X-Google-Smtp-Source: ABdhPJy+syIBhM8kx1V8ywime9iP9xvufd4f0gsLV6gbG6xM7YybTp78AmXxxeqXUOso9/bnBhpTyQ== X-Received: by 2002:a62:3044:0:b029:142:2501:398b with SMTP id w65-20020a6230440000b02901422501398bmr1767708pfw.80.1600175006499; Tue, 15 Sep 2020 06:03:26 -0700 (PDT) Received: from localhost.bytedance.net ([103.136.220.66]) by smtp.gmail.com with ESMTPSA id w185sm14269855pfc.36.2020.09.15.06.03.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 06:03:25 -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 Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Muchun Song Subject: [RFC PATCH 20/24] mm/hugetlb: Add a kernel parameter hugetlb_free_vmemmap Date: Tue, 15 Sep 2020 20:59:43 +0800 Message-Id: <20200915125947.26204-21-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20200915125947.26204-1-songmuchun@bytedance.com> References: <20200915125947.26204-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3DE6018140B82 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable 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/Documentat= ion/admin-guide/kernel-parameters.txt index 5debfe238027..69d18ef6f66b 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] =20 + hugetlb_free_vmemmap=3D + [KNL] When CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is set, + this disables freeing unused vmemmap pages associated + each HugeTLB page. + Format: { on (default) | off } + + on: enable the feature + off: dosable the feature + hung_task_panic=3D [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 =20 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. =20 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 56c0bf2370ed..28c154679838 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1310,6 +1310,8 @@ static void __free_hugepage(struct hstate *h, struc= t page *page); (__boundary - 1 < (end) - 1) ? __boundary : (end); \ }) =20 +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 hst= ate *h) unsigned int order =3D huge_page_order(h); unsigned int vmemmap_pages; =20 + if (hugetlb_free_vmemmap_disabled) { + h->nr_free_vmemmap_pages =3D 0; + pr_info("HugeTLB: disable free vmemmap pages for %s\n", + h->name); + return; + } + vmemmap_pages =3D ((1 << order) * sizeof(struct page)) >> PAGE_SHIFT; /* * The head page and the first tail page not free to buddy system, @@ -1867,6 +1876,20 @@ static inline void clear_subpage_hwpoison(struct p= age *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 =3D 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) { --=20 2.20.1