Commit f074a8f4 authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Linus Torvalds

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: default avatarVladimir Davydov <vdavydov@parallels.com>
Reviewed-by: default avatarAndres 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 33c3fc71
...@@ -70,6 +70,7 @@ There are four components to pagemap: ...@@ -70,6 +70,7 @@ There are four components to pagemap:
22. THP 22. THP
23. BALLOON 23. BALLOON
24. ZERO_PAGE 24. ZERO_PAGE
25. IDLE
* /proc/kpagecgroup. This file contains a 64-bit inode number of the * /proc/kpagecgroup. This file contains a 64-bit inode number of the
memory cgroup each page is charged to, indexed by PFN. Only available when memory cgroup each page is charged to, indexed by PFN. Only available when
...@@ -120,6 +121,12 @@ Short descriptions to the page flags: ...@@ -120,6 +121,12 @@ Short descriptions to the page flags:
24. ZERO_PAGE 24. ZERO_PAGE
zero page for pfn_zero or huge_zero page zero page for pfn_zero or huge_zero page
25. IDLE
page has not been accessed since it was marked idle (see
Documentation/vm/idle_page_tracking.txt). Note that this flag may be
stale in case the page was accessed via a PTE. To make sure the flag
is up-to-date one has to read /sys/kernel/mm/page_idle/bitmap first.
[IO related page flags] [IO related page flags]
1. ERROR IO error occurred 1. ERROR IO error occurred
3. UPTODATE page has up-to-date data 3. UPTODATE page has up-to-date data
......
...@@ -150,6 +150,9 @@ u64 stable_page_flags(struct page *page) ...@@ -150,6 +150,9 @@ u64 stable_page_flags(struct page *page)
if (PageBalloon(page)) if (PageBalloon(page))
u |= 1 << KPF_BALLOON; u |= 1 << KPF_BALLOON;
if (page_is_idle(page))
u |= 1 << KPF_IDLE;
u |= kpf_copy_bit(k, KPF_LOCKED, PG_locked); u |= kpf_copy_bit(k, KPF_LOCKED, PG_locked);
u |= kpf_copy_bit(k, KPF_SLAB, PG_slab); u |= kpf_copy_bit(k, KPF_SLAB, PG_slab);
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#define KPF_THP 22 #define KPF_THP 22
#define KPF_BALLOON 23 #define KPF_BALLOON 23
#define KPF_ZERO_PAGE 24 #define KPF_ZERO_PAGE 24
#define KPF_IDLE 25
#endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */ #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment