Skip to contentSkip to conversation

mm: scalable and unified arch_get_unmapped_area

PATCH In review Rik van Riel 3 participants 14 messages Jun 18, 2012

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

cover mm: scalable and unified arch_get_unmapped_area

A long time ago, we decided to limit the number of VMAs per process to 64k. As it turns out, there actually are programs using tens of thousands of VMAs.

The linear search in arch_get_unmapped_area and arch_get_unmapped_area_topdown can be a real issue for those programs.

This patch series aims to fix the scalability issue by tracking the size of each free hole in the VMA rbtree, propagating the free hole info up the tree.

Another major goal is to put the bulk of the necessary arch_get_unmapped_area(_topdown) functionality into one set of functions, so we can eliminate the custom large functions per architecture, sticking to a few much smaller architecture specific functions instead.

In this version I have only gotten rid of the x86, ARM and MIPS arch-specific code, and am already showing a fairly promising diffstat:

 arch/arm/include/asm/pgtable.h    |    6 
 arch/arm/mm/init.c                |    3 
 arch/arm/mm/mmap.c                |  217 ------------------
 arch/mips/include/asm/page.h      |    2 
 arch/mips/include/asm/pgtable.h   |    7 
 arch/mips/mm/mmap.c               |  177 --------------
 arch/x86/include/asm/elf.h        |    3 
 arch/x86/include/asm/pgtable_64.h |    4 
 arch/x86/kernel/sys_x86_64.c      |  200 ++--------------
 arch/x86/vdso/vma.c               |    2 
 include/linux/mm_types.h          |    8 
 include/linux/sched.h             |   13 +
 mm/internal.h                     |    5 
 mm/mmap.c                         |  455 ++++++++++++++++++++++++++++++--------
 14 files changed, 420 insertions(+), 682 deletions(-)

