Re: [PATCH] better align percpu counter (Was Re: [tip:sched/core]sched: cpuacct: Use bigger percpu counter batch values for stats counters

From: KAMEZAWA Hiroyuki
Date: Thu Aug 20 2009 - 23:59:09 EST


On Thu, 20 Aug 2009 17:41:23 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:

>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> ---
> include/linux/percpu_counter.h | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> Index: linux-2.6.31-rc6/include/linux/percpu_counter.h
> ===================================================================
> --- linux-2.6.31-rc6.orig/include/linux/percpu_counter.h 2009-08-20 12:09:27.000000000 +0900
> +++ linux-2.6.31-rc6/include/linux/percpu_counter.h 2009-08-20 17:31:13.000000000 +0900
> @@ -14,14 +14,24 @@
> #include <linux/types.h>
>
> #ifdef CONFIG_SMP
> +struct __percpu_counter_padding {
> + char x[0];
> +} ____cacheline_internodealigned_in_smp;

above alignement is too big...plz ignore this patch :(

-Kame


> +#define CACHELINE_PADDING(name) struct __percpu_counter_padding name
>
> struct percpu_counter {
> + /*
> + * This pointer is persistent and accessed firstly.
> + * Then, should not be purged by locking in other cpus.
> + */
> + s32 *counters;
> + CACHELINE_PADDING(pad);
> spinlock_t lock;
> s64 count;
> #ifdef CONFIG_HOTPLUG_CPU
> + /* rarely accessed field */
> struct list_head list; /* All percpu_counters are on a list */
> #endif
> - s32 *counters;
> };
>
> extern int percpu_counter_batch;
>
>
> --
> 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/
>

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