Commit 1fa38ca8 authored by Shakeel Butt's avatar Shakeel Butt Committed by Chen Ridong
Browse files

mm: writeback: ratelimit stat flush from mem_cgroup_wb_stats

mainline inclusion
from mainline-v6.9-rc1
commit d9b3ce8769e371554a669f262bbc61c02a40efcc
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB0CT3

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d9b3ce8769e371554a669f262bbc61c02a40efcc

----------------------------------------------------------------------

One of our workloads (Postgres 14) has regressed when migrated from 5.10
to 6.1 upstream kernel.  The regression can be reproduced by sysbench's
oltp_write_only benchmark.  It seems like the always on rstat flush in
mem_cgroup_wb_stats() is causing the regression.  So, rate limit that
specific rstat flush.  One potential consequence would be the dirty
throttling might be decided on stale memcg stats.  However from our
benchmarks and production traffic we have not observed any change in the
dirty throttling behavior of the application.

Link: https://lkml.kernel.org/r/20240118184235.618164-1-shakeelb@google.com


Fixes: 2d146aa3 ("mm: memcontrol: switch to rstat")
Signed-off-by: default avatarShakeel Butt <shakeelb@google.com>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarRoman Gushchin <roman.gushchin@linux.dev>
Cc: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>

Conflicts:
	mm/memcontrol.c
[patch set:mm: memcg: restore subtree stats flushing was not merged,
kabi is changed if merge this patchset]
Signed-off-by: default avatarChen Ridong <chenridong@huawei.com>
parent 2ae4bb58
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5398,7 +5398,7 @@ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
	struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css);
	struct mem_cgroup *parent;

	mem_cgroup_flush_stats();
	mem_cgroup_flush_stats_ratelimited();

	*pdirty = memcg_page_state(memcg, NR_FILE_DIRTY);
	*pwriteback = memcg_page_state(memcg, NR_WRITEBACK);