Re: [PATCH] mm:vmscan: fix inaccurate reclaim during proactive reclaim

From: Andrew Morton
Date: Fri Jul 07 2023 - 15:09:51 EST


(cc hannes)

On Fri, 7 Jul 2023 18:32:26 +0800 Efly Young <yangyifei03@xxxxxxxxxxxx> wrote:

> With commit f53af4285d77 ("mm: vmscan: fix extreme overreclaim
> and swap floods"), proactive reclaim still seems inaccurate.
>
> Our problematic scene also are almost anon pages. Request 1G
> by writing memory.reclaim will reclaim 1.7G or other values
> more than 1G by swapping.
>
> This try to fix the inaccurate reclaim problem.

It would be helpful to have some additional explanation of why you
believe the current code is incorrect?

> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -6208,7 +6208,7 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
> unsigned long nr_to_scan;
> enum lru_list lru;
> unsigned long nr_reclaimed = 0;
> - unsigned long nr_to_reclaim = sc->nr_to_reclaim;
> + unsigned long nr_to_reclaim = (sc->nr_to_reclaim - sc->nr_reclaimed);
> bool proportional_reclaim;
> struct blk_plug plug;
>