All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] cpuset controller fixes
@ 2013-09-26 10:30 Stanislav Kholmanskikh
  2013-09-26 10:30 ` [LTP] [PATCH 1/7] controllers/cpuset: removed bash sweetnesses Stanislav Kholmanskikh
                   ` (7 more replies)
  0 siblings, 8 replies; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-26 10:30 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

Hi!

I have very limited access to real hardware with 4 NUMA nodes. So most
of these fixes were checked with numa=fake=4 kernel cmdline.

It would be great if somebody verified it on real hardware.

And:
1. What do you think about idea of assigning to each cpuset controller test
a separate testcase name in runtest/controllers? Instead of using a single
run_cpuset_test.sh. 
This will greatly simplify output results analysis.

For example rename current cpuset01 testcase to cpuset12 and 
assign names cpuset01 cpuset11 cpuset_*.sh tests.

2. How do you think about adding a separate tst_kvercmp2 binary
(using tst_kvercmp2() function). 
It would help in cpuset_base_ops_testset.sh because several distribution
kernels have these fixes. Because on we also need to make testing based on
distribution kernel version.

Like this:
tst_kvercmp2 X Y Z "RHEL5:234 SLES10:0.91"

Thank you.


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [PATCH 1/7] controllers/cpuset: removed bash sweetnesses
  2013-09-26 10:30 [LTP] cpuset controller fixes Stanislav Kholmanskikh
@ 2013-09-26 10:30 ` Stanislav Kholmanskikh
  2013-09-26 10:30 ` [LTP] [PATCH 2/7] cpuset/cpuset_base_ops_test: fix expected error Stanislav Kholmanskikh
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-26 10:30 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../cpuset_base_ops_testset.sh                     |   12 ++--
 .../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 +-
 .../cpuset_load_balance_test.sh                    |    6 +-
 .../cpuset_sched_domains_test.sh                   |    7 +-
 .../cpuset_memory_pressure_testset.sh              |    6 +-
 .../cpuset_memory_spread_testset.sh                |   60 +++++++++++++++-----
 .../cpuset_memory_test/cpuset_memory_testset.sh    |    6 +-
 .../cpuset_syscall_test/cpuset_syscall_testset.sh  |    6 +-
 .../kernel/controllers/cpuset/run_cpuset_test.sh   |    6 +-
 13 files changed, 82 insertions(+), 53 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..8b21210 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()
@@ -190,7 +190,7 @@ attach_task_test()
 	if [ $? -ne 0 ]; then
 		exit_status=1
 		cleanup
-		: $((TST_COUNT++))
+		TST_COUNT=$(($TST_COUNT + 1))
 		return
 	fi
 
@@ -199,7 +199,7 @@ attach_task_test()
 	if [ $? -ne 0 ]; then
 		exit_status=1
 		cleanup
-		: $((TST_COUNT++))
+		TST_COUNT=$(($TST_COUNT + 1))
 		return
 	fi
 
@@ -227,7 +227,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_load_balance_test/cpuset_load_balance_test.sh b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh
index 854be72..003e9cf 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,12 +24,12 @@
 
 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))
@@ -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_test.sh b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh
index bfead80..4547367 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,12 +24,12 @@
 
 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))
@@ -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..a357e22 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,12 +24,12 @@
 
 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
@@ -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=""
+
+# 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_mems_info_array()
+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
@@ -214,7 +244,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 +276,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 +331,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[*]})."
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..85f1863 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,14 +22,14 @@
 #                                                                              #
 ################################################################################
 
-. ./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))
@@ -825,7 +825,7 @@ do
 			fi
 		fi
 	fi
-	: $((TST_COUNT++))
+	TST_COUNT=$(($TST_COUNT + 1))
 done
 
 exit $exit_status
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..35e368c 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"
@@ -338,7 +338,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;
-- 
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [PATCH 2/7] cpuset/cpuset_base_ops_test: fix expected error
  2013-09-26 10:30 [LTP] cpuset controller fixes Stanislav Kholmanskikh
  2013-09-26 10:30 ` [LTP] [PATCH 1/7] controllers/cpuset: removed bash sweetnesses Stanislav Kholmanskikh
@ 2013-09-26 10:30 ` Stanislav Kholmanskikh
  2013-09-26 10:30 ` [LTP] [PATCH 3/7] cpuset/cpuset_syscall_test: fixes Stanislav Kholmanskikh
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-26 10:30 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

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 <stanislav.kholmanskikh@oracle.com>
---
 .../cpuset_base_ops_testset.sh                     |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 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 8b21210..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
@@ -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()
-- 
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [PATCH 3/7] cpuset/cpuset_syscall_test: fixes
  2013-09-26 10:30 [LTP] cpuset controller fixes Stanislav Kholmanskikh
  2013-09-26 10:30 ` [LTP] [PATCH 1/7] controllers/cpuset: removed bash sweetnesses Stanislav Kholmanskikh
  2013-09-26 10:30 ` [LTP] [PATCH 2/7] cpuset/cpuset_base_ops_test: fix expected error Stanislav Kholmanskikh
@ 2013-09-26 10:30 ` Stanislav Kholmanskikh
  2013-09-26 10:30 ` [LTP] [PATCH 4/7] cpuset/cpuset_lib: cpuinfo.c compiled incorrectly Stanislav Kholmanskikh
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-26 10:30 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

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 <stanislav.kholmanskikh@oracle.com>
---
 .../cpuset/cpuset_syscall_test/Makefile            |    1 +
 .../cpuset_syscall_test/cpuset_syscall_test.c      |   61 +++++---------------
 .../cpuset_syscall_test/cpuset_syscall_testset.sh  |   16 +++--
 3 files changed, 25 insertions(+), 53 deletions(-)

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 35e368c..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
@@ -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
 }
 
-- 
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [PATCH 4/7] cpuset/cpuset_lib: cpuinfo.c compiled incorrectly
  2013-09-26 10:30 [LTP] cpuset controller fixes Stanislav Kholmanskikh
                   ` (2 preceding siblings ...)
  2013-09-26 10:30 ` [LTP] [PATCH 3/7] cpuset/cpuset_syscall_test: fixes Stanislav Kholmanskikh
@ 2013-09-26 10:30 ` Stanislav Kholmanskikh
  2013-09-26 10:30 ` [LTP] [PATCH 5/7] cpuset/cpuset_memory_test: fixes Stanislav Kholmanskikh
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-26 10:30 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

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 <stanislav.kholmanskikh@oracle.com>
---
 .../kernel/controllers/cpuset/cpuset_lib/cpuinfo.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

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>
-- 
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [PATCH 5/7] cpuset/cpuset_memory_test: fixes
  2013-09-26 10:30 [LTP] cpuset controller fixes Stanislav Kholmanskikh
                   ` (3 preceding siblings ...)
  2013-09-26 10:30 ` [LTP] [PATCH 4/7] cpuset/cpuset_lib: cpuinfo.c compiled incorrectly Stanislav Kholmanskikh
@ 2013-09-26 10:30 ` Stanislav Kholmanskikh
  2013-09-26 12:22   ` chrubis
  2013-09-26 10:30 ` [LTP] [PATCH 6/7] cpuset_memory_spread_test: number of nodes and sleep timeout Stanislav Kholmanskikh
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-26 10:30 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

