[lkml]   [2008]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [patch 1/4] mempolicy: convert MPOL constants to enum
On Tue, 12 Feb 2008, Paul Jackson wrote:

> However, once inside the kernel, how we store this flag in struct mempolicy,
> and how we pass it about between kernel routines, is our choice.
> We can leave it packed, and unpack and repack it each time we consider the
> flag and mode bits, or we can store and pass it as separate flags.
> I urge us to consider handling it as separate flags within the kernel
> because it most clearly and explicitly represents what is going on logically.
> There are two different kinds of flags here, the original mempolicy modes,
> and these meta modes (MPOL_F_STATIC_NODES, being the first example) which
> affect the nodemask intepretation.

Again, if you did it this way, the lower MPOL_FLAG_SHIFT bits of the new
'flags' member would always be zero if you are still going to use the
MPOL_F_* defines from linux/mempolicy.h to do your bit testing.

I do not subscribe to the theory that just because we have a couple extra
bytes of space somewhere in struct mempolicy that we have to use it

> Cramming both these into a single int is necessary across the kernel-user API,
> but it's an obfuscation that is not needed, therefore better avoided, within
> the kernel code.

It makes the kernel code simpler, in a way.

Now we only have to pass a single actual among functions that include both
the mode and optional flags (there are a lot of them and they span not
only the VM but also filesystem code). The catch is that we have to use a
mpol_mode() wrapper for mode conditionals or switch statements.

But testing the flags is just as easy as

if (mode & MPOL_F_STATIC_NODES) {

That test would remain unchanged (except for s/mode/flags/) if flags were
stored in a separate member.

So by storing them both in an 'unsigned short' member of struct mempolicy:

- we don't use any additional memory (and we can use those two extra
bytes you identified earlier later), and

- we only have to pass a single actual to many different functions that
require both the mode and optional mode flags.

 \ /
  Last update: 2008-02-13 03:45    [W:0.151 / U:1.952 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site