Commit 5095a2b
mm/mglru: try to stop at high watermarks
The initial MGLRU patchset didn't include the memcg LRU support, and it
relied on should_abort_scan(), added by commit f76c833 ("mm:
multi-gen LRU: optimize multiple memcgs"), to "backoff to avoid
overshooting their aggregate reclaim target by too much".
Later on when the memcg LRU was added, should_abort_scan() was deemed
unnecessary, and the test results [1] showed no side effects after it was
removed by commit a579086 ("mm: multi-gen LRU: remove eviction
fairness safeguard").
However, that test used memory.reclaim, which sets nr_to_reclaim to
SWAP_CLUSTER_MAX. So it can overshoot only by SWAP_CLUSTER_MAX-1 pages,
i.e., from nr_reclaimed=nr_to_reclaim-1 to
nr_reclaimed=nr_to_reclaim+SWAP_CLUSTER_MAX-1. Compared with the batch
size kswapd sets to nr_to_reclaim, SWAP_CLUSTER_MAX is tiny. Therefore
that test isn't able to reproduce the worst case scenario, i.e., kswapd
overshooting GBs on large systems and "consuming 100% CPU" (see the Closes
tag).
Bring back a simplified version of should_abort_scan() on top of the memcg
LRU, so that kswapd stops when all eligible zones are above their
respective high watermarks plus a small delta to lower the chance of
KSWAPD_HIGH_WMARK_HIT_QUICKLY. Note that this only applies to order-0
reclaim, meaning compaction-induced reclaim can still run wild (which is a
different problem).
On Android, launching 55 apps sequentially:
Before After Change
pgpgin 838377172 802955040 -4%
pgpgout 38037080 34336300 -10%
[1] https://lore.kernel.org/20221222041905.2431096-1-yuzhao@google.com/
Link: https://lkml.kernel.org/r/20231208061407.2125867-2-yuzhao@google.com
Fixes: a579086 ("mm: multi-gen LRU: remove eviction fairness safeguard")
Signed-off-by: Yu Zhao <yuzhao@google.com>
Reported-by: Charan Teja Kalla <quic_charante@quicinc.com>
Reported-by: Jaroslav Pulchart <jaroslav.pulchart@gooddata.com>
Closes: https://lore.kernel.org/CAK8fFZ4DY+GtBA40Pm7Nn5xCHy+51w3sfxPqkqpqakSXYyX+Wg@mail.gmail.com/
Tested-by: Jaroslav Pulchart <jaroslav.pulchart@gooddata.com>
Tested-by: Kalesh Singh <kaleshsingh@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Kairui Song <ryncsn@gmail.com>
Cc: T.J. Mercier <tjmercier@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>1 parent 0814880 commit 5095a2b
1 file changed
Lines changed: 28 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4648 | 4648 | | |
4649 | 4649 | | |
4650 | 4650 | | |
4651 | | - | |
| 4651 | + | |
4652 | 4652 | | |
| 4653 | + | |
| 4654 | + | |
| 4655 | + | |
4653 | 4656 | | |
4654 | 4657 | | |
4655 | | - | |
| 4658 | + | |
| 4659 | + | |
| 4660 | + | |
| 4661 | + | |
| 4662 | + | |
| 4663 | + | |
| 4664 | + | |
| 4665 | + | |
4656 | 4666 | | |
4657 | | - | |
| 4667 | + | |
| 4668 | + | |
| 4669 | + | |
| 4670 | + | |
| 4671 | + | |
| 4672 | + | |
| 4673 | + | |
| 4674 | + | |
| 4675 | + | |
| 4676 | + | |
| 4677 | + | |
| 4678 | + | |
| 4679 | + | |
4658 | 4680 | | |
4659 | 4681 | | |
4660 | 4682 | | |
4661 | 4683 | | |
4662 | 4684 | | |
4663 | 4685 | | |
4664 | | - | |
4665 | 4686 | | |
4666 | 4687 | | |
4667 | 4688 | | |
| |||
4683 | 4704 | | |
4684 | 4705 | | |
4685 | 4706 | | |
4686 | | - | |
| 4707 | + | |
4687 | 4708 | | |
4688 | 4709 | | |
4689 | 4710 | | |
| |||
4744 | 4765 | | |
4745 | 4766 | | |
4746 | 4767 | | |
4747 | | - | |
4748 | 4768 | | |
4749 | 4769 | | |
4750 | 4770 | | |
| |||
4777 | 4797 | | |
4778 | 4798 | | |
4779 | 4799 | | |
4780 | | - | |
| 4800 | + | |
4781 | 4801 | | |
4782 | 4802 | | |
4783 | 4803 | | |
| |||
4788 | 4808 | | |
4789 | 4809 | | |
4790 | 4810 | | |
4791 | | - | |
| 4811 | + | |
4792 | 4812 | | |
4793 | 4813 | | |
4794 | 4814 | | |
| |||
0 commit comments