[patch 8/9] mm: vmalloc make guard configurable

npiggin
2008-11-08T02:15:20Z

[-- Attachment #1: mm-vmalloc-guard-config.patch --]
[-- Type: text/plain, Size: 1377 bytes --]

In mm/vmalloc.c, make usage of guard pages dependant on CONFIG_DEBUG_PAGEALLOC.

Signed-off-by: Glauber Costa <glommer@redhat.com>

Reworked so the guard size logic remains inside the allocator.

Signed-off-by: Nick Piggin <npiggin@suse.de>
---
mm/vmalloc.c | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)

Index: linux-2.6/mm/vmalloc.c
===================================================================
--- linux-2.6.orig/mm/vmalloc.c
+++ linux-2.6/mm/vmalloc.c
@@ -29,6 +29,16 @@
#include <asm/uaccess.h>
#include <asm/tlbflush.h>

+/*
+ * Add a guard page between each kernel virtual address allocation if
+ * DEBUG_PAGEALLOC is turned on (could be a separate config option, but
+ * no big deal).
+ */
+#ifdef CONFIG_DEBUG_PAGEALLOC
+#define GUARD_SIZE PAGE_SIZE
+#else
+#define GUARD_SIZE 0
+#endif

/*** Page table manipulation functions ***/

@@ -364,7 +374,7 @@ retry:
}

while (addr + size > first->va_start && addr + size <= vend) {
- addr = ALIGN(first->va_end + PAGE_SIZE, align);
+ addr = ALIGN(first->va_end + GUARD_SIZE, align);

n = rb_next(&first->rb_node);
if (n)