[PATCH] uml: MADV_REMOVE fixes
authorJeff Dike <jdike@addtoit.com>
Wed, 19 Apr 2006 05:20:24 +0000 (22:20 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 19 Apr 2006 16:13:49 +0000 (09:13 -0700)
MADV_REMOVE fixes - change the test mapping to be MAP_SHARED instead of
MAP_PRIVATE, as MADV_REMOVE on MAP_PRIVATE maps won't work.  Also, use
the kernel's definition of MADV_REMOVE instead of hardcoding it if there
isn't a libc definition.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Hugh Dickins <hugh@veritas.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/um/include/sysdep-i386/kernel-offsets.h
arch/um/include/sysdep-x86_64/kernel-offsets.h
arch/um/os-Linux/process.c

index 82f96c574144cbc327daa8b5c82624014bb9cf83..2c13de321f2fb330eb5dc162fe53bffca57f3bad 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/stddef.h>
 #include <linux/sched.h>
 #include <linux/elf.h>
+#include <asm/mman.h>
 
 #define DEFINE(sym, val) \
        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -16,6 +17,7 @@
 void foo(void)
 {
        OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs);
+       DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
 #ifdef CONFIG_MODE_TT
        OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
 #endif
index 5ce93abd0b54fd79f95dea8df40cf3a756366bc0..939cc475757a583e7b38977f02c6f095de004465 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/time.h>
 #include <linux/elf.h>
 #include <asm/page.h>
+#include <asm/mman.h>
 
 #define DEFINE(sym, val) \
        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -18,6 +19,7 @@
 
 void foo(void)
 {
+       DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
 #ifdef CONFIG_MODE_TT
        OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
 #endif
index 8176b0b52047061ae681e19d51583f4e683cad97..2064e8400d94ab45b2f5886420368b02a610dabb 100644 (file)
@@ -190,7 +190,7 @@ int os_unmap_memory(void *addr, int len)
 }
 
 #ifndef MADV_REMOVE
-#define MADV_REMOVE    0x5             /* remove these pages & resources */
+#define MADV_REMOVE KERNEL_MADV_REMOVE
 #endif
 
 int os_drop_memory(void *addr, int length)
@@ -216,7 +216,7 @@ int can_drop_memory(void)
        }
 
        addr = mmap64(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE,
-                     MAP_PRIVATE, fd, 0);
+                     MAP_SHARED, fd, 0);
        if(addr == MAP_FAILED){
                printk("Mapping test memory file failed, err = %d\n", -errno);
                return 0;