mbox series

[v2,0/8] Add helper functions to remove repeated code and improve readability of cgroup writeback

Message ID 20240514125254.142203-1-shikemeng@huaweicloud.com (mailing list archive)
Headers show
Series Add helper functions to remove repeated code and improve readability of cgroup writeback | expand

Message

Kemeng Shi May 14, 2024, 12:52 p.m. UTC
v1->v2:
-add dtc_is_global() helper
-rename "bool bg" to "include_writeback"
-fold patches using domain_dirty_avail
-reflow comment to 80col
-Fix potential NULL deref of mdtc->dirty_exceeded

This series add a lot of helpers to remove repeated code between domain
and wb; dirty limit and dirty background; global domain and wb domain.
The helpers also improve readability. More details can be found on
respective patches.
Thanks.

A simple domain hierarchy is tested:
global domain (> 20G)
	|
cgroup domain1(10G)
	|
	wb1
	|
	fio

Test steps:
/* make it easy to observe */
echo 300000 > /proc/sys/vm/dirty_expire_centisecs
echo 3000 > /proc/sys/vm/dirty_writeback_centisecs

/* create cgroup domain */
cd /sys/fs/cgroup
echo "+memory +io" > cgroup.subtree_control
mkdir group1
cd group1
echo 10G > memory.high
echo 10G > memory.max
echo $$ > cgroup.procs
mkfs.ext4 -F /dev/vdb
mount /dev/vdb /bdi1/

/* run fio to generate dirty pages */
fio -name test -filename=/bdi1/file -size=xxx -ioengine=libaio -bs=4K \
-iodepth=1 -rw=write -direct=0 --time_based -runtime=600 -invalidate=0

When fio size is 1G, the wb is in freerun state and dirty pages are only
written back when dirty inode is expired after 30 seconds.
When fio size is 2G, the dirty pages keep being written back and
bandwidth of fio is limited.

Kemeng Shi (8):
  writeback: factor out wb_bg_dirty_limits to remove repeated code
  writeback: add general function domain_dirty_avail to calculate dirty
    and avail of domain
  writeback: factor out domain_over_bg_thresh to remove repeated code
  writeback: Factor out code of freerun to remove repeated code
  writeback: factor out wb_dirty_freerun to remove more repeated freerun
    code
  writeback: factor out balance_domain_limits to remove repeated code
  writeback: factor out wb_dirty_exceeded to remove repeated code
  writeback: factor out balance_wb_limits to remove repeated code

 mm/page-writeback.c | 315 ++++++++++++++++++++++++--------------------
 1 file changed, 169 insertions(+), 146 deletions(-)

Comments

Tejun Heo May 30, 2024, 6:35 p.m. UTC | #1
Hello,

Sorry about the long delay. The first seven patches look fine to me and
improve code readability quite a bit. Andrew, would you mind applying the
first seven?

Thanks.
Andrew Morton May 30, 2024, 6:55 p.m. UTC | #2
On Thu, 30 May 2024 08:35:05 -1000 Tejun Heo <tj@kernel.org> wrote:

> Hello,
> 
> Sorry about the long delay. The first seven patches look fine to me and
> improve code readability quite a bit. Andrew, would you mind applying the
> first seven?
> 

Thanks.  All 8 are in the mm-unstable branch of mm.git.  I've added a
note to the eighth, to wait and see how that unfolds.