lkml.org 
[lkml]   [2011]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 7/X] uprobes: xol_add_vma: simply use TASK_SIZE as a hint
I don't understand why xol_add_vma() abuses mm->mm_rb to find the
highest mapping. We can simply use TASK_SIZE-PAGE_SIZE a hint.

If this area is already occupied, the hint will be ignored with
or without this change. Otherwise the result is "obviously better"
and the code becomes simpler.

---

kernel/uprobes.c | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/kernel/uprobes.c b/kernel/uprobes.c
index 038f21c..b876977 100644
--- a/kernel/uprobes.c
+++ b/kernel/uprobes.c
@@ -1045,9 +1045,7 @@ void munmap_uprobe(struct vm_area_struct *vma)
/* Slot allocation for XOL */
static int xol_add_vma(struct uprobes_xol_area *area)
{
- struct vm_area_struct *vma;
struct mm_struct *mm;
- unsigned long addr_hint;
int ret;

area->page = alloc_page(GFP_HIGHUSER);
@@ -1060,15 +1058,12 @@ static int xol_add_vma(struct uprobes_xol_area *area)
ret = -EALREADY;
if (mm->uprobes_xol_area)
goto fail;
+
/*
- * Find the end of the top mapping and skip a page.
- * If there is no space for PAGE_SIZE above that,
- * this hint will be ignored.
+ * Try to map as high as possible, this is only a hint.
*/
- vma = rb_entry(rb_last(&mm->mm_rb), struct vm_area_struct, vm_rb);
- addr_hint = vma->vm_end + PAGE_SIZE;
-
- area->vaddr = get_unmapped_area(NULL, addr_hint, PAGE_SIZE, 0, 0);
+ area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE,
+ PAGE_SIZE, 0, 0);
if (IS_ERR_VALUE(area->vaddr)) {
ret = area->vaddr;
goto fail;


\
 
 \ /
  Last update: 2011-10-16 18:21    [W:0.568 / U:16.424 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site