summaryrefslogtreecommitdiffstats
path: root/recipes-core/numad/numad-0.6
diff options
context:
space:
mode:
authorAdrian Dudau <adrian.dudau@enea.com>2014-06-26 11:48:23 (GMT)
committerAdrian Dudau <adrian.dudau@enea.com>2014-06-26 11:48:23 (GMT)
commit1b6242fc583a6b871304fb995af6dc211b58f69b (patch)
treeb5d434d90dedae24792906aa304897c23a134386 /recipes-core/numad/numad-0.6
downloadmeta-ip-1b6242fc583a6b871304fb995af6dc211b58f69b.tar.gz
initial commit for Enea Linux 4.0daisy-enea
Migrated from the internal git server on the daisy-enea branch Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'recipes-core/numad/numad-0.6')
-rw-r--r--recipes-core/numad/numad-0.6/Makefile.patch50
-rw-r--r--recipes-core/numad/numad-0.6/numad.conf.patch14
-rw-r--r--recipes-core/numad/numad-0.6/numad.init.patch85
-rwxr-xr-xrecipes-core/numad/numad-0.6/run-ptest20
-rw-r--r--recipes-core/numad/numad-0.6/test.patch175
5 files changed, 344 insertions, 0 deletions
diff --git a/recipes-core/numad/numad-0.6/Makefile.patch b/recipes-core/numad/numad-0.6/Makefile.patch
new file mode 100644
index 0000000..f6a564d
--- /dev/null
+++ b/recipes-core/numad/numad-0.6/Makefile.patch
@@ -0,0 +1,50 @@
1Add 'test-install' rule.
2Allow 'prefix' variable to be overloaded.
3
4Signed-off-by: Radu Patriu <radu.patriu@enea.com>
5Upstream-Status: Pending
6
7Index: numad/Makefile
8===================================================================
9--- numad.orig/Makefile 2014-05-13 00:17:16.094991993 +0300
10+++ numad/Makefile 2014-05-13 00:22:22.318986948 +0300
11@@ -22,21 +22,23 @@
12 BENCH_CFLAGS += -ftree-vectorize
13 endif
14
15-CLEANFILES := numad.o numad .depend .depend.X empty.c empty.o
16+CLEANFILES := numad.o numad .depend .depend.X empty.c empty.o test.o test
17
18-SOURCES := numad.c
19+SOURCES := numad.c test.c
20
21-prefix := /usr
22+prefix ?= /usr
23 docdir := ${prefix}/share/doc
24
25 all: numad
26
27 numad: numad.o -lpthread -lrt
28
29+test: test.o -lnuma
30+
31 AR ?= ar
32 RANLIB ?= ranlib
33
34-.PHONY: install all clean html depend
35+.PHONY: install all clean html depend -lpthread -lrt -lnuma
36
37 # BB_FIXME MANPAGES := numa.3 numactl.8 numastat.8 migratepages.8 migspeed.8
38
39@@ -46,6 +48,11 @@
40 install -m 0755 numad ${prefix}/bin
41 install -m 0644 numad.8 ${prefix}/share/man/man8
42
43+TEST_DESTDIR ?= ${prefix}/lib/numad/ptest
44+test-install: test
45+ install -d ${TEST_DESTDIR}
46+ install test ${TEST_DESTDIR}
47+
48 clean:
49 rm -f ${CLEANFILES}
50 @rm -rf html
diff --git a/recipes-core/numad/numad-0.6/numad.conf.patch b/recipes-core/numad/numad-0.6/numad.conf.patch
new file mode 100644
index 0000000..0b63ca0
--- /dev/null
+++ b/recipes-core/numad/numad-0.6/numad.conf.patch
@@ -0,0 +1,14 @@
1Add DIRECTORY_MOUNT_POINT to configuration file.
2
3Signed-off-by: Radu Patriu <radu.patriu@enea.com>
4Upstream-Status: Pending
5
6Index: numad/numad.conf
7===================================================================
8--- numad.orig/numad.conf 2014-03-13 17:12:38.000000000 +0200
9+++ numad/numad.conf 2014-03-13 17:40:39.417851081 +0200
10@@ -3,3 +3,4 @@
11 # Default INTERVAL is 15
12 # modify below to change it
13 INTERVAL=15
14+DIRECTORY_MOUNT_POINT="/sys/fs/cgroup/cpuset"
diff --git a/recipes-core/numad/numad-0.6/numad.init.patch b/recipes-core/numad/numad-0.6/numad.init.patch
new file mode 100644
index 0000000..c95f8d6
--- /dev/null
+++ b/recipes-core/numad/numad-0.6/numad.init.patch
@@ -0,0 +1,85 @@
1Fix source functions path.
2Use start-stop-daemon.
3
4Signed-off-by: Radu Patriu <radu.patriu@enea.com>
5Upstream-Status: Pending
6
7Index: numad/numad.init
8===================================================================
9--- numad.orig/numad.init 2014-03-13 15:27:26.000000000 +0200
10+++ numad/numad.init 2014-03-13 16:39:13.089952014 +0200
11@@ -6,13 +6,13 @@
12 ### BEGIN INIT INFO
13 # Provides: numad
14 # Required-Start: cgconfig
15-# Required-Stop:
16-# Should-Start:
17-# Should-Stop:
18-# Default-Start:
19-# Default-Stop:
20+# Required-Stop:
21+# Should-Start:
22+# Should-Stop:
23+# Default-Start:
24+# Default-Stop:
25 # Short-Description: numad control
26-# Description:
27+# Description:
28 ### END INIT INFO
29
30 if [ $(id -u) -ne 0 ]; then
31@@ -21,7 +21,7 @@
32 fi
33
34 # Source function library.
35-. /etc/rc.d/init.d/functions
36+. /etc/init.d/functions
37
38 exec="/usr/bin/numad"
39 prog="numad"
40@@ -29,32 +29,36 @@
41
42 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
43
44-lockfile=/var/lock/subsys/$prog
45-base=${0##*/}
46-
47 start() {
48 [ -x $exec ] || exit 5
49 [ -f $config ] || exit 6
50 echo -n $"Starting $prog: "
51 . $config
52- daemon "$exec -i $INTERVAL"
53+ start-stop-daemon --start --quiet --exec $exec -- -i $INTERVAL -D $DIRECTORY_MOUNT_POINT
54 retval=$?
55- echo
56- [ $retval -eq 0 ] && touch $lockfile
57+ if [ $retval -eq 0 ] ; then
58+ echo "OK"
59+ else
60+ echo "FAIL"
61+ fi
62 return $retval
63 }
64
65 stop() {
66 echo -n $"Stopping $prog: "
67- killproc $prog
68+ start-stop-daemon --stop --quiet --exec $exec
69 retval=$?
70- echo
71- [ $retval -eq 0 ] && rm -f $lockfile
72+ if [ $retval -eq 0 ] ; then
73+ echo "OK"
74+ else
75+ echo "FAIL"
76+ fi
77 return $retval
78 }
79
80 restart() {
81 stop
82+ sleep 1
83 start
84 }
85
diff --git a/recipes-core/numad/numad-0.6/run-ptest b/recipes-core/numad/numad-0.6/run-ptest
new file mode 100755
index 0000000..5c49181
--- /dev/null
+++ b/recipes-core/numad/numad-0.6/run-ptest
@@ -0,0 +1,20 @@
1#!/bin/sh
2
3CPUSET_PATH="/tmp/numad-cpuset"
4
5/etc/init.d/numad.init status
6STATUS=$?
7/etc/init.d/numad.init stop
8mkdir $CPUSET_PATH; mount -t cgroup -ocpuset cpuset $CPUSET_PATH
9./test 2>&1&
10TEST_PID=$!
11sleep 2
12numad -d -S 0 -u 50 -i 5:5 -p $TEST_PID -D $CPUSET_PATH
13wait
14numad -i 0
15sleep 1
16umount $CPUSET_PATH ; rmdir $CPUSET_PATH
17if [ "$STATUS" = "0" ]; then
18 /etc/init.d/numad.init start
19fi
20
diff --git a/recipes-core/numad/numad-0.6/test.patch b/recipes-core/numad/numad-0.6/test.patch
new file mode 100644
index 0000000..762790c
--- /dev/null
+++ b/recipes-core/numad/numad-0.6/test.patch
@@ -0,0 +1,175 @@
1Test output format: ptest style (PASS, FAIL, SKIP)
2Description: Allocate memory from a node other than
3the current CPU is running on. Wait for numad to modify
4memory and CPU policy binding the process to run and allocate on
5the same node.
6Dependencies: libnuma
7
8Signed-off-by: Radu Patriu <radu.patriu@enea.com>
9Upstream-Status: Pending
10
11Index: numa-test/test.c
12===================================================================
13--- /dev/null 1970-01-01 00:00:00.000000000 +0000
14+++ numa-test/test.c 2014-02-18 17:22:49.952290472 +0200
15@@ -0,0 +1,160 @@
16+#define _GNU_SOURCE
17+#include <sched.h>
18+#include <stdio.h>
19+#include <unistd.h>
20+#include <ctype.h>
21+#include <sys/time.h>
22+#include <sched.h>
23+#include <numa.h>
24+
25+#define TIMEOUT (1000 * 60) /*60 seconds*/
26+#define LOOP_TIME (1000 * 5) /*5 seconds*/
27+#define MEM_POLICY_CHANGED 1
28+#define NODE_POLICY_CHANGED 2
29+#define TEST_DONE (MEM_POLICY_CHANGED | NODE_POLICY_CHANGED)
30+
31+#define TEST_PASS 0
32+#define TEST_FAIL 1
33+#define TEST_SKIP 2
34+
35+#define MEM_SIZE 0.3 /* 30 % node memory */
36+
37+unsigned int numa_bitmask_weight(const struct bitmask *bmp);
38+
39+void print_bitmask(struct bitmask *mask)
40+{
41+ /*assume 32 max nodes*/
42+ printf("0x%08lx", *(mask->maskp));
43+}
44+
45+int test()
46+{
47+ int i, j, total_nodes, total_mem_nodes, total_cpus, prefered_node;
48+ struct bitmask *allowed_mem_nodes, *allowed_nodes, *cpu_mask, *mem_bind, *bit_mask;
49+ long long mem_size, page_size;
50+ unsigned char *mem;
51+ struct timeval start, end, res;
52+ int local_node, local_cpu, other_node, test_complete;
53+
54+ allowed_mem_nodes = numa_allocate_nodemask();
55+ allowed_nodes = numa_allocate_nodemask();
56+ mem_bind = numa_allocate_nodemask();
57+ cpu_mask = numa_allocate_cpumask();
58+ if (!(allowed_mem_nodes && allowed_nodes && mem_bind && cpu_mask)) {
59+ printf("Error: numa_allocate failed\n");
60+ return TEST_FAIL;
61+ }
62+
63+ total_nodes = numa_max_node() + 1;
64+ printf("total_nodes %d\n", total_nodes);
65+
66+ total_mem_nodes = numa_num_configured_nodes();
67+ printf("total_mem_nodes %d\n", total_mem_nodes);
68+
69+ total_cpus = numa_num_configured_cpus();
70+ printf("total_cpus %d\n", total_cpus);
71+
72+ page_size = numa_pagesize();
73+ printf("page_size %llu\n", page_size);
74+
75+ i = 0;
76+ test_complete = 0;
77+ gettimeofday(&start, NULL);
78+ do {
79+ printf("\n\n\nLoop %d\n", i);
80+
81+ bit_mask = numa_get_mems_allowed();
82+ if (i && !numa_bitmask_equal(bit_mask, allowed_mem_nodes)) {
83+ printf("\nInfo: memory policy modified\n\n");
84+ test_complete |= MEM_POLICY_CHANGED;
85+ }
86+ copy_bitmask_to_bitmask(bit_mask, allowed_mem_nodes);
87+ printf("allowed_mem_nodes "); print_bitmask(allowed_mem_nodes); printf("\n");
88+ if ((0 == i) && (1 == numa_bitmask_weight(allowed_mem_nodes))) {
89+ printf("Error: need at least two memory nodes\n");
90+ return TEST_SKIP;
91+ }
92+
93+ bit_mask = numa_get_run_node_mask();
94+ if (i && !numa_bitmask_equal(bit_mask, allowed_nodes)) {
95+ printf("\nInfo: node/cpu policy modified\n\n");
96+ test_complete |= NODE_POLICY_CHANGED;
97+ }
98+ copy_bitmask_to_bitmask(bit_mask, allowed_nodes);
99+ printf("allowed_nodes "); print_bitmask(allowed_nodes); printf("\n");
100+
101+ prefered_node = numa_preferred();
102+ printf("prefered_node %d\n", prefered_node);
103+
104+ bit_mask = numa_get_membind();
105+ copy_bitmask_to_bitmask(bit_mask, mem_bind);
106+ printf("mem_bind "); print_bitmask(mem_bind); printf("\n");
107+
108+ if (numa_sched_getaffinity(0, cpu_mask) < 0) {
109+ printf("Error: numa_sched_getaffinity failed\n");
110+ return TEST_FAIL;
111+ }
112+ printf("sched_affinity "); print_bitmask(cpu_mask); printf("\n");
113+
114+ other_node = -1;
115+ local_cpu = sched_getcpu();
116+ local_node = numa_node_of_cpu(local_cpu);
117+ for (j = 0; j < total_mem_nodes; ++j)
118+ if (numa_bitmask_isbitset(allowed_mem_nodes, j) && (j != local_node))
119+ other_node = j;
120+
121+ printf("running on node %d, cpu %d\n", local_node, local_cpu);
122+ printf("alloc memory from node %d\n", other_node);
123+
124+ mem_size = numa_node_size64(other_node, NULL) * MEM_SIZE;
125+ printf("test_mem_size %llu\n", mem_size);
126+
127+ /* avoid mbind: Invalid argument */
128+ if (TEST_DONE == test_complete)
129+ return TEST_PASS;
130+
131+ mem = numa_alloc_onnode(mem_size, other_node);
132+ if (!mem) {
133+ printf("Error: numa_alloc_onnode failed for node %d\n", other_node);
134+ return TEST_FAIL;
135+ }
136+
137+ gettimeofday(&end, NULL);
138+ /* do some work */
139+ do {
140+ struct timeval now;
141+ memcpy(mem, mem + mem_size/2, mem_size/2);
142+ gettimeofday(&now, NULL);
143+ timersub(&now, &end, &res);
144+ } while((res.tv_sec * 1000 + res.tv_usec / 1000) < LOOP_TIME);
145+
146+ numa_free(mem, mem_size);
147+ ++i;
148+ gettimeofday(&end, NULL);
149+ timersub(&end, &start, &res);
150+ } while((res.tv_sec * 1000 + res.tv_usec / 1000) < TIMEOUT);
151+
152+ return TEST_FAIL;
153+}
154+
155+int main()
156+{
157+ if (numa_available() < 0) {
158+ printf("Error: numa not available\n");
159+ printf("SKIP: numad\n");
160+ return 0;
161+ }
162+
163+ switch(test()) {
164+ case TEST_PASS:
165+ printf("PASS: numad\n");
166+ break;
167+ case TEST_SKIP:
168+ printf("FAIL: numad\n");
169+ break;
170+ default:
171+ printf("FAIL: numad\n");
172+ }
173+
174+ return 0;
175+}