diff options
author | Vladimir Davydov <vdavydov@parallels.com> | 2015-09-09 18:35:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-10 16:29:01 -0400 |
commit | f074a8f49eb87cde95ac9d040ad5e7ea4f029738 (patch) | |
tree | c78d0a5386ee6d9db9de32c733df404e783088d5 | |
parent | 33c3fc71c8cfa3cc3a98beaa901c069c177dc295 (diff) |
proc: export idle flag via kpageflags
As noted by Minchan, a benefit of reading idle flag from /proc/kpageflags
is that one can easily filter dirty and/or unevictable pages while
estimating the size of unused memory.
Note that idle flag read from /proc/kpageflags may be stale in case the
page was accessed via a PTE, because it would be too costly to iterate
over all page mappings on each /proc/kpageflags read to provide an
up-to-date value. To make sure the flag is up-to-date one has to read
/sys/kernel/mm/page_idle/bitmap first.
Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Reviewed-by: Andres Lagar-Cavilla <andreslc@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Greg Thelen <gthelen@google.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | Documentation/vm/pagemap.txt | 7 | ||||
-rw-r--r-- | fs/proc/page.c | 3 | ||||
-rw-r--r-- | include/uapi/linux/kernel-page-flags.h | 1 |
3 files changed, 11 insertions, 0 deletions
diff --git a/Documentation/vm/pagemap.txt b/Documentation/vm/pagemap.txt index ce294b0aace4..0e1e55588b59 100644 --- a/Documentation/vm/pagemap.txt +++ b/Documentation/vm/pagemap.txt | |||
@@ -70,6 +70,7 @@ There are four components to pagemap: | |||
70 | 22. THP | 70 | 22. THP |
71 | 23. BALLOON | 71 | 23. BALLOON |
72 | 24. ZERO_PAGE | 72 | 24. ZERO_PAGE |
73 | 25. IDLE | ||
73 | 74 | ||
74 | * /proc/kpagecgroup. This file contains a 64-bit inode number of the | 75 | * /proc/kpagecgroup. This file contains a 64-bit inode number of the |
75 | memory cgroup each page is charged to, indexed by PFN. Only available when | 76 | memory cgroup each page is charged to, indexed by PFN. Only available when |
@@ -120,6 +121,12 @@ Short descriptions to the page flags: | |||
120 | 24. ZERO_PAGE | 121 | 24. ZERO_PAGE |
121 | zero page for pfn_zero or huge_zero page | 122 | zero page for pfn_zero or huge_zero page |
122 | 123 | ||
124 | 25. IDLE | ||
125 | page has not been accessed since it was marked idle (see | ||
126 | Documentation/vm/idle_page_tracking.txt). Note that this flag may be | ||
127 | stale in case the page was accessed via a PTE. To make sure the flag | ||
128 | is up-to-date one has to read /sys/kernel/mm/page_idle/bitmap first. | ||
129 | |||
123 | [IO related page flags] | 130 | [IO related page flags] |
124 | 1. ERROR IO error occurred | 131 | 1. ERROR IO error occurred |
125 | 3. UPTODATE page has up-to-date data | 132 | 3. UPTODATE page has up-to-date data |
diff --git a/fs/proc/page.c b/fs/proc/page.c index c2d29edcaa6b..0b8286450a93 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c | |||
@@ -150,6 +150,9 @@ u64 stable_page_flags(struct page *page) | |||
150 | if (PageBalloon(page)) | 150 | if (PageBalloon(page)) |
151 | u |= 1 << KPF_BALLOON; | 151 | u |= 1 << KPF_BALLOON; |
152 | 152 | ||
153 | if (page_is_idle(page)) | ||
154 | u |= 1 << KPF_IDLE; | ||
155 | |||
153 | u |= kpf_copy_bit(k, KPF_LOCKED, PG_locked); | 156 | u |= kpf_copy_bit(k, KPF_LOCKED, PG_locked); |
154 | 157 | ||
155 | u |= kpf_copy_bit(k, KPF_SLAB, PG_slab); | 158 | u |= kpf_copy_bit(k, KPF_SLAB, PG_slab); |
diff --git a/include/uapi/linux/kernel-page-flags.h b/include/uapi/linux/kernel-page-flags.h index a6c4962e5d46..5da5f8751ce7 100644 --- a/include/uapi/linux/kernel-page-flags.h +++ b/include/uapi/linux/kernel-page-flags.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #define KPF_THP 22 | 33 | #define KPF_THP 22 |
34 | #define KPF_BALLOON 23 | 34 | #define KPF_BALLOON 23 |
35 | #define KPF_ZERO_PAGE 24 | 35 | #define KPF_ZERO_PAGE 24 |
36 | #define KPF_IDLE 25 | ||
36 | 37 | ||
37 | 38 | ||
38 | #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */ | 39 | #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */ |