PATCH 2/10 libnuma: add numa_get_mems_allowed() Against: numactl-1.0.3-rc1 Depends-on: MPOL_F_MEMS_ALLOWED kernel patch Provide libnuma API for MPOL_F_MEMS_ALLOWED flag. Return nodes allowed by the application's current cpuset context via new API numa_get_mems_allowed(). Signed-off-by: Lee Schermerhorn <lee.schermerhorn@xxxxxx> libnuma.c | 15 +++++++++++++++ numa.3 | 8 ++++++++ numa.h | 3 +++ numaif.h | 1 + versions.ldscript | 1 + 5 files changed, 28 insertions(+) Index: numactl-1.0.3-rc1/numaif.h =================================================================== --- numactl-1.0.3-rc1.orig/numaif.h 2008-02-10 20:54:17.000000000 -0500 +++ numactl-1.0.3-rc1/numaif.h 2008-04-01 21:04:54.000000000 -0400 @@ -33,6 +33,7 @@ extern long move_pages(int pid, unsigned /* Warning: MPOL_F_NODE is unsupported and subject to change. Don't use. */ #define MPOL_F_ADDR (1<<1) /* look up vma using address */ +#define MPOL_F_MEMS_ALLOWED (1<<2) /* query nodes allowed in cpuset */ /* Flags for mbind */ #define MPOL_MF_STRICT (1<<0) /* Verify existing pages in the mapping */ Index: numactl-1.0.3-rc1/numa.3 =================================================================== --- numactl-1.0.3-rc1.orig/numa.3 2008-04-01 21:04:26.000000000 -0400 +++ numactl-1.0.3-rc1/numa.3 2008-04-01 21:12:24.000000000 -0400 @@ -34,6 +34,8 @@ numa \- NUMA policy library .br .BI "int numa_num_configured_nodes();" .br +.B struct bitmask *numa_get_mems_allowed(void); +.sp .BI "int numa_num_configured_cpus(void);" .br .BI "struct bitmask *numa_all_nodes_ptr;" @@ -251,6 +253,12 @@ includes any nodes that are currently di the node numbers in /sys/devices/system/node. (Depends on the kernel being configured with /sys (CONFIG_SYSFS)). +.BR numa_get_mems_allowed() +returns the mask of nodes from which the process is allowed to allocate +memory in it's current cpuset context. +Any nodes that are not included in the returned bitmask will be ignored +in any of the following libnuma memory policy calls. + .BR numa_num_configured_cpus() returns the number of cpus in the system. This count includes any cpus that are currently disabled. This count is derived from the cpu Index: numactl-1.0.3-rc1/libnuma.c =================================================================== --- numactl-1.0.3-rc1.orig/libnuma.c 2008-02-10 20:54:15.000000000 -0500 +++ numactl-1.0.3-rc1/libnuma.c 2008-04-01 21:04:54.000000000 -0400 @@ -1034,6 +1034,21 @@ numa_get_membind_v2(void) } __asm__(".symver numa_get_membind_v2,numa_get_membind@@libnuma_1.2"); +//TODO: Cliff: do I need a v1 nodemask_t version? +struct bitmask *numa_get_mems_allowed(void) +{ + struct bitmask *bmp; + + /* + * can change, so query on each call. + */ + bmp = numa_allocate_nodemask(); + getpol(NULL, bmp); + return bmp; +} +make_internal_alias(numa_get_mems_allowed); + + void numa_free(void *mem, size_t size) { munmap(mem, size); Index: numactl-1.0.3-rc1/numa.h =================================================================== --- numactl-1.0.3-rc1.orig/numa.h 2008-02-10 20:54:17.000000000 -0500 +++ numactl-1.0.3-rc1/numa.h 2008-04-01 21:04:54.000000000 -0400 @@ -134,6 +134,9 @@ void numa_set_membind(struct bitmask *no /* Return current membind */ struct bitmask *numa_get_membind(void); +/* Return allowed memories [nodes] */ +struct bitmask *numa_get_mems_allowed(void); + int numa_get_interleave_node(void); /* NUMA memory allocation. These functions always round to page size Index: numactl-1.0.3-rc1/versions.ldscript =================================================================== --- numactl-1.0.3-rc1.orig/versions.ldscript 2008-02-10 20:54:22.000000000 -0500 +++ numactl-1.0.3-rc1/versions.ldscript 2008-04-01 21:06:58.000000000 -0400 @@ -105,6 +105,7 @@ libnuma_1.2 { numa_get_interleave_mask; numa_get_interleave_node; numa_get_membind; + numa_get_mems_allowed; numa_get_run_node_mask; numa_interleave_memory; numa_max_node; -- To unsubscribe from this list: send the line "unsubscribe linux-numa" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html