Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sparc64: Register hugepages during arch init

Add hstate for each supported hugepage size using
arch initcall. This change fixes some hugepage
parameter parsing inconsistencies:

case 1: no hugepage parameters

Without hugepage parameters, only a hugepages-8192kB entry is visible
in sysfs. It's different from x86_64 where both 2M and 1G hugepage
sizes are available.

case 2: default_hugepagesz=[64K|256M|2G]

When specifying only a default_hugepagesz parameter, the default
hugepage size isn't really changed and it stays at 8M. This is again
different from x86_64.

Orabug: 25869946

Reviewed-by: Bob Picco <bob.picco@oracle.com>
Signed-off-by: Nitin Gupta <nitin.m.gupta@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Nitin Gupta and committed by
David S. Miller
8399e4b8 fc290a11

+24 -1
+24 -1
arch/sparc/mm/init_64.c
··· 325 325 } 326 326 327 327 #ifdef CONFIG_HUGETLB_PAGE 328 + static void __init add_huge_page_size(unsigned long size) 329 + { 330 + unsigned int order; 331 + 332 + if (size_to_hstate(size)) 333 + return; 334 + 335 + order = ilog2(size) - PAGE_SHIFT; 336 + hugetlb_add_hstate(order); 337 + } 338 + 339 + static int __init hugetlbpage_init(void) 340 + { 341 + add_huge_page_size(1UL << HPAGE_64K_SHIFT); 342 + add_huge_page_size(1UL << HPAGE_SHIFT); 343 + add_huge_page_size(1UL << HPAGE_256MB_SHIFT); 344 + add_huge_page_size(1UL << HPAGE_2GB_SHIFT); 345 + 346 + return 0; 347 + } 348 + 349 + arch_initcall(hugetlbpage_init); 350 + 328 351 static int __init setup_hugepagesz(char *string) 329 352 { 330 353 unsigned long long hugepage_size; ··· 387 364 goto out; 388 365 } 389 366 390 - hugetlb_add_hstate(hugepage_shift - PAGE_SHIFT); 367 + add_huge_page_size(hugepage_size); 391 368 rc = 1; 392 369 393 370 out: