--- libnuma.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ numa.h | 2 ++ versions.ldscript | 8 ++++++++ 3 files changed, 56 insertions(+) diff --git a/libnuma.c b/libnuma.c index a319bcc..091261c 100755 --- a/libnuma.c +++ b/libnuma.c @@ -1524,6 +1524,52 @@ __asm__(".symver numa_run_on_node_mask_v2,numa_run_on_node_mask@@libnuma_1.2"); make_internal_alias(numa_run_on_node_mask_v2); +/* + * Given a node mask (size of a kernel nodemask_t) (probably populated by + * a user argument list) set up a map of cpus (map "cpus") on those nodes + * without any cpuset awareness. Then set affinity to those cpus. + */ +int +numa_run_on_node_mask_all(struct bitmask *bmp) +{ + int ncpus, i, k, err; + struct bitmask *cpus, *nodecpus; + + cpus = numa_allocate_cpumask(); + ncpus = cpus->size; + nodecpus = numa_allocate_cpumask(); + + for (i = 0; i < bmp->size; i++) { + if (bmp->maskp[i / BITS_PER_LONG] == 0) + continue; + if (numa_bitmask_isbitset(bmp, i)) { + if (!numa_bitmask_isbitset(numa_possible_nodes_ptr, i)) { + numa_warn(W_noderunmask, + "node %d not allowed", i); + continue; + } + if (numa_node_to_cpus_v2_int(i, nodecpus) < 0) { + numa_warn(W_noderunmask, + "Cannot read node cpumask from sysfs"); + continue; + } + for (k = 0; k < CPU_LONGS(ncpus); k++) + cpus->maskp[k] |= nodecpus->maskp[k]; + } + } + err = numa_sched_setaffinity_v2_int(0, cpus); + + numa_bitmask_free(cpus); + numa_bitmask_free(nodecpus); + + /* With possible nodes freedom it can happen easily now */ + if (err < 0) { + numa_error("numa_sched_setaffinity_v2_int() failed; abort\n"); + } + + return err; +} + nodemask_t numa_get_run_node_mask_v1(void) { diff --git a/numa.h b/numa.h index 5982fdc..01b3165 100755 --- a/numa.h +++ b/numa.h @@ -238,6 +238,8 @@ void numa_police_memory(void *start, size_t size); /* Run current task only on nodes in mask */ int numa_run_on_node_mask(struct bitmask *mask); +/* Run current task on nodes in mask without any cpuset awareness */ +int numa_run_on_node_mask_all(struct bitmask *mask); /* Run current task only on node */ int numa_run_on_node(int node); /* Return current mask of nodes the task can run on */ diff --git a/versions.ldscript b/versions.ldscript index 2f2d254..eaddc7e 100755 --- a/versions.ldscript +++ b/versions.ldscript @@ -165,3 +165,11 @@ libnuma_1.3 { *; } libnuma_1.2; +# New interface with customizable cpuset awareness +# was added into version 1.4 +libnuma_1.4 { + global: + numa_run_on_node_mask_all; + local: + *; +} libnuma_1.3; -- 1.8.1.4 -- 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