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 151CE646 for ; Thu, 12 Dec 2024 00:13:07 +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=1733962388; cv=none; b=q0pQi03z93FNJz3uA02s9SNnvfp3rHWcwvWRA8Ith16VzdN7ZxDJsQSIGGp0H1AprYFW45/8sf/dhngAKW5yVotwCNguyyOEWc/P5qrn2/afVp7fbxfO9rkp7l+A2tzsXk7XuHKV8gYsLP2TyE0hYTFyDQjffKwO8JOXYMrgQ4k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733962388; c=relaxed/simple; bh=G3s7xIn1jllE7EQw9uKmDfNLRZaEt2osKoq+6CKdD5w=; h=Date:To:From:Subject:Message-Id; b=LJWWDn6EkTJeWrbVUNa5WuRD3igCDsySe82kUAoDNszzj3HkR+v3x1YehDe5YeAPmDDV6P0u0w/E6sLt243WrTbdri+OiZDc6SvfSEQ0jxi+NTbNNAsVrCNCCo1rM90kMpFf9b27x0wTfj3HMckbI+gN5yOMsPijSVYrshrs+Nk= 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=RazQmbEj; 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="RazQmbEj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F261C4CED2; Thu, 12 Dec 2024 00:13:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1733962387; bh=G3s7xIn1jllE7EQw9uKmDfNLRZaEt2osKoq+6CKdD5w=; h=Date:To:From:Subject:From; b=RazQmbEjB4w3e9L8skj4NqrksgHN1TzdvBCcoOmKUr55OCIWGtxqf+UDsM/mSQLLv eCiTESpBGc2LpPUa7eWRtRnNAyz/+kib8bcY//GMn/DC+Lx0D8NnnXXkEtusectDHY +KQfBhGWxqluQthd2S/uy3VLiFThWk9a0PpaEacM= Date: Wed, 11 Dec 2024 16:13:06 -0800 To: mm-commits@vger.kernel.org,ysato@users.sourceforge.jp,yang@os.amperecomputing.com,vbabka@suse.cz,tsbogend@alpha.franken.de,tglx@linutronix.de,riel@surriel.com,minchan@kernel.org,linux@armlinux.org.uk,leitao@debian.org,jcmvbkbc@gmail.com,jason.andryuk@amd.com,James.Bottomley@HansenPartnership.com,glaubitz@physik.fu-berlin.de,david@redhat.com,davem@davemloft.net,dave.hansen@linux.intel.com,dalias@libc.org,chris@zankel.net,bp@alien8.de,bhelgaas@google.com,andreas@gaisler.com,kaleshsingh@google.com,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-csky-introduce-arch_mmap_hint.patch added to mm-unstable branch Message-Id: <20241212001307.7F261C4CED2@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm: csky: introduce arch_mmap_hint() has been added to the -mm mm-unstable branch. Its filename is mm-csky-introduce-arch_mmap_hint.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-csky-introduce-arch_mmap_hint.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: Kalesh Singh Subject: mm: csky: introduce arch_mmap_hint() Date: Wed, 11 Dec 2024 15:27:44 -0800 Introduce csky arch_mmap_hint() and define HAVE_ARCH_MMAP_HINT. This is a preparatory patch, no functional change is introduced. Link: https://lkml.kernel.org/r/20241211232754.1583023-7-kaleshsingh@google.com Signed-off-by: Kalesh Singh Cc: Andreas Larsson Cc: Bjorn Helgaas Cc: Borislav Petkov (AMD) Cc: Breno Leitao Cc: Chris Zankel Cc: Dave Hansen Cc: David Hildenbrand Cc: David S. Miller Cc: James Bottomley Cc: Jason Andryuk Cc: John Paul Adrian Glaubitz Cc: Max Filippov Cc: Minchan Kim Cc: Rich Felker Cc: Rik van Riel Cc: Russell King Cc: Thomas Bogendoerfer Cc: Thomas Gleixner Cc: Vlastimil Babka Cc: Yang Shi Cc: Yoshinori Sato Signed-off-by: Andrew Morton --- arch/csky/abiv1/inc/abi/pgtable-bits.h | 1 arch/csky/abiv1/mmap.c | 68 ++++++++++++----------- 2 files changed, 38 insertions(+), 31 deletions(-) --- a/arch/csky/abiv1/inc/abi/pgtable-bits.h~mm-csky-introduce-arch_mmap_hint +++ a/arch/csky/abiv1/inc/abi/pgtable-bits.h @@ -51,5 +51,6 @@ ((offset) << 10)}) #define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_MMAP_HINT #endif /* __ASM_CSKY_PGTABLE_BITS_H */ --- a/arch/csky/abiv1/mmap.c~mm-csky-introduce-arch_mmap_hint +++ a/arch/csky/abiv1/mmap.c @@ -13,6 +13,39 @@ ((((addr)+SHMLBA-1)&~(SHMLBA-1)) + \ (((pgoff)< TASK_SIZE) + return -ENOMEM; + + /* + * We only need to do colour alignment if either the I or D + * caches alias. + */ + do_align = filp || (flags & MAP_SHARED); + + /* + * We enforce the MAP_FIXED case. + */ + if (flags & MAP_FIXED) { + if (flags & MAP_SHARED && + (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)) + return -EINVAL; + return addr; + } + + if (do_align) + addr = COLOUR_ALIGN(addr, pgoff); + else + addr = PAGE_ALIGN(addr); + + return generic_mmap_hint(filp, addr, len, pgoff, flags); +} + /* * We need to ensure that shared mappings are correctly aligned to * avoid aliasing issues with VIPT caches. We need to ensure that @@ -27,8 +60,7 @@ arch_get_unmapped_area(struct file *filp unsigned long flags, vm_flags_t vm_flags) { struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; - int do_align = 0; + bool do_align; struct vm_unmapped_area_info info = { .length = len, .low_limit = mm->mmap_base, @@ -36,37 +68,11 @@ arch_get_unmapped_area(struct file *filp .align_offset = pgoff << PAGE_SHIFT }; - /* - * We only need to do colour alignment if either the I or D - * caches alias. - */ - do_align = filp || (flags & MAP_SHARED); - - /* - * We enforce the MAP_FIXED case. - */ - if (flags & MAP_FIXED) { - if (flags & MAP_SHARED && - (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)) - return -EINVAL; + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) return addr; - } - - if (len > TASK_SIZE) - return -ENOMEM; - - if (addr) { - if (do_align) - addr = COLOUR_ALIGN(addr, pgoff); - else - addr = PAGE_ALIGN(addr); - - vma = find_vma(mm, addr); - if (TASK_SIZE - len >= addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } + do_align = filp || (flags & MAP_SHARED); info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; return vm_unmapped_area(&info); } _ Patches currently in -mm which might be from kaleshsingh@google.com are mm-introduce-generic_mmap_hint.patch mm-x86-introduce-arch_mmap_hint.patch mm-arm-introduce-arch_mmap_hint.patch mm-alpha-introduce-arch_mmap_hint.patch mm-arc-use-generic_mmap_hint.patch mm-csky-introduce-arch_mmap_hint.patch mm-loongarch-introduce-arch_mmap_hint.patch mm-mips-introduce-arch_align_mmap_hint.patch mm-parisc-introduce-arch_align_mmap_hint.patch mm-s390-use-generic_mmap_hint.patch mm-sh-introduce-arch_mmap_hint.patch mm-sparc32-introduce-arch_mmap_hint.patch mm-sparc64-introduce-arch_mmap_hint.patch mm-xtensa-introduce-arch_mmap_hint.patch mm-powerpc-introduce-arch_mmap_hint.patch mm-respect-mmap-hint-before-thp-alignment-if-allocation-is-possible.patch