1#!/bin/sh 2 3################################################################################ 4# # 5# Copyright (c) 2009 FUJITSU LIMITED # 6# # 7# This program is free software; you can redistribute it and#or modify # 8# it under the terms of the GNU General Public License as published by # 9# the Free Software Foundation; either version 2 of the License, or # 10# (at your option) any later version. # 11# # 12# This program is distributed in the hope that it will be useful, but # 13# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # 14# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # 15# for more details. # 16# # 17# You should have received a copy of the GNU General Public License # 18# along with this program; if not, write to the Free Software # 19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # 20# # 21# Author: Miao Xie <miaox@cn.fujitsu.com> # 22# # 23################################################################################ 24 25export TCID="cpuset_memory" 26export TST_TOTAL=18 27export TST_COUNT=1 28 29. cpuset_funcs.sh 30 31check 32 33exit_status=0 34 35nr_cpus=$NR_CPUS 36nr_mems=$N_NODES 37 38cpus_all="$(seq -s, 0 $((nr_cpus-1)))" 39mems_all="$(seq -s, 0 $((nr_mems-1)))" 40 41cpu_of_node0=0 42 43HUGEPAGESIZE=$(awk '/Hugepagesize/{ print $2 }' /proc/meminfo) 44HUGEPAGESIZE=$(($HUGEPAGESIZE * 1024)) 45 46MEMORY_RESULT="$CPUSET_TMP/memory_result" 47 48# simple_getresult 49# $1 - cpuset_memory_test's pid 50# $2 - move cpuset_memory_test's pid to this cpuset 51simple_getresult() 52{ 53 sleep 1 54 echo $1 > "$2/tasks" 55 /bin/kill -s SIGUSR1 $1 56 sleep 1 57 /bin/kill -s SIGUSR1 $1 58 sleep 1 59 /bin/kill -s SIGINT $1 60 wait $1 61 read node < "$MEMORY_RESULT" 62} 63 64test1() 65{ 66 cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 67 if [ $? -ne 0 ]; then 68 cpuset_log_error $CPUSET_TMP/stderr 69 tst_resm TFAIL "set general group parameter failed." 70 return 1 71 fi 72 73 cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & 74 simple_getresult $! "$CPUSET/0" 75 if [ "$node" != "0" ]; then 76 tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." 77 return 1 78 fi 79} 80 81test2() 82{ 83 cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 84 if [ $? -ne 0 ]; then 85 cpuset_log_error $CPUSET_TMP/stderr 86 tst_resm TFAIL "set general group parameter failed." 87 return 1 88 fi 89 90 cpuset_memory_test --mmap-file >"$MEMORY_RESULT" & 91 simple_getresult $! "$CPUSET/0" 92 if [ "$node" != "0" ]; then 93 tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." 94 return 1 95 fi 96} 97 98test3() 99{ 100 cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 101 if [ $? -ne 0 ]; then 102 cpuset_log_error $CPUSET_TMP/stderr 103 tst_resm TFAIL "set general group parameter failed." 104 return 1 105 fi 106 107 cpuset_memory_test --shm >"$MEMORY_RESULT" & 108 simple_getresult $! "$CPUSET/0" 109 if [ "$node" != "0" ]; then 110 tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." 111 return 1 112 fi 113} 114 115test4() 116{ 117 cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 118 if [ $? -ne 0 ]; then 119 cpuset_log_error $CPUSET_TMP/stderr 120 tst_resm TFAIL "set general group parameter failed." 121 return 1 122 fi 123 124 cpuset_memory_test --mmap-lock1 >"$MEMORY_RESULT" & 125 simple_getresult $! "$CPUSET/0" 126 if [ "$node" != "0" ]; then 127 tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." 128 return 1 129 fi 130} 131 132test5() 133{ 134 cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 135 if [ $? -ne 0 ]; then 136 cpuset_log_error $CPUSET_TMP/stderr 137 tst_resm TFAIL "set general group parameter failed." 138 return 1 139 fi 140 141 cpuset_memory_test --mmap-lock2 >"$MEMORY_RESULT" & 142 simple_getresult $! "$CPUSET/0" 143 if [ "$node" != "0" ]; then 144 tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." 145 return 1 146 fi 147} 148 149# check whether the system supports hugetlbfs or not 150# return 0 - don't support hugetlbfs 151# 1 - support hugetlbfs 152check_hugetlbfs() 153{ 154 local fssupport=$(grep -w hugetlbfs /proc/filesystems 2>/dev/null | cut -f2) 155 156 if [ "$fssupport" = "hugetlbfs" ]; then 157 return 1 158 else 159 return 0 160 fi 161} 162 163test6() 164{ 165 cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 166 if [ $? -ne 0 ]; then 167 cpuset_log_error $CPUSET_TMP/stderr 168 tst_resm TFAIL "set general group parameter failed." 169 return 1 170 fi 171 172 check_hugetlbfs 173 if [ $? -eq 0 ]; then 174 tst_resm TCONF "This system don't support hugetlbfs" 175 return 0 176 fi 177 178 mkdir /hugetlb 179 mount -t hugetlbfs none /hugetlb 180 181 save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages) 182 echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages 183 184 cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" & 185 simple_getresult $! "$CPUSET/0" 186 187 umount /hugetlb 188 rmdir /hugetlb 189 190 echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages 191 if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then 192 tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)." 193 return 1 194 fi 195 196 if [ "$node" != "0" ]; then 197 tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." 198 return 1 199 fi 200} 201 202test7() 203{ 204 cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 205 if [ $? -ne 0 ]; then 206 cpuset_log_error $CPUSET_TMP/stderr 207 tst_resm TFAIL "set general group parameter failed." 208 return 1 209 fi 210 211 check_hugetlbfs 212 if [ $? -eq 0 ]; then 213 tst_resm TCONF "This system don't support hugetlbfs" 214 return 0 215 fi 216 217 mkdir /hugetlb 218 mount -t hugetlbfs none /hugetlb 219 220 save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages) 221 echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages 222 223 cpuset_memory_test --shm --hugepage -s $HUGEPAGESIZE --key=7 >"$MEMORY_RESULT" & 224 simple_getresult $! "$CPUSET/0" 225 226 umount /hugetlb 227 rmdir /hugetlb 228 229 echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages 230 if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then 231 tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)." 232 return 1 233 fi 234 235 if [ "$node" != "0" ]; then 236 tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." 237 return 1 238 fi 239} 240 241test8() 242{ 243 cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 244 if [ $? -ne 0 ]; then 245 cpuset_log_error $CPUSET_TMP/stderr 246 tst_resm TFAIL "set general group parameter failed." 247 return 1 248 fi 249 250 cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & 251 simple_getresult $! "$CPUSET/0" 252 if [ "$node" != "0" ]; then 253 tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." 254 return 1 255 fi 256} 257 258test9() 259{ 260 cpuset_set "$CPUSET/0" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr 261 if [ $? -ne 0 ]; then 262 cpuset_log_error $CPUSET_TMP/stderr 263 tst_resm TFAIL "set general group parameter failed." 264 return 1 265 fi 266 267 cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & 268 simple_getresult $! "$CPUSET/0" 269 if [ "$node" != "1" ]; then 270 tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#1)." 271 return 1 272 fi 273} 274 275# talk2memory_test_for_case_10_11 276# $1 - cpuset_memory_test's pid 277# $2 - move cpuset_memory_test's pid to this cpuset 278# $3 - move cpuset_memory_test's pid to this cpuset(a new cpuset) 279talk2memory_test_for_case_10_11() 280{ 281 sleep 1 282 echo $1 > "$2/tasks" 283 /bin/kill -s SIGUSR1 $1 284 sleep 1 285 echo $1 > "$3/tasks" 286 /bin/kill -s SIGUSR1 $1 287 sleep 1 288 /bin/kill -s SIGUSR1 $1 289 sleep 1 290 /bin/kill -s SIGINT $1 291 wait $1 292} 293 294test10() 295{ 296 cpuset_set "$CPUSET/1" "$cpus_all" "0" "0" 2> $CPUSET_TMP/stderr 297 if [ $? -ne 0 ]; then 298 cpuset_log_error $CPUSET_TMP/stderr 299 tst_resm TFAIL "set general group1's parameter failed." 300 return 1 301 fi 302 303 cpuset_set "$CPUSET/2" "$cpus_all" "1" "0" 2> $CPUSET_TMP/stderr 304 if [ $? -ne 0 ]; then 305 cpuset_log_error $CPUSET_TMP/stderr 306 tst_resm TFAIL "set general group2's parameter failed." 307 return 1 308 fi 309 310 cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" & 311 talk2memory_test_for_case_10_11 $! "$CPUSET/1" "$CPUSET/2" 312 { 313 read node0 314 read node1 315 read node2 316 } < "$MEMORY_RESULT" 317 318 if [ "$node0" != "0" ]; then 319 tst_resm TFAIL "allocate memory on the Node#$node0(Expect: Node#0)." 320 return 1 321 fi 322 if [ "$node1" != "0" ]; then 323 tst_resm TFAIL "Allocated memory was moved to the Node#$node1(Expect: Node#0)." 324 return 1 325 fi 326 if [ "$node2" != "1" ]; then 327 tst_resm TFAIL "allocate memory on the Node#$node2(Expect: Node#1) after changing group." 328 return 1 329 fi 330} 331 332test11() 333{ 334 cpuset_set "$CPUSET/1" "$cpus_all" "0" "0" 2> $CPUSET_TMP/stderr 335 if [ $? -ne 0 ]; then 336 cpuset_log_error $CPUSET_TMP/stderr 337 tst_resm TFAIL "set general group1's parameter failed." 338 return 1 339 fi 340 341 cpuset_set "$CPUSET/2" "$cpus_all" "1" "0" 2> $CPUSET_TMP/stderr 342 if [ $? -ne 0 ]; then 343 cpuset_log_error $CPUSET_TMP/stderr 344 tst_resm TFAIL "set general group2's parameter failed." 345 return 1 346 fi 347 348 echo 1 > "$CPUSET/2/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr 349 if [ $? -ne 0 ]; then 350 cpuset_log_error $CPUSET_TMP/stderr 351 tst_resm TFAIL "set general group2's memory_migrate failed." 352 return 1 353 fi 354 355 cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" & 356 talk2memory_test_for_case_10_11 $! "$CPUSET/1" "$CPUSET/2" 357 { 358 read node0 359 read node1 360 read node2 361 } < "$MEMORY_RESULT" 362 363 if [ "$node0" != "0" ]; then 364 tst_resm TFAIL "allocate memory on the Node#$node0(Expect: Node#0)." 365 return 1 366 fi 367 if [ "$node1" != "1" ]; then 368 tst_resm TFAIL "Allocated memory was not moved to the Node#1(Result: Node#$node1)." 369 return 1 370 fi 371 if [ "$node2" != "1" ]; then 372 tst_resm TFAIL "allocate memory on the Node#$node2(Expect: Node#1) after changing group." 373 return 1 374 fi 375} 376 377 378# talk2memory_test_for_case_12_13 379# $1 - cpuset_memory_test's pid 380# $2 - the test cpuset 381talk2memory_test_for_case_12_13() 382{ 383 sleep 1 384 echo $1 > "$2/tasks" 385 /bin/kill -s SIGUSR1 $1 386 387 echo 0 > "$2/cpuset.mems" || return 1 388 sleep 1 389 /bin/kill -s SIGUSR1 $1 390 sleep 1 391 /bin/kill -s SIGUSR1 $1 392 sleep 1 393 /bin/kill -s SIGINT $1 394 wait $1 395} 396 397 398test12() 399{ 400 cpuset_set "$CPUSET/0" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr 401 if [ $? -ne 0 ]; then 402 cpuset_log_error $CPUSET_TMP/stderr 403 tst_resm TFAIL "set general group's parameter failed." 404 return 1 405 fi 406 407 cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & 408 talk2memory_test_for_case_12_13 $! "$CPUSET/0" 409 410 { 411 read node0 412 read node1 413 } < "$MEMORY_RESULT" 414 415 if [ "$node0" != "1" ]; then 416 tst_resm TFAIL "allocate memory on the Node#$node0(Expect: Node#1)." 417 return 1 418 fi 419 if [ "$node1" != "0" ]; then 420 tst_resm TFAIL "allocate memory on the Node#$node1(Expect: Node#0) after changing mems." 421 return 1 422 fi 423} 424 425 426test13() 427{ 428 cpuset_set "$CPUSET/0" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr 429 if [ $? -ne 0 ]; then 430 cpuset_log_error $CPUSET_TMP/stderr 431 tst_resm TFAIL "set general group's parameter failed." 432 return 1 433 fi 434 435 echo 1 > "$CPUSET/0/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr 436 if [ $? -ne 0 ]; then 437 cpuset_log_error $CPUSET_TMP/stderr 438 tst_resm TFAIL "set general group's memory_migrate failed." 439 return 1 440 fi 441 442 443 cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" & 444 talk2memory_test_for_case_12_13 $! "$CPUSET/0" 445 446 { 447 read node0 448 read node1 449 read node2 450 } < "$MEMORY_RESULT" 451 452 if [ "$node0" != "1" ]; then 453 tst_resm TFAIL "allocate memory on the Node#$node0(Expect: Node#1)." 454 return 1 455 fi 456 if [ "$node1" != "0" ]; then 457 tst_resm TFAIL "Allocated memory was not moved to the Node#0(Result: Node#$node1)." 458 return 1 459 fi 460 if [ "$node2" != "0" ]; then 461 tst_resm TFAIL "allocate memory on the Node#$node2(Expect: Node#0) after changing mems." 462 return 1 463 fi 464} 465 466# get the second thread's tid 467#$1 - pid 468get_the_second() 469{ 470 ls /proc/$1/task | ( 471 read tid1 472 read tid2 473 if [ "$1" -eq "$tid1" ] 474 then 475 echo $tid2 476 else 477 echo $tid1 478 fi 479 ) 480} 481 482test14() 483{ 484 cpuset_set "$CPUSET/1" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 485 if [ $? -ne 0 ]; then 486 cpuset_log_error $CPUSET_TMP/stderr 487 tst_resm TFAIL "set general group1's parameter failed." 488 return 1 489 fi 490 491 cpuset_set "$CPUSET/2" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr 492 if [ $? -ne 0 ]; then 493 cpuset_log_error $CPUSET_TMP/stderr 494 tst_resm TFAIL "set general group2's parameter failed." 495 return 1 496 fi 497 498 cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & 499 { 500 local testpid=$! 501 sleep 1 502 local testtid=$(get_the_second $testpid) 503 504 echo $testpid > "$CPUSET/1/tasks" 505 /bin/kill -s SIGUSR1 $testpid 506 507 echo $testtid > "$CPUSET/2/tasks" 508 sleep 1 509 /bin/kill -s SIGUSR2 $testpid 510 sleep 1 511 /bin/kill -s SIGINT $testpid 512 wait $testpid 513 } 514 515 { 516 read node0 517 read node1 518 } < "$MEMORY_RESULT" 519 520 if [ "$node0" != "0" ]; then 521 tst_resm TFAIL "Thread1 allocated memory on the Node#$node0(Expect: Node#0)." 522 return 1 523 fi 524 if [ "$node1" != "1" ]; then 525 tst_resm TFAIL "Thread2 allocated memory on the Node#$node1(Expect: Node#1)." 526 return 1 527 fi 528} 529 530test15() 531{ 532 cpuset_set "$CPUSET/1" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 533 if [ $? -ne 0 ]; then 534 cpuset_log_error $CPUSET_TMP/stderr 535 tst_resm TFAIL "set general group1's parameter failed." 536 return 1 537 fi 538 539 cpuset_set "$CPUSET/2" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr 540 if [ $? -ne 0 ]; then 541 cpuset_log_error $CPUSET_TMP/stderr 542 tst_resm TFAIL "set general group2's parameter failed." 543 return 1 544 fi 545 546 echo 1 > "$CPUSET/2/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr 547 if [ $? -ne 0 ]; then 548 cpuset_log_error $CPUSET_TMP/stderr 549 tst_resm TFAIL "set general group2's memory_migrate failed." 550 return 1 551 fi 552 553 554 cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & 555 { 556 local testpid=$! 557 sleep 1 558 local testtid=$(get_the_second $testpid) 559 560 echo $testpid > "$CPUSET/1/tasks" 561 /bin/kill -s SIGUSR1 $testpid 562 563 echo $testtid > "$CPUSET/2/tasks" 564 sleep 1 565 /bin/kill -s SIGUSR2 $testpid 566 sleep 1 567 /bin/kill -s SIGINT $testpid 568 wait $testpid 569 } 570 571 { 572 read node0 573 read node1 574 } < "$MEMORY_RESULT" 575 576 if [ "$node0" != "0" ]; then 577 tst_resm TFAIL "Thread1 allocated memory on the Node#$node0(Expect: Node#0)." 578 return 1 579 fi 580 if [ "$node1" != "1" ]; then 581 tst_resm TFAIL "Thread2 allocated memory on the Node#$node1(Expect: Node#1)." 582 return 1 583 fi 584} 585 586test16() 587{ 588 cpuset_set "$CPUSET/1" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr 589 if [ $? -ne 0 ]; then 590 cpuset_log_error $CPUSET_TMP/stderr 591 tst_resm TFAIL "set general group1's parameter failed." 592 return 1 593 fi 594 595 cpuset_set "$CPUSET/2" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr 596 if [ $? -ne 0 ]; then 597 cpuset_log_error $CPUSET_TMP/stderr 598 tst_resm TFAIL "set general group2's parameter failed." 599 return 1 600 fi 601 602 echo 1 > "$CPUSET/2/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr 603 if [ $? -ne 0 ]; then 604 cpuset_log_error $CPUSET_TMP/stderr 605 tst_resm TFAIL "set general group2's memory_migrate failed." 606 return 1 607 fi 608 609 610 cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & 611 { 612 local testpid=$! 613 sleep 1 614 local testtid=$(get_the_second $testpid) 615 616 echo $testpid > "$CPUSET/1/tasks" 617 /bin/kill -s SIGUSR1 $testpid 618 619 echo $testtid > "$CPUSET/2/tasks" 620 sleep 1 621 echo 1 > "$CPUSET/1/cpuset.memory_migrate" 622 sleep 1 623 /bin/kill -s SIGUSR2 $testpid 624 sleep 1 625 /bin/kill -s SIGUSR1 $testpid 626 sleep 1 627 /bin/kill -s SIGUSR1 $testpid 628 sleep 1 629 /bin/kill -s SIGINT $testpid 630 wait $testpid 631 } 632 633 { 634 read node0 635 read node1 636 read node2 637 } < "$MEMORY_RESULT" 638 639 if [ "$node0" != "0" ]; then 640 tst_resm TFAIL "Thread1 allocated memory on the Node#$node0(Expect: Node#0) first." 641 return 1 642 fi 643 if [ "$node1" != "1" ]; then 644 tst_resm TFAIL "Thread2 allocated memory on the Node#$node1(Expect: Node#1)." 645 return 1 646 fi 647 if [ "$node2" != "0" ]; then 648 tst_resm TFAIL "Thread1 allocated memory on the Node#$node2(Expect: Node#0) second." 649 return 1 650 fi 651} 652 653test17() 654{ 655 cpuset_set "$CPUSET/1" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr 656 if [ $? -ne 0 ]; then 657 cpuset_log_error $CPUSET_TMP/stderr 658 tst_resm TFAIL "set general group1's parameter failed." 659 return 1 660 fi 661 662 cpuset_set "$CPUSET/2" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr 663 if [ $? -ne 0 ]; then 664 cpuset_log_error $CPUSET_TMP/stderr 665 tst_resm TFAIL "set general group2's parameter failed." 666 return 1 667 fi 668 669 echo 1 > "$CPUSET/2/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr 670 if [ $? -ne 0 ]; then 671 cpuset_log_error $CPUSET_TMP/stderr 672 tst_resm TFAIL "set general group2's memory_migrate failed." 673 return 1 674 fi 675 676 cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & 677 { 678 local testpid=$! 679 sleep 1 680 local testtid=$(get_the_second $testpid) 681 682 echo $testpid > "$CPUSET/1/tasks" 683 /bin/kill -s SIGUSR1 $testpid 684 685 echo $testtid > "$CPUSET/2/tasks" 686 sleep 1 687 echo 0 > "$CPUSET/1/cpuset.mems" 688 sleep 1 689 /bin/kill -s SIGUSR2 $testpid 690 sleep 1 691 /bin/kill -s SIGUSR1 $testpid 692 sleep 1 693 /bin/kill -s SIGUSR1 $testpid 694 sleep 1 695 /bin/kill -s SIGUSR2 $testpid 696 sleep 1 697 /bin/kill -s SIGUSR2 $testpid 698 sleep 1 699 /bin/kill -s SIGINT $testpid 700 wait $testpid 701 } 702 703 { 704 read node0 705 read node1 706 read node2 707 read node3 708 } < "$MEMORY_RESULT" 709 710 if [ "$node0" != "1" ]; then 711 tst_resm TFAIL "Thread1 allocated memory on the Node#$node0(Expect: Node#1) first." 712 return 1 713 fi 714 if [ "$node1" != "1" ]; then 715 tst_resm TFAIL "Thread2 allocated memory on the Node#$node1(Expect: Node#1) first." 716 return 1 717 fi 718 if [ "$node2" != "0" ]; then 719 tst_resm TFAIL "Thread1 allocated memory on the Node#$node2(Expect: Node#0) second" 720 return 1 721 fi 722 if [ "$node3" != "1" ]; then 723 tst_resm TFAIL "Thread2 allocated memory on the Node#$node3(Expect: Node#1) second" 724 return 1 725 fi 726} 727 728test18() 729{ 730 cpuset_set "$CPUSET/1" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr 731 if [ $? -ne 0 ]; then 732 cpuset_log_error $CPUSET_TMP/stderr 733 tst_resm TFAIL "set general group1's parameter failed." 734 return 1 735 fi 736 737 echo 1 > "$CPUSET/1/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr 738 if [ $? -ne 0 ]; then 739 cpuset_log_error $CPUSET_TMP/stderr 740 tst_resm TFAIL "set general group1's memory_migrate failed." 741 return 1 742 fi 743 744 cpuset_set "$CPUSET/2" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr 745 if [ $? -ne 0 ]; then 746 cpuset_log_error $CPUSET_TMP/stderr 747 tst_resm TFAIL "set general group2's parameter failed." 748 return 1 749 fi 750 751 echo 1 > "$CPUSET/2/cpuset.memory_migrate" 2> $CPUSET_TMP/stderr 752 if [ $? -ne 0 ]; then 753 cpuset_log_error $CPUSET_TMP/stderr 754 tst_resm TFAIL "set general group2's memory_migrate failed." 755 return 1 756 fi 757 758 cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & 759 { 760 local testpid=$! 761 sleep 1 762 local testtid=$(get_the_second $testpid) 763 764 echo $testpid > "$CPUSET/1/tasks" 765 /bin/kill -s SIGUSR1 $testpid 766 767 echo $testtid > "$CPUSET/2/tasks" 768 sleep 1 769 echo 0 > "$CPUSET/1/cpuset.mems" 770 sleep 1 771 /bin/kill -s SIGUSR2 $testpid 772 sleep 1 773 /bin/kill -s SIGUSR1 $testpid 774 sleep 1 775 /bin/kill -s SIGUSR1 $testpid 776 sleep 1 777 /bin/kill -s SIGUSR2 $testpid 778 sleep 1 779 /bin/kill -s SIGUSR2 $testpid 780 sleep 1 781 /bin/kill -s SIGINT $testpid 782 wait $testpid 783 } 784 785 { 786 read node0 787 read node1 788 read node2 789 read node3 790 } < "$MEMORY_RESULT" 791 792 if [ "$node0" != "1" ]; then 793 tst_resm TFAIL "Thread1 allocated memory on the Node#$node0(Expect: Node#1) first." 794 return 1 795 fi 796 if [ "$node1" != "1" ]; then 797 tst_resm TFAIL "Thread2 allocated memory on the Node#$node1(Expect: Node#1) first." 798 return 1 799 fi 800 if [ "$node2" != "0" ]; then 801 tst_resm TFAIL "Thread1 allocated memory on the Node#$node2(Expect: Node#0) second" 802 return 1 803 fi 804 if [ "$node3" != "1" ]; then 805 tst_resm TFAIL "Thread2 allocated memory on the Node#$node3(Expect: Node#1) second" 806 return 1 807 fi 808} 809 810for c in $(seq 1 $TST_TOTAL) 811do 812 setup 813 if [ $? -ne 0 ]; then 814 exit_status=1 815 else 816 test$c 817 if [ $? -ne 0 ]; then 818 exit_status=1 819 cleanup 820 else 821 cleanup 822 if [ $? -ne 0 ]; then 823 exit_status=1 824 else 825 tst_resm TPASS "Cpuset memory allocation test succeeded." 826 fi 827 fi 828 fi 829 TST_COUNT=$(($TST_COUNT + 1)) 830done 831 832exit $exit_status 833 834