1f08c3bdfSopenharmony_ci#!/bin/bash 2f08c3bdfSopenharmony_ci# 3f08c3bdfSopenharmony_ci# Test program for memory error handling for hugepages 4f08c3bdfSopenharmony_ci# Usage: ./run-huge-test.sh hugetlbfs_directory 5f08c3bdfSopenharmony_ci# Author: Naoya Horiguchi 6f08c3bdfSopenharmony_ci 7f08c3bdfSopenharmony_ciusage() 8f08c3bdfSopenharmony_ci{ 9f08c3bdfSopenharmony_ci echo "Usage: ./run-huge-test.sh hugetlbfs_directory" && exit 1 10f08c3bdfSopenharmony_ci} 11f08c3bdfSopenharmony_ci 12f08c3bdfSopenharmony_cihtdir=$1 13f08c3bdfSopenharmony_ci[ $# -ne 1 ] && usage 14f08c3bdfSopenharmony_ci[ ! -d $htdir ] && usage 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_cirm -rf $htdir/test* 17f08c3bdfSopenharmony_ciecho 1000 > /proc/sys/vm/nr_hugepages 18f08c3bdfSopenharmony_ci 19f08c3bdfSopenharmony_cinum=0 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_ciexec_testcase() { 22f08c3bdfSopenharmony_ci error=0 23f08c3bdfSopenharmony_ci echo "TestCase $@" 24f08c3bdfSopenharmony_ci hpage_size=$1 25f08c3bdfSopenharmony_ci hpage_target=$2 26f08c3bdfSopenharmony_ci num=$7 27f08c3bdfSopenharmony_ci 28f08c3bdfSopenharmony_ci if [ "$3" = "head" ] ; then 29f08c3bdfSopenharmony_ci hpage_target_offset=0 30f08c3bdfSopenharmony_ci elif [ "$3" = "tail" ] ; then 31f08c3bdfSopenharmony_ci hpage_target_offset=1 32f08c3bdfSopenharmony_ci else 33f08c3bdfSopenharmony_ci error=1 34f08c3bdfSopenharmony_ci fi 35f08c3bdfSopenharmony_ci hpage_target=$((hpage_target * 512 + hpage_target_offset)) 36f08c3bdfSopenharmony_ci 37f08c3bdfSopenharmony_ci if [ "$4" = "early" ] ; then 38f08c3bdfSopenharmony_ci process_type="-e" 39f08c3bdfSopenharmony_ci elif [ "$4" = "late_touch" ] ; then 40f08c3bdfSopenharmony_ci process_type="" 41f08c3bdfSopenharmony_ci elif [ "$4" = "late_avoid" ] ; then 42f08c3bdfSopenharmony_ci process_type="-a" 43f08c3bdfSopenharmony_ci else 44f08c3bdfSopenharmony_ci error=1 45f08c3bdfSopenharmony_ci fi 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ci if [ "$5" = "anonymous" ] ; then 48f08c3bdfSopenharmony_ci file_type="-A" 49f08c3bdfSopenharmony_ci elif [ "$5" = "file" ] ; then 50f08c3bdfSopenharmony_ci file_type="-f $num" 51f08c3bdfSopenharmony_ci elif [ "$5" = "shm" ] ; then 52f08c3bdfSopenharmony_ci file_type="-S" 53f08c3bdfSopenharmony_ci else 54f08c3bdfSopenharmony_ci error=1 55f08c3bdfSopenharmony_ci fi 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_ci if [ "$6" = "fork_shared" ] ; then 58f08c3bdfSopenharmony_ci share_type="-F" 59f08c3bdfSopenharmony_ci elif [ "$6" = "fork_private_nocow" ] ; then 60f08c3bdfSopenharmony_ci share_type="-Fp" 61f08c3bdfSopenharmony_ci elif [ "$6" = "fork_private_cow" ] ; then 62f08c3bdfSopenharmony_ci share_type="-Fpc" 63f08c3bdfSopenharmony_ci else 64f08c3bdfSopenharmony_ci error=1 65f08c3bdfSopenharmony_ci fi 66f08c3bdfSopenharmony_ci 67f08c3bdfSopenharmony_ci command="./thugetlb -x -m $hpage_size -o $hpage_target $process_type $file_type $share_type $htdir &" 68f08c3bdfSopenharmony_ci echo $command 69f08c3bdfSopenharmony_ci eval $command 70f08c3bdfSopenharmony_ci wait $! 71f08c3bdfSopenharmony_ci echo "" 72f08c3bdfSopenharmony_ci 73f08c3bdfSopenharmony_ci return 0 74f08c3bdfSopenharmony_ci} 75f08c3bdfSopenharmony_ci 76f08c3bdfSopenharmony_cinum=$((num+1)) 77f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "early" "file" "fork_shared" $num 78f08c3bdfSopenharmony_cinum=$((num+1)) 79f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "early" "file" "fork_private_nocow" $num 80f08c3bdfSopenharmony_cinum=$((num+1)) 81f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "early" "file" "fork_private_cow" $num 82f08c3bdfSopenharmony_cinum=$((num+1)) 83f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "early" "shm" "fork_shared" $num 84f08c3bdfSopenharmony_cinum=$((num+1)) 85f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "early" "anonymous" "fork_shared" $num 86f08c3bdfSopenharmony_cinum=$((num+1)) 87f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "early" "anonymous" "fork_private_nocow" $num 88f08c3bdfSopenharmony_cinum=$((num+1)) 89f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "early" "anonymous" "fork_private_cow" $num 90f08c3bdfSopenharmony_ci 91f08c3bdfSopenharmony_cinum=$((num+1)) 92f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_touch" "file" "fork_shared" $num 93f08c3bdfSopenharmony_cinum=$((num+1)) 94f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_touch" "file" "fork_private_nocow" $num 95f08c3bdfSopenharmony_cinum=$((num+1)) 96f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_touch" "file" "fork_private_cow" $num 97f08c3bdfSopenharmony_cinum=$((num+1)) 98f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_touch" "shm" "fork_shared" $num 99f08c3bdfSopenharmony_cinum=$((num+1)) 100f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_touch" "anonymous" "fork_shared" $num 101f08c3bdfSopenharmony_cinum=$((num+1)) 102f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_touch" "anonymous" "fork_private_nocow" $num 103f08c3bdfSopenharmony_cinum=$((num+1)) 104f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_touch" "anonymous" "fork_private_cow" $num 105f08c3bdfSopenharmony_ci 106f08c3bdfSopenharmony_cinum=$((num+1)) 107f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_avoid" "file" "fork_shared" $num 108f08c3bdfSopenharmony_cinum=$((num+1)) 109f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_avoid" "file" "fork_private_nocow" $num 110f08c3bdfSopenharmony_cinum=$((num+1)) 111f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_avoid" "file" "fork_private_cow" $num 112f08c3bdfSopenharmony_cinum=$((num+1)) 113f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_avoid" "shm" "fork_shared" $num 114f08c3bdfSopenharmony_cinum=$((num+1)) 115f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_avoid" "anonymous" "fork_shared" $num 116f08c3bdfSopenharmony_cinum=$((num+1)) 117f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_avoid" "anonymous" "fork_private_nocow" $num 118f08c3bdfSopenharmony_cinum=$((num+1)) 119f08c3bdfSopenharmony_ciexec_testcase 2 1 "head" "late_avoid" "anonymous" "fork_private_cow" $num 120f08c3bdfSopenharmony_ci 121f08c3bdfSopenharmony_cinum=$((num+1)) 122f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "early" "file" "fork_shared" $num 123f08c3bdfSopenharmony_cinum=$((num+1)) 124f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "early" "file" "fork_private_nocow" $num 125f08c3bdfSopenharmony_cinum=$((num+1)) 126f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "early" "file" "fork_private_cow" $num 127f08c3bdfSopenharmony_cinum=$((num+1)) 128f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "early" "shm" "fork_shared" $num 129f08c3bdfSopenharmony_cinum=$((num+1)) 130f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "early" "anonymous" "fork_shared" $num 131f08c3bdfSopenharmony_cinum=$((num+1)) 132f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "early" "anonymous" "fork_private_nocow" $num 133f08c3bdfSopenharmony_cinum=$((num+1)) 134f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "early" "anonymous" "fork_private_cow" $num 135f08c3bdfSopenharmony_ci 136f08c3bdfSopenharmony_cinum=$((num+1)) 137f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_touch" "file" "fork_shared" $num 138f08c3bdfSopenharmony_cinum=$((num+1)) 139f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_touch" "file" "fork_private_nocow" $num 140f08c3bdfSopenharmony_cinum=$((num+1)) 141f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_touch" "file" "fork_private_cow" $num 142f08c3bdfSopenharmony_cinum=$((num+1)) 143f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_touch" "shm" "fork_shared" $num 144f08c3bdfSopenharmony_cinum=$((num+1)) 145f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_touch" "anonymous" "fork_shared" $num 146f08c3bdfSopenharmony_cinum=$((num+1)) 147f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_touch" "anonymous" "fork_private_nocow" $num 148f08c3bdfSopenharmony_cinum=$((num+1)) 149f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_touch" "anonymous" "fork_private_cow" $num 150f08c3bdfSopenharmony_ci 151f08c3bdfSopenharmony_cinum=$((num+1)) 152f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_avoid" "file" "fork_shared" $num 153f08c3bdfSopenharmony_cinum=$((num+1)) 154f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_avoid" "file" "fork_private_nocow" $num 155f08c3bdfSopenharmony_cinum=$((num+1)) 156f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_avoid" "file" "fork_private_cow" $num 157f08c3bdfSopenharmony_cinum=$((num+1)) 158f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_avoid" "shm" "fork_shared" $num 159f08c3bdfSopenharmony_cinum=$((num+1)) 160f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_avoid" "anonymous" "fork_shared" $num 161f08c3bdfSopenharmony_cinum=$((num+1)) 162f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_avoid" "anonymous" "fork_private_nocow" $num 163f08c3bdfSopenharmony_cinum=$((num+1)) 164f08c3bdfSopenharmony_ciexec_testcase 2 1 "tail" "late_avoid" "anonymous" "fork_private_cow" $num 165f08c3bdfSopenharmony_ci 166f08c3bdfSopenharmony_ci# free IPC semaphores used by thugetlb.c 167f08c3bdfSopenharmony_ciipcs -s|grep $USER|cut -f2 -d' '|xargs ipcrm sem 168f08c3bdfSopenharmony_ci 169