123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833 |
- #!/bin/sh
- ################################################################################
- # #
- # 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 #
- # #
- # Author: Miao Xie <miaox@cn.fujitsu.com> #
- # #
- ################################################################################
- export TCID="cpuset_memory"
- export TST_TOTAL=18
- export TST_COUNT=1
- . cpuset_funcs.sh
- check
- exit_status=0
- nr_cpus=$NR_CPUS
- nr_mems=$N_NODES
- cpus_all="$(seq -s, 0 $((nr_cpus-1)))"
- mems_all="$(seq -s, 0 $((nr_mems-1)))"
- cpu_of_node0=0
- HUGEPAGESIZE=$(awk '/Hugepagesize/{ print $2 }' /proc/meminfo)
- HUGEPAGESIZE=$(($HUGEPAGESIZE * 1024))
- MEMORY_RESULT="$CPUSET_TMP/memory_result"
- # simple_getresult
- # $1 - cpuset_memory_test's pid
- # $2 - move cpuset_memory_test's pid to this cpuset
- simple_getresult()
- {
- sleep 1
- 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"
- }
- test1()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group parameter failed."
- return 1
- fi
- cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" &
- simple_getresult $! "$CPUSET/0"
- if [ "$node" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
- return 1
- fi
- }
- test2()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group parameter failed."
- return 1
- fi
- cpuset_memory_test --mmap-file >"$MEMORY_RESULT" &
- simple_getresult $! "$CPUSET/0"
- if [ "$node" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
- return 1
- fi
- }
- test3()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group parameter failed."
- return 1
- fi
- cpuset_memory_test --shm >"$MEMORY_RESULT" &
- simple_getresult $! "$CPUSET/0"
- if [ "$node" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
- return 1
- fi
- }
- test4()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group parameter failed."
- return 1
- fi
- cpuset_memory_test --mmap-lock1 >"$MEMORY_RESULT" &
- simple_getresult $! "$CPUSET/0"
- if [ "$node" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
- return 1
- fi
- }
- test5()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group parameter failed."
- return 1
- fi
- cpuset_memory_test --mmap-lock2 >"$MEMORY_RESULT" &
- simple_getresult $! "$CPUSET/0"
- if [ "$node" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
- return 1
- fi
- }
- # check whether the system supports hugetlbfs or not
- # return 0 - don't support hugetlbfs
- # 1 - support hugetlbfs
- check_hugetlbfs()
- {
- local fssupport=$(grep -w hugetlbfs /proc/filesystems 2>/dev/null | cut -f2)
- if [ "$fssupport" = "hugetlbfs" ]; then
- return 1
- else
- return 0
- fi
- }
- test6()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group parameter failed."
- return 1
- fi
- check_hugetlbfs
- if [ $? -eq 0 ]; then
- tst_resm TCONF "This system don't support hugetlbfs"
- return 0
- fi
- mkdir /hugetlb
- mount -t hugetlbfs none /hugetlb
- save_nr_hugepages=$(cat /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"
- umount /hugetlb
- rmdir /hugetlb
- echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
- 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
- if [ "$node" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
- return 1
- fi
- }
- test7()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group parameter failed."
- return 1
- fi
- check_hugetlbfs
- if [ $? -eq 0 ]; then
- tst_resm TCONF "This system don't support hugetlbfs"
- return 0
- fi
- mkdir /hugetlb
- mount -t hugetlbfs none /hugetlb
- save_nr_hugepages=$(cat /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"
- umount /hugetlb
- rmdir /hugetlb
- echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
- 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
- if [ "$node" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
- return 1
- fi
- }
- test8()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group parameter failed."
- return 1
- fi
- cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" &
- simple_getresult $! "$CPUSET/0"
- if [ "$node" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
- return 1
- fi
- }
- test9()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group parameter failed."
- return 1
- fi
- cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" &
- simple_getresult $! "$CPUSET/0"
- if [ "$node" != "1" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#1)."
- return 1
- fi
- }
- # talk2memory_test_for_case_10_11
- # $1 - cpuset_memory_test's pid
- # $2 - move cpuset_memory_test's pid to this cpuset
- # $3 - move cpuset_memory_test's pid to this cpuset(a new cpuset)
- talk2memory_test_for_case_10_11()
- {
- sleep 1
- echo $1 > "$2/tasks"
- /bin/kill -s SIGUSR1 $1
- sleep 1
- echo $1 > "$3/tasks"
- /bin/kill -s SIGUSR1 $1
- sleep 1
- /bin/kill -s SIGUSR1 $1
- sleep 1
- /bin/kill -s SIGINT $1
- wait $1
- }
- test10()
- {
- cpuset_set "$CPUSET/1" "$cpus_all" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group1's parameter failed."
- return 1
- fi
- cpuset_set "$CPUSET/2" "$cpus_all" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's parameter failed."
- return 1
- fi
- cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" &
- talk2memory_test_for_case_10_11 $! "$CPUSET/1" "$CPUSET/2"
- {
- read node0
- read node1
- read node2
- } < "$MEMORY_RESULT"
- if [ "$node0" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node0(Expect: Node#0)."
- return 1
- fi
- if [ "$node1" != "0" ]; then
- tst_resm TFAIL "Allocated memory was moved to the Node#$node1(Expect: Node#0)."
- return 1
- fi
- if [ "$node2" != "1" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node2(Expect: Node#1) after changing group."
- return 1
- fi
- }
- test11()
- {
- cpuset_set "$CPUSET/1" "$cpus_all" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group1's parameter failed."
- return 1
- fi
- cpuset_set "$CPUSET/2" "$cpus_all" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's parameter failed."
- return 1
- fi
- echo 1 > "$CPUSET/2/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's memory_migrate failed."
- return 1
- fi
- cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" &
- talk2memory_test_for_case_10_11 $! "$CPUSET/1" "$CPUSET/2"
- {
- read node0
- read node1
- read node2
- } < "$MEMORY_RESULT"
- if [ "$node0" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node0(Expect: Node#0)."
- return 1
- fi
- if [ "$node1" != "1" ]; then
- tst_resm TFAIL "Allocated memory was not moved to the Node#1(Result: Node#$node1)."
- return 1
- fi
- if [ "$node2" != "1" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node2(Expect: Node#1) after changing group."
- return 1
- fi
- }
- # talk2memory_test_for_case_12_13
- # $1 - cpuset_memory_test's pid
- # $2 - the test cpuset
- talk2memory_test_for_case_12_13()
- {
- sleep 1
- echo $1 > "$2/tasks"
- /bin/kill -s SIGUSR1 $1
- echo 0 > "$2/cpuset.mems" || return 1
- sleep 1
- /bin/kill -s SIGUSR1 $1
- sleep 1
- /bin/kill -s SIGUSR1 $1
- sleep 1
- /bin/kill -s SIGINT $1
- wait $1
- }
- test12()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group's parameter failed."
- return 1
- fi
- cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" &
- talk2memory_test_for_case_12_13 $! "$CPUSET/0"
- {
- read node0
- read node1
- } < "$MEMORY_RESULT"
- if [ "$node0" != "1" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node0(Expect: Node#1)."
- return 1
- fi
- if [ "$node1" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node1(Expect: Node#0) after changing mems."
- return 1
- fi
- }
- test13()
- {
- cpuset_set "$CPUSET/0" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group's parameter failed."
- return 1
- fi
- echo 1 > "$CPUSET/0/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group's memory_migrate failed."
- return 1
- fi
- cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" &
- talk2memory_test_for_case_12_13 $! "$CPUSET/0"
- {
- read node0
- read node1
- read node2
- } < "$MEMORY_RESULT"
- if [ "$node0" != "1" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node0(Expect: Node#1)."
- return 1
- fi
- if [ "$node1" != "0" ]; then
- tst_resm TFAIL "Allocated memory was not moved to the Node#0(Result: Node#$node1)."
- return 1
- fi
- if [ "$node2" != "0" ]; then
- tst_resm TFAIL "allocate memory on the Node#$node2(Expect: Node#0) after changing mems."
- return 1
- fi
- }
- # get the second thread's tid
- #$1 - pid
- get_the_second()
- {
- ls /proc/$1/task | (
- read tid1
- read tid2
- if [ "$1" -eq "$tid1" ]
- then
- echo $tid2
- else
- echo $tid1
- fi
- )
- }
- test14()
- {
- cpuset_set "$CPUSET/1" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group1's parameter failed."
- return 1
- fi
- cpuset_set "$CPUSET/2" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's parameter failed."
- return 1
- fi
- cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" &
- {
- local testpid=$!
- sleep 1
- local testtid=$(get_the_second $testpid)
- echo $testpid > "$CPUSET/1/tasks"
- /bin/kill -s SIGUSR1 $testpid
- echo $testtid > "$CPUSET/2/tasks"
- sleep 1
- /bin/kill -s SIGUSR2 $testpid
- sleep 1
- /bin/kill -s SIGINT $testpid
- wait $testpid
- }
- {
- read node0
- read node1
- } < "$MEMORY_RESULT"
- if [ "$node0" != "0" ]; then
- tst_resm TFAIL "Thread1 allocated memory on the Node#$node0(Expect: Node#0)."
- return 1
- fi
- if [ "$node1" != "1" ]; then
- tst_resm TFAIL "Thread2 allocated memory on the Node#$node1(Expect: Node#1)."
- return 1
- fi
- }
- test15()
- {
- cpuset_set "$CPUSET/1" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group1's parameter failed."
- return 1
- fi
- cpuset_set "$CPUSET/2" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's parameter failed."
- return 1
- fi
- echo 1 > "$CPUSET/2/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's memory_migrate failed."
- return 1
- fi
- cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" &
- {
- local testpid=$!
- sleep 1
- local testtid=$(get_the_second $testpid)
- echo $testpid > "$CPUSET/1/tasks"
- /bin/kill -s SIGUSR1 $testpid
- echo $testtid > "$CPUSET/2/tasks"
- sleep 1
- /bin/kill -s SIGUSR2 $testpid
- sleep 1
- /bin/kill -s SIGINT $testpid
- wait $testpid
- }
- {
- read node0
- read node1
- } < "$MEMORY_RESULT"
- if [ "$node0" != "0" ]; then
- tst_resm TFAIL "Thread1 allocated memory on the Node#$node0(Expect: Node#0)."
- return 1
- fi
- if [ "$node1" != "1" ]; then
- tst_resm TFAIL "Thread2 allocated memory on the Node#$node1(Expect: Node#1)."
- return 1
- fi
- }
- test16()
- {
- cpuset_set "$CPUSET/1" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group1's parameter failed."
- return 1
- fi
- cpuset_set "$CPUSET/2" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's parameter failed."
- return 1
- fi
- echo 1 > "$CPUSET/2/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's memory_migrate failed."
- return 1
- fi
- cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" &
- {
- local testpid=$!
- sleep 1
- local testtid=$(get_the_second $testpid)
- echo $testpid > "$CPUSET/1/tasks"
- /bin/kill -s SIGUSR1 $testpid
- echo $testtid > "$CPUSET/2/tasks"
- sleep 1
- echo 1 > "$CPUSET/1/cpuset.memory_migrate"
- sleep 1
- /bin/kill -s SIGUSR2 $testpid
- sleep 1
- /bin/kill -s SIGUSR1 $testpid
- sleep 1
- /bin/kill -s SIGUSR1 $testpid
- sleep 1
- /bin/kill -s SIGINT $testpid
- wait $testpid
- }
- {
- read node0
- read node1
- read node2
- } < "$MEMORY_RESULT"
- if [ "$node0" != "0" ]; then
- tst_resm TFAIL "Thread1 allocated memory on the Node#$node0(Expect: Node#0) first."
- return 1
- fi
- if [ "$node1" != "1" ]; then
- tst_resm TFAIL "Thread2 allocated memory on the Node#$node1(Expect: Node#1)."
- return 1
- fi
- if [ "$node2" != "0" ]; then
- tst_resm TFAIL "Thread1 allocated memory on the Node#$node2(Expect: Node#0) second."
- return 1
- fi
- }
- test17()
- {
- cpuset_set "$CPUSET/1" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group1's parameter failed."
- return 1
- fi
- cpuset_set "$CPUSET/2" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's parameter failed."
- return 1
- fi
- echo 1 > "$CPUSET/2/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's memory_migrate failed."
- return 1
- fi
- cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" &
- {
- local testpid=$!
- sleep 1
- local testtid=$(get_the_second $testpid)
- echo $testpid > "$CPUSET/1/tasks"
- /bin/kill -s SIGUSR1 $testpid
- echo $testtid > "$CPUSET/2/tasks"
- sleep 1
- echo 0 > "$CPUSET/1/cpuset.mems"
- sleep 1
- /bin/kill -s SIGUSR2 $testpid
- sleep 1
- /bin/kill -s SIGUSR1 $testpid
- sleep 1
- /bin/kill -s SIGUSR1 $testpid
- sleep 1
- /bin/kill -s SIGUSR2 $testpid
- sleep 1
- /bin/kill -s SIGUSR2 $testpid
- sleep 1
- /bin/kill -s SIGINT $testpid
- wait $testpid
- }
- {
- read node0
- read node1
- read node2
- read node3
- } < "$MEMORY_RESULT"
- if [ "$node0" != "1" ]; then
- tst_resm TFAIL "Thread1 allocated memory on the Node#$node0(Expect: Node#1) first."
- return 1
- fi
- if [ "$node1" != "1" ]; then
- tst_resm TFAIL "Thread2 allocated memory on the Node#$node1(Expect: Node#1) first."
- return 1
- fi
- if [ "$node2" != "0" ]; then
- tst_resm TFAIL "Thread1 allocated memory on the Node#$node2(Expect: Node#0) second"
- return 1
- fi
- if [ "$node3" != "1" ]; then
- tst_resm TFAIL "Thread2 allocated memory on the Node#$node3(Expect: Node#1) second"
- return 1
- fi
- }
- test18()
- {
- cpuset_set "$CPUSET/1" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group1's parameter failed."
- return 1
- fi
- echo 1 > "$CPUSET/1/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group1's memory_migrate failed."
- return 1
- fi
- cpuset_set "$CPUSET/2" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's parameter failed."
- return 1
- fi
- echo 1 > "$CPUSET/2/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr
- if [ $? -ne 0 ]; then
- cpuset_log_error $CPUSET_TMP/stderr
- tst_resm TFAIL "set general group2's memory_migrate failed."
- return 1
- fi
- cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" &
- {
- local testpid=$!
- sleep 1
- local testtid=$(get_the_second $testpid)
- echo $testpid > "$CPUSET/1/tasks"
- /bin/kill -s SIGUSR1 $testpid
- echo $testtid > "$CPUSET/2/tasks"
- sleep 1
- echo 0 > "$CPUSET/1/cpuset.mems"
- sleep 1
- /bin/kill -s SIGUSR2 $testpid
- sleep 1
- /bin/kill -s SIGUSR1 $testpid
- sleep 1
- /bin/kill -s SIGUSR1 $testpid
- sleep 1
- /bin/kill -s SIGUSR2 $testpid
- sleep 1
- /bin/kill -s SIGUSR2 $testpid
- sleep 1
- /bin/kill -s SIGINT $testpid
- wait $testpid
- }
- {
- read node0
- read node1
- read node2
- read node3
- } < "$MEMORY_RESULT"
- if [ "$node0" != "1" ]; then
- tst_resm TFAIL "Thread1 allocated memory on the Node#$node0(Expect: Node#1) first."
- return 1
- fi
- if [ "$node1" != "1" ]; then
- tst_resm TFAIL "Thread2 allocated memory on the Node#$node1(Expect: Node#1) first."
- return 1
- fi
- if [ "$node2" != "0" ]; then
- tst_resm TFAIL "Thread1 allocated memory on the Node#$node2(Expect: Node#0) second"
- return 1
- fi
- if [ "$node3" != "1" ]; then
- tst_resm TFAIL "Thread2 allocated memory on the Node#$node3(Expect: Node#1) second"
- return 1
- fi
- }
- for c in $(seq 1 $TST_TOTAL)
- do
- setup
- if [ $? -ne 0 ]; then
- exit_status=1
- else
- test$c
- if [ $? -ne 0 ]; then
- exit_status=1
- cleanup
- else
- cleanup
- if [ $? -ne 0 ]; then
- exit_status=1
- else
- tst_resm TPASS "Cpuset memory allocation test succeeded."
- fi
- fi
- fi
- TST_COUNT=$(($TST_COUNT + 1))
- done
- exit $exit_status
|