ksm: define MADV_MERGEABLE and MADV_UNMERGEABLE
authorHugh Dickins <[email protected]>
Tue, 22 Sep 2009 00:01:53 +0000 (17:01 -0700)
committerLinus Torvalds <[email protected]>
Tue, 22 Sep 2009 14:17:31 +0000 (07:17 -0700)
The out-of-tree KSM used ioctls on fds cloned from /dev/ksm to register a
memory area for merging: we prefer now to use an madvise(2) interface.

This patch just defines MADV_MERGEABLE (to tell KSM it may merge pages in
this area found identical to pages in other mergeable areas) and
MADV_UNMERGEABLE (to undo that).

Most architectures use asm-generic, but alpha, mips, parisc, xtensa need
their own definitions: included here for mmotm convenience, but we'll
probably want to split this and feed pieces to arch maintainers.

Based upon earlier patches by Chris Wright and Izik Eidus.

Signed-off-by: Hugh Dickins <[email protected]>
Signed-off-by: Chris Wright <[email protected]>
Signed-off-by: Izik Eidus <[email protected]>
Cc: Michael Kerrisk <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Kyle McMartin <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Wu Fengguang <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: Lee Schermerhorn <[email protected]>
Cc: Avi Kivity <[email protected]>
Cc: Nick Piggin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
arch/alpha/include/asm/mman.h
arch/mips/include/asm/mman.h
arch/parisc/include/asm/mman.h
arch/xtensa/include/asm/mman.h
include/asm-generic/mman-common.h

index 90d7c35d286703a86a4f1c59061b2212b2de367d..c77c55756a7c41bb8bdd3a76c6dc08a46009c28f 100644 (file)
@@ -48,6 +48,9 @@
 #define MADV_DONTFORK  10              /* don't inherit across fork */
 #define MADV_DOFORK    11              /* do inherit across fork */
 
+#define MADV_MERGEABLE   12            /* KSM may merge identical pages */
+#define MADV_UNMERGEABLE 13            /* KSM may not merge identical pages */
+
 /* compatibility flags */
 #define MAP_FILE       0
 
index e4d6f1fb1cf765c5ca8e23c3e8438f39ebcc0e2d..f15554d1518a067d544380758d47ca28b7753e6d 100644 (file)
@@ -71,6 +71,9 @@
 #define MADV_DONTFORK  10              /* don't inherit across fork */
 #define MADV_DOFORK    11              /* do inherit across fork */
 
+#define MADV_MERGEABLE   12            /* KSM may merge identical pages */
+#define MADV_UNMERGEABLE 13            /* KSM may not merge identical pages */
+
 /* compatibility flags */
 #define MAP_FILE       0
 
index defe752cc996011164ee1600bd04e67441561fed..a12d9d43f50797b5a59938a0356f0ae89ab06584 100644 (file)
@@ -54,6 +54,9 @@
 #define MADV_16M_PAGES  24              /* Use 16 Megabyte pages */
 #define MADV_64M_PAGES  26              /* Use 64 Megabyte pages */
 
+#define MADV_MERGEABLE   65            /* KSM may merge identical pages */
+#define MADV_UNMERGEABLE 66            /* KSM may not merge identical pages */
+
 /* compatibility flags */
 #define MAP_FILE       0
 #define MAP_VARIABLE   0
index 9b92620c8a1ed262d3b10a9cb44dd0b746feacc8..6e55b4d1f9c5ef9a37aee57c6626fee81f3d6b1a 100644 (file)
@@ -78,6 +78,9 @@
 #define MADV_DONTFORK  10              /* don't inherit across fork */
 #define MADV_DOFORK    11              /* do inherit across fork */
 
+#define MADV_MERGEABLE   12            /* KSM may merge identical pages */
+#define MADV_UNMERGEABLE 13            /* KSM may not merge identical pages */
+
 /* compatibility flags */
 #define MAP_FILE       0
 
index 3b69ad34189a9d87e267e131daeb23557b7bfc7a..dd63bd38864b23627f36e57b53c8413af63cd238 100644 (file)
@@ -35,6 +35,9 @@
 #define MADV_DONTFORK  10              /* don't inherit across fork */
 #define MADV_DOFORK    11              /* do inherit across fork */
 
+#define MADV_MERGEABLE   12            /* KSM may merge identical pages */
+#define MADV_UNMERGEABLE 13            /* KSM may not merge identical pages */
+
 /* compatibility flags */
 #define MAP_FILE       0