From: Mel Gorman <mel@csn.ul.ie>
To: Lee Schermerhorn <lee.schermerhorn@hp.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org, ak@suse.de,
mtk-manpages@gmx.net, clameter@sgi.com, solo@google.com,
eric.whitney@hp.com
Subject: Re: [PATCH/RFC 5/5] Mem Policy: add MPOL_F_MEMS_ALLOWED get_mempolicy() flag
Date: Tue, 11 Sep 2007 20:07:59 +0100 [thread overview]
Message-ID: <1189537679.32731.97.camel@localhost> (raw)
In-Reply-To: <20070830185130.22619.93436.sendpatchset@localhost>
On Thu, 2007-08-30 at 14:51 -0400, Lee Schermerhorn wrote:
> PATCH/RFC 05/05 - add MPOL_F_MEMS_ALLOWED get_mempolicy() flag
>
> Against: 2.6.23-rc3-mm1
>
> Allow an application to query the memories allowed by its context.
>
I think you may be underplaying the significance of this patch here.
>From what understand, an application that is only policy aware can run
inside a cpuset and think it can use nodes it's not allowed. If that is
right, then the language here implies that a policy-aware application
can now get useful information without going through complicated hoops.
That is pretty important.
> Updated numa_memory_policy.txt to mention that applications can use this
> to obtain allowed memories for constructing valid policies.
>
> TODO: update out-of-tree libnuma wrapper[s], or maybe add a new
> wrapper--e.g., numa_get_mems_allowed() ?
>
> Tested with memtoy V>=0.13.
>
> Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
>
> Documentation/vm/numa_memory_policy.txt | 28 +++++++++++-----------------
> include/linux/mempolicy.h | 1 +
> mm/mempolicy.c | 14 +++++++++++++-
> 3 files changed, 25 insertions(+), 18 deletions(-)
>
> Index: Linux/include/linux/mempolicy.h
> ===================================================================
> --- Linux.orig/include/linux/mempolicy.h 2007-08-29 11:44:18.000000000 -0400
> +++ Linux/include/linux/mempolicy.h 2007-08-29 11:45:23.000000000 -0400
> @@ -26,6 +26,7 @@
> /* Flags for get_mem_policy */
> #define MPOL_F_NODE (1<<0) /* return next IL mode instead of node mask */
> #define MPOL_F_ADDR (1<<1) /* look up vma using address */
> +#define MPOL_F_MEMS_ALLOWED (1<<2) /* return allowed memories */
>
> /* Flags for mbind */
> #define MPOL_MF_STRICT (1<<0) /* Verify existing pages in the mapping */
> Index: Linux/mm/mempolicy.c
> ===================================================================
> --- Linux.orig/mm/mempolicy.c 2007-08-29 11:45:09.000000000 -0400
> +++ Linux/mm/mempolicy.c 2007-08-29 11:45:23.000000000 -0400
> @@ -560,8 +560,20 @@ static long do_get_mempolicy(int *policy
> struct mempolicy *pol = current->mempolicy;
>
> cpuset_update_task_memory_state();
> - if (flags & ~(unsigned long)(MPOL_F_NODE|MPOL_F_ADDR))
> + if (flags &
> + ~(unsigned long)(MPOL_F_NODE|MPOL_F_ADDR|MPOL_F_MEMS_ALLOWED))
> return -EINVAL;
> +
> + if (flags & MPOL_F_MEMS_ALLOWED) {
> + if (flags & (MPOL_F_NODE|MPOL_F_ADDR))
> + return -EINVAL;
> + *policy = 0; /* just so it's initialized */
> + if (!nmask)
> + return -EFAULT;
> + *nmask = cpuset_current_mems_allowed;
> + return 0;
> + }
> +
Seems a fair implementation.
> if (flags & MPOL_F_ADDR) {
> down_read(&mm->mmap_sem);
> vma = find_vma_intersection(mm, addr, addr+1);
> Index: Linux/Documentation/vm/numa_memory_policy.txt
> ===================================================================
> --- Linux.orig/Documentation/vm/numa_memory_policy.txt 2007-08-29 11:44:18.000000000 -0400
> +++ Linux/Documentation/vm/numa_memory_policy.txt 2007-08-29 11:45:23.000000000 -0400
> @@ -294,24 +294,20 @@ MEMORY POLICIES AND CPUSETS
>
> Memory policies work within cpusets as described above. For memory policies
> that require a node or set of nodes, the nodes are restricted to the set of
> -nodes whose memories are allowed by the cpuset constraints. If the
> -intersection of the set of nodes specified for the policy and the set of nodes
> -allowed by the cpuset is the empty set, the policy is considered invalid and
> -cannot be installed.
> +nodes whose memories are allowed by the cpuset constraints. If the nodemask
> +specified for the policy contains nodes that are not allowed by the cpuset, or
> +the intersection of the set of nodes specified for the policy and the set of
> +nodes with memory is the empty set, the policy is considered invalid
> +and cannot be installed.
>
> The interaction of memory policies and cpusets can be problematic for a
> couple of reasons:
>
> -1) the memory policy APIs take physical node id's as arguments. However, the
> - memory policy APIs do not provide a way to determine what nodes are valid
> - in the context where the application is running. An application MAY consult
> - the cpuset file system [directly or via an out of tree, and not generally
> - available, libcpuset API] to obtain this information, but then the
> - application must be aware that it is running in a cpuset and use what are
> - intended primarily as administrative APIs.
> -
> - However, as long as the policy specifies at least one node that is valid
> - in the controlling cpuset, the policy can be used.
> +1) the memory policy APIs take physical node id's as arguments. As mentioned
> + above, it is illegal to specify nodes that are not allowed in the cpuset.
> + The application must query the allowed nodes using the get_mempolicy()
> + API with the MPOL_F_MEMS_ALLOWED flag to determine the allowed nodes and
> + restrict itself to those nodes.
>
> 2) when tasks in two cpusets share access to a memory region, such as shared
> memory segments created by shmget() of mmap() with the MAP_ANONYMOUS and
> @@ -321,7 +317,5 @@ couple of reasons:
> the memory policy APIs, as well as knowing in what cpusets other task might
> be attaching to the shared region, to use the cpuset information.
> Furthermore, if the cpusets' allowed memory sets are disjoint, "local"
> + allocation and "contextual interleave" are the only valid policies.
>
> -Note, however, that local allocation, whether specified by MPOL_DEFAULT or
> -MPOL_PREFERRED with an empty nodemask and "contextual interleave"--
> -MPOL_INTERLEAVE with an empty nodemask--are valid policies in any context.
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-09-11 19:07 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-30 18:50 [PATCH/RFC 0/5] Memory Policy Cleanups and Enhancements Lee Schermerhorn
2007-08-30 18:51 ` [PATCH/RFC 1/5] Mem Policy: fix reference counting Lee Schermerhorn
2007-09-11 18:48 ` Mel Gorman
2007-09-11 18:12 ` Lee Schermerhorn
2007-09-13 9:45 ` Mel Gorman
2007-08-30 18:51 ` [PATCH/RFC 2/5] Mem Policy: Use MPOL_PREFERRED for system-wide default policy Lee Schermerhorn
2007-09-11 18:54 ` Mel Gorman
2007-09-11 18:22 ` Lee Schermerhorn
2007-09-13 9:48 ` Mel Gorman
2007-08-30 18:51 ` [PATCH/RFC 3/5] Mem Policy: MPOL_PREFERRED fixups for "local allocation" Lee Schermerhorn
2007-09-11 18:58 ` Mel Gorman
2007-09-11 18:34 ` Lee Schermerhorn
2007-09-12 22:10 ` Christoph Lameter
2007-09-13 13:51 ` Lee Schermerhorn
2007-09-13 18:18 ` Christoph Lameter
2007-09-13 9:55 ` Mel Gorman
2007-09-12 22:06 ` Christoph Lameter
2007-09-13 13:35 ` Lee Schermerhorn
2007-09-13 18:21 ` Christoph Lameter
2007-08-30 18:51 ` [PATCH/RFC 4/5] Mem Policy: cpuset-independent interleave policy Lee Schermerhorn
2007-09-12 21:20 ` Ethan Solomita
2007-09-12 22:14 ` Christoph Lameter
2007-09-13 13:26 ` Lee Schermerhorn
2007-09-13 17:17 ` Ethan Solomita
2007-09-12 21:59 ` Ethan Solomita
2007-09-13 13:32 ` Lee Schermerhorn
2007-09-13 17:19 ` Ethan Solomita
2007-09-13 18:20 ` Christoph Lameter
2007-10-09 6:15 ` Ethan Solomita
2007-10-09 13:39 ` Lee Schermerhorn
2007-10-09 18:49 ` Christoph Lameter
2007-10-09 19:02 ` Lee Schermerhorn
2007-08-30 18:51 ` [PATCH/RFC 5/5] Mem Policy: add MPOL_F_MEMS_ALLOWED get_mempolicy() flag Lee Schermerhorn
2007-09-11 19:07 ` Mel Gorman [this message]
2007-09-11 18:42 ` Lee Schermerhorn
2007-09-12 22:14 ` Christoph Lameter
2007-09-14 20:24 ` [PATCH] " Lee Schermerhorn
2007-09-14 20:27 ` Christoph Lameter
2007-09-11 16:20 ` [PATCH/RFC 0/5] Memory Policy Cleanups and Enhancements Lee Schermerhorn
2007-09-11 19:12 ` Mel Gorman
2007-09-11 18:45 ` Lee Schermerhorn
2007-09-12 22:17 ` Christoph Lameter
2007-09-13 13:57 ` Lee Schermerhorn
2007-09-13 15:31 ` Mel Gorman
2007-09-13 15:01 ` Lee Schermerhorn
2007-09-13 18:55 ` Mel Gorman
2007-09-13 18:19 ` Christoph Lameter
2007-09-13 18:23 ` Mel Gorman
2007-09-13 18:26 ` Christoph Lameter
2007-09-13 21:17 ` Andrew Morton
2007-09-14 2:20 ` Christoph Lameter
2007-09-14 8:53 ` Mel Gorman
2007-09-14 15:06 ` Lee Schermerhorn
2007-09-14 17:46 ` Mel Gorman
2007-09-14 18:41 ` Christoph Lameter
2007-09-16 18:02 ` Mel Gorman
2007-09-17 18:12 ` Christoph Lameter
2007-09-17 18:19 ` Christoph Lameter
2007-09-17 20:14 ` Mel Gorman
2007-09-17 19:16 ` Christoph Lameter
2007-09-17 20:03 ` Mel Gorman
2007-09-14 20:15 ` Lee Schermerhorn
2007-09-16 18:05 ` Mel Gorman
2007-09-16 19:34 ` Andrew Morton
2007-09-16 21:22 ` Mel Gorman
2007-09-17 13:29 ` Lee Schermerhorn
2007-09-17 18:14 ` Christoph Lameter
2007-09-13 15:49 ` Lee Schermerhorn
2007-09-13 18:22 ` Christoph Lameter
2007-09-17 19:00 ` [PATCH] Fix NUMA Memory Policy Reference Counting Lee Schermerhorn
2007-09-17 19:14 ` Christoph Lameter
2007-09-17 19:38 ` Lee Schermerhorn
2007-09-17 19:43 ` Christoph Lameter
2007-09-19 22:03 ` Lee Schermerhorn
2007-09-19 22:23 ` Christoph Lameter
2007-09-18 10:36 ` Mel Gorman
2007-09-17 19:32 ` [PATCH] 2.6.23-rc6: " Lee Schermerhorn
2007-09-17 19:37 ` Christoph Lameter
2007-09-17 20:19 ` Lee Schermerhorn
2007-09-17 21:23 ` Christoph Lameter
2007-09-17 22:25 ` Andi Kleen
2007-09-18 19:30 ` Christoph Lameter
2007-09-17 22:28 ` Andi Kleen
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=1189537679.32731.97.camel@localhost \
--to=mel@csn.ul.ie \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=clameter@sgi.com \
--cc=eric.whitney@hp.com \
--cc=lee.schermerhorn@hp.com \
--cc=linux-mm@kvack.org \
--cc=mtk-manpages@gmx.net \
--cc=solo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.