linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Chao Xu <amos.xuchao@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Chao Xu <Chao.Xu9@zeekrlife.com>,
	yu@cmpxchg.org
Subject: Re: [PATCH v1] mm/vmscan: simplify the nr assignment logic for pages to scan
Date: Thu, 17 Nov 2022 13:07:24 -0500	[thread overview]
Message-ID: <Y3Z4XMKvcBOAwZvU@cmpxchg.org> (raw)
In-Reply-To: <20221110113130.284290-1-Chao.Xu9@zeekrlife.com>

On Thu, Nov 10, 2022 at 07:31:30PM +0800, Chao Xu 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.
> 
> Signed-off-by: Chao Xu <Chao.Xu9@zeekrlife.com>
> ---
>  mm/vmscan.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 04d8b88e5216..69e458e51c81 100644
> --- 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 += LRU_ACTIVE) {

As Yu points out, this will loop until lru overflows.

NAK.


      reply	other threads:[~2022-11-17 18:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 11:31 Chao Xu
2022-11-17 18:07 ` Johannes Weiner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3Z4XMKvcBOAwZvU@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=Chao.Xu9@zeekrlife.com \
    --cc=akpm@linux-foundation.org \
    --cc=amos.xuchao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=yu@cmpxchg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox