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

Configure Feed

Select the types of activity you want to include in your feed.

powerpc/mm: Move get_unmapped_area functions to slice.c

hugetlb_get_unmapped_area() is now identical to the
generic version if only RADIX is enabled, so move it
to slice.c and let it fallback on the generic one
when HASH MMU is not compiled in.

Do the same with arch_get_unmapped_area() and
arch_get_unmapped_area_topdown().

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/b5d9c124e82889e0cb115c150915a0c0d84eb960.1649523076.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
ab57bd75 1a0261fd

+48 -63
-6
arch/powerpc/include/asm/book3s/64/mmu.h
··· 4 4 5 5 #include <asm/page.h> 6 6 7 - #ifdef CONFIG_HUGETLB_PAGE 8 - #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA 9 - #endif 10 - #define HAVE_ARCH_UNMAPPED_AREA 11 - #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN 12 - 13 7 #ifndef __ASSEMBLY__ 14 8 /* 15 9 * Page size definition
+6
arch/powerpc/include/asm/book3s/64/slice.h
··· 4 4 5 5 #ifndef __ASSEMBLY__ 6 6 7 + #ifdef CONFIG_HUGETLB_PAGE 8 + #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA 9 + #endif 10 + #define HAVE_ARCH_UNMAPPED_AREA 11 + #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN 12 + 7 13 #define SLICE_LOW_SHIFT 28 8 14 #define SLICE_LOW_TOP (0x100000000ul) 9 15 #define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT)
+42
arch/powerpc/mm/book3s64/slice.c
··· 639 639 } 640 640 EXPORT_SYMBOL_GPL(slice_get_unmapped_area); 641 641 642 + unsigned long arch_get_unmapped_area(struct file *filp, 643 + unsigned long addr, 644 + unsigned long len, 645 + unsigned long pgoff, 646 + unsigned long flags) 647 + { 648 + if (radix_enabled()) 649 + return generic_get_unmapped_area(filp, addr, len, pgoff, flags); 650 + 651 + return slice_get_unmapped_area(addr, len, flags, 652 + mm_ctx_user_psize(&current->mm->context), 0); 653 + } 654 + 655 + unsigned long arch_get_unmapped_area_topdown(struct file *filp, 656 + const unsigned long addr0, 657 + const unsigned long len, 658 + const unsigned long pgoff, 659 + const unsigned long flags) 660 + { 661 + if (radix_enabled()) 662 + return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags); 663 + 664 + return slice_get_unmapped_area(addr0, len, flags, 665 + mm_ctx_user_psize(&current->mm->context), 1); 666 + } 667 + 642 668 unsigned int notrace get_slice_psize(struct mm_struct *mm, unsigned long addr) 643 669 { 644 670 unsigned char *psizes; ··· 791 765 return vma_kernel_pagesize(vma); 792 766 793 767 return 1UL << mmu_psize_to_shift(get_slice_psize(vma->vm_mm, vma->vm_start)); 768 + } 769 + 770 + static int file_to_psize(struct file *file) 771 + { 772 + struct hstate *hstate = hstate_file(file); 773 + return shift_to_mmu_psize(huge_page_shift(hstate)); 774 + } 775 + 776 + unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, 777 + unsigned long len, unsigned long pgoff, 778 + unsigned long flags) 779 + { 780 + if (radix_enabled()) 781 + return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); 782 + 783 + return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); 794 784 } 795 785 #endif
-21
arch/powerpc/mm/hugetlbpage.c
··· 542 542 return page; 543 543 } 544 544 545 - #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA 546 - static inline int file_to_psize(struct file *file) 547 - { 548 - struct hstate *hstate = hstate_file(file); 549 - return shift_to_mmu_psize(huge_page_shift(hstate)); 550 - } 551 - 552 - unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, 553 - unsigned long len, unsigned long pgoff, 554 - unsigned long flags) 555 - { 556 - if (radix_enabled()) 557 - return generic_hugetlb_get_unmapped_area(file, addr, len, 558 - pgoff, flags); 559 - #ifdef CONFIG_PPC_64S_HASH_MMU 560 - return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); 561 - #endif 562 - BUG(); 563 - } 564 - #endif 565 - 566 545 bool __init arch_hugetlb_valid_size(unsigned long size) 567 546 { 568 547 int shift = __ffs(size);
-36
arch/powerpc/mm/mmap.c
··· 80 80 return PAGE_ALIGN(DEFAULT_MAP_WINDOW - gap - rnd); 81 81 } 82 82 83 - #ifdef HAVE_ARCH_UNMAPPED_AREA 84 - unsigned long arch_get_unmapped_area(struct file *filp, 85 - unsigned long addr, 86 - unsigned long len, 87 - unsigned long pgoff, 88 - unsigned long flags) 89 - { 90 - if (radix_enabled()) 91 - return generic_get_unmapped_area(filp, addr, len, pgoff, flags); 92 - 93 - #ifdef CONFIG_PPC_64S_HASH_MMU 94 - return slice_get_unmapped_area(addr, len, flags, 95 - mm_ctx_user_psize(&current->mm->context), 0); 96 - #else 97 - BUG(); 98 - #endif 99 - } 100 - 101 - unsigned long arch_get_unmapped_area_topdown(struct file *filp, 102 - const unsigned long addr0, 103 - const unsigned long len, 104 - const unsigned long pgoff, 105 - const unsigned long flags) 106 - { 107 - if (radix_enabled()) 108 - return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags); 109 - 110 - #ifdef CONFIG_PPC_64S_HASH_MMU 111 - return slice_get_unmapped_area(addr0, len, flags, 112 - mm_ctx_user_psize(&current->mm->context), 1); 113 - #else 114 - BUG(); 115 - #endif 116 - } 117 - #endif /* HAVE_ARCH_UNMAPPED_AREA */ 118 - 119 83 /* 120 84 * This function, called very early during the creation of a new 121 85 * process VM image, sets up which VM layout function to use: