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

arch/s390: teach arch_get_unmapped_area{_topdown} to handle hugetlb mappings

We want to stop special casing hugetlb mappings and make them go through
generic channels, so teach arch_get_unmapped_area{_topdown} to handle
those.

s390 specific hugetlb function does not set info.align_offset, so do the
same here for compatibility.

Link: https://lkml.kernel.org/r/20241007075037.267650-3-osalvador@suse.de
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@redhat.com>
Cc: Donet Tom <donettom@linux.ibm.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Peter Xu <peterx@redhat.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Oscar Salvador and committed by
Andrew Morton
7d7dba7f 7f24cbc9

+7 -2
+7 -2
arch/s390/mm/mmap.c
··· 17 17 #include <linux/random.h> 18 18 #include <linux/compat.h> 19 19 #include <linux/security.h> 20 + #include <linux/hugetlb.h> 20 21 #include <asm/elf.h> 21 22 22 23 static unsigned long stack_maxrandom_size(void) ··· 74 73 75 74 static int get_align_mask(struct file *filp, unsigned long flags) 76 75 { 76 + if (filp && is_file_hugepages(filp)) 77 + return huge_page_mask_align(filp); 77 78 if (!(current->flags & PF_RANDOMIZE)) 78 79 return 0; 79 80 if (filp || (flags & MAP_SHARED)) ··· 109 106 info.low_limit = mm->mmap_base; 110 107 info.high_limit = TASK_SIZE; 111 108 info.align_mask = get_align_mask(filp, flags); 112 - info.align_offset = pgoff << PAGE_SHIFT; 109 + if (!(filp && is_file_hugepages(filp))) 110 + info.align_offset = pgoff << PAGE_SHIFT; 113 111 addr = vm_unmapped_area(&info); 114 112 if (offset_in_page(addr)) 115 113 return addr; ··· 148 144 info.low_limit = PAGE_SIZE; 149 145 info.high_limit = mm->mmap_base; 150 146 info.align_mask = get_align_mask(filp, flags); 151 - info.align_offset = pgoff << PAGE_SHIFT; 147 + if (!(filp && is_file_hugepages(filp))) 148 + info.align_offset = pgoff << PAGE_SHIFT; 152 149 addr = vm_unmapped_area(&info); 153 150 154 151 /*