Skip to contentSkip to conversation

PATCH: Introduce struct vma_link_info

PATCH Luiz Fernando N. Capitulino 2 participants 3 messages Mar 20, 2009 – Mar 23, 2009

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Andrew,

Currently find_vma_prepare() and low-level VMA functions (eg. __vma_link())
require callers to provide three parameters to return/pass "link" information (pprev, rb_link and rb_parent):

static struct vm_area_struct *
find_vma_prepare(struct mm_struct *mm, unsigned long addr,
struct vm_area_struct **pprev, struct rb_node ***rb_link, struct rb_node ** rb_parent);

With this patch callers can pass a struct vma_link_info instead:

static struct vm_area_struct * find_vma_prepare(struct mm_struct *mm, unsigned long addr,

                struct vma_link_info *link_info);

The code gets simpler and it should be better because less variables
are pushed into the stack/registers. As shown by the following kernel build test:

kernel real user sys

2.6.29-rc8-vanilla 1136.64 1033.38 82.88
2.6.29-rc8-linfo 1135.07 1032.44 82.92

I have also ran hackbench, but I can't understand why its result
indicates a regression:

kernel Avarage of three runs (25 processes groups)

2.6.29.rc8-vanilla 2.03
2.6.29.rc8-linfo 2.12

Rik has said to me that this could be inside error margin. So, I'm
submitting the patch for inclusion.

---
 include/linux/mm.h |    8 ++++-
 kernel/fork.c      |   12 +++---
 mm/mmap.c          |   91 +++++++++++++++++++++++++--------------------------
 3 files changed, 58 insertions(+), 53 deletions(-)
include/linux/mm.h +7 -1
index 065cdf8..be73b86 100644
@@ -1097,6 +1097,12 @@ static inline void vma_nonlinear_insert(struct vm_area_struct *vma,
 }
 
 /* mmap.c */
+struct vma_link_info {
+	struct rb_node *rb_parent;
+	struct rb_node **rb_link;
+	struct vm_area_struct *prev;
+};
+
 extern int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin);
 extern void vma_adjust(struct vm_area_struct *vma, unsigned long start,
 	unsigned long end, pgoff_t pgoff, struct vm_area_struct *insert);
@@ -1109,7 +1115,7 @@ extern int split_vma(struct mm_struct *,
 	struct vm_area_struct *, unsigned long addr, int new_below);
 extern int insert_vm_struct(struct mm_struct *, struct vm_area_struct *);
 extern void __vma_link_rb(struct mm_struct *, struct vm_area_struct *,
-	struct rb_node **, struct rb_node *);
+		struct vma_link_info *link_info);
 extern void unlink_file_vma(struct vm_area_struct *);
 extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
 	unsigned long addr, unsigned long len, pgoff_t pgoff);
