Re: [PATCH v2 1/2] vmscan: don't subtraction of unsined

From: KOSAKI Motohiro
Date: Tue Jul 13 2010 - 05:32:30 EST


> On Fri, 9 Jul 2010 10:16:33 +0900 (JST)
> KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> wrote:
>
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
> > @@ -2588,7 +2588,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
> > .swappiness = vm_swappiness,
> > .order = order,
> > };
> > - unsigned long slab_reclaimable;
> > + unsigned long nr_slab_pages0, nr_slab_pages1;
> >
> > disable_swap_token();
> > cond_resched();
> > @@ -2615,8 +2615,8 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
> > } while (priority >= 0 && sc.nr_reclaimed < nr_pages);
> > }
> >
> > - slab_reclaimable = zone_page_state(zone, NR_SLAB_RECLAIMABLE);
> > - if (slab_reclaimable > zone->min_slab_pages) {
> > + nr_slab_pages0 = zone_page_state(zone, NR_SLAB_RECLAIMABLE);
> > + if (nr_slab_pages0 > zone->min_slab_pages) {
> > /*
> > * shrink_slab() does not currently allow us to determine how
> > * many pages were freed in this zone.
>
> Well no, but it could do so, with some minor changes to struct
> reclaim_state and its handling. Put a zone* and a counter in
> reclaim_state, handle them in sl?b.c.
>
> > So we take the current
> > @@ -2628,16 +2628,17 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
> > * take a long time.
> > */
> > while (shrink_slab(sc.nr_scanned, gfp_mask, order) &&
> > - zone_page_state(zone, NR_SLAB_RECLAIMABLE) >
> > - slab_reclaimable - nr_pages)
> > + (zone_page_state(zone, NR_SLAB_RECLAIMABLE) + nr_pages >
> > + nr_slab_pages0))
> > ;
> >
> > /*
> > * Update nr_reclaimed by the number of slab pages we
> > * reclaimed from this zone.
> > */
> > - sc.nr_reclaimed += slab_reclaimable -
> > - zone_page_state(zone, NR_SLAB_RECLAIMABLE);
> > + nr_slab_pages1 = zone_page_state(zone, NR_SLAB_RECLAIMABLE);
> > + if (nr_slab_pages1 < nr_slab_pages0)
> > + sc.nr_reclaimed += nr_slab_pages0 - nr_slab_pages1;
>
> My, that's horrible. The whole expression says "this number is
> basically a pile of random junk. Let's add it in anyway".
>
>
> > }
> >
> > p->reclaim_state = NULL;


How's this?

Christoph, Can we hear your opinion about to add new branch in slab-free path?
I think this is ok, because reclaim makes a lot of cache miss then branch
mistaken is relatively minor penalty. thought?