TODO:
- eliminate arch-specific functions for more architectures
- integrate hugetlbfs alignment (with Andi Kleen's patch?)

Performance

Testing performance with a benchmark that allocates tens of thousands of VMAs, unmaps them and mmaps them some more in a loop, shows promising results.

Vanilla 3.4 kernel:

$ ./agua_frag_test_64
..........

Min Time (ms): 6
Avg. Time (ms): 294.0000
Max Time (ms): 609
Std Dev (ms): 113.1664
Standard deviation exceeds 10

With patches:

$ ./agua_frag_test_64
..........

Min Time (ms): 14
Avg. Time (ms): 38.0000
Max Time (ms): 60
Std Dev (ms): 3.9312
All checks pass

The total run time of the test goes down by about a factor 4. More importantly, the worst case performance of the loop (which is what really hurt some applications) has gone down by about a factor 10.

--
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>

#1 lore raw

PATCH 1/6 mm: get unmapped area from VMA tree

From: Rik van Riel <[email protected]>

Change the generic implementations of arch_get_unmapped_area(_topdown) to use the free space info in the VMA rbtree. This makes it possible to find free address space in O(log(N)) complexity.

For bottom-up allocations, we pick the lowest hole that is large enough for our allocation. For topdown allocations, we pick the highest hole of sufficient size.

For topdown allocations, we need to keep track of the highest mapped VMA address, because it might be below mm->mmap_base, and we only keep track of free space to the left of each VMA in the VMA tree. It is tempting to try and keep track of the free space to the right of each VMA when running in topdown mode, but that gets us into trouble when running on x86, where a process can switch direction in the middle of execve.

We have to leave the mm->free_area_cache and mm->largest_hole_size in place for now, because the architecture specific versions still use those.

---
 include/linux/mm_types.h |    1 +
 mm/mmap.c                |  270 +++++++++++++++++++++++++++++++---------------
 2 files changed, 184 insertions(+), 87 deletions(-)
include/linux/mm_types.h +1 -0
index bf56d66..8ccb4e1 100644
@@ -307,6 +307,7 @@ struct mm_struct {
 	unsigned long task_size;		/* size of task vm space */
 	unsigned long cached_hole_size; 	/* if non-zero, the largest hole below free_area_cache */
 	unsigned long free_area_cache;		/* first hole of size cached_hole_size or larger */
+	unsigned long highest_vma;		/* highest vma end address */
 	pgd_t * pgd;
 	atomic_t mm_users;			/* How many users with user space? */
 	atomic_t mm_count;			/* How many references to "struct mm_struct" (users count as 1) */
mm/mmap.c +183 -87

366 lines not on this page · raw message

Signature · 7 lines
1.7.7.6

--
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

PATCH 2/6 Allow each architecture to specify the address range that can be used for this allocation.

In reply to Rik van Riel

From: Rik van Riel <[email protected]>

On x86-64, this is used to implement MMAP_32BIT semantics.

On PPC and IA64, allocations using certain page sizes need to be restricted to certain virtual address ranges. This callback could be used to implement such address restrictions with minimal hassle.

---
 arch/mips/mm/mmap.c               |    8 ++----
 arch/x86/include/asm/pgtable_64.h |    1 +
 arch/x86/kernel/sys_x86_64.c      |   11 ++++++---
 include/linux/sched.h             |    7 ++++++
 mm/mmap.c                         |   38 ++++++++++++++++++++++++++++++++++--
 5 files changed, 53 insertions(+), 12 deletions(-)
arch/mips/mm/mmap.c +3 -5
index 302d779..3f8af17 100644
@@ -61,8 +61,6 @@ static inline unsigned long COLOUR_ALIGN_DOWN(unsigned long addr,
 	((((addr) + shm_align_mask) & ~shm_align_mask) +	\
 	 (((pgoff) << PAGE_SHIFT) & shm_align_mask))
 
-enum mmap_allocation_direction {UP, DOWN};
-
 static unsigned long arch_get_unmapped_area_common(struct file *filp,
 	unsigned long addr0, unsigned long len, unsigned long pgoff,
 	unsigned long flags, enum mmap_allocation_direction dir)
@@ -107,7 +105,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
 			return addr;
 	}
 
-	if (dir == UP) {
+	if (dir == ALLOC_UP) {
 		addr = mm->mmap_base;
 		if (do_color_align)
 			addr = COLOUR_ALIGN(addr, pgoff);
@@ -204,7 +202,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr0,
 	unsigned long len, unsigned long pgoff, unsigned long flags)
 {
 	return arch_get_unmapped_area_common(filp,
-			addr0, len, pgoff, flags, UP);
+			addr0, len, pgoff, flags, ALLOC_UP);
 }
 
 /*
@@ -216,7 +214,7 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp,
 	unsigned long flags)
 {
 	return arch_get_unmapped_area_common(filp,
-			addr0, len, pgoff, flags, DOWN);
+			addr0, len, pgoff, flags, ALLOC_DOWN);
 }
 
 void arch_pick_mmap_layout(struct mm_struct *mm)
arch/x86/include/asm/pgtable_64.h +1 -0
index 975f709..8af36f6 100644
@@ -169,6 +169,7 @@ extern void cleanup_highmap(void);
 
 #define HAVE_ARCH_UNMAPPED_AREA
 #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
+#define HAVE_ARCH_GET_ADDRESS_RANGE
 
 #define pgtable_cache_init()   do { } while (0)
 #define check_pgt_cache()      do { } while (0)
arch/x86/kernel/sys_x86_64.c +7 -4
index b4d3c39..2595a5e 100644
@@ -95,8 +95,8 @@ out:
 	return error;
 }
 
-static void find_start_end(unsigned long flags, unsigned long *begin,
-			   unsigned long *end)
+void arch_get_address_range(unsigned long flags, unsigned long *begin,
+		unsigned long *end, enum mmap_allocation_direction direction)
 {
 	if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
 		unsigned long new_begin;
@@ -114,9 +114,12 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
 			if (new_begin)
 				*begin = new_begin;
 		}
-	} else {
+	} else if (direction == ALLOC_UP) {
 		*begin = TASK_UNMAPPED_BASE;
 		*end = TASK_SIZE;
+	} else /* direction == ALLOC_DOWN */ {
+		*begin = 0;
+		*end = current->mm->mmap_base;
 	}
 }
 
@@ -132,7 +135,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	if (flags & MAP_FIXED)
 		return addr;
 
-	find_start_end(flags, &begin, &end);
+	arch_get_address_range(flags, &begin, &end, ALLOC_UP);
 
 	if (len > end)
 		return -ENOMEM;
include/linux/sched.h +7 -0
index 4059c0f..fc76318 100644
@@ -388,7 +388,14 @@ extern int sysctl_max_map_count;
 #include <linux/aio.h>
 
 #ifdef CONFIG_MMU
+enum mmap_allocation_direction {
+	ALLOC_UP,
+	ALLOC_DOWN
+};
 extern void arch_pick_mmap_layout(struct mm_struct *mm);
+extern void
+arch_get_address_range(unsigned long flags, unsigned long *begin,
+		unsigned long *end, enum mmap_allocation_direction direction);
 extern unsigned long
 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
 		       unsigned long, unsigned long);
