Messages in this thread | | | Date | Thu, 14 Feb 2008 13:38:57 -0800 (PST) | From | David Rientjes <> | Subject | Re: [patch 3/4] mempolicy: add MPOL_F_STATIC_NODES flag |
| |
On Thu, 14 Feb 2008, Paul Jackson wrote:
> In mempolicy.h, the lines: > > /* > * The lower MPOL_FLAG_SHIFT bits of the policy mode represent the MPOL_* > * constants defined in enum mempolicy_mode. The upper bits represent > * optional set_mempolicy() MPOL_F_* mode flags. > */ > #define MPOL_FLAG_SHIFT (8) > #define MPOL_MODE_MASK ((1 << MPOL_FLAG_SHIFT) - 1) > > /* Flags for set_mempolicy */ > #define MPOL_F_STATIC_NODES (1 << MPOL_FLAG_SHIFT) > #define MPOL_MODE_FLAGS (MPOL_F_STATIC_NODES) /* legal set_mempolicy() MPOL_* mode flags */ > > could be simplified, to: > > /* > * Optional flags that modify nodemask numbering. > */ > #define MPOL_F_RELATIVE_NODES (1<<14) /* remapped relative to cpuset */ > #define MPOL_F_STATIC_NODES (1<<15) /* unremapped physical masks */ > #define MPOL_MODE_FLAGS (MPOL_F_RELATIVE_NODES|MPOL_F_STATIC_NODES) > /* combined MPOL_F_* mask flags */ > > (really, that MPOL_FLAG_SHIFT is just unnecessary distracting detail.) >
It would be easy to define mpol_mode() and mpol_flags() in terms of MPOL_MODE_FLAGS as well, yes. But without MPOL_FLAG_SHIFT it becomes impossible to determine whether a user passed an invalid flag.
I think we're all in agreement that passing an invalid flag bit should be rejected with -EINVAL. So to do that we need MPOL_MODE_MASK to expicitly define the parts of the int *policy passed from set_mempolicy() that represent the mode.
David
| |