From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 034707E1 for ; Mon, 29 Jul 2024 23:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722295897; cv=none; b=jgQaN8toYEQB1SwsdG1g84ya7SSDiQtS9LGzLweYQ5asFy4423bzi2+xJgiLna7SuxRFnXLT5hAH7jqUXRkmC/z3HG0nLoFEg6qDMN5aQhwzQIPVz8RDEEIeiEIZqg1YL0TFVGnJ/KkZBJl9odQU/Z4hvRdcvRN8m6MXeIm/y6o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722295897; c=relaxed/simple; bh=xpmKiRv+MZL0tBia5fFQhAW7Gib92vhzaPEMj7Gg1wo=; h=Date:To:From:Subject:Message-Id; b=fdQ9yf2ukgwRlW1/xS5+qqBiM1AbdAR7uTWdl7MZ40axEjKKEgD3vXxD9+Z9TgT30qeEhXYvswBGwRWMyTyfym4pt4CfUCPq/i0AVHSRnsjZ0tN0WBpY3v2gZoCSU9yKkdfoFYhUyubeodnw4cp+F7r9unos7IT1OPjH1n7SQw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=kTqUnIBr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="kTqUnIBr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBAFBC32786; Mon, 29 Jul 2024 23:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1722295896; bh=xpmKiRv+MZL0tBia5fFQhAW7Gib92vhzaPEMj7Gg1wo=; h=Date:To:From:Subject:From; b=kTqUnIBrAE8WsI57PilgTCJ1Gy6/ClxfvI4ubQ6VieqLfNbxPa0sRM1Zj9sHfmhbT 1VAAMeoaVONDR5bgW6/5GVg5K+r+sLENMxr5lxSIceMfz7jfzDB7lk/M1MIiZLvWIb 47oCfVPlqjIipeCIzvUKxeRc5zrGmMGyyZ60hk3k= Date: Mon, 29 Jul 2024 16:31:36 -0700 To: mm-commits@vger.kernel.org,willy@infradead.org,vbabka@suse.cz,peterx@redhat.com,muchun.song@linux.dev,mhocko@suse.com,donettom@linux.ibm.com,david@redhat.com,osalvador@suse.de,akpm@linux-foundation.org From: Andrew Morton Subject: + arch-powerpc-teach-book3s64-arch_get_unmapped_area_topdown-to-handle-hugetlb-mappings.patch added to mm-unstable branch Message-Id: <20240729233136.BBAFBC32786@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: arch/powerpc: teach book3s64 arch_get_unmapped_area{_topdown} to handle hugetlb mappings has been added to the -mm mm-unstable branch. Its filename is arch-powerpc-teach-book3s64-arch_get_unmapped_area_topdown-to-handle-hugetlb-mappings.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/arch-powerpc-teach-book3s64-arch_get_unmapped_area_topdown-to-handle-hugetlb-mappings.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Oscar Salvador Subject: arch/powerpc: teach book3s64 arch_get_unmapped_area{_topdown} to handle hugetlb mappings Date: Mon, 29 Jul 2024 11:10:14 +0200 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. Reshuffle file_to_psize() definition so arch_get_unmapped_area{_topdown} can make use of it. Link: https://lkml.kernel.org/r/20240729091018.2152-6-osalvador@suse.de Signed-off-by: Oscar Salvador Cc: David Hildenbrand Cc: Donet Tom Cc: Matthew Wilcox (Oracle) Cc: Michal Hocko Cc: Muchun Song Cc: Peter Xu Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- arch/powerpc/mm/book3s64/slice.c | 39 +++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) --- a/arch/powerpc/mm/book3s64/slice.c~arch-powerpc-teach-book3s64-arch_get_unmapped_area_topdown-to-handle-hugetlb-mappings +++ a/arch/powerpc/mm/book3s64/slice.c @@ -633,17 +633,36 @@ return_addr: } EXPORT_SYMBOL_GPL(slice_get_unmapped_area); +#ifdef CONFIG_HUGETLB_PAGE +static int file_to_psize(struct file *file) +{ + struct hstate *hstate = hstate_file(file); + return shift_to_mmu_psize(huge_page_shift(hstate)); +} +#else +static int file_to_psize(struct file *file) +{ + return 0; +} +#endif + unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { + unsigned int psize; + if (radix_enabled()) return generic_get_unmapped_area(filp, addr, len, pgoff, flags); - return slice_get_unmapped_area(addr, len, flags, - mm_ctx_user_psize(¤t->mm->context), 0); + if (filp && is_file_hugepages(filp)) + psize = file_to_psize(filp); + else + psize = mm_ctx_user_psize(¤t->mm->context); + + return slice_get_unmapped_area(addr, len, flags, psize, 0); } unsigned long arch_get_unmapped_area_topdown(struct file *filp, @@ -652,11 +671,17 @@ unsigned long arch_get_unmapped_area_top const unsigned long pgoff, const unsigned long flags) { + unsigned int psize; + if (radix_enabled()) return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags); - return slice_get_unmapped_area(addr0, len, flags, - mm_ctx_user_psize(¤t->mm->context), 1); + if (filp && is_file_hugepages(filp)) + psize = file_to_psize(filp); + else + psize = mm_ctx_user_psize(¤t->mm->context); + + return slice_get_unmapped_area(addr0, len, flags, psize, 1); } unsigned int notrace get_slice_psize(struct mm_struct *mm, unsigned long addr) @@ -787,12 +812,6 @@ unsigned long vma_mmu_pagesize(struct vm return 1UL << mmu_psize_to_shift(get_slice_psize(vma->vm_mm, vma->vm_start)); } -static int file_to_psize(struct file *file) -{ - struct hstate *hstate = hstate_file(file); - return shift_to_mmu_psize(huge_page_shift(hstate)); -} - unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) _ Patches currently in -mm which might be from osalvador@suse.de are mm-mmap-teach-generic_get_unmapped_area_topdown-to-handle-hugetlb-mappings.patch arch-s390-teach-arch_get_unmapped_area_topdown-to-handle-hugetlb-mappings.patch arch-x86-teach-arch_get_unmapped_area_vmflags-to-handle-hugetlb-mappings.patch arch-sparc-teach-arch_get_unmapped_area_topdown-to-handle-hugetlb-mappings.patch arch-powerpc-teach-book3s64-arch_get_unmapped_area_topdown-to-handle-hugetlb-mappings.patch mm-make-hugetlb-mappings-go-through-mm_get_unmapped_area_vmflags.patch mm-drop-hugetlb_get_unmapped_area_-functions.patch arch-s390-clean-up-hugetlb-definitions.patch mm-consolidate-common-checks-in-hugetlb_mmap_check_and_align.patch