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

From: David Rientjes
Date: Mon Feb 11 2008 - 15:04:50 EST


On Mon, 11 Feb 2008, Christoph Lameter wrote:

> Then you could follow through with the enum mempolicy thing
> throughtout. Why not use enum mempolicy in struct mempolicy?
>

Mempolicy flags, as I implemented them in patch 2 in this series, are not
integer constants that are enumerated starting at 0. They are individual
bits that are shifted a pre-defined length and intersected with the
enumerated mode. This allows both the mode and the flags to be stored in
the same object.

Just because enum mempolicy_mode is the equivalent of passing an int in C
is irrelevant; its semantics are that the value is coming from enum
mempolicy_mode. That includes _only_ the mode itself:

enum mempolicy_mode {
MPOL_DEFAULT,
MPOL_BIND,
MPOL_PREFERRED,
MPOL_INTERLEAVE,
MPOL_MAX,
};

And changing the policy member of struct mempolicy to 'enum
mempolicy_mode' instead of 'unsigned short' would increase its size. Not
that it matters, since in the third patch I add a whole nodemask_t, but
it's simply unnecessary. Right now we have the capacity to store 256
individual mempolicy modes (we currently use four) and eight mempolicy
flags with unsigned short.

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/