From: Longpeng <longpeng2@xxxxxxxxxx> Some architectures(e.g. x86,risv) doesn't add 2M-hstate by default, so if we add 'default_hugepagesz=2M' but without 'hugepagesz=2M' in cmdline, we'll get a message as follow: "HugeTLB: unsupported default_hugepagesz 2097152. Reverting to 2097152" As architecture-specific HPAGE_SIZE hstate should be supported by default, we can avoid this weird message by add it if we hadn't yet. Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Qian Cai <cai@xxxxxx> Cc: linux-kernel@xxxxxxxxxxxxxxx Cc: linux-mm@xxxxxxxxx Signed-off-by: Longpeng <longpeng2@xxxxxxxxxx> --- mm/hugetlb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index dd8737a..21f623b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2829,6 +2829,9 @@ static int __init hugetlb_init(void) if (!hugepages_supported()) return 0; + if (!size_to_hstate(HPAGE_SIZE)) + hugetlb_add_hstate(HUGETLB_PAGE_ORDER); + if (!size_to_hstate(default_hstate_size)) { if (default_hstate_size != 0) { pr_err("HugeTLB: unsupported default_hugepagesz %lu. Reverting to %lu\n", @@ -2836,8 +2839,6 @@ static int __init hugetlb_init(void) } default_hstate_size = HPAGE_SIZE; - if (!size_to_hstate(default_hstate_size)) - hugetlb_add_hstate(HUGETLB_PAGE_ORDER); } default_hstate_idx = hstate_index(size_to_hstate(default_hstate_size)); if (default_hstate_max_huge_pages) { -- 1.8.3.1