Re: [PATCH 1/4] vmscan: change the number of the unmapped files inzone reclaim

From: Wu Fengguang
Date: Sun May 17 2009 - 23:53:53 EST


On Mon, May 18, 2009 at 11:35:31AM +0800, KOSAKI Motohiro wrote:
> >> --- a/mm/vmscan.c
> >> +++ b/mm/vmscan.c
> >> @@ -2397,6 +2397,7 @@ static int __zone_reclaim(struct zone *z
> >> Â Â Â Â Â Â Â .isolate_pages = isolate_pages_global,
> >> Â Â Â };
> >> Â Â Â unsigned long slab_reclaimable;
> >> + Â Â long nr_unmapped_file_pages;
> >>
> >> Â Â Â disable_swap_token();
> >> Â Â Â cond_resched();
> >> @@ -2409,9 +2410,11 @@ static int __zone_reclaim(struct zone *z
> >> Â Â Â reclaim_state.reclaimed_slab = 0;
> >> Â Â Â p->reclaim_state = &reclaim_state;
> >>
> >> - Â Â if (zone_page_state(zone, NR_FILE_PAGES) -
> >> - Â Â Â Â Â Â zone_page_state(zone, NR_FILE_MAPPED) >
> >> - Â Â Â Â Â Â zone->min_unmapped_pages) {
> >> + Â Â nr_unmapped_file_pages = zone_page_state(zone, NR_INACTIVE_FILE) +
> >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âzone_page_state(zone, NR_ACTIVE_FILE) -
> >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âzone_page_state(zone, NR_FILE_MAPPED);
> >
> > This can possibly go negative.
>
> Is this a problem?
> negative value mean almost pages are mapped. Thus
>
> (nr_unmapped_file_pages > zone->min_unmapped_pages) => 0
>
> is ok, I think.

I wonder why you didn't get a gcc warning, because zone->min_unmapped_pages
is a "unsigned long".

Anyway, add a simple note to the code if it works *implicitly*?

Thanks,
Fengguang

> >
> >> + Â Â if (nr_unmapped_file_pages > zone->min_unmapped_pages) {
> >> Â Â Â Â Â Â Â /*
> >> Â Â Â Â Â Â Â Â* Free memory by calling shrink zone with increasing
> >> Â Â Â Â Â Â Â Â* priorities until we have enough memory freed.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/