Re: [Patch 5/6] statistics infrastructure

From: Andrew Morton
Date: Mon May 29 2006 - 21:11:53 EST


On Tue, 30 May 2006 00:17:08 +0200
Martin Peschke <mp3@xxxxxxxxxx> wrote:

> > > +static void statistic_set_sparse(struct statistic *stat, s64 value, u64 total)
> > > +{
> > > + struct statistic_sparse_list *slist = (struct statistic_sparse_list *)
> > > + stat->pdata;
> >
> > Hang on, what's happening here? statistic.pdata is `struct percpu_data *'.
> > That's
> >
> > struct percpu_data {
> > void *ptrs[NR_CPUS];
> > };
> >
> > How can we cast that to a statistic_sparse_list* and then start playing
> > with it? We're supposed to use per_cpu_ptr() to get at the actual data.
>
> With regard to the data that a statistic feeds on, there are are two
> types of statistics: statistics that accumulate incremental updates
> (pushed - probably frequently - through statistic_add() or
> statistic_inc()), and statistics that accept total numbers (pulled
> through statistic_set() only when read by user). We use per-cpu data for
> the former. As to the latter, per-cpu data would be way to heavy.
> That is why, my code is capable of dealing with both per-cpu data and
> non-per-cpu data. Since a particular statistic is either per-cpu or
> non-per-cpu, I use the same data pointer for both cases in order to keep
> struct statistic as small as possible.
>
> I admit the cast looks a bit fishy. But lines above are correct.

<head spins>

Perhaps a suitable comment somewhere so people don't fall out of their
chairs when they see this like I did?

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