2005-12-07 10:26:24

by Wu Fengguang

[permalink] [raw]
Subject: [PATCH 13/16] mm: fix minor scan count bugs

- in isolate_lru_pages(): reports one more scan. Fix it.
- in shrink_cache(): 0 pages taken does not mean 0 pages scanned. Fix it.

Signed-off-by: Wu Fengguang <[email protected]>
---

mm/vmscan.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)

--- linux.orig/mm/vmscan.c
+++ linux/mm/vmscan.c
@@ -864,7 +864,8 @@ static int isolate_lru_pages(int nr_to_s
struct page *page;
int scan = 0;

- while (scan++ < nr_to_scan && !list_empty(src)) {
+ while (scan < nr_to_scan && !list_empty(src)) {
+ scan++;
page = lru_to_page(src);
prefetchw_prev_lru_page(page, src, flags);

@@ -911,14 +912,15 @@ static void shrink_cache(struct zone *zo
update_zone_age(zone, nr_scan);
spin_unlock_irq(&zone->lru_lock);

- if (nr_taken == 0)
- return;
-
sc->nr_scanned += nr_scan;
if (current_is_kswapd())
mod_page_state_zone(zone, pgscan_kswapd, nr_scan);
else
mod_page_state_zone(zone, pgscan_direct, nr_scan);
+
+ if (nr_taken == 0)
+ return;
+
nr_freed = shrink_list(&page_list, sc);
if (current_is_kswapd())
mod_page_state(kswapd_steal, nr_freed);

--


2005-12-07 10:32:58

by Nick Piggin

[permalink] [raw]
Subject: Re: [PATCH 13/16] mm: fix minor scan count bugs

Wu Fengguang wrote:
> - in isolate_lru_pages(): reports one more scan. Fix it.
> - in shrink_cache(): 0 pages taken does not mean 0 pages scanned. Fix it.
>

This looks good, although in the first hunk it might be nicer
to turn it into the more familiar for-loop.

for (scan = 0; scan < nr_to_scan && !list_empty(src); scan++) {

> Signed-off-by: Wu Fengguang <[email protected]>
> ---
>
> mm/vmscan.c | 10 ++++++----
> 1 files changed, 6 insertions(+), 4 deletions(-)
>
> --- linux.orig/mm/vmscan.c
> +++ linux/mm/vmscan.c
> @@ -864,7 +864,8 @@ static int isolate_lru_pages(int nr_to_s
> struct page *page;
> int scan = 0;
>
> - while (scan++ < nr_to_scan && !list_empty(src)) {
> + while (scan < nr_to_scan && !list_empty(src)) {
> + scan++;
> page = lru_to_page(src);
> prefetchw_prev_lru_page(page, src, flags);
>
> @@ -911,14 +912,15 @@ static void shrink_cache(struct zone *zo
> update_zone_age(zone, nr_scan);
> spin_unlock_irq(&zone->lru_lock);
>
> - if (nr_taken == 0)
> - return;
> -
> sc->nr_scanned += nr_scan;
> if (current_is_kswapd())
> mod_page_state_zone(zone, pgscan_kswapd, nr_scan);
> else
> mod_page_state_zone(zone, pgscan_direct, nr_scan);
> +
> + if (nr_taken == 0)
> + return;
> +
> nr_freed = shrink_list(&page_list, sc);
> if (current_is_kswapd())
> mod_page_state(kswapd_steal, nr_freed);
>

--
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com

2005-12-07 10:36:08

by Wu Fengguang

[permalink] [raw]
Subject: Re: [PATCH 13/16] mm: fix minor scan count bugs

Hi Andrew,

Here is the standalone version for -mm inclusion.


Subject: mm: fix minor scan count bugs

- in isolate_lru_pages(): reports one more scan. Fix it.
- in shrink_cache(): 0 pages taken does not mean 0 pages scanned. Fix it.

Signed-off-by: Wu Fengguang <[email protected]>
---

--- linux.orig/mm/vmscan.c
+++ linux/mm/vmscan.c
@@ -837,7 +837,8 @@ static int isolate_lru_pages(int nr_to_s
struct page *page;
int scan = 0;

- while (scan++ < nr_to_scan && !list_empty(src)) {
+ while (scan < nr_to_scan && !list_empty(src)) {
+ scan++;
page = lru_to_page(src);
prefetchw_prev_lru_page(page, src, flags);

@@ -886,14 +887,15 @@ static void shrink_cache(struct zone *zo
zone->pages_scanned += nr_scan;
spin_unlock_irq(&zone->lru_lock);

- if (nr_taken == 0)
- goto done;
-
max_scan -= nr_scan;
if (current_is_kswapd())
mod_page_state_zone(zone, pgscan_kswapd, nr_scan);
else
mod_page_state_zone(zone, pgscan_direct, nr_scan);
+
+ if (nr_taken == 0)
+ goto done;
+
nr_freed = shrink_list(&page_list, sc);
if (current_is_kswapd())
mod_page_state(kswapd_steal, nr_freed);