diff options
author | Yafang Shao <laoar.shao@gmail.com> | 2019-05-13 20:23:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-14 12:47:51 -0400 |
commit | 19343b5bdd16ad4ae6b845ef829f68b683c4dfb5 (patch) | |
tree | f6e36441b6b86ea3e4d499ebc35e3e7c9b6bd203 | |
parent | 60b62ff7cc4217ac3de76535fa4c1510a798dbcb (diff) |
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@gmail.com
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/pagemap.h | 10 | ||||
-rw-r--r-- | include/trace/events/writeback.h | 16 | ||||
-rw-r--r-- | mm/page-writeback.c | 12 |
3 files changed, 28 insertions, 10 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 2e8438a1216a..112f15bb5907 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h | |||
@@ -540,15 +540,7 @@ static inline int wait_on_page_locked_killable(struct page *page) | |||
540 | 540 | ||
541 | extern void put_and_wait_on_page_locked(struct page *page); | 541 | extern void put_and_wait_on_page_locked(struct page *page); |
542 | 542 | ||
543 | /* | 543 | void wait_on_page_writeback(struct page *page); |
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 | |||
552 | extern void end_page_writeback(struct page *page); | 544 | extern void end_page_writeback(struct page *page); |
553 | void wait_for_stable_page(struct page *page); | 545 | void wait_for_stable_page(struct page *page); |
554 | 546 | ||
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h index 32db72c7c055..aa7f3aeac740 100644 --- a/include/trace/events/writeback.h +++ b/include/trace/events/writeback.h | |||
@@ -53,7 +53,7 @@ WB_WORK_REASON | |||
53 | 53 | ||
54 | struct wb_writeback_work; | 54 | struct wb_writeback_work; |
55 | 55 | ||
56 | TRACE_EVENT(writeback_dirty_page, | 56 | DECLARE_EVENT_CLASS(writeback_page_template, |
57 | 57 | ||
58 | TP_PROTO(struct page *page, struct address_space *mapping), | 58 | TP_PROTO(struct page *page, struct address_space *mapping), |
59 | 59 | ||
@@ -79,6 +79,20 @@ TRACE_EVENT(writeback_dirty_page, | |||
79 | ) | 79 | ) |
80 | ); | 80 | ); |
81 | 81 | ||
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 | |||
82 | DECLARE_EVENT_CLASS(writeback_dirty_inode_template, | 96 | DECLARE_EVENT_CLASS(writeback_dirty_inode_template, |
83 | 97 | ||
84 | TP_PROTO(struct inode *inode, int flags), | 98 | TP_PROTO(struct inode *inode, int flags), |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 9f61dfec6a1f..07656485c0e6 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -2808,6 +2808,18 @@ int __test_set_page_writeback(struct page *page, bool keep_write) | |||
2808 | } | 2808 | } |
2809 | EXPORT_SYMBOL(__test_set_page_writeback); | 2809 | EXPORT_SYMBOL(__test_set_page_writeback); |
2810 | 2810 | ||
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 | |||
2811 | /** | 2823 | /** |
2812 | * wait_for_stable_page() - wait for writeback to finish, if necessary. | 2824 | * wait_for_stable_page() - wait for writeback to finish, if necessary. |
2813 | * @page: The page to wait on. | 2825 | * @page: The page to wait on. |