Re: [PATCH] shrink_all_memory() use sc.nr_reclaimed

From: KOSAKI Motohiro
Date: Wed Feb 11 2009 - 06:50:56 EST


> On Wed, Feb 11, 2009 at 05:41:21AM +0900, KOSAKI Motohiro wrote:
> > >> {
> > >> struct zone *zone;
> > >> - unsigned long nr_to_scan, ret = 0;
> > >> + unsigned long nr_to_scan;
> > >> enum lru_list l;
> > >
> > > Basing it on swsusp-clean-up-shrink_all_zones.patch probably makes it
> > > easier for Andrew to pick it up.
> >
> > ok, thanks.
> >
> > >> reclaim_state.reclaimed_slab = 0;
> > >> - shrink_slab(nr_pages, sc.gfp_mask, global_lru_pages());
> > >> - ret += reclaim_state.reclaimed_slab;
> > >> - } while (ret < nr_pages && reclaim_state.reclaimed_slab > 0);
> > >> + shrink_slab(nr_pages, sc.gfp_mask,
> > >> + global_lru_pages());
> > >> + sc.nr_reclaimed += reclaim_state.reclaimed_slab;
> > >> + } while (sc.nr_reclaimed < nr_pages &&
> > >> + reclaim_state.reclaimed_slab > 0);
> > >
> > > :(
> > >
> > > Is this really an improvement? `ret' is better to read than
> > > `sc.nr_reclaimed'.
> >
> > I know it's debetable thing.
> > but I still think code consistency is important than variable name preference.
>
> How about this ?
>
> I followed do_try_to_free_pages coding style.
> It use both 'sc->nr_reclaimed' and 'ret'.
> It can support code consistency and readability.
>
> So, I think it would be better.
> If you don't mind, I will resend with your sign-off.

looks good. thanks.


> -static unsigned long shrink_all_zones(unsigned long nr_pages, int prio,
> +static void shrink_all_zones(unsigned long nr_pages, int prio,
> int pass, struct scan_control *sc)
> {
> struct zone *zone;
> unsigned long nr_to_scan, ret = 0;
> + unsigned long nr_reclaimed = sc->nr_reclaimed;
> enum lru_list l;

and, please changelog change.
this patch have behavior change.

old bale-out checking didn't checked properly.
it's because shrink_all_memory() has five pass. but shrink_all_zones()
initialize ret = 0 every time.

then, at pass 1-4, if(ret >= nr_pages) don't judge reclaimed enough page or not.




--
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/