The patch titled Subject: mm/page-writeback: introduce tracepoint for wait_on_page_writeback() has been added to the -mm tree. Its filename is mm-page-writeback-introduce-tracepoint-for-wait_on_page_writeback.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-page-writeback-introduce-tracepoint-for-wait_on_page_writeback.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-page-writeback-introduce-tracepoint-for-wait_on_page_writeback.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yafang Shao <laoar.shao@xxxxxxxxx> Subject: mm/page-writeback: introduce tracepoint for wait_on_page_writeback() Recently there have been some hung tasks on our server due to wait_on_page_writeback(), and we want to know the details of this PG_writeback, i.e. this page is writing back to which device. But it is not so convenient to get the details. I think it would be better to introduce a tracepoint for diagnosing the writeback details. Link: http://lkml.kernel.org/r/1556274402-19018-1-git-send-email-laoar.shao@xxxxxxxxx Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx> Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Jan Kara <jack@xxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/pagemap.h | 10 +--------- include/trace/events/writeback.h | 16 +++++++++++++++- mm/page-writeback.c | 12 ++++++++++++ 3 files changed, 28 insertions(+), 10 deletions(-) --- a/include/linux/pagemap.h~mm-page-writeback-introduce-tracepoint-for-wait_on_page_writeback +++ a/include/linux/pagemap.h @@ -540,15 +540,7 @@ static inline int wait_on_page_locked_ki extern void put_and_wait_on_page_locked(struct page *page); -/* - * Wait for a page to complete writeback - */ -static inline void wait_on_page_writeback(struct page *page) -{ - if (PageWriteback(page)) - wait_on_page_bit(page, PG_writeback); -} - +void wait_on_page_writeback(struct page *page); extern void end_page_writeback(struct page *page); void wait_for_stable_page(struct page *page); --- a/include/trace/events/writeback.h~mm-page-writeback-introduce-tracepoint-for-wait_on_page_writeback +++ a/include/trace/events/writeback.h @@ -53,7 +53,7 @@ WB_WORK_REASON struct wb_writeback_work; -TRACE_EVENT(writeback_dirty_page, +DECLARE_EVENT_CLASS(writeback_page_template, TP_PROTO(struct page *page, struct address_space *mapping), @@ -79,6 +79,20 @@ TRACE_EVENT(writeback_dirty_page, ) ); +DEFINE_EVENT(writeback_page_template, writeback_dirty_page, + + TP_PROTO(struct page *page, struct address_space *mapping), + + TP_ARGS(page, mapping) +); + +DEFINE_EVENT(writeback_page_template, wait_on_page_writeback, + + TP_PROTO(struct page *page, struct address_space *mapping), + + TP_ARGS(page, mapping) +); + DECLARE_EVENT_CLASS(writeback_dirty_inode_template, TP_PROTO(struct inode *inode, int flags), --- a/mm/page-writeback.c~mm-page-writeback-introduce-tracepoint-for-wait_on_page_writeback +++ a/mm/page-writeback.c @@ -2808,6 +2808,18 @@ int __test_set_page_writeback(struct pag } EXPORT_SYMBOL(__test_set_page_writeback); +/* + * Wait for a page to complete writeback + */ +void wait_on_page_writeback(struct page *page) +{ + if (PageWriteback(page)) { + trace_wait_on_page_writeback(page, page_mapping(page)); + wait_on_page_bit(page, PG_writeback); + } +} +EXPORT_SYMBOL_GPL(wait_on_page_writeback); + /** * wait_for_stable_page() - wait for writeback to finish, if necessary. * @page: The page to wait on. _ Patches currently in -mm which might be from laoar.shao@xxxxxxxxx are mm-vmscan-drop-zone-id-from-kswapd-tracepoints.patch mm-compaction-show-gfp-flag-names-in-try_to_compact_pages-tracepoint.patch mm-compaction-some-tracepoints-should-be-defined-only-when-config_compaction-is-set.patch mm-vmscan-add-tracepoints-for-node-reclaim.patch mm-vmscan-drop-may_writepage-and-classzone_idx-from-direct-reclaim-begin-template.patch mm-page_alloc-remove-unnecessary-parameter-in-rmqueue_pcplist.patch mm-vmscan-dont-disable-irq-again-when-count-pgrefill-for-memcg.patch mm-vmscan-simplify-trace_reclaim_flags-and-trace_shrink_flags.patch mm-page-writeback-introduce-tracepoint-for-wait_on_page_writeback.patch