proc/kpageflags: add KPF_WAITERS
Subsystems (4)
PATCH 1/1 proc/kpageflags: add KPF_WAITERS
KPF_WAITERS indicates tasks are waiting for a page lock or writeback. This might be false-positive, in this case next unlock will clear it. This looks like worth information not only for kernel hacking.
In tool page-types in non-raw mode treat KPF_WAITERS without KPF_LOCKED and KPF_WRITEBACK as false-positive and hide it.
--- fs/proc/page.c | 1 + include/uapi/linux/kernel-page-flags.h | 1 + tools/vm/page-types.c | 7 +++++++ 3 files changed, 9 insertions(+)
fs/proc/page.c +1 -0
@@ -159,6 +159,7 @@ u64 stable_page_flags(struct page *page) u |=1 <<KPF_IDLE ; u |=kpf_copy_bit (k,KPF_LOCKED , PG_locked); + u |=kpf_copy_bit (k,KPF_WAITERS , PG_waiters); u |=kpf_copy_bit (k,KPF_SLAB , PG_slab);if (PageTail (page) &&PageSlab (compound_head (page)))
include/uapi/linux/kernel-page-flags.h +1 -0
@@ -35,6 +35,7 @@#define KPF_BALLOON 23#define KPF_ZERO_PAGE 24#define KPF_IDLE 25 +#define KPF_WAITERS 26#endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */
tools/vm/page-types.c +7 -0
@@ -107,6 +107,7 @@static const char *const page_flag_names[] = { [KPF_LOCKED ] ="L:locked" , + [KPF_WAITERS ] ="Q:waiters" , [KPF_ERROR ] ="E:error" , [KPF_REFERENCED ] ="R:referenced" , [KPF_UPTODATE ] ="U:uptodate" ,
@@ -498,6 +499,12 @@ static uint64_t well_known_flags(uint64_t flags)if ((flags &BITS_COMPOUND ) && !(flags &BIT (HUGE ))) flags &= ~BITS_COMPOUND ; +/* Treat WAITERS without LOCKED or WRITEBACK as false-postive */ +if ((flags & (BIT (WAITERS ) | +BIT (LOCKED ) | +BIT (WRITEBACK ))) ==BIT (WAITERS )) + flags &= ~BIT (WAITERS ); +return flags; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 2 lines · On Sun, 11 Feb 2018 13:36:41 +0300 Konstantin Khlebnikov…
KPF_WAITERSindicates tasks are waiting for a page lock or writeback. This might be false-positive, in this case next unlock will clear it.
Well, kpageflags is full of potential false-positives. Or do you think this flag is especially vulnerable?
In other words, under what circumstances will we have KPF_WAITERS set when PG_locked and PG-writeback are clear?
Quoted 1 line
This looks like worth information not only for kernel hacking.
Why? What are the use-cases, in detail? How are we to justify this modification?
Quoted 6 lines
In tool page-types in non-raw mode treat
KPF_WAITERSwithoutKPF_LOCKEDandKPF_WRITEBACKas false-positive and hide it.fs/proc/page.c | 1 + include/uapi/linux/kernel-page-flags.h | 1 + tools/vm/page-types.c | 7 +++++++
Please update Documentation/vm/pagemap.txt.
Quoted 10 lines · Andrew Morton
Quoted 2 lines · On Sun, 11 Feb 2018 13:36:41 +0300 Konstantin Khlebnikov…
KPF_WAITERSindicates tasks are waiting for a page lock or writeback. This might be false-positive, in this case next unlock will clear it.Well, kpageflags is full of potential false-positives. Or do you think this flag is especially vulnerable?
In other words, under what circumstances will we have
KPF_WAITERSset whenPG_lockedand PG-writeback are clear?
Looks like lock_page() - unlock_page() shouldn't leave longstanding
false-positive: last unlock_page() must clear PG_waiters.
But I've seen them. Probably that was from wait_on_page_writeback():
it test PG_writeback, set PG_waiters under queue lock unconditionally and then test PG_writeback again before sleep - and might exit without wakeup i.e. without clearing PG_waiters.
This could be fixed with extra check for in wait_on_page_bit_common() under queue lock.
mm/filemap.c +5 -1
@@ -1087,6 +1087,10 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,spin_lock_irq (&q->lock);if (likely (list_empty (&wait->entry))) { +if (unlikely (!test_bit (bit_nr, &page->flags))) { +spin_unlock_irq (&q->lock); + goto try; + }__add_wait_queue_entry_tail (q, wait);SetPageWaiters (page); }
@@ -1098,7 +1102,7 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,if (likely (test_bit (bit_nr, &page->flags))) {io_schedule (); } - +try:if (lock) {if (!test_and_set_bit_lock (bit_nr, &page->flags))break ;
But this seems redundant.
Quoted 5 lines
Quoted 2 lines
This looks like worth information not only for kernel hacking.
Why? What are the use-cases, in detail? How are we to justify this modification?
This bit tells which page or D 3/4 ffset in file is actually wanted by somebody in the system. That's another way to track where major faults or writeback blocks something. We don't have to record flow of events - snapshot of page-flags will show where contention is.
Quoted 10 lines
Quoted 7 lines
In tool page-types in non-raw mode treat
KPF_WAITERSwithoutKPF_LOCKEDandKPF_WRITEBACKas false-positive and hide it.fs/proc/page.c | 1 + include/uapi/linux/kernel-page-flags.h | 1 + tools/vm/page-types.c | 7 +++++++Please update
Documentation/vm/pagemap.txt.
ok
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 23 lines · On Sat, 17 Feb 2018 11:14:10 +0300 Konstantin Khlebnikov…
Quoted 10 lines · Andrew Morton
Quoted 2 lines · On Sun, 11 Feb 2018 13:36:41 +0300 Konstantin Khlebnikov…
KPF_WAITERSindicates tasks are waiting for a page lock or writeback. This might be false-positive, in this case next unlock will clear it.Well, kpageflags is full of potential false-positives. Or do you think this flag is especially vulnerable?
In other words, under what circumstances will we have
KPF_WAITERSset whenPG_lockedand PG-writeback are clear?Looks like
lock_page()-unlock_page()shouldn't leave longstanding
false-positive: lastunlock_page()must clearPG_waiters.But I've seen them. Probably that was from
wait_on_page_writeback():
it testPG_writeback, setPG_waitersunder queue lock unconditionally and then testPG_writebackagain before sleep - and might exit without wakeup i.e. without clearingPG_waiters.This could be fixed with extra check for in
wait_on_page_bit_common()under queue lock.
Quoted 7 lines
...
This bit tells which page or оffset in file is actually wanted by somebody in the system. That's another way to track where major faults or writeback blocks something. We don't have to record flow of events - snapshot of page-flags will show where contention is.
Please send a v2 and let's get all this info into the changelog?
PATCH 1/1 Documentation/vm/pagemap.txt: document bit WAITERS
In reply to Konstantin Khlebnikov--- Documentation/vm/pagemap.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/vm/pagemap.txt +8 -0
@@ -71,6 +71,7 @@ There are four components to pagemap: 23. BALLOON 24. ZERO_PAGE 25. IDLE + 26. WAITERS * /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
@@ -127,6 +128,13 @@ Short descriptions to the page flags: 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. +26. WAITERS + Indicates tasks are waiting when bits LOCKED or WRITEBACK will be cleared. + They might be blocked by undergoing IO or by contention on page lock. + Bit WAITERS might be false-positive, in this case next clear of LOCKED or + WRITEBACK will clear WAITERS too. I.e. without LOCKED and WRITEBACK it's + false-positive for sure. + [IO related page flags] 1. ERROR IO error occurred 3. UPTODATE page has up-to-date data
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>