From patchwork Thu Mar 24 07:40:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Liu X-Patchwork-Id: 12790477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F597C433F5 for ; Thu, 24 Mar 2022 07:26:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C6918D0005; Thu, 24 Mar 2022 03:26:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9769C8D0003; Thu, 24 Mar 2022 03:26:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83CB28D0005; Thu, 24 Mar 2022 03:26:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 719B48D0003 for ; Thu, 24 Mar 2022 03:26:18 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 45C321627 for ; Thu, 24 Mar 2022 07:26:18 +0000 (UTC) X-FDA: 79278446436.11.153CA57 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf22.hostedemail.com (Postfix) with ESMTP id 2EAD5C001F for ; Thu, 24 Mar 2022 07:26:17 +0000 (UTC) Received: from kwepemi500011.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KPGtY2zFZzCql5; Thu, 24 Mar 2022 15:24:05 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi500011.china.huawei.com (7.221.188.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 24 Mar 2022 15:26:13 +0800 Received: from localhost.localdomain (10.175.112.125) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 24 Mar 2022 15:26:12 +0800 From: Peng Liu To: , , , , CC: Subject: [PATCH] hugetlb: Fix hugepages_setup when deal with pernode Date: Thu, 24 Mar 2022 07:40:37 +0000 Message-ID: <20220324074037.2024608-1-liupeng256@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of liupeng256@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liupeng256@huawei.com X-Stat-Signature: ckimag1nm76ni1sw8ujtm3kpmxeqw84u X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2EAD5C001F X-HE-Tag: 1648106777-762974 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: Hugepages can be specified to pernode since "hugetlbfs: extend the definition of hugepages parameter to support node allocation", but the following two problems are observed. 1) Confusing behavior is observed when both 1G and 2M hugepage is set after "numa=off". cmdline hugepage settings: hugepagesz=1G hugepages=0:3,1:3 hugepagesz=2M hugepages=0:1024,1:1024 results: HugeTLB registered 1.00 GiB page size, pre-allocated 0 pages HugeTLB registered 2.00 MiB page size, pre-allocated 1024 pages 2) Using invalid option values causes the entire kernel boot option string to be reported as Unknown. Unknown kernel command line parameters "hugepages=0:1024,1:1024" To fix "1)", hugetlb_hstate_alloc_pages should be called even when hugepages_setup going to invalid. To fix "2)", return 1 so that init's environment is not polluted with kernel boot options. Fixes: b5389086ad7b ("hugetlbfs: extend the definition of hugepages parameter to support node allocation") Signed-off-by: Peng Liu --- mm/hugetlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index b34f50156f7e..de8e1d8a2c66 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4189,6 +4189,7 @@ static int __init hugepages_setup(char *s) } } +out: /* * Global state is always initialized later in hugetlb_init. * But we need to allocate gigantic hstates here early to still @@ -4203,7 +4204,7 @@ static int __init hugepages_setup(char *s) invalid: pr_warn("HugeTLB: Invalid hugepages parameter %s\n", p); - return 0; + goto out; } __setup("hugepages=", hugepages_setup);