]> git.baikalelectronics.ru Git - kernel.git/commit
cgroup,writeback: don't switch wbs immediately on dead wbs if the memcg is dead
authorTejun Heo <tj@kernel.org>
Fri, 8 Nov 2019 20:18:29 +0000 (12:18 -0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 8 Nov 2019 20:37:24 +0000 (13:37 -0700)
commitf92ccba3760feff4cb7cc661b5adf7fbea668b7b
treeab8166a34aa1f1b32acefb5b7ea09ce0442eb7d4
parent29f22a3c095b10ff2d459a06f3f94dd3f47b60b0
cgroup,writeback: don't switch wbs immediately on dead wbs if the memcg is dead

cgroup writeback tries to refresh the associated wb immediately if the
current wb is dead.  This is to avoid keeping issuing IOs on the stale
wb after memcg - blkcg association has changed (ie. when blkcg got
disabled / enabled higher up in the hierarchy).

Unfortunately, the logic gets triggered spuriously on inodes which are
associated with dead cgroups.  When the logic is triggered on dead
cgroups, the attempt fails only after doing quite a bit of work
allocating and initializing a new wb.

While bab3d59e196c ("mm/filemap.c: don't initiate writeback if mapping
has no dirty pages") alleviated the issue significantly as it now only
triggers when the inode has dirty pages.  However, the condition can
still be triggered before the inode is switched to a different cgroup
and the logic simply doesn't make sense.

Skip the immediate switching if the associated memcg is dying.

This is a simplified version of the following two patches:

 * https://lore.kernel.org/linux-mm/20190513183053.GA73423@dennisz-mbp/
 * http://lkml.kernel.org/r/156355839560.2063.5265687291430814589.stgit@buzz

Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Fixes: 63d2cb77a4c6 ("writeback: disassociate inodes from dying bdi_writebacks")
Acked-by: Dennis Zhou <dennis@kernel.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/fs-writeback.c