Messages in this thread | | | Date | Wed, 27 Feb 2008 11:59:54 -0800 (PST) | From | David Rientjes <> | Subject | Re: [patch 1/6] mempolicy: convert MPOL constants to enum |
| |
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
| |