History

hugetlbfs: move hugepagesz= parsing to arch independent code

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.

Mike Kravetz committed 6 years ago

Commit 359f2541 parent ae94da88 files · +17 −109Browse files

Unified · Split

8 files
  1. arch/arm64/mm/hugetlbpage.c +0 −15
  2. arch/powerpc/mm/hugetlbpage.c +0 −15
  3. arch/riscv/mm/hugetlbpage.c +0 −16
  4. arch/s390/mm/hugetlbpage.c +0 −18
  5. arch/sparc/mm/init_64.c +0 −22
  6. arch/x86/mm/hugetlbpage.c +0 −16
  7. include/linux/hugetlb.h +0 −1
  8. mm/hugetlb.c +17 −6
arch/arm64/mm/hugetlbpage.c+0−15
@@ -478,18 +478,3 @@ bool __init arch_hugetlb_valid_size(unsigned long size) · 477 unmodified lines
478478
479479 return false;
480480 }
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);
arch/powerpc/mm/hugetlbpage.c+0−15
@@ -589,21 +589,6 @@ static int __init add_huge_page_size(unsigned long long size) · 588 unmodified lines
589589 return 0;
590590 }
591591
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−
607592 static int __init hugetlbpage_init(void)
608593 {
609594 bool configured = false;
arch/riscv/mm/hugetlbpage.c+0−16
@@ -22,22 +22,6 @@ bool __init arch_hugetlb_valid_size(unsigned long size) · 21 unmodified lines
2222 return false;
2323 }
2424
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−
4125 #ifdef CONFIG_CONTIG_ALLOC
4226 static __init int gigantic_pages_init(void)
4327 {
arch/s390/mm/hugetlbpage.c+0−18
@@ -264,24 +264,6 @@ bool __init arch_hugetlb_valid_size(unsigned long size) · 263 unmodified lines
264264 return false;
265265 }
266266
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−
285267 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
286268 unsigned long addr, unsigned long len,
287269 unsigned long pgoff, unsigned long flags)
arch/sparc/mm/init_64.c+0−22
@@ -397,28 +397,6 @@ bool __init arch_hugetlb_valid_size(unsigned long size) · 396 unmodified lines
397397
398398 return true;
399399 }
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);
422400 #endif /* CONFIG_HUGETLB_PAGE */
423401
424402 void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *ptep)
arch/x86/mm/hugetlbpage.c+0−16
@@ -191,22 +191,6 @@ bool __init arch_hugetlb_valid_size(unsigned long size) · 190 unmodified lines
191191 return false;
192192 }
193193
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−
210194 #ifdef CONFIG_CONTIG_ALLOC
211195 static __init int gigantic_pages_init(void)
212196 {
include/linux/hugetlb.h+0−1
@@ -519,7 +519,6 @@ int huge_add_to_page_cache(struct page *page, struct address_space *mapping, · 518 unmodified lines
519519 int __init __alloc_bootmem_huge_page(struct hstate *h);
520520 int __init alloc_bootmem_huge_page(struct hstate *h);
521521
522−void __init hugetlb_bad_size(void);
523522 void __init hugetlb_add_hstate(unsigned order);
524523 bool __init arch_hugetlb_valid_size(unsigned long size);
525524 struct hstate *size_to_hstate(unsigned long size);
mm/hugetlb.c+17−6
@@ -3262,12 +3262,6 @@ bool __init __attribute((weak)) arch_hugetlb_valid_size(unsigned long size) · 3261 unmodified lines
32623262 return size == HPAGE_SIZE;
32633263 }
32643264
3265−/* Should be called on processing a hugepagesz=... option */
3266−void __init hugetlb_bad_size(void)
3267−{
3268− parsed_valid_hugepagesz = false;
3269−}
3270−
32713265 void __init hugetlb_add_hstate(unsigned int order)
32723266 {
32733267 struct hstate *h;
@@ -3337,6 +3331,23 @@ static int __init hugetlb_nrpages_setup(char *s) · 63 unmodified lines
33373331 }
33383332 __setup("hugepages=", hugetlb_nrpages_setup);
33393333
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+
33403351 static int __init default_hugepagesz_setup(char *s)
33413352 {
33423353 unsigned long size;