Skip to content

Commit 81a70c2

Browse files
kvaneeshakpm00
authored andcommitted
mm/cgroup/reclaim: fix dirty pages throttling on cgroup v1
balance_dirty_pages doesn't do the required dirty throttling on cgroupv1. See commit 9badce0 ("cgroup, writeback: don't enable cgroup writeback on traditional hierarchies"). Instead, the kernel depends on writeback throttling in shrink_folio_list to achieve the same goal. With large memory systems, the flusher may not be able to writeback quickly enough such that we will start finding pages in the shrink_folio_list already in writeback. Hence for cgroupv1 let's do a reclaim throttle after waking up the flusher. The below test which used to fail on a 256GB system completes till the the file system is full with this change. root@lp2:/sys/fs/cgroup/memory# mkdir test root@lp2:/sys/fs/cgroup/memory# cd test/ root@lp2:/sys/fs/cgroup/memory/test# echo 120M > memory.limit_in_bytes root@lp2:/sys/fs/cgroup/memory/test# echo $$ > tasks root@lp2:/sys/fs/cgroup/memory/test# dd if=/dev/zero of=/home/kvaneesh/test bs=1M Killed Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Aneesh Kumar K.V <[email protected]> Suggested-by: Johannes Weiner <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: Tejun Heo <[email protected]> Cc: zefan li <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ea4452d commit 81a70c2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

mm/vmscan.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2514,8 +2514,20 @@ static unsigned long shrink_inactive_list(unsigned long nr_to_scan,
25142514
* the flushers simply cannot keep up with the allocation
25152515
* rate. Nudge the flusher threads in case they are asleep.
25162516
*/
2517-
if (stat.nr_unqueued_dirty == nr_taken)
2517+
if (stat.nr_unqueued_dirty == nr_taken) {
25182518
wakeup_flusher_threads(WB_REASON_VMSCAN);
2519+
/*
2520+
* For cgroupv1 dirty throttling is achieved by waking up
2521+
* the kernel flusher here and later waiting on folios
2522+
* which are in writeback to finish (see shrink_folio_list()).
2523+
*
2524+
* Flusher may not be able to issue writeback quickly
2525+
* enough for cgroupv1 writeback throttling to work
2526+
* on a large system.
2527+
*/
2528+
if (!writeback_throttling_sane(sc))
2529+
reclaim_throttle(pgdat, VMSCAN_THROTTLE_WRITEBACK);
2530+
}
25192531

25202532
sc->nr.dirty += stat.nr_dirty;
25212533
sc->nr.congested += stat.nr_congested;

0 commit comments

Comments
 (0)