Re: [RFC][PATCH 2/6] CART Implementation

Peter Zijlstra
2005-08-29T04:15:07Z

On Sun, 2005-08-28 at 23:02 -0400, Rik van Riel wrote:
> On Sat, 27 Aug 2005, a.p.zijlstra@chello.nl wrote:
>
> > +static void bucket_stats(struct nr_bucket * nr_bucket, int * b1, int * b2)
> > +{
> > + unsigned int i, b[2] = {0, 0};
> > + for (i = 0; i < 2; ++i) {
> > + unsigned int j = nr_bucket->hand[i];
> > + do
> > + {
> > + u32 *slot = &nr_bucket->slot[j];
> > + if (!!(GET_FLAGS(*slot) & NR_list) != !!i)
> > + break;
> > +
> > + j = GET_INDEX(*slot);
> > + ++b[i];
> > + } while (j != nr_bucket->hand[i]);
>
> Does this properly skip empty slots ?

There are no empty slots. This thing always has B1_j + B2_j = NR_SLOTS.
I couldn't manage keeping track of two lists and empty slots. It doesn't
really matter though. I just have to start out with |B1| = 0 and |B2| =
c. I fill B2_j with zero cookies, so getting a hit there is very
unlikely, that way they just get overwritten due to old age and all is
well.

>
> Remember that a page that got paged in leaves a zeroed
> out slot in the bucket...
>
Yeah, I was playing aroung with that. I'll change that back because it
does indeed generate a problem elsewhere.

--
Peter Zijlstra <a.p.zijlstra@chello.nl>