Skip to content

Commit 766a9d6

Browse files
htejunaxboe
authored andcommitted
writeback: implement backing_dev_info->tot_write_bandwidth
cgroup writeback support needs to keep track of the sum of avg_write_bandwidth of all wb's (bdi_writeback's) with dirty inodes to distribute write workload. This patch adds bdi->tot_write_bandwidth and updates inode_wb_list_move_locked(), inode_wb_list_del_locked() and wb_update_write_bandwidth() to adjust it as wb's gain and lose dirty inodes and its avg_write_bandwidth gets updated. As the update events are not synchronized with each other, bdi->tot_write_bandwidth is an atomic_long_t. Signed-off-by: Tejun Heo <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Jan Kara <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent d6c10f1 commit 766a9d6

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

fs/fs-writeback.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,20 @@ static bool wb_io_lists_populated(struct bdi_writeback *wb)
9999
return false;
100100
} else {
101101
set_bit(WB_has_dirty_io, &wb->state);
102+
atomic_long_add(wb->avg_write_bandwidth,
103+
&wb->bdi->tot_write_bandwidth);
102104
return true;
103105
}
104106
}
105107

106108
static void wb_io_lists_depopulated(struct bdi_writeback *wb)
107109
{
108110
if (wb_has_dirty_io(wb) && list_empty(&wb->b_dirty) &&
109-
list_empty(&wb->b_io) && list_empty(&wb->b_more_io))
111+
list_empty(&wb->b_io) && list_empty(&wb->b_more_io)) {
110112
clear_bit(WB_has_dirty_io, &wb->state);
113+
atomic_long_sub(wb->avg_write_bandwidth,
114+
&wb->bdi->tot_write_bandwidth);
115+
}
111116
}
112117

113118
/**

include/linux/backing-dev-defs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ struct backing_dev_info {
142142
unsigned int min_ratio;
143143
unsigned int max_ratio, max_prop_frac;
144144

145+
atomic_long_t tot_write_bandwidth; /* sum of active avg_write_bw */
146+
145147
struct bdi_writeback wb; /* the root writeback info for this bdi */
146148
struct bdi_writeback_congested wb_congested; /* its congested state */
147149
#ifdef CONFIG_CGROUP_WRITEBACK

mm/page-writeback.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,9 @@ static void wb_update_write_bandwidth(struct bdi_writeback *wb,
881881
avg += (old - avg) >> 3;
882882

883883
out:
884+
if (wb_has_dirty_io(wb))
885+
atomic_long_add(avg - wb->avg_write_bandwidth,
886+
&wb->bdi->tot_write_bandwidth);
884887
wb->write_bandwidth = bw;
885888
wb->avg_write_bandwidth = avg;
886889
}

0 commit comments

Comments
 (0)