linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
To: David Rientjes <rientjes@google.com>
Cc: Paul Jackson <pj@sgi.com>,
	akpm@linux-foundation.org, clameter@sgi.com, ak@suse.de,
	linux-kernel@vger.kernel.org, mel@csn.ul.ie
Subject: Re: [patch 3/4] mempolicy: add MPOL_F_STATIC_NODES flag
Date: Wed, 13 Feb 2008 12:05:11 -0700	[thread overview]
Message-ID: <1202929511.4978.88.camel@localhost> (raw)
In-Reply-To: <alpine.DEB.1.00.0802131035020.9186@chino.kir.corp.google.com>

On Wed, 2008-02-13 at 10:48 -0800, David Rientjes wrote:
> On Wed, 13 Feb 2008, Lee Schermerhorn wrote:
> 
> > > >  2) Those 'mpol_mode()' wrappers on all those mempolicy->policy
> > > >     evaluations look dangerous to me.  It looks like a code bug
> > > >     waiting to happen.  Unless I miss my guess, if you forget one of
> > > >     those wrappers (or someone making a future change misses one), no
> > > >     one will notice until sometime at runtime, someone makes use of the
> > > >     new fangled MPOL_F_STATIC_NODES mode in some new situation, and we
> > > >     end up executing code that we didn't expect to execute just then.
> > > > 
> > > >     I urge you to reconsider, and keep it so that the 'policy' field of struct
> > > >     mempolicy naturally evaluates to just the policy.  There should be just one
> > > >     pair of places, on entry to, and exit from, the kernel, where the code is
> > > >     aware of the need to pack the mode and the policy into a single word.
> > > > 
> > > 
> > > Ok.
> > 
> > I was hoping David wouldn't cave on this point. ;-)  I do agree with
> > David that if we ever end up with nr_modes + nr_mode_flags > 16, the API
> > will become too complex for myself, at least, to comprehend.  I don't
> > feel too strongly either way, and I'll explain more below, but first:
> > 
> 
> Hmm, I don't remember "caving" on this point; Paul asked me to reconsider 
> and I said that I would.  I think it's also helpful to have more 
> discussion on the matter by including other people's opinions.

> 
> > I do agree with Paul that there is a danger of missing one of these in
> > converting existing code.  In fact, I missed one in my ref counting
> > rework patch that I will ultimately rebase atop David's final version
> > [I'm already dependent on Mel Gorman's patch series].  To catch this, I
> > decided to rename the "policy" member to "mode".  This also aligns the
> > struct better with the numa_memory_policy doc [I think of the "policy"
> > as the tuple:  mode + optional nodemask].  For future code, I think we
> > could add comments to the struct definition warning that one should use
> > the wrappers to access the mode or mode flags.
> > 
> 
> I considered this when I implemented it the way I did, and that was part 
> of the reason I was in favor of enum mempolicy_mode so much: functions 
> that had a formal of type 'enum mempolicy_mode' were only the mode and 
> formals of type 'int' or 'unsigned short' were the combination.  I even 
> stated that difference in Documentation/vm/numa_memory_policy.txt in the 
> first patchset.
> 
> > However, let's step back and look at the usage of the mempolicy struct.
> > In earlier mail, David mentioned that it is passed around outside of
> > mempolicy.c.  While this is true, the only place that I see where code
> > outside of mempolicy.c deals with the policy/mode and nodemask
> > separately--as opposed to using an opaque mempolicy struct--is in the
> > shmem mount option parsing.  Everywhere else, as far as I can see, just
> > uses the struct mempolicy.  Even slab/slub call into slab_node() in
> > mempolicy.c to extract the target node for the policy.
> > 
> 
> Yes, struct shmem_sb_info stores the 'policy' member as well so it would 
> need to include a new 'flags' member as well.  And the interface between 
> the two, mpol_shared_policy_init() would need another formal for the 
> flags.
> 
> > So, if David does accept Paul's plea to separate the mode and the mode
> > flags in the structure, I would suggest that we do this in mpol_new().
> > That is, in {sys|do}_{set_mempolicy|mbind}(), maintain the API format
> > with the mode flags ORed into the mode.  mpol_new() can pull them apart
> > into different struct mempolicy members.  The rest of mempolicy.c can
> > use them directly from the struct without the helpers.  get_mempolicy()
> > will need to pack the mode and flags back together--perhaps with an
> > inverse helper function.
> > 
> 
> Yeah, it gets tricky.  I'm not too sure about only pulling the mode and 
> flags apart at mpol_new() time because perhaps, in the future, there will 
> be flag and mode combinations that are only applicable for set_mempolicy() 
> and not for mbind(), for example.  I can imagine that someday we may add a 
> flag that applies only to a task mempolicy and not to a VMA mempolicy.

True.  Altho' at such a time, I'd probably argue for testing for and
rejecting invalid mode/flag combinations in the respective
functions :-).


