All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Liu <liupeng256@huawei.com>
To: <mike.kravetz@oracle.com>, <akpm@linux-foundation.org>,
	<yaozhenguo1@gmail.com>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>
Cc: <liupeng256@huawei.com>
Subject: [PATCH] hugetlb: Fix hugepages_setup when deal with pernode
Date: Thu, 24 Mar 2022 07:40:37 +0000	[thread overview]
Message-ID: <20220324074037.2024608-1-liupeng256@huawei.com> (raw)

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 <liupeng256@huawei.com>
---
 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);
 
-- 
2.18.0.huawei.25


             reply	other threads:[~2022-03-24  7:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24  7:40 Peng Liu [this message]
2022-03-24 21:57 ` [PATCH] hugetlb: Fix hugepages_setup when deal with pernode Mike Kravetz
2022-03-25  3:15   ` liupeng (DM)
2022-03-29  2:46     ` Mike Kravetz
2022-03-29  3:59       ` liupeng (DM)
2022-03-29 17:43         ` Mike Kravetz
2022-03-30  1:01           ` liupeng (DM)
2022-03-31 11:23           ` liupeng (DM)
2022-03-31 21:11             ` Mike Kravetz
2022-04-01  9:56               ` liupeng (DM)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220324074037.2024608-1-liupeng256@huawei.com \
    --to=liupeng256@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=yaozhenguo1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.