[PATCH -V3 08/11] arch/powerpc: Make some of the PGTABLE_RANGE dependency explicit

Paul Mackerras paulus at samba.org
Mon Jul 23 10:20:19 EST 2012


On Mon, Jul 09, 2012 at 06:43:38PM +0530, Aneesh Kumar K.V wrote:
> From: "Aneesh Kumar K.V" <aneesh.kumar at linux.vnet.ibm.com>
> 
> slice array size and slice mask size depend on PGTABLE_RANGE. We
> can't directly include pgtable.h in these header because there is
> a circular dependency. So add compile time check for these values.

Some comments below...

>  struct slice_mask {
>  	u16 low_slices;
>  	/*
> -	 * This should be derived out of PGTABLE_RANGE. For the current
> -	 * max 64TB, u64 should be ok.
> +	 * We do this as a union so that we can verify
> +	 * SLICE_MASK_SIZE against PGTABLE_RANGE
>  	 */
> -	u64 high_slices;
> +	union {
> +		u64 high_slices;
> +		unsigned char not_used[SLICE_MASK_SIZE];
> +	};

Seems ugly to have to have a union just for that.  Can't we do
something like BUILD_BUG_ON(sizeof(u64) < SLICE_MASK_SIZE) instead?

> @@ -73,7 +73,7 @@ static struct slice_mask slice_range_to_mask(unsigned long start,
>  					     unsigned long len)
>  {
>  	unsigned long end = start + len - 1;
> -	struct slice_mask ret = { 0, 0 };
> +	struct slice_mask ret = { 0, {0} };

Wouldn't { 0 } suffice?  Similarly in several places below.

Paul.


More information about the Linuxppc-dev mailing list