mm/mmap.c +35 -3
index 40c848e..92cf0bf 100644
@@ -1465,6 +1465,20 @@ unacct_error:
 	return error;
 }
 
+#ifndef HAVE_ARCH_GET_ADDRESS_RANGE
+void arch_get_address_range(unsigned long flags, unsigned long *begin,
+		unsigned long *end, enum mmap_allocation_direction direction)
+{
+	if (direction == ALLOC_UP) {
+		*begin = TASK_UNMAPPED_BASE;
+		*end = TASK_SIZE;
+	} else /* direction == ALLOC_DOWN */ {
+		*begin = 0;
+		*end = current->mm->mmap_base;
+	}
+}
+#endif
+
 /* Get an address range which is currently unmapped.
  * For shmat() with addr=0.
  *
@@ -1499,7 +1513,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	struct mm_struct *mm = current->mm;
 	struct vm_area_struct *vma = NULL;
 	struct rb_node *rb_node;
-	unsigned long lower_limit = TASK_UNMAPPED_BASE;
+	unsigned long lower_limit, upper_limit;
+
+	arch_get_address_range(flags, &lower_limit, &upper_limit, ALLOC_UP);
 
 	if (len > TASK_SIZE)
 		return -ENOMEM;
@@ -1546,6 +1562,13 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 			continue;
 		}
 
+		/* We have gone too far right, and can not go left. */
+		if (vma->vm_end + len > upper_limit) {
+			if (!addr)
+				return -ENOMEM;
+			goto found_addr;
+		}
+
 		if (!found_here && node_free_hole(rb_node->rb_right) >= len) {
 			/* Last known hole is to the right of this subtree. */
 			rb_node = rb_node->rb_right;
@@ -1625,7 +1648,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	struct mm_struct *mm = current->mm;
 	unsigned long addr = addr0;
 	struct rb_node *rb_node = NULL;
-	unsigned long upper_limit = mm->mmap_base;
+	unsigned long lower_limit, upper_limit;
+
+	arch_get_address_range(flags, &lower_limit, &upper_limit, ALLOC_DOWN);
 
 	/* requested length too big for entire address space */
 	if (len > TASK_SIZE)
@@ -1644,7 +1669,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	}
 
 	/* requested length too big; prevent integer underflow below */