cpuset_memory_test.c:
 * lack of "config.h"
 * incorrect use of HAVE_LINUX_MEMPOLICY macro
 * 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 <stanislav.kholmanskikh@oracle.com>
---
 .../cpuset/cpuset_memory_test/cpuset_memory_test.c |   31 ++++++++++---------
 .../cpuset_memory_test/cpuset_memory_testset.sh    |   18 ++++++-----
 2 files changed, 26 insertions(+), 23 deletions(-)

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..17b3ed7 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,27 @@
 #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;
+static int flag_exit;
 
-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"
 
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 85f1863..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
@@ -33,8 +33,8 @@ export TST_COUNT=1
 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,7 +823,7 @@ 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
-- 
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [PATCH 6/7] cpuset_memory_spread_test: number of nodes and sleep timeout
  2013-09-26 10:30 [LTP] cpuset controller fixes Stanislav Kholmanskikh
                   ` (4 preceding siblings ...)
  2013-09-26 10:30 ` [LTP] [PATCH 5/7] cpuset/cpuset_memory_test: fixes Stanislav Kholmanskikh
@ 2013-09-26 10:30 ` Stanislav Kholmanskikh
  2013-09-26 12:06   ` chrubis
  2013-09-26 10:30 ` [LTP] [PATCH 7/7] cpuset/cpuset_load_balance_test: fixes Stanislav Kholmanskikh
  2013-09-26 11:46 ` [LTP] cpuset controller fixes chrubis
  7 siblings, 1 reply; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-26 10:30 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

For unification number of nodes is set based on environment.

I've not found a better way to guarantee dropping of caches than
just increasing sleep timeout twice (to 20 seconds).

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../cpuset_memory_spread_testset.sh                |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

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 a357e22..4d7bbeb 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
@@ -32,8 +32,8 @@ export TST_COUNT=1
 
 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
@@ -231,7 +231,7 @@ general_memory_spread_test()
 	fi
 
 	# wait for droping the cache
-	sleep 10
+	sleep 20
 
 	get_memsinfo
 	/bin/kill -s SIGUSR1 $test_pid
-- 
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [PATCH 7/7] cpuset/cpuset_load_balance_test: fixes
  2013-09-26 10:30 [LTP] cpuset controller fixes Stanislav Kholmanskikh
                   ` (5 preceding siblings ...)
  2013-09-26 10:30 ` [LTP] [PATCH 6/7] cpuset_memory_spread_test: number of nodes and sleep timeout Stanislav Kholmanskikh
@ 2013-09-26 10:30 ` Stanislav Kholmanskikh
  2013-09-26 11:46 ` [LTP] cpuset controller fixes chrubis
  7 siblings, 0 replies; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-26 10:30 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

Fixed lack of '#include "config.h"', perform some cleanup
and set nr_cpus, nr_mems based on environment.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../cpuset_load_balance_test/cpuset_cpu_hog.c      |   16 ++++++++--------
 .../cpuset_load_balance_test.sh                    |    4 ++--
 .../cpuset_sched_domains_check.c                   |    1 +
 .../cpuset_sched_domains_test.sh                   |    4 ++--
 4 files changed, 13 insertions(+), 12 deletions(-)

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 003e9cf..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
@@ -33,8 +33,8 @@ export TST_COUNT=1
 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)))"
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 4547367..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
@@ -33,8 +33,8 @@ export TST_COUNT=1
 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)))"
-- 
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [LTP] cpuset controller fixes
  2013-09-26 10:30 [LTP] cpuset controller fixes Stanislav Kholmanskikh
                   ` (6 preceding siblings ...)
  2013-09-26 10:30 ` [LTP] [PATCH 7/7] cpuset/cpuset_load_balance_test: fixes Stanislav Kholmanskikh
@ 2013-09-26 11:46 ` chrubis
  2013-09-30  7:34   ` [LTP] [PATCH] controllers/cpuset: reogranization Stanislav Kholmanskikh
  7 siblings, 1 reply; 21+ messages in thread
