Skip to contentSkip to conversation

mm: Deduplicate mm_get_unmapped_area()

PATCH Applied Peter Xu 3 participants 3 messages Jun 27, 2025 – Jul 1, 2025

Subsystems (2)
lore
Share & tools
lore

Peter Xu

author
#0 lore raw

PATCH 1/1 mm: Deduplicate mm_get_unmapped_area()

Essentially it sets vm_flags==0 for mm_get_unmapped_area_vmflags(). Use the helper instead to dedup the lines.

---
 mm/mmap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
mm/mmap.c +2 -3
index 8f92cf10b656..74072369e8fd 100644
@@ -871,9 +871,8 @@ mm_get_unmapped_area(struct mm_struct *mm, struct file *file,
 		     unsigned long addr, unsigned long len,
 		     unsigned long pgoff, unsigned long flags)
 {
-	if (test_bit(MMF_TOPDOWN, &mm->flags))
-		return arch_get_unmapped_area_topdown(file, addr, len, pgoff, flags, 0);
-	return arch_get_unmapped_area(file, addr, len, pgoff, flags, 0);
+	return mm_get_unmapped_area_vmflags(mm, file, addr, len,
+					    pgoff, flags, 0);
 }
 EXPORT_SYMBOL(mm_get_unmapped_area);
 
Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Peter Xu

Essentially it sets vm_flags==0 for mm_get_unmapped_area_vmflags(). Use the helper instead to dedup the lines.

Quoted 3 lines

---

Reviewed-by on v1 1/1
#2 lore raw
In reply to Peter Xu
Quoted 25 lines · Peter Xu

Essentially it sets vm_flags==0 for mm_get_unmapped_area_vmflags(). Use the helper instead to dedup the lines.

---
 mm/mmap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
mm/mmap.c +0 -0
index 8f92cf10b656..74072369e8fd 100644
@@ -871,9 +871,8 @@ mm_get_unmapped_area(struct mm_struct *mm, struct file *file,
 		     unsigned long addr, unsigned long len,

mm/mmap.c mm_get_unmapped_area(struct mm_struct *mm, struct file *file, · line 878

Quoted 10 lines
mm/mmap.c +2 -3
 		     unsigned long pgoff, unsigned long flags)
 {
-	if (test_bit(MMF_TOPDOWN, &mm->flags))
-		return arch_get_unmapped_area_topdown(file, addr, len, pgoff, flags, 0);
-	return arch_get_unmapped_area(file, addr, len, pgoff, flags, 0);
+	return mm_get_unmapped_area_vmflags(mm, file, addr, len,
+					    pgoff, flags, 0);
 }
 EXPORT_SYMBOL(mm_get_unmapped_area);