summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Williams <williams@redhat.com>2010-01-26 22:31:58 -0600
committerClark Williams <williams@redhat.com>2010-01-26 22:31:58 -0600
commitfedb3c7bc5a5a1ac28dc88281e96f906191a9f2b (patch)
tree677b9360870f433e91ede8a9005f32875c411a00
parent5384bcd747022c624268652f0427d487af2d9233 (diff)
downloadrt-tests-fedb3c7bc5a5a1ac28dc88281e96f906191a9f2b.tar.gz
added libnuma v1 API support
Modified NUMA code to handle version 1 API (for RHEL5) Signed-off-by: Clark Williams <williams@redhat.com>
-rw-r--r--rt-tests.spec-in1
-rw-r--r--src/cyclictest/rt_numa.h37
2 files changed, 38 insertions, 0 deletions
diff --git a/rt-tests.spec-in b/rt-tests.spec-in
index ff891e4..b179b39 100644
--- a/rt-tests.spec-in
+++ b/rt-tests.spec-in
@@ -10,6 +10,7 @@ URL: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/rt-tests.git
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Obsoletes: cyclictest signaltest pi_tests
+Requires: numactl-devel
%description
A set of programs that test and measure various components of "realtime"
diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h
index 1348163..a0ebe7f 100644
--- a/src/cyclictest/rt_numa.h
+++ b/src/cyclictest/rt_numa.h
@@ -8,6 +8,10 @@ static int numa = 0;
#ifdef NUMA
#include <numa.h>
+#ifndef LIBNUMA_API_VERSION
+#define LIBNUMA_API_VERSION 1
+#endif
+
static void *
threadalloc(size_t size, int node)
{
@@ -43,11 +47,44 @@ static void numa_on_and_available()
static int rt_numa_numa_node_of_cpu(int cpu)
{
+#if LIBNUMA_API_VERSION >= 2
int node;
node = numa_node_of_cpu(cpu);
if (node == -1)
fatal("invalid cpu passed to numa_node_of_cpu(%d)\n", cpu);
return node;
+#else
+ unsigned char cpumask[16];
+ int node, ret, idx, bit;
+ int max_node, max_cpus;
+
+ max_node = numa_max_node();
+ max_cpus = sysconf(_SC_NPROCESSORS_CONF);
+
+ if (cpu > max_cpus) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* calculate bitmask index and relative bit position of cpu */
+ idx = cpu / 8;
+ bit = cpu % 8;
+
+ for (node = 0; node <= max_node; node++){
+ if (numa_node_to_cpus(node, (void *) cpumask, sizeof(cpumask)))
+ return -1;
+
+ if (cpumask[idx] & (1<<bit)) {
+ ret = node;
+ goto end;
+ }
+ }
+ ret = -1;
+ errno = EINVAL;
+end:
+ return ret;
+
+#endif
}
static void *rt_numa_numa_alloc_onnode(size_t size, int node, int cpu)