> 
> > As for the shmem mount option parsing:  For now, I'd suggest that we
> > keep the mode flags OR'd into the "policy" member of the shmem_sb_info
> > struct -- i.e., the "API format"--to preserve the mpol_new() interface.
> 
> I don't like this because its not consistent.  It increases the confusion 
> of what contains a mode and what contains the combination.  I think the 
> safest thing to do, if we separate the mode and flags out in struct 
> mempolicy is to do it everywhere.  All helper functions will need 
> additional formals similar to what I did in the first patchset (that was 
> actually unpopular) and struct shmem_sb_info need to be modified to 
> include the additional member.
> 
> In other words, I'm all in favor of storing the mode and flags however we 
> want, but I think it should be done consistenty throughout the tree.  
> While mpol_mode() wrappers may not be favorable all over the place (and I 
> didn't miss any), it may be easier than the alternative.

OK.  I'm "caving"... :-)  Different views of consistency.  But,
eventually, I hope we can replace the separate mode[, flags] and
nodemask in the 'sb_info with a mempolicy and keep the details of modes,
flags, etc. internal to mempolicy.c.

Looking forward to the respin of the patches...

Lee


  parent reply	other threads:[~2008-02-13 19:05 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-11 15:30 [patch 1/4] mempolicy: convert MPOL constants to enum David Rientjes
2008-02-11 15:30 ` [patch 2/4] mempolicy: support optional mode flags David Rientjes
2008-02-11 15:30   ` [patch 3/4] mempolicy: add MPOL_F_STATIC_NODES flag David Rientjes
2008-02-11 15:30     ` [patch 4/4] mempolicy: update NUMA memory policy documentation David Rientjes
2008-02-11 16:10       ` Randy Dunlap
2008-02-11 20:06         ` [patch 4/4 v2] " David Rientjes
2008-02-11 20:14           ` Randy Dunlap
2008-02-11 18:25     ` [patch 3/4] mempolicy: add MPOL_F_STATIC_NODES flag KOSAKI Motohiro
2008-02-11 19:56       ` David Rientjes
2008-02-13  0:25         ` Lee Schermerhorn
2008-02-13  0:57           ` David Rientjes
2008-02-11 19:34     ` Christoph Lameter
2008-02-13  0:22     ` Lee Schermerhorn
2008-02-13  3:52       ` Paul Jackson
2008-02-13  4:03         ` David Rientjes
2008-02-13  4:13           ` Paul Jackson
2008-02-13  4:23             ` David Rientjes
2008-02-13  8:03               ` Paul Jackson
2008-02-13  9:36                 ` David Rientjes
2008-02-13 16:01                   ` Lee Schermerhorn
2008-02-13 18:48                     ` David Rientjes
2008-02-13 18:58                       ` Paul Jackson
2008-02-13 19:05                       ` Lee Schermerhorn [this message]
2008-02-13 19:17                         ` David Rientjes
2008-02-13 17:04                   ` Paul Jackson
2008-02-13 19:02                     ` David Rientjes
2008-02-13 20:29                       ` Paul Jackson
2008-02-13 21:35                         ` David Rientjes
2008-02-14 11:12                           ` Paul Jackson
2008-02-14 12:27                           ` Paul Jackson
2008-02-14 10:26                         ` Paul Jackson
2008-02-14 19:45                           ` David Rientjes
2008-02-15 10:19                             ` Paul Jackson
2008-02-15 20:14                               ` David Rientjes
2008-02-13  4:18       ` David Rientjes
2008-02-13  5:06         ` David Rientjes
2008-02-13 15:15           ` Lee Schermerhorn
2008-02-13 16:14         ` Lee Schermerhorn
2008-02-13 19:12           ` David Rientjes
2008-02-14 10:09     ` Paul Jackson
2008-02-14 19:40       ` David Rientjes
2008-02-15  1:44         ` David Rientjes
2008-02-15 10:00           ` Paul Jackson
2008-02-14 21:38       ` David Rientjes
2008-02-15  9:27         ` Paul Jackson
2008-02-15 20:23           ` David Rientjes
2008-02-15 20:32             ` David Rientjes
2008-02-15 23:45             ` Paul Jackson
2008-02-15 23:55               ` David Rientjes
2008-02-16  0:11                 ` Paul Jackson
2008-02-11 16:36   ` [patch 2/4] mempolicy: support optional mode flags Lee Schermerhorn
2008-02-11 19:34     ` David Rientjes
2008-02-12 15:31       ` Lee Schermerhorn
2008-02-12 19:14         ` David Rientjes
2008-02-11 20:55     ` Paul Jackson
2008-02-11 21:52       ` David Rientjes
2008-02-11 21:57         ` Paul Jackson
2008-02-13  0:14   ` Lee Schermerhorn
2008-02-13  0:25     ` David Rientjes
2008-02-11 18:45 ` [patch 1/4] mempolicy: convert MPOL constants to enum Andi Kleen
2008-02-11 19:25   ` David Rientjes
2008-02-11 19:32 ` Christoph Lameter
2008-02-11 19:40   ` David Rientjes
2008-02-11 19:48     ` Christoph Lameter
2008-02-11 20:02       ` David Rientjes
2008-02-11 20:45         ` Christoph Lameter
2008-02-13  0:10 ` Lee Schermerhorn
2008-02-13  0:31   ` Paul Jackson
2008-02-13  0:53     ` David Rientjes
2008-02-13  1:04     ` Christoph Lameter
2008-02-13  1:28       ` Paul Jackson
2008-02-13  1:32       ` Paul Jackson
2008-02-13  2:00         ` David Rientjes
2008-02-13  2:22           ` Paul Jackson
2008-02-13  2:42             ` David Rientjes
2008-02-13  2:59               ` Paul Jackson
2008-02-13  3:17                 ` David Rientjes
2008-02-13  3:22                   ` Paul Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1202929511.4978.88.camel@localhost \
    --to=lee.schermerhorn@hp.com \
    --cc=ak@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mel@csn.ul.ie \
    --cc=pj@sgi.com \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).