[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241211232754.1583023-10-kaleshsingh@google.com>
Date: Wed, 11 Dec 2024 15:27:47 -0800
From: Kalesh Singh <kaleshsingh@...gle.com>
To: akpm@...ux-foundation.org, vbabka@...e.cz, yang@...amperecomputing.com,
riel@...riel.com, david@...hat.com, minchan@...nel.org, jyescas@...gle.com
Cc: linux@...linux.org.uk, tsbogend@...ha.franken.de,
James.Bottomley@...senPartnership.com, ysato@...rs.sourceforge.jp,
dalias@...c.org, glaubitz@...sik.fu-berlin.de, davem@...emloft.net,
andreas@...sler.com, tglx@...utronix.de, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, chris@...kel.net,
jcmvbkbc@...il.com, bhelgaas@...gle.com, jason.andryuk@....com,
leitao@...ian.org, linux-alpha@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-snps-arc@...ts.infradead.org, linux-arm-kernel@...ts.infradead.org,
linux-csky@...r.kernel.org, loongarch@...ts.linux.dev,
linux-mips@...r.kernel.org, linux-parisc@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org, linux-s390@...r.kernel.org,
linux-sh@...r.kernel.org, sparclinux@...r.kernel.org, linux-mm@...ck.org,
kernel-team@...roid.com, android-mm@...gle.com,
Kalesh Singh <kaleshsingh@...gle.com>
Subject: [PATCH mm-unstable v2 09/16] mm: parisc: Introduce arch_align_mmap_hint()
Introduce parisc arch_mmap_hint() and define HAVE_ARCH_MMAP_HINT.
This is a preparatory patch, no functional change is introduced.
Signed-off-by: Kalesh Singh <kaleshsingh@...gle.com>
---
Changes in v2:
- MAP_FIXED case is also handled in arch_mmap_hint() since this is just a
special case of the hint addr being "enforced", per Yang Shi.
- Consolidate error handling in arch_mmap_hint().
arch/parisc/include/asm/pgtable.h | 1 +
arch/parisc/kernel/sys_parisc.c | 53 +++++++++++++++++--------------
2 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index babf65751e81..73987357c78e 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -505,6 +505,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
#define HAVE_ARCH_UNMAPPED_AREA
#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
+#define HAVE_ARCH_MMAP_HINT
#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index f852fe274abe..c1702d481e33 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -96,24 +96,16 @@ unsigned long mmap_upper_limit(struct rlimit *rlim_stack)
enum mmap_allocation_direction {UP, DOWN};
-static unsigned long arch_get_unmapped_area_common(struct file *filp,
- unsigned long addr, unsigned long len, unsigned long pgoff,
- unsigned long flags, enum mmap_allocation_direction dir)
+unsigned long arch_mmap_hint(struct file *filp, unsigned long addr,
+ unsigned long len, unsigned long pgoff,
+ unsigned long flags)
{
- struct mm_struct *mm = current->mm;
- struct vm_area_struct *vma, *prev;
unsigned long filp_pgoff;
- int do_color_align;
- struct vm_unmapped_area_info info = {
- .length = len
- };
+ bool do_color_align;
if (unlikely(len > TASK_SIZE))
return -ENOMEM;
- do_color_align = 0;
- if (filp || (flags & MAP_SHARED))
- do_color_align = 1;
filp_pgoff = GET_FILP_PGOFF(filp);
if (flags & MAP_FIXED) {
@@ -128,18 +120,33 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
return addr;
}
- if (addr) {
- if (do_color_align)
- addr = COLOR_ALIGN(addr, filp_pgoff, pgoff);
- else
- addr = PAGE_ALIGN(addr);
+ do_color_align = filp || (flags & MAP_SHARED);
- vma = find_vma_prev(mm, addr, &prev);
- if (TASK_SIZE - len >= addr &&
- (!vma || addr + len <= vm_start_gap(vma)) &&
- (!prev || addr >= vm_end_gap(prev)))
- return addr;
- }
+ if (do_color_align)
+ addr = COLOR_ALIGN(addr, filp_pgoff, pgoff);
+ else
+ addr = PAGE_ALIGN(addr);
+
+ return generic_mmap_hint(filp, addr, len, pgoff, flags);
+}
+
+static unsigned long arch_get_unmapped_area_common(struct file *filp,
+ unsigned long addr, unsigned long len, unsigned long pgoff,
+ unsigned long flags, enum mmap_allocation_direction dir)
+{
+ struct mm_struct *mm = current->mm;
+ unsigned long filp_pgoff;
+ bool do_color_align;
+ struct vm_unmapped_area_info info = {
+ .length = len
+ };
+
+ addr = arch_mmap_hint(filp, addr, len, pgoff, flags);
+ if (addr)
+ return addr;
+
+ filp_pgoff = GET_FILP_PGOFF(filp);
+ do_color_align = filp || (flags & MAP_SHARED);
info.align_mask = do_color_align ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
info.align_offset = shared_align_offset(filp_pgoff, pgoff);
--
2.47.0.338.g60cca15819-goog
Powered by blists - more mailing lists