1 From 87b2affc3eb06f3fb2d0923f18af37713eb6814b Mon Sep 17 00:00:00 2001
2 From: Michael Jeanson <mjeanson@efficios.com>
3 Date: Mon, 31 Aug 2020 14:16:01 -0400
4 Subject: [PATCH 08/10] fix: writeback: Fix sync livelock due to b_dirty_time
9 commit f9cae926f35e8230330f28c7b743ad088611a8de
10 Author: Jan Kara <jack@suse.cz>
11 Date: Fri May 29 16:08:58 2020 +0200
13 writeback: Fix sync livelock due to b_dirty_time processing
15 When we are processing writeback for sync(2), move_expired_inodes()
16 didn't set any inode expiry value (older_than_this). This can result in
17 writeback never completing if there's steady stream of inodes added to
18 b_dirty_time list as writeback rechecks dirty lists after each writeback
19 round whether there's more work to be done. Fix the problem by using
20 sync(2) start time is inode expiry value when processing b_dirty_time
21 list similarly as for ordinarily dirtied inodes. This requires some
22 refactoring of older_than_this handling which simplifies the code
23 noticeably as a bonus.
25 Upstream-Status: Backport
27 Change-Id: I8b894b13ccc14d9b8983ee4c2810a927c319560b
28 Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
29 Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
31 .../events/lttng-module/writeback.h | 39 ++++++++++++-------
32 1 file changed, 26 insertions(+), 13 deletions(-)
34 diff --git a/instrumentation/events/lttng-module/writeback.h b/instrumentation/events/lttng-module/writeback.h
35 index ece67ad..e9018dd 100644
36 --- a/instrumentation/events/lttng-module/writeback.h
37 +++ b/instrumentation/events/lttng-module/writeback.h
38 @@ -384,34 +384,48 @@ LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_wait, writeback_wbc_balanc
40 LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writepage, writeback_wbc_writepage)
42 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
43 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0))
44 +LTTNG_TRACEPOINT_EVENT(writeback_queue_io,
45 + TP_PROTO(struct bdi_writeback *wb,
46 + struct wb_writeback_work *work,
47 + unsigned long dirtied_before,
49 + TP_ARGS(wb, work, dirtied_before, moved),
51 + ctf_array_text(char, name, dev_name(wb->bdi->dev), 32)
52 + ctf_integer(unsigned long, older, dirtied_before)
53 + ctf_integer(int, moved, moved)
56 +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
57 LTTNG_TRACEPOINT_EVENT(writeback_queue_io,
58 TP_PROTO(struct bdi_writeback *wb,
59 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
60 struct wb_writeback_work *work,
62 - unsigned long *older_than_this,
65 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
66 TP_ARGS(wb, work, moved),
69 + ctf_array_text(char, name, dev_name(wb->bdi->dev), 32)
70 + ctf_integer(int, moved, moved)
73 +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
74 +LTTNG_TRACEPOINT_EVENT(writeback_queue_io,
75 + TP_PROTO(struct bdi_writeback *wb,
76 + unsigned long *older_than_this,
78 TP_ARGS(wb, older_than_this, moved),
81 ctf_array_text(char, name, dev_name(wb->bdi->dev), 32)
82 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
84 ctf_integer(unsigned long, older,
85 older_than_this ? *older_than_this : 0)
86 ctf_integer(long, age,
88 (jiffies - *older_than_this) * 1000 / HZ
91 ctf_integer(int, moved, moved)
96 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0))
97 LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
98 @@ -460,7 +474,7 @@ LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
99 ctf_integer(unsigned long, dirty_limit, global_dirty_limit)
103 +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
104 LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
106 writeback_global_dirty_state,
107 @@ -485,7 +499,6 @@ LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state,
113 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))