-	if (len > upper_limit)
+	if (len > upper_limit - lower_limit)
 		return -ENOMEM;
 
 	/*
@@ -1681,6 +1706,13 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 			}
 		}
 
+		/* We have gone too far left, and can not go right. */
+		if (vma->vm_start < lower_limit + len) {
+			if (!addr)
+				return -ENOMEM;
+			goto found_addr;
+		}
+
 		if (!found_here && node_free_hole(rb_node->rb_left) >= len) {
 			/* Last known hole is to the right of this subtree. */
 			rb_node = rb_node->rb_left;
Signature · 7 lines
1.7.7.6

--
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>
#3 lore raw

PATCH 3/6 Fix the x86-64 page colouring code to take pgoff into account and use that code as the basis for a generic page colouring code.

In reply to Rik van Riel

From: Rik van Riel <[email protected]>

Teach the generic arch_get_unmapped_area(_topdown) code to call the page colouring code.

---
 arch/mips/include/asm/page.h      |    2 -
 arch/mips/include/asm/pgtable.h   |    1 +
 arch/x86/include/asm/elf.h        |    3 -
 arch/x86/include/asm/pgtable_64.h |    1 +
 arch/x86/kernel/sys_x86_64.c      |   35 +++++++++-----
 arch/x86/vdso/vma.c               |    2 +-
 include/linux/sched.h             |    8 +++-
 mm/mmap.c                         |   91 ++++++++++++++++++++++++++++++++-----
 8 files changed, 111 insertions(+), 32 deletions(-)
arch/mips/include/asm/page.h +0 -2
index da9bd7d..459cc25 100644
@@ -63,8 +63,6 @@ extern void build_copy_page(void);
 extern void clear_page(void * page);
 extern void copy_page(void * to, void * from);
 
-extern unsigned long shm_align_mask;
-
 static inline unsigned long pages_do_alias(unsigned long addr1,
 	unsigned long addr2)
 {
arch/mips/include/asm/pgtable.h +1 -0
index b2202a6..f133a4c 100644
@@ -415,6 +415,7 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
  */
 #define HAVE_ARCH_UNMAPPED_AREA
 #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
+#define HAVE_ARCH_ALIGN_ADDR
 
 /*
  * No page table caches to initialise
arch/x86/include/asm/elf.h +0 -3
index 5939f44..dc2d0bf 100644
@@ -358,8 +358,6 @@ static inline int mmap_is_ia32(void)
 enum align_flags {
 	ALIGN_VA_32	= BIT(0),
 	ALIGN_VA_64	= BIT(1),
-	ALIGN_VDSO	= BIT(2),
-	ALIGN_TOPDOWN	= BIT(3),
 };
 
 struct va_alignment {
@@ -368,5 +366,4 @@ struct va_alignment {
 } ____cacheline_aligned;
 
 extern struct va_alignment va_align;
-extern unsigned long align_addr(unsigned long, struct file *, enum align_flags);
 #endif /* _ASM_X86_ELF_H */
arch/x86/include/asm/pgtable_64.h +1 -0
index 8af36f6..8408ccd 100644
@@ -170,6 +170,7 @@ extern void cleanup_highmap(void);
 #define HAVE_ARCH_UNMAPPED_AREA
 #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
 #define HAVE_ARCH_GET_ADDRESS_RANGE
+#define HAVE_ARCH_ALIGN_ADDR
 
 #define pgtable_cache_init()   do { } while (0)
 #define check_pgt_cache()      do { } while (0)
arch/x86/kernel/sys_x86_64.c +22 -13
index 2595a5e..ac0afb8 100644
@@ -25,31 +25,40 @@
  * @flags denotes the allocation direction - bottomup or topdown -
  * or vDSO; see call sites below.
  */
-unsigned long align_addr(unsigned long addr, struct file *filp,
-			 enum align_flags flags)
+unsigned long arch_align_addr(unsigned long addr, struct file *filp,
+			unsigned long pgoff, unsigned long flags,
+			enum mmap_allocation_direction direction)
 {
-	unsigned long tmp_addr;
+	unsigned long tmp_addr = PAGE_ALIGN(addr);
 
 	/* handle 32- and 64-bit case with a single conditional */
 	if (va_align.flags < 0 || !(va_align.flags & (2 - mmap_is_ia32())))
-		return addr;
+		return tmp_addr;
 
-	if (!(current->flags & PF_RANDOMIZE))
-		return addr;
+	/* Always allow MAP_FIXED. Colouring is a performance thing only. */
+	if (flags & MAP_FIXED)
+		return tmp_addr;
 
-	if (!((flags & ALIGN_VDSO) || filp))
-		return addr;
+	if (!(current->flags & PF_RANDOMIZE))
+		return tmp_addr;
 
-	tmp_addr = addr;
+	if (!(filp || direction == ALLOC_VDSO))
+		return tmp_addr;
 
 	/*
 	 * We need an address which is <= than the original
 	 * one only when in topdown direction.
 	 */
-	if (!(flags & ALIGN_TOPDOWN))
+	if (direction == ALLOC_UP)
 		tmp_addr += va_align.mask;
 
 	tmp_addr &= ~va_align.mask;
+	tmp_addr += ((pgoff << PAGE_SHIFT) & va_align.mask);
+
+	if (direction == ALLOC_DOWN && tmp_addr > addr) {
+		tmp_addr -= va_align.mask;
+		tmp_addr &= ~va_align.mask;
+	}
 
 	return tmp_addr;
 }
@@ -159,7 +168,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 
 full_search:
 
-	addr = align_addr(addr, filp, 0);
+	addr = arch_align_addr(addr, filp, pgoff, flags, ALLOC_UP);
 
 	for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
 		/* At this point:  (!vma || addr < vma->vm_end). */
@@ -186,7 +195,7 @@ full_search:
 			mm->cached_hole_size = vma->vm_start - addr;
 
 		addr = vma->vm_end;
-		addr = align_addr(addr, filp, 0);
+		addr = arch_align_addr(addr, filp, pgoff, flags, ALLOC_UP);
 	}
 }
 
