Re: [PATCH] APICID: Avoid false sharing on the read mostly x86_cpu_to_apicid

From: Andi Kleen
Date: Wed Oct 26 2011 - 04:20:34 EST


Eial Czerwacki <eial@xxxxxxxxxxx> writes:

> ===================================================================
> --- a/arch/x86/include/asm/smp.h 2010-06-01 09:56:03.000000000 -0700
> +++ b/arch/x86/include/asm/smp.h 2010-06-02 15:59:21.000000000 -0700
> @@ -36,7 +36,8 @@ static inline struct cpumask *cpu_core_m
> return per_cpu(cpu_core_map, cpu);
> }
>
> -DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid);
> +extern u16 x86_cpu_to_apicid[NR_CPUS];

That's a big waste of memory. On a CONFIG_MAX_SMP kernel compiled for
4096 CPUs you're wasting 8k now on smaller systems. The per cpu
data only allocates what is needed.

NR_CPUS is usually a bad idea and it

Perhaps need a __read_mostly cache line padded per CPU section instead
for cases like this.

-Andi

--
ak@xxxxxxxxxxxxxxx -- Speaking for myself only
--
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/