From 6f9e8c89ed722f72c833d750aaa4bf6314db923e Mon Sep 17 00:00:00 2001 From: Xu Yu Date: Sat, 22 Jul 2023 12:25:08 +0800 Subject: [PATCH 1/2] anolis: mm: make min_cache_kbytes behave explicitly ANBZ: #6025 The page cache reserve feature, i.e., min_cache_kbytes, does not take effect in some scenarios. This is because that min_cache_kbytes is subject to sc->may_deactivate and min_wmark. This makes min_cache_kbytes behave explicitly, i.e., eliminating additional restrictions such as sc->may_deactivate and min_wmark. Fixes: 1f86172dbe16 ("anolis: mm: introduce ability to reserve page cache on system wide") Signed-off-by: Xu Yu Reviewed-by: zhongjiang-ali --- mm/vmscan.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index d81495357268..d187089a1c43 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3130,7 +3130,6 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc) */ if (!cgroup_reclaim(sc)) { unsigned long total_high_wmark = 0; - unsigned long total_min_wmark = 0; unsigned long free, anon; unsigned long min_cache_kbytes; int z; @@ -3145,7 +3144,6 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc) continue; total_high_wmark += high_wmark_pages(zone); - total_min_wmark += min_wmark_pages(zone); } /* @@ -3166,10 +3164,8 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc) * given watermark. */ min_cache_kbytes = READ_ONCE(sysctl_min_cache_kbytes); - if (min_cache_kbytes) { - sc->file_is_reserved = (sc->may_deactivate & DEACTIVATE_FILE) && - file <= min(total_min_wmark, pgdat->min_cache_pages); - } + if (min_cache_kbytes) + sc->file_is_reserved = file <= pgdat->min_cache_pages; } shrink_node_memcgs(pgdat, sc); -- Gitee From 982a4b50160c7d22001dbae37c3548ce2a66de68 Mon Sep 17 00:00:00 2001 From: Xu Yu Date: Sat, 22 Jul 2023 15:04:38 +0800 Subject: [PATCH 2/2] anolis: mm: limit min_cache_kbytes ANBZ: #6025 This limits min_cache_kbytes to half of total system memory at most. Signed-off-by: Xu Yu Reviewed-by: zhongjiang-ali --- mm/page_alloc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2e5d9c54c0e3..ce001014b577 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8410,12 +8410,22 @@ int sysctl_min_cache_kbytes_sysctl_handler(struct ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos) { int rc; + unsigned long min_cache_pages; + unsigned long old_min_cache_kbytes = sysctl_min_cache_kbytes; rc = proc_doulongvec_minmax(table, write, buffer, length, ppos); if (rc) return rc; - setup_min_cache_kbytes(); + if (write) { + min_cache_pages = sysctl_min_cache_kbytes >> (PAGE_SHIFT - 10); + if (min_cache_pages > totalram_pages() / 2) { + sysctl_min_cache_kbytes = old_min_cache_kbytes; + return -EINVAL; + } + + setup_min_cache_kbytes(); + } return 0; } -- Gitee