@@ -235,7 +244,7 @@ try_again:
 
 	addr -= len;
 	do {
-		addr = align_addr(addr, filp, ALIGN_TOPDOWN);
+		addr = arch_align_addr(addr, filp, pgoff, flags, ALLOC_DOWN);
 
 		/*
 		 * Lookup failure means no vma is above this address,
arch/x86/vdso/vma.c +1 -1
index 00aaf04..83e0355 100644
@@ -141,7 +141,7 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
 	 * unaligned here as a result of stack start randomization.
 	 */
 	addr = PAGE_ALIGN(addr);
-	addr = align_addr(addr, NULL, ALIGN_VDSO);
+	addr = arch_align_addr(addr, NULL, 0, 0, ALLOC_VDSO);
 
 	return addr;
 }
include/linux/sched.h +7 -1
index fc76318..18f9326 100644
@@ -390,12 +390,18 @@ extern int sysctl_max_map_count;
 #ifdef CONFIG_MMU
 enum mmap_allocation_direction {
 	ALLOC_UP,
-	ALLOC_DOWN
+	ALLOC_DOWN,
+	ALLOC_VDSO,
 };
 extern void arch_pick_mmap_layout(struct mm_struct *mm);
 extern void
 arch_get_address_range(unsigned long flags, unsigned long *begin,
 		unsigned long *end, enum mmap_allocation_direction direction);
+extern unsigned long shm_align_mask;
+extern unsigned long
+arch_align_addr(unsigned long addr, struct file *filp,
+		unsigned long pgoff, unsigned long flags,
+		enum mmap_allocation_direction direction);
 extern unsigned long
 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
 		       unsigned long, unsigned long);
mm/mmap.c +79 -12

157 lines not on this page · raw message

Signature · 7 lines
1.7.7.6

--
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>
#4 lore raw

Re: [PATCH -mm 3/6] Fix the x86-64 page colouring code to take pgoff into account and use that code as the basis for a generic page colouring code.

Quoted 4 lines · Rik van Riel

From: Rik van Riel <[email protected]>

Teach the generic arch_get_unmapped_area(_topdown) code to call the page colouring code.

What tree is that against? I cannot find x86 page colouring code in next or mainline.