From: chrubis @ 2013-09-26 11:46 UTC (permalink / raw
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list, miaox

Hi!
> And:
> 1. What do you think about idea of assigning to each cpuset controller test
> a separate testcase name in runtest/controllers? Instead of using a single
> run_cpuset_test.sh. 
> This will greatly simplify output results analysis.
> 
> For example rename current cpuset01 testcase to cpuset12 and 
> assign names cpuset01 cpuset11 cpuset_*.sh tests.
> 
> 2. How do you think about adding a separate tst_kvercmp2 binary
> (using tst_kvercmp2() function). 
> It would help in cpuset_base_ops_testset.sh because several distribution
> kernels have these fixes. Because on we also need to make testing based on
> distribution kernel version.
> 
> Like this:
> tst_kvercmp2 X Y Z "RHEL5:234 SLES10:0.91"

Both sounds good to me.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [LTP] [PATCH 6/7] cpuset_memory_spread_test: number of nodes and sleep timeout
  2013-09-26 10:30 ` [LTP] [PATCH 6/7] cpuset_memory_spread_test: number of nodes and sleep timeout Stanislav Kholmanskikh
@ 2013-09-26 12:06   ` chrubis
       [not found]     ` <52442EAB.6070805@oracle.com>
  2013-09-30 12:49     ` [LTP] [PATCH V2 6/7] cpuset_memory_spread_test: number of nodes and sync Stanislav Kholmanskikh
  0 siblings, 2 replies; 21+ messages in thread
From: chrubis @ 2013-09-26 12:06 UTC (permalink / raw
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list, miaox

Hi!
> For unification number of nodes is set based on environment.
> 
> I've not found a better way to guarantee dropping of caches than
> just increasing sleep timeout twice (to 20 seconds).
> 
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> ---
>  .../cpuset_memory_spread_testset.sh                |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> 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 a357e22..4d7bbeb 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
> @@ -32,8 +32,8 @@ export TST_COUNT=1
>  
>  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
> @@ -231,7 +231,7 @@ general_memory_spread_test()
>  	fi
>  
>  	# wait for droping the cache
> -	sleep 10
> +	sleep 20

I've asked our kernel guys and the drop_caches is synchronous interface,
so at the time the cat returns the caches should be dropped. See
fs/drop_caches.c the sysctl handler just does the work, there is nothing
deffered to working threads.

What exactly goes wrong when this sleep is missing here?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [LTP] [PATCH 5/7] cpuset/cpuset_memory_test: fixes
  2013-09-26 10:30 ` [LTP] [PATCH 5/7] cpuset/cpuset_memory_test: fixes Stanislav Kholmanskikh
@ 2013-09-26 12:22   ` chrubis
  2013-09-27 11:13     ` [LTP] [PATCH V2 " Stanislav Kholmanskikh
  0 siblings, 1 reply; 21+ messages in thread
From: chrubis @ 2013-09-26 12:22 UTC (permalink / raw
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list, miaox

Hi!
> cpuset_memory_test.c:
>  * lack of "config.h"
>  * incorrect use of HAVE_LINUX_MEMPOLICY macro
>  * 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

Note that doing what the test does from signal handler is not safe.

If the tests needs to be driven by signals, it should sleep in pause()
or sigwaitinfo() or sigtimedwait() and execute the functions from main
loop rather than from the sighandler.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [LTP] [PATCH 6/7] cpuset_memory_spread_test: number of nodes and sleep timeout
       [not found]     ` <52442EAB.6070805@oracle.com>
@ 2013-09-26 13:57       ` chrubis
  2013-09-26 14:06         ` chrubis
  0 siblings, 1 reply; 21+ messages in thread
From: chrubis @ 2013-09-26 13:57 UTC (permalink / raw
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list, miaox

Hi!
> >> +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
> >> @@ -231,7 +231,7 @@ general_memory_spread_test()
> >>   	fi
> >>   
> >>   	# wait for droping the cache
> >> -	sleep 10
> >> +	sleep 20
> > I've asked our kernel guys and the drop_caches is synchronous interface,
> > so at the time the cat returns the caches should be dropped. See
> > fs/drop_caches.c the sysctl handler just does the work, there is nothing
> > deffered to working threads.
> >
> > What exactly goes wrong when this sleep is missing here?
> 
> If I remove this sleep and perform two sequential runs I get this error:
> root@debian7-x64:/opt/ltp/testcases/bin# ./cpuset_memory_spread_testset.sh
> 100+0 records in
> 100+0 records out
> 104857600 bytes (105 MB) copied, 0.0595533 s, 1.8 GB/s
> cpuset11    1  TFAIL  :  hog the memory on the unexpected 
> node(FilePages_For_Nodes(KB): _0: 0
> _1: 336
> _2: 0
> _3: 0, Expect Nodes: 0).
> 
> But if I take a few seconds between two runs the error disappears.
> 
> I suppose this is an environment issue but don't know how to manage it.

Hmm, strange indeed, so it looks like the memory is allocated under
wrong node.

I would guess that there is someting wrong with the cpuset that moves
the test process into the new set. Maybe the system needs some time to
move the process memory to the node we specified.

And I wasn't able to run the test yet, I've managed to get a machine
with two real nodes but the cpuset tests are not easy to run :(

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [LTP] [PATCH 6/7] cpuset_memory_spread_test: number of nodes and sleep timeout
  2013-09-26 13:57       ` chrubis
@ 2013-09-26 14:06         ` chrubis
       [not found]           ` <52493A44.8060409@oracle.com>
  0 siblings, 1 reply; 21+ messages in thread
From: chrubis @ 2013-09-26 14:06 UTC (permalink / raw
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list, miaox

Hi!
> > If I remove this sleep and perform two sequential runs I get this error:
> > root@debian7-x64:/opt/ltp/testcases/bin# ./cpuset_memory_spread_testset.sh
> > 100+0 records in
> > 100+0 records out
> > 104857600 bytes (105 MB) copied, 0.0595533 s, 1.8 GB/s
> > cpuset11    1  TFAIL  :  hog the memory on the unexpected 
> > node(FilePages_For_Nodes(KB): _0: 0
> > _1: 336
> > _2: 0
> > _3: 0, Expect Nodes: 0).
> > 
> > But if I take a few seconds between two runs the error disappears.
> > 
> > I suppose this is an environment issue but don't know how to manage it.
> 
> Hmm, strange indeed, so it looks like the memory is allocated under
> wrong node.
> 
> I would guess that there is someting wrong with the cpuset that moves
> the test process into the new set. Maybe the system needs some time to
> move the process memory to the node we specified.

What about cating /proc/$test_pid/status before we allocate the memory
and checking that Mems_allowed_list matches the expected node?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [LTP] [PATCH V2 5/7] cpuset/cpuset_memory_test: fixes
  2013-09-26 12:22   ` chrubis
@ 2013-09-27 11:13     ` Stanislav Kholmanskikh
  2013-09-30 17:11       ` chrubis
  0 siblings, 1 reply; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-27 11:13 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

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 <stanislav.kholmanskikh@oracle.com>
---
 .../cpuset/cpuset_memory_test/cpuset_memory_test.c |  159 ++++++++++----------
 .../cpuset_memory_test/cpuset_memory_testset.sh    |   18 ++-
 2 files changed, 88 insertions(+), 89 deletions(-)

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 85f1863..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
@@ -33,8 +33,8 @@ export TST_COUNT=1
 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,7 +823,7 @@ 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
-- 
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [PATCH] controllers/cpuset: reogranization
  2013-09-26 11:46 ` [LTP] cpuset controller fixes chrubis
@ 2013-09-30  7:34   ` Stanislav Kholmanskikh
  2013-09-30 14:17     ` chrubis
  0 siblings, 1 reply; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-30  7:34 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

Renamed cpuset01 to cpuset12.

A separate name (from cpuset01 to cpuset11) is assigned to each cpuset
shell testcase (which was invoked earlier by run_cpuset_test.sh).

This will simplify results analysis.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 runtest/controllers                                |   13 +
 runtest/mm                                         |    2 +-
 .../cpuset_base_ops_testset.sh                     |    2 +
 .../cpuset_exclusive_test/cpuset_exclusive_test.sh |    2 +
 .../kernel/controllers/cpuset/cpuset_funcs.sh      |   25 ++-
 .../cpuset_hierarchy_test/cpuset_hierarchy_test.sh |    2 +
 .../cpuset_hotplug_test/cpuset_hotplug_test.sh     |    2 +
 .../cpuset_inherit_test/cpuset_inherit_testset.sh  |    2 +
 .../cpuset_load_balance_test.sh                    |    2 +
 .../cpuset_sched_domains_test.sh                   |    2 +
 .../cpuset_memory_pressure_testset.sh              |    2 +
 .../cpuset_memory_spread_testset.sh                |    2 +
 .../cpuset_memory_test/cpuset_memory_testset.sh    |    2 +
 .../cpuset_syscall_test/cpuset_syscall_testset.sh  |    2 +
 .../kernel/controllers/cpuset/run_cpuset_test.sh   |  183 ---------------
 testcases/kernel/controllers/test_controllers.sh   |   20 --
 testcases/kernel/mem/cpuset/cpuset01.c             |  247 --------------------
 testcases/kernel/mem/cpuset/cpuset12.c             |  247 ++++++++++++++++++++
 18 files changed, 304 insertions(+), 455 deletions(-)
 delete mode 100755 testcases/kernel/controllers/cpuset/run_cpuset_test.sh
 delete mode 100644 testcases/kernel/mem/cpuset/cpuset01.c
 create mode 100644 testcases/kernel/mem/cpuset/cpuset12.c

diff --git a/runtest/controllers b/runtest/controllers
index 94fc185..2d33291 100644
--- a/runtest/controllers
+++ b/runtest/controllers
@@ -12,4 +12,17 @@ memcg_stress		memcg_stress_test.sh
 memcg_control		PAGESIZE=$(mem_process -p);memcg_control_test.sh $PAGESIZE $PAGESIZE $((PAGESIZE * 2))
 cgroup_fj	run_cgroup_test_fj.sh
 controllers	test_controllers.sh
+
+cpuset01	cpuset_base_ops_testset.sh
+cpuset02	cpuset_inherit_testset.sh
+cpuset03	cpuset_exclusive_test.sh
+cpuset04	cpuset_hierarchy_test.sh
+cpuset05	cpuset_syscall_testset.sh
+cpuset06	cpuset_sched_domains_test.sh
+cpuset07	cpuset_load_balance_test.sh
+cpuset08	cpuset_hotplug_test.sh
+cpuset09	cpuset_memory_testset.sh
+cpuset10	cpuset_memory_pressure_testset.sh
+cpuset11	cpuset_memory_spread_testset.sh
+
 cgroup_xattr	cgroup_xattr
diff --git a/runtest/mm b/runtest/mm
index 28151b5..86b7e99 100644
--- a/runtest/mm
+++ b/runtest/mm
@@ -74,7 +74,7 @@ ksm06 ksm06
 ksm06_1 ksm06 -n 10
 ksm06_2 ksm06 -n 10000
 
-cpuset01 cpuset01 -I 3600
+cpuset12 cpuset12 -I 3600
 
 oom01 oom01
 oom02 oom02
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 126eec5..1b556a9 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 nr_cpus=$NR_CPUS
 nr_mems=$N_NODES
 
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 0ad31e7..bb98e3c 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 exit_status=0
 
 # Case 1-9 test cpus
diff --git a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
index a83845c..5fbddf0 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
@@ -89,11 +89,18 @@ user_check()
 
 cpuset_check()
 {
-	grep cpuset /proc/cgroups > /dev/null 2>&1
-	if [ $? -ne 0 ]; then
-		tst_brkm TCONF ignored "Cpuset is not supported"
-		return 1
+        if [ -f /proc/cgroups ]; then
+		CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1`
+		CPUSET_CONTROLLER_VALUE=`grep -w cpuset /proc/cgroups | cut -f4`
+
+		if [ "$CPUSET_CONTROLLER" = "cpuset" ] && [ "$CPUSET_CONTROLLER_VALUE" = "1" ]
+		then
+			return 0
+		fi
 	fi
+
+	tst_brkm TCONF ignored "Cpuset is not supported"
+	return 1
 }
 
 check()
@@ -125,6 +132,16 @@ check()
 
 }
 
+check_and_prepare()
+{
+	check
+	if [ $? -ne 0 ]; then
+		exit 0
+	fi
+
+	cd $LTPROOT/testcases/bin/
+}
+
 # Create /dev/cpuset & mount the cgroup file system with cpuset
 # clean any group created eralier (if any)
 setup()
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 5804aa4..8d26982 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 nr_cpus=$NR_CPUS
 nr_mems=$N_NODES
 
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 2bfe0f5..bb8393f 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 exit_status=0
 
 nr_cpus=$NR_CPUS
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 780b7eb..be6f85f 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 nr_cpus=$NR_CPUS
 nr_mems=$N_NODES
 
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 55f533a..8e55fc1 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 exit_status=0
 
 # must >= 3 for: 1-$((nr_mems-2))
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 3ca70df..66b56f2 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 exit_status=0
 
 # must >= 3 for: 1-$((nr_mems-2))
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 f342e6c..5a6b907 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 exit_status=0
 
 # usable physical memory
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 4d7bbeb..49ad576 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 exit_status=0
 # must >= 3 for: 1-$((nr_mems-2))
 nr_cpus=$NR_CPUS
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 2a9f7e3..a84782a 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 exit_status=0
 
 # must >= 3 for: 1-$((nr_mems-2))
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 af92373..de620ee 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
@@ -30,6 +30,8 @@ export TST_COUNT=1
 
 . ./cpuset_funcs.sh
 
+check_and_prepare
+
 exit_status=0
 
 TEST_CPUSET="$CPUSET/0"
diff --git a/testcases/kernel/controllers/cpuset/run_cpuset_test.sh b/testcases/kernel/controllers/cpuset/run_cpuset_test.sh
deleted file mode 100755
index abdc885..0000000
--- a/testcases/kernel/controllers/cpuset/run_cpuset_test.sh
+++ /dev/null
@@ -1,183 +0,0 @@
-#!/bin/sh
-# usage ./run_cpuset_test.sh test_num
-
-################################################################################
-#                                                                              #
-# Copyright (c) 2009 FUJITSU LIMITED                                           #
-#                                                                              #
-# This program is free software;  you can redistribute it and#or modify        #
-# it under the terms of the GNU General Public License as published by         #
-# the Free Software Foundation; either version 2 of the License, or            #
-# (at your option) any later version.                                          #
-#                                                                              #
-# This program is distributed in the hope that it will be useful, but          #
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY   #
-# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License     #
-# for more details.                                                            #
-#                                                                              #
-# You should have received a copy of the GNU General Public License            #
-# along with this program;  if not, write to the Free Software                 #
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA      #
-#                                                                              #
-################################################################################
-# Name Of File: run_cpuset_test.sh                                             #
-#                                                                              #
-# Description: This file runs the setup for testing different cpuset resource  #
-#              controller features. After setup it runs diff test cases in     #
-#              diff setup.                                                     #
-#                                                                              #
-# Test 01:     Tests basal operation of control file                           #
-#                                                                              #
-# Precaution:   Avoid system use by other applications/users to get fair and   #
-#               appropriate results (avoid unnecessary killing of applicatio)  #
-#                                                                              #
-# Author:       Miao Xie   <miaox@cn.fujitsu.com>                              #
-#                                                                              #
-# History:                                                                     #
-#                                                                              #
-#  DATE         NAME           EMAIL                         DESC              #
-#                                                                              #
-#  02/03/09  Miao Xie     <miaox@cn.fujitsu.com>        Created this test      #
-#                                                                              #
-################################################################################
-
-export TCID="cpuset_test";
-export TST_TOTAL=1;
-export TST_COUNT=1;
-
-. cpuset_funcs.sh;
-
-TEST_NUM=$1;
-SCRIPT_PID=$$;
-RC=0;
-PWD=`pwd`;
-
-check
-if [ $? -ne 0 ]; then
-	exit 0
-fi
-
-# The usage of the script file
-usage()
-{
-	echo "Could not start cpuset controller test";
-	echo "usage: run_cpuset_test.sh test_num";
-	echo "Skipping the cpuset controller test...";
-}
-
-cd $LTPROOT/testcases/bin/
-
-echo "TEST $TEST_NUM: CPUSET CONTROLLER TESTING";
-
-echo "TEST STARTED: Please avoid using system while this test executes";
-#Check if  C source  file has been compiled and then run it in different groups
-
-case $TEST_NUM in
-"1" )
-	if [ -f cpuset_base_ops_testset.sh ]; then
-		./cpuset_base_ops_testset.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"2" )
-	if [ -f cpuset_inherit_testset.sh ]; then
-		./cpuset_inherit_testset.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"3" )
-	if [ -f cpuset_exclusive_test.sh ]; then
-		./cpuset_exclusive_test.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"4" )
-	if [ -f cpuset_hierarchy_test.sh ]; then
-		./cpuset_hierarchy_test.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"5" )
-	if [ -f cpuset_syscall_testset.sh ]; then
-		./cpuset_syscall_testset.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"6" )
-	if [ -f cpuset_sched_domains_test.sh ]; then
-		./cpuset_sched_domains_test.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"7" )
-	if [ -f cpuset_load_balance_test.sh ]; then
-		./cpuset_load_balance_test.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"8" )
-	if [ -f cpuset_hotplug_test.sh ]; then
-		./cpuset_hotplug_test.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"9" )
-	if [ -f cpuset_memory_testset.sh ]; then
-		./cpuset_memory_testset.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"10" )
-	if [ -f cpuset_memory_pressure_testset.sh ]; then
-		./cpuset_memory_pressure_testset.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"11" )
-	if [ -f cpuset_memory_spread_testset.sh ]; then
-		./cpuset_memory_spread_testset.sh
-		exit $?;
-	else
-		echo "Shell file not installed..Please check Makefile...Exiting"
-		exit -1;
-	fi;
-	;;
-"*" )
-	usage;
-	exit -1;
-	;;
-esac
-
-echo "Cpuset Resource Controller test executed successfully.";
-cd $PWD
-exit 0;         #to let PAN reprt success of test
diff --git a/testcases/kernel/controllers/test_controllers.sh b/testcases/kernel/controllers/test_controllers.sh
index d3c3362..7aa974f 100755
--- a/testcases/kernel/controllers/test_controllers.sh
+++ b/testcases/kernel/controllers/test_controllers.sh
@@ -47,8 +47,6 @@ then
 	IOTHROTTLE_CONTROLLER_VALUE=`grep -w blockio /proc/cgroups | cut -f4`;
 	FREEZER=`grep -w freezer /proc/cgroups | cut -f1`;
 	FREEZER_VALUE=`grep -w freezer /proc/cgroups | cut -f4`;
