From 1b6242fc583a6b871304fb995af6dc211b58f69b Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 26 Jun 2014 13:48:23 +0200 Subject: initial commit for Enea Linux 4.0 Migrated from the internal git server on the daisy-enea branch Signed-off-by: Adrian Dudau --- recipes-core/numad/numad-0.6/Makefile.patch | 50 ++++++++ recipes-core/numad/numad-0.6/numad.conf.patch | 14 +++ recipes-core/numad/numad-0.6/numad.init.patch | 85 +++++++++++++ recipes-core/numad/numad-0.6/run-ptest | 20 +++ recipes-core/numad/numad-0.6/test.patch | 175 ++++++++++++++++++++++++++ recipes-core/numad/numad_0.6.bb | 51 ++++++++ 6 files changed, 395 insertions(+) create mode 100644 recipes-core/numad/numad-0.6/Makefile.patch create mode 100644 recipes-core/numad/numad-0.6/numad.conf.patch create mode 100644 recipes-core/numad/numad-0.6/numad.init.patch create mode 100755 recipes-core/numad/numad-0.6/run-ptest create mode 100644 recipes-core/numad/numad-0.6/test.patch create mode 100644 recipes-core/numad/numad_0.6.bb (limited to 'recipes-core/numad') 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 @@ +Add 'test-install' rule. +Allow 'prefix' variable to be overloaded. + +Signed-off-by: Radu Patriu +Upstream-Status: Pending + +Index: numad/Makefile +=================================================================== +--- numad.orig/Makefile 2014-05-13 00:17:16.094991993 +0300 ++++ numad/Makefile 2014-05-13 00:22:22.318986948 +0300 +@@ -22,21 +22,23 @@ + BENCH_CFLAGS += -ftree-vectorize + endif + +-CLEANFILES := numad.o numad .depend .depend.X empty.c empty.o ++CLEANFILES := numad.o numad .depend .depend.X empty.c empty.o test.o test + +-SOURCES := numad.c ++SOURCES := numad.c test.c + +-prefix := /usr ++prefix ?= /usr + docdir := ${prefix}/share/doc + + all: numad + + numad: numad.o -lpthread -lrt + ++test: test.o -lnuma ++ + AR ?= ar + RANLIB ?= ranlib + +-.PHONY: install all clean html depend ++.PHONY: install all clean html depend -lpthread -lrt -lnuma + + # BB_FIXME MANPAGES := numa.3 numactl.8 numastat.8 migratepages.8 migspeed.8 + +@@ -46,6 +48,11 @@ + install -m 0755 numad ${prefix}/bin + install -m 0644 numad.8 ${prefix}/share/man/man8 + ++TEST_DESTDIR ?= ${prefix}/lib/numad/ptest ++test-install: test ++ install -d ${TEST_DESTDIR} ++ install test ${TEST_DESTDIR} ++ + clean: + rm -f ${CLEANFILES} + @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 @@ +Add DIRECTORY_MOUNT_POINT to configuration file. + +Signed-off-by: Radu Patriu +Upstream-Status: Pending + +Index: numad/numad.conf +=================================================================== +--- numad.orig/numad.conf 2014-03-13 17:12:38.000000000 +0200 ++++ numad/numad.conf 2014-03-13 17:40:39.417851081 +0200 +@@ -3,3 +3,4 @@ + # Default INTERVAL is 15 + # modify below to change it + INTERVAL=15 ++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 @@ +Fix source functions path. +Use start-stop-daemon. + +Signed-off-by: Radu Patriu +Upstream-Status: Pending + +Index: numad/numad.init +=================================================================== +--- numad.orig/numad.init 2014-03-13 15:27:26.000000000 +0200 ++++ numad/numad.init 2014-03-13 16:39:13.089952014 +0200 +@@ -6,13 +6,13 @@ + ### BEGIN INIT INFO + # Provides: numad + # Required-Start: cgconfig +-# Required-Stop: +-# Should-Start: +-# Should-Stop: +-# Default-Start: +-# Default-Stop: ++# Required-Stop: ++# Should-Start: ++# Should-Stop: ++# Default-Start: ++# Default-Stop: + # Short-Description: numad control +-# Description: ++# Description: + ### END INIT INFO + + if [ $(id -u) -ne 0 ]; then +@@ -21,7 +21,7 @@ + fi + + # Source function library. +-. /etc/rc.d/init.d/functions ++. /etc/init.d/functions + + exec="/usr/bin/numad" + prog="numad" +@@ -29,32 +29,36 @@ + + [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +-lockfile=/var/lock/subsys/$prog +-base=${0##*/} +- + start() { + [ -x $exec ] || exit 5 + [ -f $config ] || exit 6 + echo -n $"Starting $prog: " + . $config +- daemon "$exec -i $INTERVAL" ++ start-stop-daemon --start --quiet --exec $exec -- -i $INTERVAL -D $DIRECTORY_MOUNT_POINT + retval=$? +- echo +- [ $retval -eq 0 ] && touch $lockfile ++ if [ $retval -eq 0 ] ; then ++ echo "OK" ++ else ++ echo "FAIL" ++ fi + return $retval + } + + stop() { + echo -n $"Stopping $prog: " +- killproc $prog ++ start-stop-daemon --stop --quiet --exec $exec + retval=$? +- echo +- [ $retval -eq 0 ] && rm -f $lockfile ++ if [ $retval -eq 0 ] ; then ++ echo "OK" ++ else ++ echo "FAIL" ++ fi + return $retval + } + + restart() { + stop ++ sleep 1 + start + } + 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 @@ +#!/bin/sh + +CPUSET_PATH="/tmp/numad-cpuset" + +/etc/init.d/numad.init status +STATUS=$? +/etc/init.d/numad.init stop +mkdir $CPUSET_PATH; mount -t cgroup -ocpuset cpuset $CPUSET_PATH +./test 2>&1& +TEST_PID=$! +sleep 2 +numad -d -S 0 -u 50 -i 5:5 -p $TEST_PID -D $CPUSET_PATH +wait +numad -i 0 +sleep 1 +umount $CPUSET_PATH ; rmdir $CPUSET_PATH +if [ "$STATUS" = "0" ]; then + /etc/init.d/numad.init start +fi + 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 @@ +Test output format: ptest style (PASS, FAIL, SKIP) +Description: Allocate memory from a node other than +the current CPU is running on. Wait for numad to modify +memory and CPU policy binding the process to run and allocate on +the same node. +Dependencies: libnuma + +Signed-off-by: Radu Patriu +Upstream-Status: Pending + +Index: numa-test/test.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ numa-test/test.c 2014-02-18 17:22:49.952290472 +0200 +@@ -0,0 +1,160 @@ ++#define _GNU_SOURCE ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define TIMEOUT (1000 * 60) /*60 seconds*/ ++#define LOOP_TIME (1000 * 5) /*5 seconds*/ ++#define MEM_POLICY_CHANGED 1 ++#define NODE_POLICY_CHANGED 2 ++#define TEST_DONE (MEM_POLICY_CHANGED | NODE_POLICY_CHANGED) ++ ++#define TEST_PASS 0 ++#define TEST_FAIL 1 ++#define TEST_SKIP 2 ++ ++#define MEM_SIZE 0.3 /* 30 % node memory */ ++ ++unsigned int numa_bitmask_weight(const struct bitmask *bmp); ++ ++void print_bitmask(struct bitmask *mask) ++{ ++ /*assume 32 max nodes*/ ++ printf("0x%08lx", *(mask->maskp)); ++} ++ ++int test() ++{ ++ int i, j, total_nodes, total_mem_nodes, total_cpus, prefered_node; ++ struct bitmask *allowed_mem_nodes, *allowed_nodes, *cpu_mask, *mem_bind, *bit_mask; ++ long long mem_size, page_size; ++ unsigned char *mem; ++ struct timeval start, end, res; ++ int local_node, local_cpu, other_node, test_complete; ++ ++ allowed_mem_nodes = numa_allocate_nodemask(); ++ allowed_nodes = numa_allocate_nodemask(); ++ mem_bind = numa_allocate_nodemask(); ++ cpu_mask = numa_allocate_cpumask(); ++ if (!(allowed_mem_nodes && allowed_nodes && mem_bind && cpu_mask)) { ++ printf("Error: numa_allocate failed\n"); ++ return TEST_FAIL; ++ } ++ ++ total_nodes = numa_max_node() + 1; ++ printf("total_nodes %d\n", total_nodes); ++ ++ total_mem_nodes = numa_num_configured_nodes(); ++ printf("total_mem_nodes %d\n", total_mem_nodes); ++ ++ total_cpus = numa_num_configured_cpus(); ++ printf("total_cpus %d\n", total_cpus); ++ ++ page_size = numa_pagesize(); ++ printf("page_size %llu\n", page_size); ++ ++ i = 0; ++ test_complete = 0; ++ gettimeofday(&start, NULL); ++ do { ++ printf("\n\n\nLoop %d\n", i); ++ ++ bit_mask = numa_get_mems_allowed(); ++ if (i && !numa_bitmask_equal(bit_mask, allowed_mem_nodes)) { ++ printf("\nInfo: memory policy modified\n\n"); ++ test_complete |= MEM_POLICY_CHANGED; ++ } ++ copy_bitmask_to_bitmask(bit_mask, allowed_mem_nodes); ++ printf("allowed_mem_nodes "); print_bitmask(allowed_mem_nodes); printf("\n"); ++ if ((0 == i) && (1 == numa_bitmask_weight(allowed_mem_nodes))) { ++ printf("Error: need at least two memory nodes\n"); ++ return TEST_SKIP; ++ } ++ ++ bit_mask = numa_get_run_node_mask(); ++ if (i && !numa_bitmask_equal(bit_mask, allowed_nodes)) { ++ printf("\nInfo: node/cpu policy modified\n\n"); ++ test_complete |= NODE_POLICY_CHANGED; ++ } ++ copy_bitmask_to_bitmask(bit_mask, allowed_nodes); ++ printf("allowed_nodes "); print_bitmask(allowed_nodes); printf("\n"); ++ ++ prefered_node = numa_preferred(); ++ printf("prefered_node %d\n", prefered_node); ++ ++ bit_mask = numa_get_membind(); ++ copy_bitmask_to_bitmask(bit_mask, mem_bind); ++ printf("mem_bind "); print_bitmask(mem_bind); printf("\n"); ++ ++ if (numa_sched_getaffinity(0, cpu_mask) < 0) { ++ printf("Error: numa_sched_getaffinity failed\n"); ++ return TEST_FAIL; ++ } ++ printf("sched_affinity "); print_bitmask(cpu_mask); printf("\n"); ++ ++ other_node = -1; ++ local_cpu = sched_getcpu(); ++ local_node = numa_node_of_cpu(local_cpu); ++ for (j = 0; j < total_mem_nodes; ++j) ++ if (numa_bitmask_isbitset(allowed_mem_nodes, j) && (j != local_node)) ++ other_node = j; ++ ++ printf("running on node %d, cpu %d\n", local_node, local_cpu); ++ printf("alloc memory from node %d\n", other_node); ++ ++ mem_size = numa_node_size64(other_node, NULL) * MEM_SIZE; ++ printf("test_mem_size %llu\n", mem_size); ++ ++ /* avoid mbind: Invalid argument */ ++ if (TEST_DONE == test_complete) ++ return TEST_PASS; ++ ++ mem = numa_alloc_onnode(mem_size, other_node); ++ if (!mem) { ++ printf("Error: numa_alloc_onnode failed for node %d\n", other_node); ++ return TEST_FAIL; ++ } ++ ++ gettimeofday(&end, NULL); ++ /* do some work */ ++ do { ++ struct timeval now; ++ memcpy(mem, mem + mem_size/2, mem_size/2); ++ gettimeofday(&now, NULL); ++ timersub(&now, &end, &res); ++ } while((res.tv_sec * 1000 + res.tv_usec / 1000) < LOOP_TIME); ++ ++ numa_free(mem, mem_size); ++ ++i; ++ gettimeofday(&end, NULL); ++ timersub(&end, &start, &res); ++ } while((res.tv_sec * 1000 + res.tv_usec / 1000) < TIMEOUT); ++ ++ return TEST_FAIL; ++} ++ ++int main() ++{ ++ if (numa_available() < 0) { ++ printf("Error: numa not available\n"); ++ printf("SKIP: numad\n"); ++ return 0; ++ } ++ ++ switch(test()) { ++ case TEST_PASS: ++ printf("PASS: numad\n"); ++ break; ++ case TEST_SKIP: ++ printf("FAIL: numad\n"); ++ break; ++ default: ++ printf("FAIL: numad\n"); ++ } ++ ++ return 0; ++} diff --git a/recipes-core/numad/numad_0.6.bb b/recipes-core/numad/numad_0.6.bb new file mode 100644 index 0000000..a6e8ad6 --- /dev/null +++ b/recipes-core/numad/numad_0.6.bb @@ -0,0 +1,51 @@ +SUMMARY = "NUMA load distributing daemon" +DESCRIPTION = 'A user-level daemon that monitors NUMA topology and processes resource \ +consumption to facilitate good NUMA resource access of applications/virtual machines \ +to improve performance and minimize cost of remote memory latencies.' +HOMEPAGE = "https://git.fedorahosted.org/git/numad.git" +SECTION = "console/utils" + +LICENSE = "LGPLv2.1" + +LIC_FILES_CHKSUM = "file://numad.c;beginline=1;endline=19;md5=fc770296e974bef07ddd7033725c8e29" + +SRC_URI = "git://git.fedorahosted.org/git/numad.git;protocol=https;branch=master \ + file://Makefile.patch \ + file://test.patch \ + file://run-ptest \ + file://numad.init.patch \ + file://numad.conf.patch" + +SRCREV = "b621838bf9c8203e87137eca28e19bcc381cde2a" + +S = "${WORKDIR}/git" + +#clear .LIBPATTERNS instead of using VPATH="${STAGING_LIBDIR}:${STAGING_DIR_HOST}/${base_libdir}" +EXTRA_OEMAKE = 'prefix=${D}/usr TEST_DESTDIR=${D}${PTEST_PATH} .LIBPATTERNS=""' + +do_install () { + oe_runmake install + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${S}/numad.init ${D}${sysconfdir}/init.d + install -m 0644 ${S}/numad.conf ${D}${sysconfdir} +} + +inherit update-rc.d ptest + +DEPENDS_${PN}-ptest += "numactl" +RDEPENDS_${PN}-ptest += "libnuma" + +INITSCRIPT_NAME = "numad.init" +#INITSCRIPT_PARAMS = "start 99 5 2 . stop 20 0 1 6 ." +INITSCRIPT_PARAMS = "stop 20 5 2 . stop 20 0 1 6 ." + +#wait for numa.h +do_compile_ptest_base[depends] += "numactl:do_populate_sysroot" + +do_install_ptest () { + oe_runmake test-install +} + +do_compile_ptest () { + oe_runmake test +} -- cgit v1.2.3-54-g00ecf