Now that architectures provide arch_hugetlb_valid_size(), parsing of "hugepagesz=" can be done in architecture independent code. Create a single routine to handle hugepagesz= parsing and remove all arch specific routines. We can also remove the interface hugetlb_bad_size() as this is no longer used outside arch independent code. This also provides consistent behavior of hugetlbfs command line options. The hugepagesz= option should only be specified once for a specific size, but some architectures allow multiple instances. This appears to be more of an oversight when code was added by some architectures to set up ALL huge pages sizes.
Unified · Split
| @@ -478,18 +478,3 @@ bool __init arch_hugetlb_valid_size(unsigned long size) · 477 unmodified lines | ||
| 478 | 478 | |
| 479 | 479 | return false; |
| 480 | 480 | } |
| 481 | − | |
| 482 | −static __init int setup_hugepagesz(char *opt) | |
| 483 | −{ | |
| 484 | − unsigned long ps = memparse(opt, &opt); | |
| 485 | − | |
| 486 | − if (arch_hugetlb_valid_size(ps)) { | |
| 487 | − add_huge_page_size(ps); | |
| 488 | − return 1; | |
| 489 | − } | |
| 490 | − | |
| 491 | − hugetlb_bad_size(); | |
| 492 | − pr_err("hugepagesz: Unsupported page size %lu K\n", ps >> 10); | |
| 493 | − return 0; | |
| 494 | −} | |
| 495 | −__setup("hugepagesz=", setup_hugepagesz); | |
| @@ -589,21 +589,6 @@ static int __init add_huge_page_size(unsigned long long size) · 588 unmodified lines | ||
| 589 | 589 | return 0; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | −static int __init hugepage_setup_sz(char *str) | |
| 593 | −{ | |
| 594 | − unsigned long long size; | |
| 595 | − | |
| 596 | − size = memparse(str, &str); | |
| 597 | − | |
| 598 | − if (add_huge_page_size(size) != 0) { | |
| 599 | − hugetlb_bad_size(); | |
| 600 | − pr_err("Invalid huge page size specified(%llu)\n", size); | |
| 601 | − } | |
| 602 | − | |
| 603 | − return 1; | |
| 604 | −} | |
| 605 | −__setup("hugepagesz=", hugepage_setup_sz); | |
| 606 | − | |
| 607 | 592 | static int __init hugetlbpage_init(void) |
| 608 | 593 | { |
| 609 | 594 | bool configured = false; |
| @@ -22,22 +22,6 @@ bool __init arch_hugetlb_valid_size(unsigned long size) · 21 unmodified lines | ||
| 22 | 22 | return false; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | −static __init int setup_hugepagesz(char *opt) | |
| 26 | −{ | |
| 27 | − unsigned long ps = memparse(opt, &opt); | |
| 28 | − | |
| 29 | − if (arch_hugetlb_valid_size(ps)) { | |
| 30 | − hugetlb_add_hstate(ilog2(ps) - PAGE_SHIFT); | |
| 31 | − return 1; | |
| 32 | − } | |
| 33 | − | |
| 34 | − hugetlb_bad_size(); | |
| 35 | − pr_err("hugepagesz: Unsupported page size %lu M\n", ps >> 20); | |
| 36 | − return 0; | |
| 37 | − | |
| 38 | −} | |
| 39 | −__setup("hugepagesz=", setup_hugepagesz); | |
| 40 | − | |
| 41 | 25 | #ifdef CONFIG_CONTIG_ALLOC |
| 42 | 26 | static __init int gigantic_pages_init(void) |
| 43 | 27 | { |
| @@ -264,24 +264,6 @@ bool __init arch_hugetlb_valid_size(unsigned long size) · 263 unmodified lines | ||
| 264 | 264 | return false; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | −static __init int setup_hugepagesz(char *opt) | |
| 268 | −{ | |
| 269 | − unsigned long size; | |
| 270 | − char *string = opt; | |
| 271 | − | |
| 272 | − size = memparse(opt, &opt); | |
| 273 | − if (arch_hugetlb_valid_size(size)) { | |
| 274 | − hugetlb_add_hstate(ilog2(size) - PAGE_SHIFT); | |
| 275 | − } else { | |
| 276 | − hugetlb_bad_size(); | |
| 277 | − pr_err("hugepagesz= specifies an unsupported page size %s\n", | |
| 278 | − string); | |
| 279 | − return 0; | |
| 280 | − } | |
| 281 | − return 1; | |
| 282 | −} | |
| 283 | −__setup("hugepagesz=", setup_hugepagesz); | |
| 284 | − | |
| 285 | 267 | static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file, |
| 286 | 268 | unsigned long addr, unsigned long len, |
| 287 | 269 | unsigned long pgoff, unsigned long flags) |
| @@ -397,28 +397,6 @@ bool __init arch_hugetlb_valid_size(unsigned long size) · 396 unmodified lines | ||
| 397 | 397 | |
| 398 | 398 | return true; |
| 399 | 399 | } |
| 400 | − | |
| 401 | −static int __init setup_hugepagesz(char *string) | |
| 402 | −{ | |
| 403 | − unsigned long long hugepage_size; | |
| 404 | − int rc = 0; | |
| 405 | − | |
| 406 | − hugepage_size = memparse(string, &string); | |
| 407 | − | |
| 408 | − if (!arch_hugetlb_valid_size((unsigned long)hugepage_size)) { | |
| 409 | − hugetlb_bad_size(); | |
| 410 | − pr_err("hugepagesz=%llu not supported by MMU.\n", | |
| 411 | − hugepage_size); | |
| 412 | − goto out; | |
| 413 | − } | |
| 414 | − | |
| 415 | − add_huge_page_size(hugepage_size); | |
| 416 | − rc = 1; | |
| 417 | − | |
| 418 | −out: | |
| 419 | − return rc; | |
| 420 | −} | |
| 421 | −__setup("hugepagesz=", setup_hugepagesz); | |
| 422 | 400 | #endif /* CONFIG_HUGETLB_PAGE */ |
| 423 | 401 | |
| 424 | 402 | void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) |
| @@ -191,22 +191,6 @@ bool __init arch_hugetlb_valid_size(unsigned long size) · 190 unmodified lines | ||
| 191 | 191 | return false; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | −static __init int setup_hugepagesz(char *opt) | |
| 195 | −{ | |
| 196 | − unsigned long ps = memparse(opt, &opt); | |
| 197 | − | |
| 198 | − if (arch_hugetlb_valid_size(ps)) { | |
| 199 | − hugetlb_add_hstate(ilog2(ps) - PAGE_SHIFT); | |
| 200 | − } else { | |
| 201 | − hugetlb_bad_size(); | |
| 202 | − printk(KERN_ERR "hugepagesz: Unsupported page size %lu M\n", | |
| 203 | − ps >> 20); | |
| 204 | − return 0; | |
| 205 | − } | |
| 206 | − return 1; | |
| 207 | −} | |
| 208 | −__setup("hugepagesz=", setup_hugepagesz); | |
| 209 | − | |
| 210 | 194 | #ifdef CONFIG_CONTIG_ALLOC |
| 211 | 195 | static __init int gigantic_pages_init(void) |
| 212 | 196 | { |
| @@ -519,7 +519,6 @@ int huge_add_to_page_cache(struct page *page, struct address_space *mapping, · 518 unmodified lines | ||
| 519 | 519 | int __init __alloc_bootmem_huge_page(struct hstate *h); |
| 520 | 520 | int __init alloc_bootmem_huge_page(struct hstate *h); |
| 521 | 521 | |
| 522 | −void __init hugetlb_bad_size(void); | |
| 523 | 522 | void __init hugetlb_add_hstate(unsigned order); |
| 524 | 523 | bool __init arch_hugetlb_valid_size(unsigned long size); |
| 525 | 524 | struct hstate *size_to_hstate(unsigned long size); |
| @@ -3262,12 +3262,6 @@ bool __init __attribute((weak)) arch_hugetlb_valid_size(unsigned long size) · 3261 unmodified lines | ||
| 3262 | 3262 | return size == HPAGE_SIZE; |
| 3263 | 3263 | } |
| 3264 | 3264 | |
| 3265 | −/* Should be called on processing a hugepagesz=... option */ | |
| 3266 | −void __init hugetlb_bad_size(void) | |
| 3267 | −{ | |
| 3268 | − parsed_valid_hugepagesz = false; | |
| 3269 | −} | |
| 3270 | − | |
| 3271 | 3265 | void __init hugetlb_add_hstate(unsigned int order) |
| 3272 | 3266 | { |
| 3273 | 3267 | struct hstate *h; |
| @@ -3337,6 +3331,23 @@ static int __init hugetlb_nrpages_setup(char *s) · 63 unmodified lines | ||
| 3337 | 3331 | } |
| 3338 | 3332 | __setup("hugepages=", hugetlb_nrpages_setup); |
| 3339 | 3333 | |
| 3334 | +static int __init hugepagesz_setup(char *s) | |
| 3335 | +{ | |
| 3336 | + unsigned long size; | |
| 3337 | + | |
| 3338 | + size = (unsigned long)memparse(s, NULL); | |
| 3339 | + | |
| 3340 | + if (!arch_hugetlb_valid_size(size)) { | |
| 3341 | + parsed_valid_hugepagesz = false; | |
| 3342 | + pr_err("HugeTLB: unsupported hugepagesz %s\n", s); | |
| 3343 | + return 0; | |
| 3344 | + } | |
| 3345 | + | |
| 3346 | + hugetlb_add_hstate(ilog2(size) - PAGE_SHIFT); | |
| 3347 | + return 1; | |
| 3348 | +} | |
| 3349 | +__setup("hugepagesz=", hugepagesz_setup); | |
| 3350 | + | |
| 3340 | 3351 | static int __init default_hugepagesz_setup(char *s) |
| 3341 | 3352 | { |
| 3342 | 3353 | unsigned long size; |