-	CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1`
-	CPUSET_CONTROLLER_VALUE=`grep -w cpuset /proc/cgroups | cut -f4`
 	CPUACCOUNT_CONTROLLER=`grep -w cpuacct /proc/cgroups | cut -f1`
 	CPUACCOUNT_CONTROLLER_VALUE=`grep -w cpuacct /proc/cgroups | cut -f4`
 
@@ -102,24 +100,6 @@ then
 		echo "Kernel does not support freezer controller";
 		echo "Skipping all freezer testcases....";
 	fi
-	if [ "$CPUSET_CONTROLLER" = "cpuset" ] && [ "$CPUSET_CONTROLLER_VALUE" = "1" ]
-	then
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 1;
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 2;
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 3;
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 4;
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 5;
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 6;
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 7;
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 8;
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 9;
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 10;
-		$LTPROOT/testcases/bin/run_cpuset_test.sh 11;
-	else
-		echo "CONTROLLERS TESTCASES: WARNING";
-		echo "Either Kernel does not support for cpuset controller or functionality is not enabled";
-		echo "Skipping all cpuset controller testcases....";
-	fi
 	if [ "$CPUACCOUNT_CONTROLLER" = "cpuacct" ] && [ "$CPUACCOUNT_CONTROLLER_VALUE" = "1" ]
         then
                 $LTPROOT/testcases/bin/run_cpuacct_test.sh 1;
diff --git a/testcases/kernel/mem/cpuset/cpuset01.c b/testcases/kernel/mem/cpuset/cpuset01.c
deleted file mode 100644
index abba489..0000000
--- a/testcases/kernel/mem/cpuset/cpuset01.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Out Of Memory when changing cpuset's mems on NUMA. There was a
- * problem reported upstream that the allocator may see an empty
- * nodemask when changing cpuset's mems.
- * http://lkml.org/lkml/2010/5/4/77
- * http://lkml.org/lkml/2010/5/4/79
- * http://lkml.org/lkml/2010/5/4/80
- * This test is based on the reproducers for the above issue.
- *
- * Copyright (C) 2010  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-#include "config.h"
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <math.h>
-#if HAVE_NUMAIF_H
-#include <numaif.h>
-#endif
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "test.h"
-#include "usctest.h"
-#include "mem.h"
-#include "numa_helper.h"
-
-char *TCID = "cpuset01";
-int TST_TOTAL = 1;
-
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
-volatile int end;
-static int *nodes;
-static int nnodes;
-static long ncpus;
-
-static void testcpuset(void);
-static void sighandler(int signo LTP_ATTRIBUTE_UNUSED);
-static int mem_hog(void);
-static int mem_hog_cpuset(int ntasks);
-static long count_cpu(void);
-
-int main(int argc, char *argv[])
-{
-	char *msg;
-
-	msg = parse_opts(argc, argv, NULL, NULL);
-	if (msg != NULL)
-		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-
-	ncpus = count_cpu();
-	if (get_allowed_nodes_arr(NH_MEMS | NH_CPUS, &nnodes, &nodes) < 0)
-		tst_brkm(TBROK | TERRNO, NULL, "get_allowed_nodes_arr");
-	if (nnodes <= 1)
-		tst_brkm(TCONF, NULL, "requires a NUMA system.");
-
-	setup();
-	testcpuset();
-	cleanup();
-	tst_exit();
-}
-
-static void testcpuset(void)
-{
-	int lc;
-	int child, i, status;
-	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
-	char mems[BUFSIZ], buf[BUFSIZ];
-
-	read_cpuset_files(CPATH, "cpus", buf);
-	write_cpuset_files(CPATH_NEW, "cpus", buf);
-	read_cpuset_files(CPATH, "mems", mems);
-	write_cpuset_files(CPATH_NEW, "mems", mems);
-	SAFE_FILE_PRINTF(cleanup, CPATH_NEW "/tasks", "%d", getpid());
-
-	switch (child = fork()) {
-	case -1:
-		tst_brkm(TBROK | TERRNO, cleanup, "fork");
-	case 0:
-		for (i = 0; i < nnodes; i++) {
-			if (nodes[i] >= MAXNODES)
-				continue;
-			set_node(nmask, nodes[i]);
-		}
-		if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "set_mempolicy");
-		exit(mem_hog_cpuset(ncpus > 1 ? ncpus : 1));
-	}
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		snprintf(buf, BUFSIZ, "%d", nodes[0]);
-		write_cpuset_files(CPATH_NEW, "mems", buf);
-		snprintf(buf, BUFSIZ, "%d", nodes[1]);
-		write_cpuset_files(CPATH_NEW, "mems", buf);
-	}
-
-	if (waitpid(child, &status, WUNTRACED | WCONTINUED) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
-	if (WEXITSTATUS(status) != 0)
-		tst_resm(TFAIL, "child exit status is %d", WEXITSTATUS(status));
-}
-
-void setup(void)
-{
-	tst_require_root(NULL);
-
-	if (tst_kvercmp(2, 6, 32) < 0)
-		tst_brkm(TCONF, NULL, "2.6.32 or greater kernel required");
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
-
-	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
-}
-
-void cleanup(void)
-{
-	umount_mem(CPATH, CPATH_NEW);
-
-	TEST_CLEANUP;
-}
-
-static void sighandler(int signo LTP_ATTRIBUTE_UNUSED)
-{
-	end = 1;
-}
-
-static int mem_hog(void)
-{
-	long pagesize;
-	unsigned long *addr;
-	int ret = 0;
-
-	pagesize = getpagesize();
-	while (!end) {
-		addr = mmap(NULL, pagesize * 10, PROT_READ | PROT_WRITE,
-			    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-		if (addr == MAP_FAILED) {
-			ret = 1;
-			tst_resm(TFAIL | TERRNO, "mmap");
-			break;
-		}
-		memset(addr, 0xF7, pagesize * 10);
-		munmap(addr, pagesize * 10);
-	}
-	return ret;
-}
-
-static int mem_hog_cpuset(int ntasks)
-{
-	int i, lc, status, ret = 0;
-	struct sigaction sa;
-	pid_t *pids;
-
-	if (ntasks <= 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "ntasks is small.");
-	sa.sa_handler = sighandler;
-	if (sigemptyset(&sa.sa_mask) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "sigemptyset");
-	sa.sa_flags = 0;
-	if (sigaction(SIGUSR1, &sa, NULL) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "sigaction");
-
-	pids = malloc(sizeof(pid_t) * ntasks);
-	if (pids == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "malloc");
-	for (i = 0; i < ntasks; i++) {
-		switch (pids[i] = fork()) {
-		case -1:
-			tst_resm(TFAIL | TERRNO, "fork %d", pids[i]);
-			ret = 1;
-			break;
-		case 0:
-			ret = mem_hog();
-			exit(ret);
-		default:
-			break;
-		}
-	}
-	for (lc = 0; TEST_LOOPING(lc); lc++) ;
-	while (i--) {
-		if (kill(pids[i], SIGUSR1) == -1) {
-			tst_resm(TFAIL | TERRNO, "kill %d", pids[i]);
-			ret = 1;
-		}
-	}
-	while (waitpid(-1, &status, WUNTRACED | WCONTINUED) > 0) {
-		if (WIFEXITED(status)) {
-			if (WEXITSTATUS(status) != 0) {
-				tst_resm(TFAIL, "child exit status is %d",
-					 WEXITSTATUS(status));
-				ret = 1;
-			}
-		} else if (WIFSIGNALED(status)) {
-			tst_resm(TFAIL, "child caught signal %d",
-				 WTERMSIG(status));
-			ret = 1;
-		}
-	}
-	return ret;
-}
-
-static long count_cpu(void)
-{
-	int ncpus = 0;
-
-	while (path_exist(PATH_SYS_SYSTEM "/cpu/cpu%d", ncpus))
-		ncpus++;
-
-	return ncpus;
-}
-
-#else /* no NUMA */
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
-}
-#endif
diff --git a/testcases/kernel/mem/cpuset/cpuset12.c b/testcases/kernel/mem/cpuset/cpuset12.c
new file mode 100644
index 0000000..036c001
--- /dev/null
+++ b/testcases/kernel/mem/cpuset/cpuset12.c
@@ -0,0 +1,247 @@
+/*
+ * Out Of Memory when changing cpuset's mems on NUMA. There was a
+ * problem reported upstream that the allocator may see an empty
+ * nodemask when changing cpuset's mems.
+ * http://lkml.org/lkml/2010/5/4/77
+ * http://lkml.org/lkml/2010/5/4/79
+ * http://lkml.org/lkml/2010/5/4/80
+ * This test is based on the reproducers for the above issue.
+ *
+ * Copyright (C) 2010  Red Hat, Inc.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it
+ * is free of the rightful claim of any third person regarding
+ * infringement or the like.  Any license provided herein, whether
+ * implied or otherwise, applies only to this software file.  Patent
+ * licenses, if any, provided herein do not apply to combinations of
+ * this program with other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+#include "config.h"
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <math.h>
+#if HAVE_NUMAIF_H
+#include <numaif.h>
+#endif
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "test.h"
+#include "usctest.h"
+#include "mem.h"
+#include "numa_helper.h"
+
+char *TCID = "cpuset12";
+int TST_TOTAL = 1;
+
+#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
+	&& HAVE_MPOL_CONSTANTS
+volatile int end;
+static int *nodes;
+static int nnodes;
+static long ncpus;
+
+static void testcpuset(void);
+static void sighandler(int signo LTP_ATTRIBUTE_UNUSED);
+static int mem_hog(void);
+static int mem_hog_cpuset(int ntasks);
+static long count_cpu(void);
+
+int main(int argc, char *argv[])
+{
+	char *msg;
+
+	msg = parse_opts(argc, argv, NULL, NULL);
+	if (msg != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	ncpus = count_cpu();
+	if (get_allowed_nodes_arr(NH_MEMS | NH_CPUS, &nnodes, &nodes) < 0)
+		tst_brkm(TBROK | TERRNO, NULL, "get_allowed_nodes_arr");
+	if (nnodes <= 1)
+		tst_brkm(TCONF, NULL, "requires a NUMA system.");
+
+	setup();
+	testcpuset();
+	cleanup();
+	tst_exit();
+}
+
+static void testcpuset(void)
+{
+	int lc;
+	int child, i, status;
+	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
+	char mems[BUFSIZ], buf[BUFSIZ];
+
+	read_cpuset_files(CPATH, "cpus", buf);
+	write_cpuset_files(CPATH_NEW, "cpus", buf);
+	read_cpuset_files(CPATH, "mems", mems);
+	write_cpuset_files(CPATH_NEW, "mems", mems);
+	SAFE_FILE_PRINTF(cleanup, CPATH_NEW "/tasks", "%d", getpid());
+
+	switch (child = fork()) {
+	case -1:
+		tst_brkm(TBROK | TERRNO, cleanup, "fork");
+	case 0:
+		for (i = 0; i < nnodes; i++) {
+			if (nodes[i] >= MAXNODES)
+				continue;
+			set_node(nmask, nodes[i]);
+		}
+		if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1)
+			tst_brkm(TBROK | TERRNO, cleanup, "set_mempolicy");
+		exit(mem_hog_cpuset(ncpus > 1 ? ncpus : 1));
+	}
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+		snprintf(buf, BUFSIZ, "%d", nodes[0]);
+		write_cpuset_files(CPATH_NEW, "mems", buf);
+		snprintf(buf, BUFSIZ, "%d", nodes[1]);
+		write_cpuset_files(CPATH_NEW, "mems", buf);
+	}
+
+	if (waitpid(child, &status, WUNTRACED | WCONTINUED) == -1)
+		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+	if (WEXITSTATUS(status) != 0)
+		tst_resm(TFAIL, "child exit status is %d", WEXITSTATUS(status));
+}
+
+void setup(void)
+{
+	tst_require_root(NULL);
+
+	if (tst_kvercmp(2, 6, 32) < 0)
+		tst_brkm(TCONF, NULL, "2.6.32 or greater kernel required");
+
+	tst_sig(FORK, DEF_HANDLER, cleanup);
+	TEST_PAUSE;
+
+	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
+}
+
+void cleanup(void)
+{
+	umount_mem(CPATH, CPATH_NEW);
+
+	TEST_CLEANUP;
+}
+
+static void sighandler(int signo LTP_ATTRIBUTE_UNUSED)
+{
+	end = 1;
+}
+
+static int mem_hog(void)
+{
+	long pagesize;
+	unsigned long *addr;
+	int ret = 0;
+
+	pagesize = getpagesize();
+	while (!end) {
+		addr = mmap(NULL, pagesize * 10, PROT_READ | PROT_WRITE,
+			    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+		if (addr == MAP_FAILED) {
+			ret = 1;
+			tst_resm(TFAIL | TERRNO, "mmap");
+			break;
+		}
+		memset(addr, 0xF7, pagesize * 10);
+		munmap(addr, pagesize * 10);
+	}
+	return ret;
+}
+
+static int mem_hog_cpuset(int ntasks)
+{
+	int i, lc, status, ret = 0;
+	struct sigaction sa;
+	pid_t *pids;
+
+	if (ntasks <= 0)
+		tst_brkm(TBROK | TERRNO, cleanup, "ntasks is small.");
+	sa.sa_handler = sighandler;
+	if (sigemptyset(&sa.sa_mask) < 0)
+		tst_brkm(TBROK | TERRNO, cleanup, "sigemptyset");
+	sa.sa_flags = 0;
+	if (sigaction(SIGUSR1, &sa, NULL) < 0)
+		tst_brkm(TBROK | TERRNO, cleanup, "sigaction");
+
+	pids = malloc(sizeof(pid_t) * ntasks);
+	if (pids == NULL)
+		tst_brkm(TBROK | TERRNO, cleanup, "malloc");
+	for (i = 0; i < ntasks; i++) {
+		switch (pids[i] = fork()) {
+		case -1:
+			tst_resm(TFAIL | TERRNO, "fork %d", pids[i]);
+			ret = 1;
+			break;
+		case 0:
+			ret = mem_hog();
+			exit(ret);
+		default:
+			break;
+		}
+	}
+	for (lc = 0; TEST_LOOPING(lc); lc++) ;
+	while (i--) {
+		if (kill(pids[i], SIGUSR1) == -1) {
+			tst_resm(TFAIL | TERRNO, "kill %d", pids[i]);
+			ret = 1;
+		}
+	}
+	while (waitpid(-1, &status, WUNTRACED | WCONTINUED) > 0) {
+		if (WIFEXITED(status)) {
+			if (WEXITSTATUS(status) != 0) {
+				tst_resm(TFAIL, "child exit status is %d",
+					 WEXITSTATUS(status));
+				ret = 1;
+			}
+		} else if (WIFSIGNALED(status)) {
+			tst_resm(TFAIL, "child caught signal %d",
+				 WTERMSIG(status));
+			ret = 1;
+		}
+	}
+	return ret;
+}
+
+static long count_cpu(void)
+{
+	int ncpus = 0;
+
+	while (path_exist(PATH_SYS_SYSTEM "/cpu/cpu%d", ncpus))
+		ncpus++;
+
+	return ncpus;
+}
+
+#else /* no NUMA */
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
+}
+#endif
-- 
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [LTP] [PATCH V2 6/7] cpuset_memory_spread_test: number of nodes and sync
  2013-09-26 12:06   ` chrubis
       [not found]     ` <52442EAB.6070805@oracle.com>
@ 2013-09-30 12:49     ` Stanislav Kholmanskikh
  1 sibling, 0 replies; 21+ messages in thread
