Re: [patch 1/6] mempolicy: convert MPOL constants to enum

From: David Rientjes
Date: Wed Feb 27 2008 - 15:01:10 EST


On Wed, 27 Feb 2008, Christoph Lameter wrote:

> On Mon, 25 Feb 2008, David Rientjes wrote:
>
> > struct mempolicy {
> > atomic_t refcnt;
> > - short policy; /* See MPOL_* above */
> > + unsigned short policy; /* See MPOL_* above */
>
> The point here is to have a 16 bit value? There are no space savins due to
> the alignment requirement of the union. Isnt it possible to use the enum
> here? If not then what is the point of the enum?
>

It was already a 16-bit value, that is unchanged, so no space savings is
intended.

It is not possible to use the enum here because an additional unsigned
short member to hold the mode flags is added to this struct later. The
increase in size of an int compared to an unsigned short would make the
entire struct bigger; the alignment requirement of the union no longer
prevents that. After this patchset, it is 24 bytes in size while using
unsigned short compared to 32 bytes while using int.

The enum is there to ensure MPOL_MAX is always accurate since it is now
the sole way of testing for a proper mode being passed from the user, and
modes should be sequentially numbered. A later change will add an array
instance of a mempolicy_operations structure for the various modes. It's
just cleaner.

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