[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.1.00.0802121832520.29792@chino.kir.corp.google.com>
Date: Tue, 12 Feb 2008 18:42:01 -0800 (PST)
From: David Rientjes <rientjes@...gle.com>
To: Paul Jackson <pj@....com>
cc: clameter@....com, Lee.Schermerhorn@...com,
akpm@...ux-foundation.org, ak@...e.de, linux-kernel@...r.kernel.org
Subject: Re: [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
immediately.
> 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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists