mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Jackson <pj@sgi.com>
To: David Rientjes <rientjes@google.com>
Cc: akpm@linux-foundation.org, clameter@sgi.com,
	Lee.Schermerhorn@hp.com, ak@suse.de,
	linux-kernel@vger.kernel.org
Subject: Re: [patch 3/4] mempolicy: add MPOL_F_STATIC_NODES flag
Date: Fri, 15 Feb 2008 03:27:48 -0600	[thread overview]
Message-ID: <20080215032748.8b07e5eb.pj@sgi.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0802141336590.6067@chino.kir.corp.google.com>

David wrote:
> But without MPOL_FLAG_SHIFT it becomes 
> impossible to determine whether a user passed an invalid flag.

I don't think so.  It's not possible to detemine if exactly the low
eight bits of the 'policy' short are a valid mode, -however- that
"eight" is a spurious detail.  Remove it.

Instead of specifying that the 'policy' short consists of two bytes,
one for mode and one for flags, rather specify that the policy fields
consists of some high bits for flags, and the remaining low bits
(however many remain) for the mode.

That in turn exposes the opportunity to remove a couple of checks
for "(mpol_flags(mode) & ~MPOL_MODE_FLAGS)" being zero, and that
in turn makes it obvious that the 'flags' variable in
sys_set_mempolicy() is unused.

Consider the following patch, on top of the latest you sent me a day
ago.

---
 include/linux/mempolicy.h |   26 +++++++++++++++-----------
 mm/mempolicy.c            |    6 ------
 2 files changed, 15 insertions(+), 17 deletions(-)

--- 2.6.24-mm1.orig/include/linux/mempolicy.h	2008-02-15 00:11:10.000000000 -0800
+++ 2.6.24-mm1/include/linux/mempolicy.h	2008-02-15 01:13:51.597894429 -0800
@@ -8,6 +8,14 @@
  * Copyright 2003,2004 Andi Kleen SuSE Labs
  */
 
+/*
+ * The 'policy' field of 'struct mempolicy' has both a mode and
+ * some flags packed into it.  The flags (MPOL_F_* below) occupy
+ * the high bit positions (MPOL_MODE_FLAGS), and the mempolicy
+ * modes (the "Policies" below) are encoded in the remaining low
+ * bit positions.
+ */
+
 /* Policies */
 enum {
 	MPOL_DEFAULT,
@@ -18,16 +26,12 @@ enum {
 };
 
 /*
- * The lower MPOL_FLAG_SHIFT bits of the policy mode represent the MPOL_*
- * constants defined in the above enum.  The upper bits represent optional
- * set_mempolicy() or mbind() MPOL_F_* mode flags.
+ * Optional flags that modify nodemask numbering.
  */
-#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_F_* flags */
+#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 */
 
 /* Flags for get_mempolicy */
 #define MPOL_F_NODE	(1<<0)	/* return next IL mode instead of node mask */
@@ -130,12 +134,12 @@ static inline int mpol_equal(struct memp
 
 static inline unsigned char mpol_mode(unsigned short mode)
 {
-	return mode & MPOL_MODE_MASK;
+	return mode & ~MPOL_MODE_FLAGS;
 }
 
 static inline unsigned short mpol_flags(unsigned short mode)
 {
-	return mode & ~MPOL_MODE_MASK;
+	return mode & MPOL_MODE_FLAGS;
 }
 
 /*
--- 2.6.24-mm1.orig/mm/mempolicy.c	2008-02-15 00:18:35.000000000 -0800
+++ 2.6.24-mm1/mm/mempolicy.c	2008-02-15 01:23:53.775748002 -0800
@@ -884,8 +884,6 @@ asmlinkage long sys_mbind(unsigned long 
 
 	if (mpol_mode(mode) >= MPOL_MAX)
 		return -EINVAL;
-	if (mpol_flags(mode) & ~MPOL_MODE_FLAGS)
-		return -EINVAL;
 	err = get_nodes(&nodes, nmask, maxnode);
 	if (err)
 		return err;
@@ -898,13 +896,9 @@ asmlinkage long sys_set_mempolicy(int mo
 {
 	int err;
 	nodemask_t nodes;
-	unsigned short flags;
 
 	if (mpol_mode(mode) >= MPOL_MAX)
 		return -EINVAL;
-	if (mpol_flags(mode) & ~MPOL_MODE_FLAGS)
-		return -EINVAL;
-	flags = mpol_flags(mode) & MPOL_MODE_FLAGS;
 	err = get_nodes(&nodes, nmask, maxnode);
 	if (err)
 		return err;


-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@sgi.com> 1.940.382.4214

  reply	other threads:[~2008-02-15  9:29 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
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 [this message]
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=20080215032748.8b07e5eb.pj@sgi.com \
    --to=pj@sgi.com \
    --cc=Lee.Schermerhorn@hp.com \
    --cc=ak@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --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

Powered by JetHome