@@ -149,5 +149,6 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
/* arch/sh/mm/mmap.c */
#define HAVE_ARCH_UNMAPPED_AREA
#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
+#define HAVE_ARCH_MMAP_HINT
#endif /* __ASM_SH_PGTABLE_H */
@@ -51,6 +51,26 @@ static inline unsigned long COLOUR_ALIGN(unsigned long addr,
return base + off;
}
+unsigned long arch_mmap_hint(struct file *filp, unsigned long addr,
+ unsigned long len, unsigned long pgoff,
+ unsigned long flags)
+{
+ int do_color_align = 0;
+
+ if (!addr)
+ return 0;
+
+ if (filp || (flags & MAP_SHARED))
+ do_color_align = 1;
+
+ if (do_color_align)
+ addr = COLOUR_ALIGN(addr, pgoff);
+ else
+ addr = PAGE_ALIGN(addr);
+
+ return generic_mmap_hint(filp, addr, len, pgoff, flags);
+}
+
unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags,
vm_flags_t vm_flags)
@@ -77,17 +97,9 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
if (filp || (flags & MAP_SHARED))
do_colour_align = 1;
- if (addr) {
- if (do_colour_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;
- }
+ addr = arch_mmap_hint(filp, addr, len, pgoff, flags);
+ if (addr)
+ return addr;
info.length = len;
info.low_limit = TASK_UNMAPPED_BASE;
@@ -126,17 +138,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
do_colour_align = 1;
/* requesting a specific address */
- if (addr) {
- if (do_colour_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;
- }
+ addr = arch_mmap_hint(filp, addr, len, pgoff, flags);
+ if (addr)
+ return addr;
info.flags = VM_UNMAPPED_AREA_TOPDOWN;
info.length = len;
Introduce sh 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@google.com> --- arch/sh/include/asm/pgtable.h | 1 + arch/sh/mm/mmap.c | 48 +++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 22 deletions(-)