diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2e5d9c54c0e3c503cd5dd1206bc9b1ca4966bace..ce001014b5773f0dc743b67b8fbe85afdbe675ae 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; } diff --git a/mm/vmscan.c b/mm/vmscan.c index d81495357268160b98e48106a273ff7453207fb8..d187089a1c4317594521b8ee683eb45ca86bfb0d 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);