Skip to content

Commit 19343b5

Browse files
laoartorvalds
authored andcommitted
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/[email protected] Signed-off-by: Yafang Shao <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Jan Kara <[email protected]> Cc: Michal Hocko <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 60b62ff commit 19343b5

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

include/linux/pagemap.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -540,15 +540,7 @@ static inline int wait_on_page_locked_killable(struct page *page)
540540

541541
extern void put_and_wait_on_page_locked(struct page *page);
542542

543-
/*
544-
* Wait for a page to complete writeback
545-
*/
546-
static inline void wait_on_page_writeback(struct page *page)
547-
{
548-
if (PageWriteback(page))
549-
wait_on_page_bit(page, PG_writeback);
550-
}
551-
543+
void wait_on_page_writeback(struct page *page);
552544
extern void end_page_writeback(struct page *page);
553545
void wait_for_stable_page(struct page *page);
554546

include/trace/events/writeback.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ WB_WORK_REASON
5353

5454
struct wb_writeback_work;
5555

56-
TRACE_EVENT(writeback_dirty_page,
56+
DECLARE_EVENT_CLASS(writeback_page_template,
5757

5858
TP_PROTO(struct page *page, struct address_space *mapping),
5959

@@ -79,6 +79,20 @@ TRACE_EVENT(writeback_dirty_page,
7979
)
8080
);
8181

82+
DEFINE_EVENT(writeback_page_template, writeback_dirty_page,
83+
84+
TP_PROTO(struct page *page, struct address_space *mapping),
85+
86+
TP_ARGS(page, mapping)
87+
);
88+
89+
DEFINE_EVENT(writeback_page_template, wait_on_page_writeback,
90+
91+
TP_PROTO(struct page *page, struct address_space *mapping),
92+
93+
TP_ARGS(page, mapping)
94+
);
95+
8296
DECLARE_EVENT_CLASS(writeback_dirty_inode_template,
8397

8498
TP_PROTO(struct inode *inode, int flags),

mm/page-writeback.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,6 +2808,18 @@ int __test_set_page_writeback(struct page *page, bool keep_write)
28082808
}
28092809
EXPORT_SYMBOL(__test_set_page_writeback);
28102810

2811+
/*
2812+
* Wait for a page to complete writeback
2813+
*/
2814+
void wait_on_page_writeback(struct page *page)
2815+
{
2816+
if (PageWriteback(page)) {
2817+
trace_wait_on_page_writeback(page, page_mapping(page));
2818+
wait_on_page_bit(page, PG_writeback);
2819+
}
2820+
}
2821+
EXPORT_SYMBOL_GPL(wait_on_page_writeback);
2822+
28112823
/**
28122824
* wait_for_stable_page() - wait for writeback to finish, if necessary.
28132825
* @page: The page to wait on.

0 commit comments

Comments
 (0)