aboutsummaryrefslogtreecommitdiffstats
path: root/tools/vm
diff options
context:
space:
mode:
authorKonstantin Khlebnikov <khlebnikov@yandex-team.ru>2015-09-08 18:00:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-08 18:35:28 -0400
commit77bb499bb60f4b79cca7d139c8041662860fcf87 (patch)
tree6a1565ab551fcf8c04b4f38c37b085bbf0829da5 /tools/vm
parent1c90308e7a77af6742a97d1021cca923b23b7f0d (diff)
pagemap: add mmap-exclusive bit for marking pages mapped only here
This patch sets bit 56 in pagemap if this page is mapped only once. It allows to detect exclusively used pages without exposing PFN: present file exclusive state 0 0 0 non-present 1 1 0 file page mapped somewhere else 1 1 1 file page mapped only here 1 0 0 anon non-CoWed page (shared with parent/child) 1 0 1 anon CoWed page (or never forked) CoWed pages in (MAP_FILE | MAP_PRIVATE) areas are anon in this context. MMap-exclusive bit doesn't reflect potential page-sharing via swapcache: page could be mapped once but has several swap-ptes which point to it. Application could detect that by swap bit in pagemap entry and touch that pte via /proc/pid/mem to get real information. See http://lkml.kernel.org/r/CAEVpBa+_RyACkhODZrRvQLs80iy0sqpdrd0AaP_-tgnX3Y9yNQ@mail.gmail.com Requested by Mark Williamson. [akpm@linux-foundation.org: fix spello] Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Reviewed-by: Mark Williamson <mwilliamson@undo-software.com> Tested-by: Mark Williamson <mwilliamson@undo-software.com> Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'tools/vm')
-rw-r--r--tools/vm/page-types.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c
index 603ec916716b..7f73fa32a590 100644
--- a/tools/vm/page-types.c
+++ b/tools/vm/page-types.c
@@ -62,6 +62,7 @@
62#define PM_PFRAME_MASK ((1LL << PM_PFRAME_BITS) - 1) 62#define PM_PFRAME_MASK ((1LL << PM_PFRAME_BITS) - 1)
63#define PM_PFRAME(x) ((x) & PM_PFRAME_MASK) 63#define PM_PFRAME(x) ((x) & PM_PFRAME_MASK)
64#define PM_SOFT_DIRTY (1ULL << 55) 64#define PM_SOFT_DIRTY (1ULL << 55)
65#define PM_MMAP_EXCLUSIVE (1ULL << 56)
65#define PM_FILE (1ULL << 61) 66#define PM_FILE (1ULL << 61)
66#define PM_SWAP (1ULL << 62) 67#define PM_SWAP (1ULL << 62)
67#define PM_PRESENT (1ULL << 63) 68#define PM_PRESENT (1ULL << 63)
@@ -91,6 +92,8 @@
91#define KPF_SLOB_FREE 49 92#define KPF_SLOB_FREE 49
92#define KPF_SLUB_FROZEN 50 93#define KPF_SLUB_FROZEN 50
93#define KPF_SLUB_DEBUG 51 94#define KPF_SLUB_DEBUG 51
95#define KPF_FILE 62
96#define KPF_MMAP_EXCLUSIVE 63
94 97
95#define KPF_ALL_BITS ((uint64_t)~0ULL) 98#define KPF_ALL_BITS ((uint64_t)~0ULL)
96#define KPF_HACKERS_BITS (0xffffULL << 32) 99#define KPF_HACKERS_BITS (0xffffULL << 32)
@@ -140,6 +143,9 @@ static const char * const page_flag_names[] = {
140 [KPF_SLOB_FREE] = "P:slob_free", 143 [KPF_SLOB_FREE] = "P:slob_free",
141 [KPF_SLUB_FROZEN] = "A:slub_frozen", 144 [KPF_SLUB_FROZEN] = "A:slub_frozen",
142 [KPF_SLUB_DEBUG] = "E:slub_debug", 145 [KPF_SLUB_DEBUG] = "E:slub_debug",
146
147 [KPF_FILE] = "F:file",
148 [KPF_MMAP_EXCLUSIVE] = "1:mmap_exclusive",
143}; 149};
144 150
145 151
@@ -443,6 +449,10 @@ static uint64_t expand_overloaded_flags(uint64_t flags, uint64_t pme)
443 449
444 if (pme & PM_SOFT_DIRTY) 450 if (pme & PM_SOFT_DIRTY)
445 flags |= BIT(SOFTDIRTY); 451 flags |= BIT(SOFTDIRTY);
452 if (pme & PM_FILE)
453 flags |= BIT(FILE);
454 if (pme & PM_MMAP_EXCLUSIVE)
455 flags |= BIT(MMAP_EXCLUSIVE);
446 456
447 return flags; 457 return flags;
448} 458}