-Andi

Signature · 7 lines
[email protected] -- Speaking for myself only

--
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>
#5 lore raw

Re: [PATCH -mm 3/6] Fix the x86-64 page colouring code to take pgoff into account and use that code as the basis for a generic page colouring code.

Quoted 9 lines · Andi Kleen
Quoted 4 lines · Rik van Riel

From: Rik van Riel<[email protected]>

Teach the generic arch_get_unmapped_area(_topdown) code to call the page colouring code.

What tree is that against? I cannot find x86 page colouring code in next or mainline.

This is against mainline.

See align_addr in arch/x86/kernel/sys_x86_64.c and the call sites in arch_get_unmapped_area(_topdown).

On certain AMD chips, Linux tries to get certain allocations aligned to avoid cache aliasing issues.

Signature · 7 lines
All rights reversed

--
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>
maintainer
#6 lore raw

Re: [PATCH -mm 3/6] Fix the x86-64 page colouring code to take pgoff into account and use that code as the basis for a generic page colouring code.

Quoted 4 lines · Rik van Riel
Quoted 2 lines

What tree is that against? I cannot find x86 page colouring code in next or mainline.

This is against mainline.

Which mainline do you mean exactly?

1/6 doesn't apply ontop of current mainline and by "current" I mean v3.5-rc3-57-g39a50b42f702.

Signature · 8 lines
Regards/Gruss,
Boris.

--
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>
#7 lore raw

Re: [PATCH -mm 3/6] Fix the x86-64 page colouring code to take pgoff into account and use that code as the basis for a generic page colouring code.

Quoted 10 lines · Borislav Petkov
Quoted 4 lines · Rik van Riel
Quoted 2 lines

What tree is that against? I cannot find x86 page colouring code in next or mainline.

This is against mainline.

Which mainline do you mean exactly?

1/6 doesn't apply ontop of current mainline and by "current" I mean v3.5-rc3-57-g39a50b42f702.

I git pulled on Friday, then used guilt to apply and rediff all the patches. I pull from here:

git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6

I see no g39a50b... commit after pulling that tree here. Do you have any local changes by chance?

Signature · 7 lines
All rights reversed

--
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>
#8 lore raw

Re: [PATCH -mm 3/6] Fix the x86-64 page colouring code to take pgoff into account and use that code as the basis for a generic page colouring code.

In reply to Borislav Petkov
Quoted 10 lines · Borislav Petkov
Quoted 4 lines · Rik van Riel
Quoted 2 lines

What tree is that against? I cannot find x86 page colouring code in next or mainline.

This is against mainline.

Which mainline do you mean exactly?

1/6 doesn't apply ontop of current mainline and by "current" I mean v3.5-rc3-57-g39a50b42f702.

After pulling in the latest patches, including that 39a50b... commit, all patches still apply here when I type guilt push -a.

Signature · 7 lines
All rights reversed

--
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>
maintainer
#9 lore raw

Re: [PATCH -mm 3/6] Fix the x86-64 page colouring code to take pgoff into account and use that code as the basis for a generic page colouring code.

Quoted 7 lines · Rik van Riel
Quoted 6 lines · Borislav Petkov
Quoted 4 lines · Rik van Riel
Quoted 2 lines

What tree is that against? I cannot find x86 page colouring code in next or mainline.

This is against mainline.

Quoted 8 lines
Quoted 4 lines

Which mainline do you mean exactly?

1/6 doesn't apply ontop of current mainline and by "current" I mean v3.5-rc3-57-g39a50b42f702.

After pulling in the latest patches, including that 39a50b... commit, all patches still apply here when I type guilt push -a.

That's strange.

I'm also pulling from

git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6

Btw, if I had local changes, the top commit id would've changed, right? So I wouldn't have had 39a50b anymore.

Just in case, I tried applying 1/6 on another repository and it still doesn't apply:

$ patch -p1 --dry-run -i /tmp/riel.01
patching file include/linux/mm_types.h
Hunk #1 succeeded at 300 (offset -7 lines).
patching file mm/mmap.c
Hunk #2 succeeded at 206 with fuzz 1 (offset -45 lines).
Hunk #3 FAILED at 398.
Hunk #4 FAILED at 461.
Hunk #5 succeeded at 603 (offset -57 lines).
Hunk #6 succeeded at 1404 (offset -66 lines).
Hunk #7 succeeded at 1441 (offset -66 lines).
Hunk #8 succeeded at 1528 (offset -66 lines).
Hunk #9 succeeded at 1570 (offset -66 lines).
Hunk #10 FAILED at 1908.
Hunk #11 FAILED at 2093.
4 out of 11 hunks FAILED -- saving rejects to file mm/mmap.c.rej

riel.01 is the mail saved from mutt so it should be fine.

Now let's look at the first failing hunk:

Mainline has:

void validate_mm(struct mm_struct *mm)

{
	int bug = 0;
	int i = 0;
	struct vm_area_struct *tmp = mm->mmap;
	while (tmp) {
		tmp = tmp->vm_next;
		i++;
	}
	if (i != mm->map_count)
		printk("map_count %d vm_next %d\n", mm->map_count, i), bug = 1;
	i = browse_rb(&mm->mm_rb);
	if (i != mm->map_count)
		printk("map_count %d rb %d\n", mm->map_count, i), bug = 1;
	BUG_ON(bug);
}

--
and your patch has some new ifs in it:

@@ -386,12 +398,16 @@ void validate_mm(struct mm_struct *mm)
int bug = 0;
int i = 0;
struct vm_area_struct *tmp = mm->mmap;
+ unsigned long highest_address = 0;
while (tmp) {
if (tmp->free_gap != max_free_space(&tmp->vm_rb))
printk("free space %lx, correct %lx\n", tmp->free_gap, max_free_space(&tmp->vm_rb)), bug = 1;

			^^^^^^^^^^^^^^

I think this if-statement is the problem. It is not present in mainline but this patch doesn't add it so some patch earlier than that adds it which is probably in your queue?

+ highest_address = tmp->vm_end;
tmp = tmp->vm_next;
i++;
}
+ if (highest_address != mm->highest_vma)
+ printk("mm->highest_vma %lx, found %lx\n", mm->highest_vma, highest_address), bug = 1;

if (i != mm->map_count)
printk("map_count %d vm_next %d\n", mm->map_count, i), bug = 1;
i = browse_rb(&mm->mm_rb);
--

I haven't looked at the other failing hunks...

Thanks.

Signature · 8 lines
Regards/Gruss,
    Boris.

--
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>
#10 lore raw

Re: [PATCH -mm 3/6] Fix the x86-64 page colouring code to take pgoff into account and use that code as the basis for a generic page colouring code.

Quoted 13 lines · Borislav Petkov

and your patch has some new ifs in it:

(quoted diff) +1 -0
@@ -386,12 +398,16 @@ void validate_mm(struct mm_struct *mm)
  	int bug = 0;
  	int i = 0;
  	struct vm_area_struct *tmp = mm->mmap;
