aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/ksm.h50
-rw-r--r--include/linux/mm.h1
-rw-r--r--include/linux/sched.h7
3 files changed, 58 insertions, 0 deletions
diff --git a/include/linux/ksm.h b/include/linux/ksm.h
new file mode 100644
index 000000000000..eb2a448981ee
--- /dev/null
+++ b/include/linux/ksm.h
@@ -0,0 +1,50 @@
1#ifndef __LINUX_KSM_H
2#define __LINUX_KSM_H
3/*
4 * Memory merging support.
5 *
6 * This code enables dynamic sharing of identical pages found in different
7 * memory areas, even if they are not shared by fork().
8 */
9
10#include <linux/bitops.h>
11#include <linux/mm.h>
12#include <linux/sched.h>
13
14#ifdef CONFIG_KSM
15int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
16 unsigned long end, int advice, unsigned long *vm_flags);
17int __ksm_enter(struct mm_struct *mm);
18void __ksm_exit(struct mm_struct *mm);
19
20static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
21{
22 if (test_bit(MMF_VM_MERGEABLE, &oldmm->flags))
23 return __ksm_enter(mm);
24 return 0;
25}
26
27static inline void ksm_exit(struct mm_struct *mm)
28{
29 if (test_bit(MMF_VM_MERGEABLE, &mm->flags))
30 __ksm_exit(mm);
31}
32#else /* !CONFIG_KSM */
33
34static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
35 unsigned long end, int advice, unsigned long *vm_flags)
36{
37 return 0;
38}
39
40static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
41{
42 return 0;
43}
44
45static inline void ksm_exit(struct mm_struct *mm)
46{
47}
48#endif /* !CONFIG_KSM */
49
50#endif
diff --git a/include/linux/mm.h b/include/linux/mm.h
index d3c8ae7c8015..d808cf832c4d 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -103,6 +103,7 @@ extern unsigned int kobjsize(const void *objp);
103#define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */ 103#define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
104#define VM_SAO 0x20000000 /* Strong Access Ordering (powerpc) */ 104#define VM_SAO 0x20000000 /* Strong Access Ordering (powerpc) */
105#define VM_PFN_AT_MMAP 0x40000000 /* PFNMAP vma that is fully mapped at mmap time */ 105#define VM_PFN_AT_MMAP 0x40000000 /* PFNMAP vma that is fully mapped at mmap time */
106#define VM_MERGEABLE 0x80000000 /* KSM may merge identical pages */
106 107
107#ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */ 108#ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */
108#define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS 109#define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 8fe351c3914a..8f3e63cb33a6 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -434,7 +434,9 @@ extern int get_dumpable(struct mm_struct *mm);
434/* dumpable bits */ 434/* dumpable bits */
435#define MMF_DUMPABLE 0 /* core dump is permitted */ 435#define MMF_DUMPABLE 0 /* core dump is permitted */
436#define MMF_DUMP_SECURELY 1 /* core file is readable only by root */ 436#define MMF_DUMP_SECURELY 1 /* core file is readable only by root */
437
437#define MMF_DUMPABLE_BITS 2 438#define MMF_DUMPABLE_BITS 2
439#define MMF_DUMPABLE_MASK ((1 << MMF_DUMPABLE_BITS) - 1)
438 440
439/* coredump filter bits */ 441/* coredump filter bits */
440#define MMF_DUMP_ANON_PRIVATE 2 442#define MMF_DUMP_ANON_PRIVATE 2
@@ -444,6 +446,7 @@ extern int get_dumpable(struct mm_struct *mm);
444#define MMF_DUMP_ELF_HEADERS 6 446#define MMF_DUMP_ELF_HEADERS 6
445#define MMF_DUMP_HUGETLB_PRIVATE 7 447#define MMF_DUMP_HUGETLB_PRIVATE 7
446#define MMF_DUMP_HUGETLB_SHARED 8 448#define MMF_DUMP_HUGETLB_SHARED 8
449
447#define MMF_DUMP_FILTER_SHIFT MMF_DUMPABLE_BITS 450#define MMF_DUMP_FILTER_SHIFT MMF_DUMPABLE_BITS
448#define MMF_DUMP_FILTER_BITS 7 451#define MMF_DUMP_FILTER_BITS 7
449#define MMF_DUMP_FILTER_MASK \ 452#define MMF_DUMP_FILTER_MASK \
@@ -457,6 +460,10 @@ extern int get_dumpable(struct mm_struct *mm);
457#else 460#else
458# define MMF_DUMP_MASK_DEFAULT_ELF 0 461# define MMF_DUMP_MASK_DEFAULT_ELF 0
459#endif 462#endif
463 /* leave room for more dump flags */
464#define MMF_VM_MERGEABLE 16 /* KSM may merge identical pages */
465
466#define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK)
460 467
461struct sighand_struct { 468struct sighand_struct {
462 atomic_t count; 469 atomic_t count;