From: Stanislav Kholmanskikh @ 2013-09-30 12:49 UTC (permalink / raw
  To: ltp-list; +Cc: vasily.isaenko, miaox

For unification number of nodes is set based on environment.

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 <stanislav.kholmanskikh@oracle.com>
---
 .../cpuset_memory_spread_testset.sh                |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)

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 a357e22..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
@@ -32,8 +32,8 @@ export TST_COUNT=1
 
 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
@@ -223,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
@@ -230,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
@@ -344,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
-- 
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [LTP] [PATCH 6/7] cpuset_memory_spread_test: number of nodes and sleep timeout
       [not found]             ` <52496FD1.6010604@oracle.com>
@ 2013-09-30 13:04               ` chrubis
       [not found]                 ` <52497984.7090909@oracle.com>
  0 siblings, 1 reply; 21+ messages in thread
From: chrubis @ 2013-09-30 13:04 UTC (permalink / raw
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list, miaox

Hi!
> > Hmmm, Mems_allowed* content of /proc/$test_pid/status before sending
> > SIGUSR1 to $test_pid is:
> >
> > Mems_allowed:    00000000,00000001
> > Mems_allowed_list:    0
> > cpuset11    1  TFAIL  :  hog the memory on the unexpected
> > node(FilePages_For_Nodes(KB): _0: 112
> > _1: 0
> > _2: 0
> > _3: 0, Expect Nodes: 0).
> >
> > i.e. It is a failure on:
> >      base_test "0" "0" "0" "0"
> >
> > So, may be, It's a testcase issue. I'm Looking more deeply.
> >
> >
> 
> It seems that just
>    /bin/echo 3 > /proc/sys/vm/drop_caches
> is not sufficient to free memory.

Right, that drops only caches that are synced to disks and could be
freed without waiting for writeback.

> In accordance to Documentation/sysctl/vm.txt we need to invoke 'sync' 
> before that.
> 
> I removed all the 'sleep's from the testcases and add a single sync 
> before sending SIGUSR1 to mem_hog.
> 
> After that this testcase started to work reliable.

Sounds good.

So the problem (given the symptoms) may be that the test process wasn't
moved to the desired cpuset right away because kernel needed to shuffle
the process caches and since the transition wasn't complete the memory
allocated meanwhile was stil at the wrong node?

If that is so, we may also add a check that the process is moved to the
cpuset allready before starting the test. But let's proceed with the
fixes and cleanups we allready have first.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [LTP] [PATCH 6/7] cpuset_memory_spread_test: number of nodes and sleep timeout
       [not found]                 ` <52497984.7090909@oracle.com>
