Commit 8aa4206
mm/mglru: respect min_ttl_ms with memcgs
While investigating kswapd "consuming 100% CPU" [1] (also see "mm/mglru:
try to stop at high watermarks"), it was discovered that the memcg LRU can
breach the thrashing protection imposed by min_ttl_ms.
Before the memcg LRU:
kswapd()
shrink_node_memcgs()
mem_cgroup_iter()
inc_max_seq() // always hit a different memcg
lru_gen_age_node()
mem_cgroup_iter()
check the timestamp of the oldest generation
After the memcg LRU:
kswapd()
shrink_many()
restart:
iterate the memcg LRU:
inc_max_seq() // occasionally hit the same memcg
if raced with lru_gen_rotate_memcg():
goto restart
lru_gen_age_node()
mem_cgroup_iter()
check the timestamp of the oldest generation
Specifically, when the restart happens in shrink_many(), it needs to stick
with the (memcg LRU) generation it began with. In other words, it should
neither re-read memcg_lru->seq nor age an lruvec of a different
generation. Otherwise it can hit the same memcg multiple times without
giving lru_gen_age_node() a chance to check the timestamp of that memcg's
oldest generation (against min_ttl_ms).
[1] https://lore.kernel.org/CAK8fFZ4DY+GtBA40Pm7Nn5xCHy+51w3sfxPqkqpqakSXYyX+Wg@mail.gmail.com/
Link: https://lkml.kernel.org/r/20231208061407.2125867-3-yuzhao@google.com
Fixes: e4dde56 ("mm: multi-gen LRU: per-node lru_gen_folio lists")
Signed-off-by: Yu Zhao <yuzhao@google.com>
Tested-by: T.J. Mercier <tjmercier@google.com>
Cc: Charan Teja Kalla <quic_charante@quicinc.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Jaroslav Pulchart <jaroslav.pulchart@gooddata.com>
Cc: Kairui Song <ryncsn@gmail.com>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>1 parent 5095a2b commit 8aa4206
2 files changed
Lines changed: 33 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | | - | |
| 508 | + | |
509 | 509 | | |
510 | | - | |
| 510 | + | |
511 | 511 | | |
512 | | - | |
| 512 | + | |
513 | 513 | | |
514 | | - | |
| 514 | + | |
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
520 | | - | |
| 520 | + | |
521 | 521 | | |
522 | | - | |
| 522 | + | |
523 | 523 | | |
524 | | - | |
| 524 | + | |
525 | 525 | | |
526 | | - | |
| 526 | + | |
527 | 527 | | |
528 | | - | |
| 528 | + | |
529 | 529 | | |
530 | | - | |
531 | | - | |
532 | | - | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
533 | 537 | | |
534 | | - | |
| 538 | + | |
535 | 539 | | |
536 | 540 | | |
537 | 541 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4089 | 4089 | | |
4090 | 4090 | | |
4091 | 4091 | | |
| 4092 | + | |
| 4093 | + | |
| 4094 | + | |
4092 | 4095 | | |
4093 | 4096 | | |
4094 | 4097 | | |
| |||
4099 | 4102 | | |
4100 | 4103 | | |
4101 | 4104 | | |
4102 | | - | |
4103 | | - | |
4104 | | - | |
4105 | 4105 | | |
4106 | 4106 | | |
4107 | 4107 | | |
| |||
4124 | 4124 | | |
4125 | 4125 | | |
4126 | 4126 | | |
| 4127 | + | |
| 4128 | + | |
4127 | 4129 | | |
4128 | 4130 | | |
4129 | 4131 | | |
4130 | | - | |
4131 | | - | |
4132 | 4132 | | |
4133 | 4133 | | |
4134 | 4134 | | |
| |||
4635 | 4635 | | |
4636 | 4636 | | |
4637 | 4637 | | |
4638 | | - | |
| 4638 | + | |
4639 | 4639 | | |
4640 | 4640 | | |
4641 | 4641 | | |
| |||
4710 | 4710 | | |
4711 | 4711 | | |
4712 | 4712 | | |
4713 | | - | |
| 4713 | + | |
4714 | 4714 | | |
4715 | 4715 | | |
4716 | 4716 | | |
| |||
4764 | 4764 | | |
4765 | 4765 | | |
4766 | 4766 | | |
4767 | | - | |
| 4767 | + | |
4768 | 4768 | | |
| 4769 | + | |
4769 | 4770 | | |
4770 | 4771 | | |
4771 | 4772 | | |
4772 | 4773 | | |
4773 | | - | |
4774 | 4774 | | |
4775 | 4775 | | |
4776 | 4776 | | |
| |||
4781 | 4781 | | |
4782 | 4782 | | |
4783 | 4783 | | |
| 4784 | + | |
| 4785 | + | |
| 4786 | + | |
| 4787 | + | |
4784 | 4788 | | |
4785 | 4789 | | |
4786 | 4790 | | |
| |||
4865 | 4869 | | |
4866 | 4870 | | |
4867 | 4871 | | |
4868 | | - | |
4869 | | - | |
4870 | | - | |
| 4872 | + | |
| 4873 | + | |
| 4874 | + | |
4871 | 4875 | | |
4872 | 4876 | | |
4873 | 4877 | | |
4874 | 4878 | | |
4875 | 4879 | | |
4876 | | - | |
4877 | | - | |
4878 | 4880 | | |
4879 | 4881 | | |
4880 | 4882 | | |
| |||
0 commit comments