Skip to content

Commit 947e976

Browse files
htejunaxboe
authored andcommitted
writeback: update wb_over_bg_thresh() to use wb_domain aware operations
wb_over_bg_thresh() currently uses global_dirty_limits() and wb_dirty_limit() both of which are wrappers around operations which take dirty_throttle_control. For cgroup writeback support, the function will be updated to also consider memcg wb_domains which requires the context information carried in dirty_throttle_control. This patch updates wb_over_bg_thresh() so that it uses the underlying wb_domain aware operations directly and builds the global dirty_throttle_control in the process. This patch doesn't introduce any behavioral changes. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Jan Kara <jack@suse.cz> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Greg Thelen <gthelen@google.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent aa661bb commit 947e976

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

mm/page-writeback.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,15 +1749,22 @@ EXPORT_SYMBOL(balance_dirty_pages_ratelimited);
17491749
*/
17501750
bool wb_over_bg_thresh(struct bdi_writeback *wb)
17511751
{
1752-
unsigned long background_thresh, dirty_thresh;
1752+
struct dirty_throttle_control gdtc_stor = { GDTC_INIT(wb) };
1753+
struct dirty_throttle_control * const gdtc = &gdtc_stor;
17531754

1754-
global_dirty_limits(&background_thresh, &dirty_thresh);
1755+
/*
1756+
* Similar to balance_dirty_pages() but ignores pages being written
1757+
* as we're trying to decide whether to put more under writeback.
1758+
*/
1759+
gdtc->avail = global_dirtyable_memory();
1760+
gdtc->dirty = global_page_state(NR_FILE_DIRTY) +
1761+
global_page_state(NR_UNSTABLE_NFS);
1762+
domain_dirty_limits(gdtc);
17551763

1756-
if (global_page_state(NR_FILE_DIRTY) +
1757-
global_page_state(NR_UNSTABLE_NFS) > background_thresh)
1764+
if (gdtc->dirty > gdtc->bg_thresh)
17581765
return true;
17591766

1760-
if (wb_stat(wb, WB_RECLAIMABLE) > wb_calc_thresh(wb, background_thresh))
1767+
if (wb_stat(wb, WB_RECLAIMABLE) > __wb_calc_thresh(gdtc))
17611768
return true;
17621769

17631770
return false;

0 commit comments

Comments
 (0)