Re: [RFC] Scalable statistics counters using kmalloc_percpu

From: Andrew Morton (akpm@zip.com.au)
Date: Fri Jul 26 2002 - 13:46:34 EST


Ravikiran G Thirumalai wrote:
>
> Here is a Scalable statistics counter implementation which works on top
> of the kmalloc_percpu dynamic allocator published by Dipankar.
> This patch is against 2.5.27.
>
> ...
> +static inline int __statctr_init(statctr_t *stctr)
> +{
> + stctr->ctr = kmalloc_percpu(sizeof(*(stctr->ctr)), GFP_ATOMIC);
> + if(!stctr->ctr)
> + return -1;
> + return 0;
> +}

Minor nit: please force the caller to pass in the gfp_flags when
designing an API like this. The fact that you were forced to use
GFP_ATOMIC here shows why...

> + for( i=0; i < NR_CPUS; i++ )
> + res += *per_cpu_ptr(stctr->ctr, i);
> + return res;
> +}

Oh dear. Most people only have two CPUs.

Rusty, can we *please* fix this? Really soon?

General comment: we need to clean up the kernel_stat stuff. We
cannot just make it per-cpu because it is 32k in size already. I
would suggest that we should break out the disk accounting and
make the rest of kernel_stat per CPU.

That would be a great application of your interface, and a good
way to get your interface merged ;) Is that something which you
have time to do?

Thanks.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jul 30 2002 - 14:00:24 EST