Message ID | 20221110113130.284290-1-Chao.Xu9@zeekrlife.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v1] mm/vmscan: simplify the nr assignment logic for pages to scan | expand |
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.
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) { + nr_scanned = targets[lru] - nr[lru]; + nr[lru] = targets[lru] * (100 - percentage) / 100; + nr[lru] -= min(nr[lru], nr_scanned); + } scan_adjusted = true; }
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(-)