Re: ZONE_PADDING wastes 4 bytes of the new cacheline

Nick Piggin
2004-10-21T03:28:58Z

Andrea Arcangeli wrote:
> I don't see why this 'int x' exists, alignment should really work fine
> even with empty structure (works with my compiler with an userspace
> test, please double check).
>
> Index: linux-2.5/include/linux/mmzone.h
> ===================================================================
> RCS file: /home/andrea/crypto/cvs/linux-2.5/include/linux/mmzone.h,v
> retrieving revision 1.67
> diff -u -p -r1.67 mmzone.h
> --- linux-2.5/include/linux/mmzone.h 19 Oct 2004 14:58:00 -0000 1.67
> +++ linux-2.5/include/linux/mmzone.h 21 Oct 2004 01:14:20 -0000
> @@ -35,7 +35,6 @@ struct pglist_data;
> */
> #if defined(CONFIG_SMP)
> struct zone_padding {
> - int x;
> } ____cacheline_maxaligned_in_smp;
> #define ZONE_PADDING(name) struct zone_padding name;
> #else

Perhaps to keep old compilers working? Not sure.

I think it is common to use a zero length array...?

int x[0];

Although that maybe that is only used when one requires a
handle on the address.

Nick