kernel/fork.c +6 -6
index 4854c2c..a300bf6 100644
@@ -261,7 +261,7 @@ out:
 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
 {
 	struct vm_area_struct *mpnt, *tmp, **pprev;
-	struct rb_node **rb_link, *rb_parent;
+	struct vma_link_info link_info;
 	int retval;
 	unsigned long charge;
 	struct mempolicy *pol;
@@ -281,8 +281,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
 	mm->map_count = 0;
 	cpus_clear(mm->cpu_vm_mask);
 	mm->mm_rb = RB_ROOT;
-	rb_link = &mm->mm_rb.rb_node;
-	rb_parent = NULL;
+	link_info.rb_link = &mm->mm_rb.rb_node;
+	link_info.rb_parent = NULL;
 	pprev = &mm->mmap;
 
 	for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
@@ -348,9 +348,9 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
 		*pprev = tmp;
 		pprev = &tmp->vm_next;
 
-		__vma_link_rb(mm, tmp, rb_link, rb_parent);
-		rb_link = &tmp->vm_rb.rb_right;
-		rb_parent = &tmp->vm_rb;
+		__vma_link_rb(mm, tmp, &link_info);
+		link_info.rb_link = &tmp->vm_rb.rb_right;
+		link_info.rb_parent = &tmp->vm_rb;
 
 		mm->map_count++;
 		retval = copy_page_range(mm, oldmm, mpnt);
mm/mmap.c +45 -46

236 lines not on this page · raw message

maintainer
#1 lore raw
Quoted 31 lines · Luiz Fernando N. Capitulino

Andrew,

Currently find_vma_prepare() and low-level VMA functions (eg. __vma_link())
require callers to provide three parameters to return/pass "link" information (pprev, rb_link and rb_parent):

static struct vm_area_struct *
find_vma_prepare(struct mm_struct *mm, unsigned long addr,
struct vm_area_struct **pprev, struct rb_node ***rb_link, struct rb_node ** rb_parent);

With this patch callers can pass a struct vma_link_info instead:

static struct vm_area_struct * find_vma_prepare(struct mm_struct *mm, unsigned long addr,

                struct vma_link_info *link_info);

The code gets simpler and it should be better because less variables
are pushed into the stack/registers. As shown by the following kernel build test:

kernel real user sys

2.6.29-rc8-vanilla 1136.64 1033.38 82.88
2.6.29-rc8-linfo 1135.07 1032.44 82.92

I have also ran hackbench, but I can't understand why its result
indicates a regression:

kernel Avarage of three runs (25 processes groups)

Quoted 7 lines

2.6.29.rc8-vanilla 2.03
2.6.29.rc8-linfo 2.12

Rik has said to me that this could be inside error margin. So, I'm
submitting the patch for inclusion.

I'd rather we look into using the threaded RB-tree to get rid of all this prev crap.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw

Em Fri, 20 Mar 2009 21:36:29 +0100
Peter Zijlstra <[email protected]> escreveu:

| On Fri, 2009-03-20 at 10:34 -0300, Luiz Fernando N. Capitulino wrote:
| > Andrew,
| > 
| >   Currently find_vma_prepare() and low-level VMA functions (eg. __vma_link())
| > require callers to provide three parameters to return/pass "link" information
| > (pprev, rb_link and rb_parent):
| > 
| > static struct vm_area_struct *
| > find_vma_prepare(struct mm_struct *mm, unsigned long addr,
| >                 struct vm_area_struct **pprev, struct rb_node ***rb_link,
| >                 struct rb_node ** rb_parent);
| > 
| >  With this patch callers can pass a struct vma_link_info instead:
| > 
| > static struct vm_area_struct *
| > find_vma_prepare(struct mm_struct *mm, unsigned long addr,
| >                 struct vma_link_info *link_info);
| > 
| >  The code gets simpler and it should be better because less variables
| > are pushed into the stack/registers. As shown by the following
| > kernel build test:
| > 
| > kernel			real	user	sys
| > 
| > 2.6.29-rc8-vanilla      1136.64 1033.38 82.88
| > 2.6.29-rc8-linfo        1135.07 1032.44 82.92
| > 
| >  I have also ran hackbench, but I can't understand why its result
| > indicates a regression:
| > 
| > kernel                 Avarage of three runs (25 processes groups)
| > 
| > 2.6.29.rc8-vanilla                2.03
| > 2.6.29.rc8-linfo                  2.12
| > 
| >  Rik has said to me that this could be inside error margin. So, I'm
| > submitting the patch for inclusion.
| > 
| > Signed-off-by: Luiz Fernando N. Capitulino <[email protected]>
| 
| I'd rather we look into using the threaded RB-tree to get rid of all
| this prev crap.

Okay, it makes sense. Also, Eduardo has a point for the hackbench's
regression: the patch is probably dropping some of gcc's optimizations on the variables that got packed into the struct (although I haven't checked the assembly yet).

So, better to forget this one.

Are there patches for the threaded tree available already?

Signature · 7 lines
Luiz Fernando N. Capitulino

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>