Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame^] | 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 |
| 5 | processing (v5.9) |
| 6 | |
| 7 | See upstream commit: |
| 8 | |
| 9 | commit f9cae926f35e8230330f28c7b743ad088611a8de |
| 10 | Author: Jan Kara <jack@suse.cz> |
| 11 | Date: Fri May 29 16:08:58 2020 +0200 |
| 12 | |
| 13 | writeback: Fix sync livelock due to b_dirty_time processing |
| 14 | |
| 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. |
| 24 | |
| 25 | Upstream-Status: Backport |
| 26 | |
| 27 | Change-Id: I8b894b13ccc14d9b8983ee4c2810a927c319560b |
| 28 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> |
| 29 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 30 | --- |
| 31 | .../events/lttng-module/writeback.h | 39 ++++++++++++------- |
| 32 | 1 file changed, 26 insertions(+), 13 deletions(-) |
| 33 | |
| 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 |
| 39 | #endif |
| 40 | LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writepage, writeback_wbc_writepage) |
| 41 | |
| 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, |
| 48 | + int moved), |
| 49 | + TP_ARGS(wb, work, dirtied_before, moved), |
| 50 | + TP_FIELDS( |
| 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) |
| 54 | + ) |
| 55 | +) |
| 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, |
| 61 | -#else |
| 62 | - unsigned long *older_than_this, |
| 63 | -#endif |
| 64 | int moved), |
| 65 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) |
| 66 | TP_ARGS(wb, work, moved), |
| 67 | -#else |
| 68 | + TP_FIELDS( |
| 69 | + ctf_array_text(char, name, dev_name(wb->bdi->dev), 32) |
| 70 | + ctf_integer(int, moved, moved) |
| 71 | + ) |
| 72 | +) |
| 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, |
| 77 | + int moved), |
| 78 | TP_ARGS(wb, older_than_this, moved), |
| 79 | -#endif |
| 80 | TP_FIELDS( |
| 81 | ctf_array_text(char, name, dev_name(wb->bdi->dev), 32) |
| 82 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) |
| 83 | -#else |
| 84 | ctf_integer(unsigned long, older, |
| 85 | older_than_this ? *older_than_this : 0) |
| 86 | ctf_integer(long, age, |
| 87 | older_than_this ? |
| 88 | (jiffies - *older_than_this) * 1000 / HZ |
| 89 | : -1) |
| 90 | -#endif |
| 91 | ctf_integer(int, moved, moved) |
| 92 | ) |
| 93 | ) |
| 94 | +#endif |
| 95 | |
| 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) |
| 100 | ) |
| 101 | ) |
| 102 | -#else |
| 103 | +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) |
| 104 | LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state, |
| 105 | |
| 106 | writeback_global_dirty_state, |
| 107 | @@ -485,7 +499,6 @@ LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state, |
| 108 | ) |
| 109 | ) |
| 110 | #endif |
| 111 | -#endif |
| 112 | |
| 113 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) |
| 114 | |
| 115 | -- |
| 116 | 2.19.1 |
| 117 | |