Skip to content

Commit 6cc4c3a

Browse files
Tang Yizhouakpm00
authored andcommitted
writeback: fix calculations in trace_balance_dirty_pages() for cgwb
In the commit dcc25ae ("writeback: move global_dirty_limit into wb_domain") of the cgroup writeback backpressure propagation patchset, Tejun made some adaptations to trace_balance_dirty_pages() for cgroup writeback. However, this adaptation was incomplete and Tejun missed further adaptation in the subsequent patches. In the cgroup writeback scenario, if sdtc in balance_dirty_pages() is assigned to mdtc, then upon entering trace_balance_dirty_pages(), __entry->limit should be assigned based on the dirty_limit of the corresponding memcg's wb_domain, rather than global_wb_domain. To address this issue and simplify the implementation, introduce a 'limit' field in struct dirty_throttle_control to store the hard_limit value computed in wb_position_ratio() by calling hard_dirty_limit(). This field will then be used in trace_balance_dirty_pages() to assign the value to __entry->limit. Link: https://lkml.kernel.org/r/[email protected] Fixes: dcc25ae ("writeback: move global_dirty_limit into wb_domain") Signed-off-by: Tang Yizhou <[email protected]> Acked-by: Tejun Heo <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Jan Kara <[email protected]> Cc: "Masami Hiramatsu (Google)" <[email protected]> Cc: Matthew Wilcow (Oracle) <[email protected]> Cc: Steven Rostedt <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 28c24ef commit 6cc4c3a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

include/linux/writeback.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ struct dirty_throttle_control {
326326
unsigned long dirty; /* file_dirty + write + nfs */
327327
unsigned long thresh; /* dirty threshold */
328328
unsigned long bg_thresh; /* dirty background threshold */
329+
unsigned long limit; /* hard dirty limit */
329330

330331
unsigned long wb_dirty; /* per-wb counterparts */
331332
unsigned long wb_thresh;

include/trace/events/writeback.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,8 @@ TRACE_EVENT(balance_dirty_pages,
663663
unsigned long freerun = (dtc->thresh + dtc->bg_thresh) / 2;
664664
strscpy_pad(__entry->bdi, bdi_dev_name(wb->bdi), 32);
665665

666-
__entry->limit = global_wb_domain.dirty_limit;
667-
__entry->setpoint = (global_wb_domain.dirty_limit +
668-
freerun) / 2;
666+
__entry->limit = dtc->limit;
667+
__entry->setpoint = (dtc->limit + freerun) / 2;
669668
__entry->dirty = dtc->dirty;
670669
__entry->wb_setpoint = __entry->setpoint *
671670
dtc->wb_thresh / (dtc->thresh + 1);

mm/page-writeback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static void wb_position_ratio(struct dirty_throttle_control *dtc)
10721072
struct bdi_writeback *wb = dtc->wb;
10731073
unsigned long write_bw = READ_ONCE(wb->avg_write_bandwidth);
10741074
unsigned long freerun = dirty_freerun_ceiling(dtc->thresh, dtc->bg_thresh);
1075-
unsigned long limit = hard_dirty_limit(dtc_dom(dtc), dtc->thresh);
1075+
unsigned long limit = dtc->limit = hard_dirty_limit(dtc_dom(dtc), dtc->thresh);
10761076
unsigned long wb_thresh = dtc->wb_thresh;
10771077
unsigned long x_intercept;
10781078
unsigned long setpoint; /* dirty pages' target balance point */

0 commit comments

Comments
 (0)