@ 2013-09-30 13:27                   ` chrubis
  0 siblings, 0 replies; 21+ messages in thread
From: chrubis @ 2013-09-30 13:27 UTC (permalink / raw
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list, miaox

Hi!
> I suppose the problem is of different nature. The problem is that
> the caches are not dropped after performing 'dd'. And since dd is executed
> in root cpuset (at the beginning of the testcase where no other cpusets 
> are defined),
> these caches are spread among all memory nodes.
> 
> The test process is placed in desired cpuset. It reads DATAFILE (which is
> already in memory, since the caches are in memory), but this reading 
> doesn't increase
> memory consumption.
> 
> And delta (memory consumption after mem_hog's reading - memory 
> consumption before mem_hog's
> reading taken on each node) is equal to zero (approximately). So the 
> testcase fails.

Ah, that explains it. Thanks for the detailed description (and don't
forget to add this information into the corresponding git commit
message).

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [LTP] [PATCH] controllers/cpuset: reogranization
  2013-09-30  7:34   ` [LTP] [PATCH] controllers/cpuset: reogranization Stanislav Kholmanskikh
@ 2013-09-30 14:17     ` chrubis
  0 siblings, 0 replies; 21+ messages in thread
From: chrubis @ 2013-09-30 14:17 UTC (permalink / raw
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list, miaox

Hi!
> Renamed cpuset01 to cpuset12.

I slightly preffere to keep the test ids constant if possible. Note that
there are databases of test results used for comparsions and changing
the test ids would confuse such systems.

So in this case I would just name the newly added cpuset tests
differently, either add some reasonable prefix or start the numbering
from some higher number.

>  . ./cpuset_funcs.sh

Drop the './' here. When LTP is executed the directory with the tests
binaries and scripts is in $PATH. When you run scripts from git the
files are found in $CWD. With './' the LTP tests must be executed
with CWD set to /opt/ltp/testcases/bin/, which is something I wan't to
get rid in the future.


-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [LTP] [PATCH V2 5/7] cpuset/cpuset_memory_test: fixes
  2013-09-27 11:13     ` [LTP] [PATCH V2 " Stanislav Kholmanskikh
@ 2013-09-30 17:11       ` chrubis
  2013-10-01 12:12         ` chrubis
  0 siblings, 1 reply; 21+ messages in thread
From: chrubis @ 2013-09-30 17:11 UTC (permalink / raw
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list, miaox

Hi!
> 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

Looks good.

I will try to apply the patchset and run the tests tomorrow.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [LTP] [PATCH V2 5/7] cpuset/cpuset_memory_test: fixes
  2013-09-30 17:11       ` chrubis
@ 2013-10-01 12:12         ` chrubis
  0 siblings, 0 replies; 21+ messages in thread
From: chrubis @ 2013-10-01 12:12 UTC (permalink / raw
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list, miaox

Hi!
> 
> Looks good.
> 
> I will try to apply the patchset and run the tests tomorrow.

I've tested the patset (all 8 patches) and it works fine.

I've got a failure on cpuset_memory_pressure_testset.sh:

cpuset10    5  TFAIL  :  root group's memory_pressure didn't have memory pressure rate.
/opt/ltp/testcases/bin/cpuset_memory_pressure_testset.sh: line 195:
15280 Killed                  ./cpuset_memory_pressure $usemem
cpuset10    6  TFAIL  :  root group's memory_pressure didn't have memory pressure rate.

however the changes you did to the test are more or less cosmetic.

Now I would like to see a bit more verbose git log for
"cpuset_memory_spread_test: number of nodes and sync" patch (You should
write commit logs verbose enough so that peroson who wasn't involved in
the fix would understand how the changes fix the prolem).

And with the fixes to the reorganization patch and then I'm fine with
the whole series.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2013-10-01 12:12 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-26 10:30 [LTP] cpuset controller fixes Stanislav Kholmanskikh
2013-09-26 10:30 ` [LTP] [PATCH 1/7] controllers/cpuset: removed bash sweetnesses Stanislav Kholmanskikh
2013-09-26 10:30 ` [LTP] [PATCH 2/7] cpuset/cpuset_base_ops_test: fix expected error Stanislav Kholmanskikh
2013-09-26 10:30 ` [LTP] [PATCH 3/7] cpuset/cpuset_syscall_test: fixes Stanislav Kholmanskikh
2013-09-26 10:30 ` [LTP] [PATCH 4/7] cpuset/cpuset_lib: cpuinfo.c compiled incorrectly Stanislav Kholmanskikh
2013-09-26 10:30 ` [LTP] [PATCH 5/7] cpuset/cpuset_memory_test: fixes Stanislav Kholmanskikh
2013-09-26 12:22   ` chrubis
2013-09-27 11:13     ` [LTP] [PATCH V2 " Stanislav Kholmanskikh
2013-09-30 17:11       ` chrubis
2013-10-01 12:12         ` chrubis
2013-09-26 10:30 ` [LTP] [PATCH 6/7] cpuset_memory_spread_test: number of nodes and sleep timeout Stanislav Kholmanskikh
2013-09-26 12:06   ` chrubis
     [not found]     ` <52442EAB.6070805@oracle.com>
2013-09-26 13:57       ` chrubis
2013-09-26 14:06         ` chrubis
     [not found]           ` <52493A44.8060409@oracle.com>
     [not found]             ` <52496FD1.6010604@oracle.com>
2013-09-30 13:04               ` chrubis
     [not found]                 ` <52497984.7090909@oracle.com>
2013-09-30 13:27                   ` chrubis
2013-09-30 12:49     ` [LTP] [PATCH V2 6/7] cpuset_memory_spread_test: number of nodes and sync Stanislav Kholmanskikh
2013-09-26 10:30 ` [LTP] [PATCH 7/7] cpuset/cpuset_load_balance_test: fixes Stanislav Kholmanskikh
2013-09-26 11:46 ` [LTP] cpuset controller fixes chrubis
2013-09-30  7:34   ` [LTP] [PATCH] controllers/cpuset: reogranization Stanislav Kholmanskikh
2013-09-30 14:17     ` chrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.