[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221109171952.826d991327e07319c5eb8cd3@linux-foundation.org>
Date: Wed, 9 Nov 2022 17:19:52 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Chao Xu <amos.xuchao@...il.com>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Chao Xu <Chao.Xu9@...krlife.com>
Subject: Re: [PATCH] mm/vmscan: simplify the nr assignment logic for pages
to scan
On Wed, 9 Nov 2022 15:04:16 +0800 Chao Xu <amos.xuchao@...il.com> wrote:
> By default the assignment logic of anonymouns or file inactive
> pages and active pages to scan using the same duplicated code
> snippet. To simplify the logic, merge the same part.
>
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -5932,14 +5932,11 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
> * scan target and the percentage scanning already complete
> */
> lru = (lru == LRU_FILE) ? LRU_BASE : LRU_FILE;
> - nr_scanned = targets[lru] - nr[lru];
> - nr[lru] = targets[lru] * (100 - percentage) / 100;
> - nr[lru] -= min(nr[lru], nr_scanned);
> -
> - lru += LRU_ACTIVE;
> - nr_scanned = targets[lru] - nr[lru];
> - nr[lru] = targets[lru] * (100 - percentage) / 100;
> - nr[lru] -= min(nr[lru], nr_scanned);
> + for ( ; lru <= lru + LRU_ACTIVE; lru++) {
The "lru++" implicitly assumes that LRU_ACTIVE=1. That happens to be
the case, but a more accurate translation of the existing code would
use "lru += LRU_ACTIVE" here, yes?
> + nr_scanned = targets[lru] - nr[lru];
> + nr[lru] = targets[lru] * (100 - percentage) / 100;
> + nr[lru] -= min(nr[lru], nr_scanned);
> + }
>
> scan_adjusted = true;
> }
Powered by blists - more mailing lists