+	unsigned long highest_address = 0;
  	while (tmp) {
  		if (tmp->free_gap != max_free_space(&tmp->vm_rb))
  			printk("free space %lx, correct %lx\n", tmp->free_gap, max_free_space(&tmp->vm_rb)), bug = 1;
 
 			^^^^^^^^^^^^^^
 
Quoted 3 lines

I think this if-statement is the problem. It is not present in mainline but this patch doesn't add it so some patch earlier than that adds it which is probably in your queue?

Argh! I see the problem now.

guilt-patchbomb sent everything from my second patch onwards, not my first patch :(

Let me resend the series properly, I have 7 patches not 6.

I am having a bad email day...

Signature · 7 lines
All rights reversed

--
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>
#11 lore raw

PATCH 4/6 mm: remove x86 arch_get_unmapped_area(_topdown)

In reply to Rik van Riel

From: Rik van Riel <[email protected]>

The generic arch_get_unmapped_area(_topdown) should now be able to do everything x86 needs. Remove the x86 specific functions.

TODO: make the hugetlbfs arch_get_unmapped_area call the generic code with proper alignment info.

---
 arch/x86/include/asm/pgtable_64.h |    2 -
 arch/x86/kernel/sys_x86_64.c      |  162 -------------------------------------
 2 files changed, 0 insertions(+), 164 deletions(-)
arch/x86/include/asm/pgtable_64.h +0 -2
index 8408ccd..0ff6500 100644
@@ -167,8 +167,6 @@ static inline int pgd_large(pgd_t pgd) { return 0; }
 extern int kern_addr_valid(unsigned long addr);
 extern void cleanup_highmap(void);
 
-#define HAVE_ARCH_UNMAPPED_AREA
-#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
 #define HAVE_ARCH_GET_ADDRESS_RANGE
 #define HAVE_ARCH_ALIGN_ADDR
 
arch/x86/kernel/sys_x86_64.c +0 -162

165 lines not on this page · raw message

Signature · 7 lines
1.7.7.6

--
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>
#12 lore raw

PATCH 5/6 remove MIPS arch_get_unmapped_area code

In reply to Rik van Riel

From: Rik van Riel <[email protected]>

Remove all the MIPS specific arch_get_unmapped_area(_topdown) and page colouring code, now that the generic code should be able to handle things.

Untested, because I do not have any MIPS systems.

---
 arch/mips/include/asm/pgtable.h |    8 --
 arch/mips/mm/mmap.c             |  175 ---------------------------------------
 2 files changed, 0 insertions(+), 183 deletions(-)
arch/mips/include/asm/pgtable.h +0 -8
index f133a4c..5f9c49a 100644
@@ -410,14 +410,6 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
 #endif
 
 /*
- * We provide our own get_unmapped area to cope with the virtual aliasing
- * constraints placed on us by the cache architecture.
- */
-#define HAVE_ARCH_UNMAPPED_AREA
-#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
-#define HAVE_ARCH_ALIGN_ADDR
-
-/*
  * No page table caches to initialise
  */
 #define pgtable_cache_init()	do { } while (0)
arch/mips/mm/mmap.c +0 -175

187 lines not on this page · raw message

Signature · 7 lines
1.7.7.6

--
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>
#13 lore raw

PATCH 6/6 remove ARM arch_get_unmapped_area functions

In reply to Rik van Riel

From: Rik van Riel <[email protected]>

Remove the ARM special variants of arch_get_unmapped_area since the generic functions should now be able to handle everything.

Untested because I have no ARM hardware.

---
 arch/arm/include/asm/pgtable.h |    6 -
 arch/arm/mm/init.c             |    3 +
 arch/arm/mm/mmap.c             |  217 +---------------------------------------
 3 files changed, 4 insertions(+), 222 deletions(-)
arch/arm/include/asm/pgtable.h +0 -6
index f66626d..6754183 100644
@@ -296,12 +296,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 #include <asm-generic/pgtable.h>
 
 /*
- * We provide our own arch_get_unmapped_area to cope with VIPT caches.
- */
-#define HAVE_ARCH_UNMAPPED_AREA
-#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
-
-/*
  * remap a physical page `pfn' of size `size' with page protection `prot'
  * into virtual address `from'
  */
arch/arm/mm/init.c +3 -0
index f54d592..534dd96 100644
@@ -600,6 +600,9 @@ void __init mem_init(void)
 	extern u32 itcm_end;
 #endif
 
+	/* Tell the page colouring code what we need. */
+	shm_align_mask = SHMLBA - 1;
+
 	max_mapnr   = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
 
 	/* this will put all unused low memory onto the freelists */
arch/arm/mm/mmap.c +1 -216

229 lines not on this page · raw message

Signature · 7 lines
1.7.7.6

--
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>