|
From: Cyril H. <su...@li...> - 2013-10-01 15:51:15
|
The branch, master, has been updated
via 971bcd7e51e4e6f94a58374f9b3cd22e53e7e53e (commit)
via 8ddc6cd37204819e67dbb2b7164475ebb21b02dd (commit)
via b5077cf12f122b97ee69f0f1438071ef1ddd66e3 (commit)
via aeafd8315e2d0d31207b54e6b246f1dae4836e18 (commit)
via 87156a05a2ffd50f5e467d6f986daae9da7b9cf7 (commit)
via 08f8781892b8a28efbba8b4104beacb623ce39dd (commit)
via 27f2cc5998cd63a26a3c3d679bd1dec40cf741e7 (commit)
from 8b458d6e9125dee8be4dd08b9ab7db79b3873c5f (commit)
- Log -----------------------------------------------------------------
commit 971bcd7e51e4e6f94a58374f9b3cd22e53e7e53e
Author: Stanislav Kholmanskikh <sta...@or...>
Date: Tue Oct 1 17:44:54 2013 +0400
cpuset/cpuset_load_balance_test: fixes
Fixed lack of '#include "config.h"', perform some cleanup
and set nr_cpus, nr_mems based on environment.
Signed-off-by: Stanislav Kholmanskikh <sta...@or...>
commit 8ddc6cd37204819e67dbb2b7164475ebb21b02dd
Author: Stanislav Kholmanskikh <sta...@or...>
Date: Tue Oct 1 17:44:53 2013 +0400
cpuset_memory_spread_test: number of nodes and sync
For unification number of nodes is set based on environment.
OS caches were not reliably dropped after execution of 'dd'
on DATAFILE. And since 'dd' was executed in root cpuset the
caches were spread among all available memory nodes. Because on
consecutive reading of DATAFILE in cpuset_mem_hog didn't increase
memory consumption. This situation caused random failures of
the testcase.
In accordance to Documentation/sysctl/vm.txt to reliably drop caches
we should invoke 'sync' before 'echo N > /proc/sys/vm/drop_caches'.
Signed-off-by: Stanislav Kholmanskikh <sta...@or...>
commit b5077cf12f122b97ee69f0f1438071ef1ddd66e3
Author: Stanislav Kholmanskikh <sta...@or...>
Date: Tue Oct 1 17:44:52 2013 +0400
cpuset/cpuset_memory_test: fixes
cpuset_memory_test.c:
* lack of "config.h"
* incorrect use of HAVE_LINUX_MEMPOLICY macro
* modification to make use of sigwaitinfo
* some cleanup
cpuset_memory_testset.sh:
* number of cpu and memory nodes are set based on environment
* we send second SIGUSR1 signal to make the child free its resources
* setting nr_hugepages to a value of 2 is not sufficient. Because there
is no guarantee that these hugepages will be allocated on the specified
node
* cleanup and several typos are fixed
Signed-off-by: Stanislav Kholmanskikh <sta...@or...>
commit aeafd8315e2d0d31207b54e6b246f1dae4836e18
Author: Stanislav Kholmanskikh <sta...@or...>
Date: Tue Oct 1 17:44:51 2013 +0400
cpuset/cpuset_lib: cpuinfo.c compiled incorrectly
Because of lack of '#include "config.h"' cpuinfo.c file
was compiled incorrectly (i.e. final lib libcpu_set.a didn't contain
the functions/variables from cpuinfo.c)
Signed-off-by: Stanislav Kholmanskikh <sta...@or...>
commit 87156a05a2ffd50f5e467d6f986daae9da7b9cf7
Author: Stanislav Kholmanskikh <sta...@or...>
Date: Tue Oct 1 17:44:50 2013 +0400
cpuset/cpuset_syscall_test: fixes
cpuset_syscall_test.c:
I suppose that now there is no need in many '#if' and explicit
definition of functions get_mempolicy, set_mempolicy, mbind.
Including numa.h and numaif.h (as we do in the other testcases)
should be sufficient.
cpuset_syscall_testset.sh:
Since linux kernel 3.8.0 (commit 5606e3877ad8baea42f3a71ebde0a03622bbb551
"mm: numa: Migrate on reference policy") default task memory policy and
its output in /proc/<pid>/numa_maps changed.
For example in 3.7.10 for stack vma /proc/<pid>/numa_maps show:
7fff81e01000 default stack anon=3 dirty=3 N3=3
but in 3.8.0:
7fff08950000 prefer:3 stack anon=5 dirty=5 N2=4 N3=1
So modified a check in test 10 and removed unnessesary checks for "default"
memory policy from tests 14, 15, 16.
Signed-off-by: Stanislav Kholmanskikh <sta...@or...>
commit 08f8781892b8a28efbba8b4104beacb623ce39dd
Author: Stanislav Kholmanskikh <sta...@or...>
Date: Tue Oct 1 17:44:49 2013 +0400
cpuset/cpuset_base_ops_test: fix expected error
At least since kernel 3.0.0 writing '0-' to
$CPUSET/N/{cpus, mems} files doesn't raise an error.
Reading content of these files after writing gives '0'.
Signed-off-by: Stanislav Kholmanskikh <sta...@or...>
commit 27f2cc5998cd63a26a3c3d679bd1dec40cf741e7
Author: Stanislav Kholmanskikh <sta...@or...>
Date: Tue Oct 1 17:44:48 2013 +0400
controllers/cpuset: removed bash sweetnesses
Signed-off-by: Stanislav Kholmanskikh <sta...@or...>
-----------------------------------------------------------------------
Summary of changes:
.../cpuset_base_ops_testset.sh | 28 +++-
.../cpuset_exclusive_test/cpuset_exclusive_test.sh | 6 +-
.../kernel/controllers/cpuset/cpuset_funcs.sh | 2 +-
.../cpuset_hierarchy_test/cpuset_hierarchy_test.sh | 6 +-
.../cpuset_hotplug_test/cpuset_hotplug_test.sh | 6 +-
.../cpuset_inherit_test/cpuset_inherit_testset.sh | 6 +-
.../kernel/controllers/cpuset/cpuset_lib/cpuinfo.c | 1 +
.../cpuset_load_balance_test/cpuset_cpu_hog.c | 16 +-
.../cpuset_load_balance_test.sh | 10 +-
.../cpuset_sched_domains_check.c | 1 +
.../cpuset_sched_domains_test.sh | 11 +-
.../cpuset_memory_pressure_testset.sh | 6 +-
.../cpuset_memory_spread_testset.sh | 74 ++++++----
.../cpuset/cpuset_memory_test/cpuset_memory_test.c | 159 ++++++++++----------
.../cpuset_memory_test/cpuset_memory_testset.sh | 24 ++--
.../cpuset/cpuset_syscall_test/Makefile | 1 +
.../cpuset_syscall_test/cpuset_syscall_test.c | 61 ++------
.../cpuset_syscall_test/cpuset_syscall_testset.sh | 22 ++--
.../kernel/controllers/cpuset/run_cpuset_test.sh | 6 +-
19 files changed, 226 insertions(+), 220 deletions(-)
diff --git a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh
index a40c46b..126eec5 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh
@@ -24,12 +24,12 @@
cd $LTPROOT/testcases/bin
-. ./cpuset_funcs.sh
-
export TCID="cpuset01"
export TST_TOTAL=97
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
nr_cpus=$NR_CPUS
nr_mems=$N_NODES
@@ -97,7 +97,7 @@ base_op_test()
exit_status=1
fi
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
}
test_cpus()
@@ -117,7 +117,6 @@ test_cpus()
0-$((nr_cpus-1)) 0-$((nr_cpus-1))
-1 WRITE_ERROR
0-$nr_cpus WRITE_ERROR
- 0- WRITE_ERROR
0--$((nr_cpus-1)) WRITE_ERROR
0,1-$((nr_cpus-2)),$((nr_cpus-1)) 0-$((nr_cpus-1))
0,1-$((nr_cpus-2)), 0-$((nr_cpus-2))
@@ -125,6 +124,13 @@ test_cpus()
AAA WRITE_ERROR
EOF
# while read cpus result
+
+ tst_kvercmp 3 0 0
+ if [ $? -eq 0 ]; then
+ base_op_test "$CPUSET/1/cpus" "0-" "WRITE_ERROR"
+ else
+ base_op_test "$CPUSET/1/cpus" "0-" "0"
+ fi
}
test_mems()
@@ -144,7 +150,6 @@ test_mems()
0-$((nr_mems-1)) 0-$((nr_mems-1))
-1 WRITE_ERROR
0-$nr_mems WRITE_ERROR
- 0- WRITE_ERROR
0--$((nr_mems-1)) WRITE_ERROR
0,1-$((nr_mems-2)),$((nr_mems-1)) 0-$((nr_mems-1))
0,1-$((nr_mems-2)), 0-$((nr_mems-2))
@@ -152,6 +157,13 @@ test_mems()
AAA WRITE_ERROR
EOF
# while read mems result
+
+ tst_kvercmp 3 0 0
+ if [ $? -eq 0 ]; then
+ base_op_test "$CPUSET/1/mems" "0-" "WRITE_ERROR"
+ else
+ base_op_test "$CPUSET/1/mems" "0-" "0"
+ fi
}
test_flags()
@@ -190,7 +202,7 @@ attach_task_test()
if [ $? -ne 0 ]; then
exit_status=1
cleanup
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
return
fi
@@ -199,7 +211,7 @@ attach_task_test()
if [ $? -ne 0 ]; then
exit_status=1
cleanup
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
return
fi
@@ -227,7 +239,7 @@ attach_task_test()
if [ $? -ne 0 ]; then
exit_status=1
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
}
diff --git a/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh b/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh
index 363317c..0ad31e7 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh
@@ -24,12 +24,12 @@
cd $LTPROOT/testcases/bin
-. ./cpuset_funcs.sh
-
export TCID="cpuset03"
export TST_TOTAL=18
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
exit_status=0
# Case 1-9 test cpus
@@ -238,7 +238,7 @@ do
exit_status=1
fi
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
done
exit $exit_status
diff --git a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
index b996461..a83845c 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
@@ -31,7 +31,7 @@ else
N_NODES="`cat /sys/devices/system/node/has_normal_memory`"
fi
N_NODES=${N_NODES#*-*}
-: $((N_NODES++))
+N_NODES=$(($N_NODES + 1))
CPUSET="/dev/cpuset"
CPUSET_TMP="/tmp/cpuset_tmp"
diff --git a/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh b/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh
index 1b633c1..5804aa4 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh
@@ -24,12 +24,12 @@
cd $LTPROOT/testcases/bin
-. ./cpuset_funcs.sh
-
export TCID="cpuset04"
export TST_TOTAL=32
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
nr_cpus=$NR_CPUS
nr_mems=$N_NODES
@@ -463,7 +463,7 @@ do
exit_status=1
fi
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
done
exit $exit_status
diff --git a/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh b/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh
index 205152c..2bfe0f5 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh
@@ -24,12 +24,12 @@
cd $LTPROOT/testcases/bin
-. ./cpuset_funcs.sh
-
export TCID="cpuset08"
export TST_TOTAL=13
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
exit_status=0
nr_cpus=$NR_CPUS
@@ -218,7 +218,7 @@ base_test()
cpu_hotplug_cleanup
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
}
# Test Case 1-2
diff --git a/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh
index 27d9a61..780b7eb 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh
@@ -24,12 +24,12 @@
cd $LTPROOT/testcases/bin
-. ./cpuset_funcs.sh
-
export TCID="cpuset02"
export TST_TOTAL=27
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
nr_cpus=$NR_CPUS
nr_mems=$N_NODES
@@ -97,7 +97,7 @@ inherit_test()
exit_status=1
fi
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
}
test_cpus()
diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c b/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c
index 65c5072..3e7961f 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c
@@ -1,3 +1,4 @@
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c
index 4b4e965..5dd2ced 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c
@@ -20,6 +20,7 @@
/* */
/******************************************************************************/
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -33,24 +34,23 @@
#include <sys/stat.h>
#include <fcntl.h>
+char *TCID = "cpuset_cpu_hog";
+int TST_TOTAL = 1;
+
+#if HAVE_LINUX_MEMPOLICY_H
+
#include "../cpuset_lib/common.h"
#include "../cpuset_lib/bitmask.h"
#include "../cpuset_lib/cpuset.h"
-#if HAVE_LINUX_MEMPOLICY_H
-
#define MAX_NPROCS 1000
#define USAGE ("Usage: %s [-p nprocs] [-h]\n" \
"\t-p nprocs\n" \
"\t\tThe num of the procs. [Default = 2 * nr_cpus]\n" \
"\t-h\tHelp.\n")
-char *TCID = "cpuset_cpu_hog";
-int TST_TOTAL = 1;
-
-unsigned long count;
-int nprocs;
-volatile int end;
+static int nprocs;
+static volatile int end;
/*
* report executing result to the parent by fifo
diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh
index 854be72..55f533a 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh
@@ -24,17 +24,17 @@
cd $LTPROOT/testcases/bin
-. ./cpuset_funcs.sh
-
export TCID="cpuset07"
export TST_TOTAL=13
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
exit_status=0
# must >= 3 for: 1-$((nr_mems-2))
-nr_cpus=4
-nr_mems=3
+nr_cpus=$NR_CPUS
+nr_mems=$N_NODES
cpus_all="$(seq -s, 0 $((nr_cpus-1)))"
mems_all="$(seq -s, 0 $((nr_mems-1)))"
@@ -307,7 +307,7 @@ base_test()
cpu_hotplug_cleanup
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
}
test_general_load_balance1()
diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_check.c b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_check.c
index 9fe4f01..15259e7 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_check.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_check.c
@@ -20,6 +20,7 @@
/* */
/******************************************************************************/
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh
index bfead80..3ca70df 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh
@@ -24,17 +24,17 @@
cd $LTPROOT/testcases/bin
-. ./cpuset_funcs.sh
-
export TCID="cpuset06"
export TST_TOTAL=19
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
exit_status=0
# must >= 3 for: 1-$((nr_mems-2))
-nr_cpus=4
-nr_mems=3
+nr_cpus=$NR_CPUS
+nr_mems=$N_NODES
cpus_all="$(seq -s, 0 $((nr_cpus-1)))"
mems_all="$(seq -s, 0 $((nr_mems-1)))"
@@ -222,7 +222,7 @@ base_test()
cpu_hotplug_cleanup
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
}
# Casee 1-6
@@ -236,7 +236,6 @@ test_root_load_balance()
while read isbalance level hotplug
do
base_test $isbalance $hotplug
- : $((file_case_num++))
done <<- EOF
0 none
1 none
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh
index 185a028..f342e6c 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh
@@ -24,12 +24,12 @@
cd $LTPROOT/testcases/bin
-. ./cpuset_funcs.sh
-
export TCID="cpuset10"
export TST_TOTAL=6
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
exit_status=0
# usable physical memory
@@ -254,7 +254,7 @@ do
fi
fi
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
done
exit $exit_status
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh
index 0a954c0..ffce419 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh
@@ -24,16 +24,16 @@
cd $LTPROOT/testcases/bin
-. ./cpuset_funcs.sh
-
export TCID="cpuset11"
export TST_TOTAL=6
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
exit_status=0
# must >= 3 for: 1-$((nr_mems-2))
-nr_cpus=4
-nr_mems=3
+nr_cpus=$NR_CPUS
+nr_mems=$N_NODES
# In general, the cache hog will use more than 10000 kb slab space on the nodes
# on which it is running. The other nodes' slab space has littler change.(less
@@ -48,15 +48,45 @@ nodedir="/sys/devices/system/node"
FIFO="./myfifo"
-declare -a memsinfo
+# memsinfo is an array implementation of the form of a multi-line string
+# _0: value0
+# _1: value1
+# _2: value2
+#
+memsinfo=""
-init_mems_info_array()
+# set value to memsinfo ($1 - index, $2 - value)
+set_memsinfo_val()
+{
+ local nl='
+'
+ # clearing existent value (if present)
+ memsinfo=`echo "$memsinfo" | sed -r "/^\_$1\:\s/d"`
+
+ if [ -z "$memsinfo" ]; then
+ memsinfo="_$1: $2"
+ else
+ memsinfo="$memsinfo${nl}_$1: $2"
+ fi
+}
+
+# get value from memsinfo ($1 - index)
+get_memsinfo_val()
+{
+ local value=
+ value=`echo "$memsinfo" | grep -e "^\_$1\:\s"`
+ value=`echo "$value" | sed -r "s/^.*\:\s(.*)$/\1/"`
+ echo "$value"
+}
+
+
+init_memsinfo_array()
{
local i=
for i in `seq 0 $((nr_mems-1))`
do
- memsinfo[$i]=0
+ set_memsinfo_val $i 0
done
}
@@ -67,8 +97,8 @@ get_meminfo()
local nodepath="$nodedir/node$nodeid"
local nodememinfo="$nodepath/meminfo"
local item="$2"
- local infoarray=(`cat $nodememinfo | grep $item`)
- memsinfo[$nodeid]=${infoarray[3]}
+ local info=`cat $nodememinfo | grep $item | awk '{print $4}'`
+ set_memsinfo_val $nodeid $info
}
# freemem_check
@@ -88,7 +118,7 @@ freemem_check()
for i in `seq 0 $((nr_mems-1))`
do
# I think we need 100MB free memory to run test
- if [ ${memsinfo[$i]} -lt 100000 ]; then
+ if [ $(get_memsinfo_val $i) -lt 100000 ]; then
return 1
fi
done
@@ -109,9 +139,9 @@ get_memsinfo()
account_meminfo()
{
local nodeId="$1"
- local tmp="${memsinfo[$nodeId]}"
+ local tmp="$(get_memsinfo_val $nodeId)"
get_meminfo $@ "FilePages"
- memsinfo[$nodeId]=$((${memsinfo[$nodeId]}-$tmp))
+ set_memsinfo_val $nodeId $(($(get_memsinfo_val $nodeId)-$tmp))
}
# account_memsinfo
@@ -136,7 +166,7 @@ result_check()
for i in $nodelist
do
- if [ ${memsinfo[$i]} -le $upperlimit ]; then
+ if [ $(get_memsinfo_val $i) -le $upperlimit ]; then
return 1
fi
done
@@ -153,7 +183,7 @@ result_check()
for i in $othernodelist
do
- if [ ${memsinfo[$i]} -gt $lowerlimit ]; then
+ if [ $(get_memsinfo_val $i) -gt $lowerlimit ]; then
return 1
fi
done
@@ -193,6 +223,7 @@ general_memory_spread_test()
fi
# we'd better drop the caches before we test page cache.
+ sync
/bin/echo 3 > /proc/sys/vm/drop_caches 2> $CPUSET_TMP/stderr
if [ $? -ne 0 ]; then
cpuset_log_error $CPUSET_TMP/stderr
@@ -200,9 +231,6 @@ general_memory_spread_test()
return 1
fi
- # wait for droping the cache
- sleep 10
-
get_memsinfo
/bin/kill -s SIGUSR1 $test_pid
read exit_num < $FIFO
@@ -214,7 +242,7 @@ general_memory_spread_test()
account_memsinfo
result_check $expect_nodes
if [ $? -ne 0 ]; then
- tst_resm TFAIL "hog the memory on the unexpected node(FilePages_For_Nodes(KB): ${memsinfo[*]}, Expect Nodes: $expect_nodes)."
+ tst_resm TFAIL "hog the memory on the unexpected node(FilePages_For_Nodes(KB): ${memsinfo}, Expect Nodes: $expect_nodes)."
return 1
fi
}
@@ -246,7 +274,7 @@ base_test()
tst_resm TPASS "Cpuset memory spread page test succeeded."
fi
fi
- ((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
}
# test general spread page cache in a cpuset
@@ -301,7 +329,7 @@ test_spread_page2()
fi
}
-init_mems_info_array
+init_memsinfo_array
freemem_check
if [ $? -ne 0 ]; then
tst_brkm TFAIL ignored "Some node doesn't has enough free memory(100MB) to do test(MemFree_For_Nodes(KB): ${memsinfo[*]})."
@@ -314,12 +342,6 @@ if [ $? -ne 0 ]; then
exit 1
fi
-# drop page caches
-/bin/echo 1 > /proc/sys/vm/drop_caches
-
-# wait for droping caches
-sleep 10
-
mkfifo $FIFO
if [ $? -ne 0 ]; then
rm -f DATAFILE
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c
index ddf5935..e4206cf 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c
@@ -20,6 +20,7 @@
/* */
/******************************************************************************/
+#include "config.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@@ -36,27 +37,26 @@
#include <syscall.h>
#include <pthread.h>
-#include "../cpuset_lib/cpuset.h"
-
char *TCID = "cpuset_memory_test";
int TST_TOTAL = 1;
-#if HAVE_LINUX_MEMPOLICY_TEST
+#if HAVE_LINUX_MEMPOLICY_H
+
+#include "../cpuset_lib/cpuset.h"
-int fd;
-int flag_exit;
+static int fd;
-int opt_mmap_anon;
-int opt_mmap_file;
-int opt_mmap_lock1;
-int opt_mmap_lock2;
-int opt_shm;
-int opt_hugepage;
-int opt_check; /* check node when munmap memory (only for mmap_anon()) */
-int opt_thread;
+static int opt_mmap_anon;
+static int opt_mmap_file;
+static int opt_mmap_lock1;
+static int opt_mmap_lock2;
+static int opt_shm;
+static int opt_hugepage;
+static int opt_check; /* check node when munmap memory (only for mmap_anon()) */
+static int opt_thread;
-int key_id; /* used with opt_shm */
-unsigned long memsize;
+static int key_id; /* used with opt_shm */
+static unsigned long memsize;
#define FILE_HUGEPAGE "/hugetlb/hugepagefile"
@@ -136,7 +136,7 @@ void process_options(int argc, char *argv[])
}
if (!memsize)
- memsize = getpagesize();
+ memsize = sysconf(_SC_PAGESIZE);
}
/*
@@ -145,7 +145,7 @@ void process_options(int argc, char *argv[])
void touch_memory_and_echo_node(char *p, int size)
{
int i;
- int pagesize = getpagesize();
+ int pagesize = sysconf(_SC_PAGESIZE);
for (i = 0; i < size; i += pagesize)
p[i] = 0xef;
@@ -281,90 +281,54 @@ void shm(int flag_allocated)
}
}
-/*
- * sigint_handler: handle SIGINT by set the exit flag.
- */
-void sigint_handler(int __attribute__ ((unused)) signo)
-{
- flag_exit = 1;
-}
-
-/*
- * sigusr_handler: handler SIGUSR
- *
- * When we receive SIGUSR, we allocate some memory according
- * to the user input when the process started.
- *
- * When we recive SIGUSR again, we will free all the allocated
- * memory.
- */
-void sigusr_handler(int __attribute__ ((unused)) signo)
-{
- static int flag_allocated = 0;
-
- if (opt_mmap_anon)
- mmap_anon(flag_allocated);
-
- if (opt_mmap_file)
- mmap_file(flag_allocated);
-
- if (opt_mmap_lock1)
- mmap_lock1(flag_allocated);
-
- if (opt_mmap_lock2)
- mmap_lock2(flag_allocated);
-
- if (opt_shm)
- shm(flag_allocated);
-
- flag_allocated = !flag_allocated;
-}
-
-void sigusr2(int __attribute__ ((unused)) signo)
-{
- static int flag_allocated = 0;
- mmap_anon(flag_allocated);
- flag_allocated = !flag_allocated;
-}
-
void *thread2_routine(void __attribute__ ((unused)) * arg)
{
sigset_t set;
- struct sigaction sigusr2_action;
+ sigset_t waitset;
+ int flag_allocated;
sigemptyset(&set);
sigaddset(&set, SIGUSR1);
sigaddset(&set, SIGINT);
pthread_sigmask(SIG_BLOCK, &set, NULL);
- memset(&sigusr2_action, 0, sizeof(sigusr2_action));
- sigusr2_action.sa_handler = &sigusr2;
- sigaction(SIGUSR2, &sigusr2_action, NULL);
+ sigemptyset(&waitset);
+ sigaddset(&waitset, SIGUSR2);
+ pthread_sigmask(SIG_BLOCK, &waitset, NULL);
+
+ flag_allocated = 0;
+
+ for (;;) {
+ if (sigwaitinfo(&waitset, NULL) < 0)
+ err(1, "sigwaitinfo() in thread2 failed");
- while (!flag_exit)
- sleep(1);
+ mmap_anon(flag_allocated);
+ flag_allocated = !flag_allocated;
+ }
return NULL;
}
+/*
+ * When we receive SIGUSR1, we allocate some memory according
+ * to the user intput when the process started.
+ * When we receive SIGUSR1 again, we will free all the allocated
+ * memory.
+ * Similiar for --thread option but SIGUSR2 signal is used
+ * to control thread2 behaviour.
+ */
int main(int argc, char *argv[])
{
- struct sigaction sigint_action;
- struct sigaction sigusr_action;
+ sigset_t waitset;
+ int signo;
+ int flag_allocated;
+
pthread_t thread2;
fd = open("/dev/zero", O_RDWR);
if (fd < 0)
err(1, "open /dev/zero failed");
- memset(&sigint_action, 0, sizeof(sigint_action));
- sigint_action.sa_handler = &sigint_handler;
- sigaction(SIGINT, &sigint_action, NULL);
-
- memset(&sigusr_action, 0, sizeof(sigusr_action));
- sigusr_action.sa_handler = &sigusr_handler;
- sigaction(SIGUSR1, &sigusr_action, NULL);
-
process_options(argc, argv);
if (opt_thread) {
@@ -377,8 +341,41 @@ int main(int argc, char *argv[])
pthread_sigmask(SIG_BLOCK, &set, NULL);
}
- while (!flag_exit)
- sleep(1);
+
+ sigemptyset(&waitset);
+ sigaddset(&waitset, SIGINT);
+ sigaddset(&waitset, SIGUSR1);
+
+ pthread_sigmask(SIG_BLOCK, &waitset, NULL);
+
+ flag_allocated = 0;
+
+ for (;;) {
+ signo = sigwaitinfo(&waitset, NULL);
+ if (signo < 0)
+ err(1, "sigwaitinfo() failed");
+
+ if (signo == SIGUSR1) {
+ if (opt_mmap_anon)
+ mmap_anon(flag_allocated);
+
+ if (opt_mmap_file)
+ mmap_file(flag_allocated);
+
+ if (opt_mmap_lock1)
+ mmap_lock1(flag_allocated);
+
+ if (opt_mmap_lock2)
+ mmap_lock2(flag_allocated);
+
+ if (opt_shm)
+ shm(flag_allocated);
+
+ flag_allocated = !flag_allocated;
+ } else {
+ break;
+ }
+ }
if (opt_thread) {
void *retv;
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh
index b117932..2a9f7e3 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh
@@ -22,19 +22,19 @@
# #
################################################################################
-. ./cpuset_funcs.sh
-
cd $LTPROOT/testcases/bin
export TCID="cpuset09"
export TST_TOTAL=18
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
exit_status=0
# must >= 3 for: 1-$((nr_mems-2))
-nr_cpus=4
-nr_mems=3
+nr_cpus=$NR_CPUS
+nr_mems=$N_NODES
cpus_all="$(seq -s, 0 $((nr_cpus-1)))"
mems_all="$(seq -s, 0 $((nr_mems-1)))"
@@ -55,6 +55,8 @@ simple_getresult()
echo $1 > "$2/tasks"
/bin/kill -s SIGUSR1 $1
sleep 1
+ /bin/kill -s SIGUSR1 $1
+ sleep 1
/bin/kill -s SIGINT $1
wait $1
read node < "$MEMORY_RESULT"
@@ -150,7 +152,7 @@ test5()
# 1 - support hugetlbfs
check_hugetlbfs()
{
- local fssupport="grep -w hugetlbfs /proc/filesystems 2>/dev/null | cut -f2"
+ local fssupport=$(grep -w hugetlbfs /proc/filesystems 2>/dev/null | cut -f2)
if [ "$fssupport" = "hugetlbfs" ]; then
return 1
@@ -178,7 +180,7 @@ test6()
mount -t hugetlbfs none /hugetlb
save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
- echo 2 > /proc/sys/vm/nr_hugepages
+ echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
./cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" &
simple_getresult $! "$CPUSET/0"
@@ -187,7 +189,7 @@ test6()
rmdir /hugetlb
echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
- if [ $! -ne 0 ]; then
+ if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then
tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)."
return 1
fi
@@ -217,7 +219,7 @@ test7()
mount -t hugetlbfs none /hugetlb
save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
- echo 2 > /proc/sys/vm/nr_hugepages
+ echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
./cpuset_memory_test --shm --hugepage -s $HUGEPAGESIZE --key=7 >"$MEMORY_RESULT" &
simple_getresult $! "$CPUSET/0"
@@ -226,7 +228,7 @@ test7()
rmdir /hugetlb
echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
- if [ $! -ne 0 ]; then
+ if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then
tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)."
return 1
fi
@@ -821,11 +823,11 @@ do
if [ $? -ne 0 ]; then
exit_status=1
else
- tst_resm TPASS "Cpuset memory alloaction test succeeded."
+ tst_resm TPASS "Cpuset memory allocation test succeeded."
fi
fi
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
done
exit $exit_status
diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
index 6565631..54393e7 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
@@ -26,6 +26,7 @@ include $(top_srcdir)/include/mk/testcases.mk
include $(abs_srcdir)/../Makefile.inc
LDLIBS += $(NUMA_LIBS)
+CPPFLAGS += $(NUMA_CPPFLAGS)
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
index 5c30763..dd35cd0 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
@@ -22,6 +22,7 @@
#define _GNU_SOURCE
+#include "config.h"
#include <sched.h>
#include <unistd.h>
#include <stdlib.h>
@@ -38,49 +39,29 @@
#include <sys/shm.h>
#include <syscall.h>
#include <inttypes.h>
-#include "config.h"
-#include "linux_syscall_numbers.h"
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
+#if HAVE_NUMAIF_H
+#include <numaif.h>
+#endif
+
#include "test.h"
#include "usctest.h"
char *TCID = "cpuset_syscall_test";
+int TST_TOTAL = 1;
-#if HAVE_LINUX_MEMPOLICY_H
-#include <linux/mempolicy.h>
+#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
+ && HAVE_MPOL_CONSTANTS
#include "../cpuset_lib/cpuset.h"
#include "../cpuset_lib/bitmask.h"
-int TST_TOTAL = 1;
-
-unsigned long mask;
-int test = -1;
-int flag_exit;
-int ret;
-
-#if HAVE_DECL_MPOL_F_MEMS_ALLOWED
-static int get_mempolicy(int *policy, unsigned long *nmask,
- unsigned long maxnode, void *addr, int flags)
-{
- return ltp_syscall(__NR_get_mempolicy, policy, nmask, maxnode, addr,
- flags);
-}
-#endif
-
-#if HAVE_DECL_MPOL_BIND
-static int mbind(void *start, unsigned long len, int policy,
- unsigned long *nodemask, unsigned long maxnode, unsigned flags)
-{
- return ltp_syscall(__NR_mbind, start, len, policy, nodemask, maxnode,
- flags);
-}
-
-static int set_mempolicy(int policy, unsigned long *nodemask,
- unsigned long maxnode)
-{
- return ltp_syscall(__NR_set_mempolicy, policy, nodemask, maxnode);
-}
-#endif
+static unsigned long mask;
+static int test = -1;
+static int flag_exit;
+static int ret;
#define OPT_setaffinity (SCHAR_MAX + 1)
#define OPT_getaffinity (SCHAR_MAX + 2)
@@ -178,20 +159,12 @@ void test_mbind(void)
return;
}
printf("%p\n", addr);
-#if HAVE_DECL_MPOL_BIND
ret = mbind(addr, len, MPOL_BIND, &mask, 8 * sizeof(mask), 0);
-#else
- ret = 1;
-#endif
}
void test_set_mempolicy(void)
{
-#if HAVE_DECL_MPOL_BIND
ret = set_mempolicy(MPOL_BIND, &mask, 8 * sizeof(mask));
-#else
- ret = -1;
-#endif
}
void test_get_mempolicy(void)
@@ -213,12 +186,8 @@ void test_get_mempolicy(void)
ret = 1;
return;
}
-#if HAVE_DECL_MPOL_F_MEMS_ALLOWED
ret = get_mempolicy(NULL, bitmask_mask(nmask), bitmask_nbits(nmask), 0,
MPOL_F_MEMS_ALLOWED);
-#else
- ret = -1;
-#endif
bitmask_displaylist(str, 256, nmask);
puts(str);
diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh
index 02a41a3..af92373 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh
@@ -24,12 +24,12 @@
cd $LTPROOT/testcases/bin
-. ./cpuset_funcs.sh
-
export TCID="cpuset05"
export TST_TOTAL=16
export TST_COUNT=1
+. ./cpuset_funcs.sh
+
exit_status=0
TEST_CPUSET="$CPUSET/0"
@@ -230,15 +230,20 @@ test10()
allowed_list=$(cat $TEST_PROCNUMA | grep "$memory_addr" | \
awk '{print $2}')
allowed_list="$(echo $allowed_list | sed -e s/bind://)"
- test "$allowed_list" = "default"
+
+ task_policy=$(cat $TEST_PROCNUMA | grep -e "\s\+stack\s\+anon" | \
+ awk '{print $2}')
+
+ test "$allowed_list" = "$task_policy"
if [ $? -ne 0 ]; then
- tst_resm TFAIL "Result(/proc/<pid>/status) = \"$allowed_list\", expect = \"default\")"
+ tst_resm TFAIL "Result(/proc/<pid>/status) = \"$allowed_list\",\
+ expect = \"$task_policy\")"
return 1
fi
return 0
}
-# this function is used by case 11-16
+# this function is used by case 11-13
# check_result <expect>
check_result()
{
@@ -279,8 +284,7 @@ test13()
test14()
{
do_syscall_test 0 0 --set_mempolicy=6 1 || return 1
- check_result "default"
- return $?
+ return 0
}
test15()
@@ -297,7 +301,6 @@ test15()
tst_resm TFAIL "Result(/proc/<pid>/status) = \"$allowed_list\", expect = \"0\")"
return 1
fi
- check_result "default" || return 1
return 0
}
@@ -315,7 +318,6 @@ test16()
tst_resm TFAIL "Result(/proc/<pid>/status) = \"$allowed_list\", expect = \"0-1\")"
return 1
fi
- check_result "default" || return 1
return 0
}
@@ -338,7 +340,7 @@ do
fi
fi
fi
- : $((TST_COUNT++))
+ TST_COUNT=$(($TST_COUNT + 1))
done
exit $exit_status
diff --git a/testcases/kernel/controllers/cpuset/run_cpuset_test.sh b/testcases/kernel/controllers/cpuset/run_cpuset_test.sh
index ee269f9..abdc885 100755
--- a/testcases/kernel/controllers/cpuset/run_cpuset_test.sh
+++ b/testcases/kernel/controllers/cpuset/run_cpuset_test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# usage ./run_cpuset_test.sh test_num
################################################################################
@@ -41,12 +41,12 @@
# #
################################################################################
-source cpuset_funcs.sh;
-
export TCID="cpuset_test";
export TST_TOTAL=1;
export TST_COUNT=1;
+. cpuset_funcs.sh;
+
TEST_NUM=$1;
SCRIPT_PID=$$;
RC=0;
hooks/post-receive
--
ltp
|