linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chao Xu <amos.xuchao@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Chao Xu <Chao.Xu9@zeekrlife.com>
Subject: Re: [PATCH] mm/vmscan: simplify the nr assignment logic for pages to scan
Date: Thu, 10 Nov 2022 10:48:24 +0800	[thread overview]
Message-ID: <7113d66a-9792-b026-cece-5c1b21dd989d@gmail.com> (raw)
In-Reply-To: <20221109171952.826d991327e07319c5eb8cd3@linux-foundation.org>


在 2022/11/10 9:19, Andrew Morton 写道:
> On Wed,  9 Nov 2022 15:04:16 +0800 Chao Xu <amos.xuchao@gmail.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?
By default the value of LRU_ACTIVE is 1,but if someone change it one day, I
use "lru++" maybe facing some exceptions, which is not robust. So I 
agree with
that "lru += LRU_ACTIVE" is appropriate instead of "lru++". I will send 
a new patch.
>> +			nr_scanned = targets[lru] - nr[lru];
>> +			nr[lru] = targets[lru] * (100 - percentage) / 100;
>> +			nr[lru] -= min(nr[lru], nr_scanned);
>> +		}
>>   
>>   		scan_adjusted = true;
>>   	}


      reply	other threads:[~2022-11-10  2:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  7:04 Chao Xu
2022-11-10  1:19 ` Andrew Morton
2022-11-10  2:48   ` Chao Xu [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=7113d66a-9792-b026-cece-5c1b21dd989d@gmail.com \
    --to=amos.xuchao@gmail.com \
    --cc=Chao.Xu9@zeekrlife.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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