1f08c3bdfSopenharmony_ci#! /bin/bash 2f08c3bdfSopenharmony_ci# 3f08c3bdfSopenharmony_ci# Stress test driver for Linux MCA High Level Handlers 4f08c3bdfSopenharmony_ci# 5f08c3bdfSopenharmony_ci# This program is free software; you can redistribute it and/or 6f08c3bdfSopenharmony_ci# modify it under the terms of the GNU General Public 7f08c3bdfSopenharmony_ci# License as published by the Free Software Foundation; version 8f08c3bdfSopenharmony_ci# 2. 9f08c3bdfSopenharmony_ci# 10f08c3bdfSopenharmony_ci# This program is distributed in the hope that it will be useful, 11f08c3bdfSopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of 12f08c3bdfSopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13f08c3bdfSopenharmony_ci# General Public License for more details. 14f08c3bdfSopenharmony_ci# 15f08c3bdfSopenharmony_ci# You should find a copy of v2 of the GNU General Public License somewhere 16f08c3bdfSopenharmony_ci# on your Linux system; if not, write to the Free Software Foundation, 17f08c3bdfSopenharmony_ci# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18f08c3bdfSopenharmony_ci# 19f08c3bdfSopenharmony_ci# Copyright (C) 2009, Intel Corp. 20f08c3bdfSopenharmony_ci# Author: Haicheng Li <haicheng.li@intel.com> 21f08c3bdfSopenharmony_ci# 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_ci#set -x 24f08c3bdfSopenharmony_cisd=$(dirname "$0") 25f08c3bdfSopenharmony_ciexport ROOT=`(cd $sd/..; pwd)` 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci. $ROOT/lib/mce.sh 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ciDEBUG=0 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_cisilent_exec() 32f08c3bdfSopenharmony_ci{ 33f08c3bdfSopenharmony_ci local cmd=$@ 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_ci if [ $DEBUG -eq 0 ]; then 36f08c3bdfSopenharmony_ci $cmd > /dev/null 2>&1 37f08c3bdfSopenharmony_ci else 38f08c3bdfSopenharmony_ci $cmd 39f08c3bdfSopenharmony_ci fi 40f08c3bdfSopenharmony_ci return $? 41f08c3bdfSopenharmony_ci} 42f08c3bdfSopenharmony_ci 43f08c3bdfSopenharmony_cisilent_exec_background() 44f08c3bdfSopenharmony_ci{ 45f08c3bdfSopenharmony_ci local cmd=$@ 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ci if [ $DEBUG -eq 0 ]; then 48f08c3bdfSopenharmony_ci $cmd > /dev/null 2>&1 & 49f08c3bdfSopenharmony_ci else 50f08c3bdfSopenharmony_ci $cmd & 51f08c3bdfSopenharmony_ci fi 52f08c3bdfSopenharmony_ci return $? 53f08c3bdfSopenharmony_ci} 54f08c3bdfSopenharmony_ci 55f08c3bdfSopenharmony_ci_print() 56f08c3bdfSopenharmony_ci{ 57f08c3bdfSopenharmony_ci echo $* > $g_tty 58f08c3bdfSopenharmony_ci} 59f08c3bdfSopenharmony_ci 60f08c3bdfSopenharmony_cidbp() 61f08c3bdfSopenharmony_ci{ 62f08c3bdfSopenharmony_ci [ $DEBUG -ne 1 ] && return 63f08c3bdfSopenharmony_ci _print -en "\\033[0;33m" # set font color as yellow 64f08c3bdfSopenharmony_ci _print "[debug] $*" > $g_tty 65f08c3bdfSopenharmony_ci echo "[debug] $*" >> $g_logfile 66f08c3bdfSopenharmony_ci _print -en "\\033[0;39m" # restore font color to normal 67f08c3bdfSopenharmony_ci} 68f08c3bdfSopenharmony_ci 69f08c3bdfSopenharmony_cilog() 70f08c3bdfSopenharmony_ci{ 71f08c3bdfSopenharmony_ci _print -en "\\033[0;33m" # set font color as yellow 72f08c3bdfSopenharmony_ci _print "[info] $*" > $g_tty 73f08c3bdfSopenharmony_ci echo "[info] $*" >> $g_logfile 74f08c3bdfSopenharmony_ci _print -en "\\033[0;39m" # restore font color to normal 75f08c3bdfSopenharmony_ci} 76f08c3bdfSopenharmony_ci 77f08c3bdfSopenharmony_cibegin() 78f08c3bdfSopenharmony_ci{ 79f08c3bdfSopenharmony_ci _print -n "$*" > $g_tty 80f08c3bdfSopenharmony_ci _print -en "\\033[0;32m" # set font color as green 81f08c3bdfSopenharmony_ci _print -e "\t [start]" > $g_tty 82f08c3bdfSopenharmony_ci echo -e "$* \t [start]" >> $g_logfile 83f08c3bdfSopenharmony_ci _print -en "\\033[0;39m" # restore font color to normal 84f08c3bdfSopenharmony_ci} 85f08c3bdfSopenharmony_ci 86f08c3bdfSopenharmony_ciend() 87f08c3bdfSopenharmony_ci{ 88f08c3bdfSopenharmony_ci _print -n "$*" > $g_tty 89f08c3bdfSopenharmony_ci _print -en "\\033[0;32m" # set font color as green 90f08c3bdfSopenharmony_ci _print -e "\t [done]" > $g_tty 91f08c3bdfSopenharmony_ci echo -e "$* \t [done]" >> $g_logfile 92f08c3bdfSopenharmony_ci _print -en "\\033[0;39m" # restore font color to normal 93f08c3bdfSopenharmony_ci} 94f08c3bdfSopenharmony_ci 95f08c3bdfSopenharmony_cierr() 96f08c3bdfSopenharmony_ci{ 97f08c3bdfSopenharmony_ci _print -en "\\033[0;31m" # set font color as red 98f08c3bdfSopenharmony_ci echo > $g_tty 99f08c3bdfSopenharmony_ci echo "Test aborted by unexpected error!" > $g_tty 100f08c3bdfSopenharmony_ci _print "[error] !!! $* !!!" > $g_tty 101f08c3bdfSopenharmony_ci echo > $g_tty 102f08c3bdfSopenharmony_ci echo "Test aborted by unexpected error!" >> $g_result 103f08c3bdfSopenharmony_ci echo "[error] !!! $* !!!" >> $g_result 104f08c3bdfSopenharmony_ci echo "[error] !!! $* !!!" >> $g_logfile 105f08c3bdfSopenharmony_ci _print -en "\\033[0;39m" # restore font color to normal 106f08c3bdfSopenharmony_ci exit 1 107f08c3bdfSopenharmony_ci} 108f08c3bdfSopenharmony_ci 109f08c3bdfSopenharmony_cidie() 110f08c3bdfSopenharmony_ci{ 111f08c3bdfSopenharmony_ci err $@ 112f08c3bdfSopenharmony_ci} 113f08c3bdfSopenharmony_ci 114f08c3bdfSopenharmony_ciinvalid() 115f08c3bdfSopenharmony_ci{ 116f08c3bdfSopenharmony_ci _print -en "\\033[0;31m" # set font color as red 117f08c3bdfSopenharmony_ci echo > $g_tty 118f08c3bdfSopenharmony_ci echo "Test aborted by unexpected error!" > $g_tty 119f08c3bdfSopenharmony_ci _print "[error] !!! $* !!!" > $g_tty 120f08c3bdfSopenharmony_ci echo > $g_tty 121f08c3bdfSopenharmony_ci echo "Try \`./hwposion -h\` for more information." > $g_tty 122f08c3bdfSopenharmony_ci echo > $g_tty 123f08c3bdfSopenharmony_ci echo "Test aborted by unexpected error!" >> $g_result 124f08c3bdfSopenharmony_ci echo "[error] !!! $* !!!" >> $g_result 125f08c3bdfSopenharmony_ci echo "[error] !!! $* !!!" >> $g_logfile 126f08c3bdfSopenharmony_ci _print -en "\\033[0;39m" # restore font color to normal 127f08c3bdfSopenharmony_ci exit 1 128f08c3bdfSopenharmony_ci} 129f08c3bdfSopenharmony_ci 130f08c3bdfSopenharmony_ciresult() 131f08c3bdfSopenharmony_ci{ 132f08c3bdfSopenharmony_ci _print -en "\\033[0;34m" # set font color as blue 133f08c3bdfSopenharmony_ci _print -e "$*" > $g_tty 134f08c3bdfSopenharmony_ci echo -e "$*" >> $g_result 135f08c3bdfSopenharmony_ci echo -e "$*" >> $g_logfile 136f08c3bdfSopenharmony_ci _print -en "\\033[0;39m" # restore font color to normal 137f08c3bdfSopenharmony_ci} 138f08c3bdfSopenharmony_ci 139f08c3bdfSopenharmony_cisetup_meminfo() 140f08c3bdfSopenharmony_ci{ 141f08c3bdfSopenharmony_ci local maxmem=0 142f08c3bdfSopenharmony_ci local lowmem_s=0 143f08c3bdfSopenharmony_ci local lowmem_e=0 144f08c3bdfSopenharmony_ci local highmem_s=0 145f08c3bdfSopenharmony_ci local highmem_e=0 146f08c3bdfSopenharmony_ci local tmp= 147f08c3bdfSopenharmony_ci 148f08c3bdfSopenharmony_ci lowmem_s=`printf "%i" 0x100000` # start pfn of mem < 4G 149f08c3bdfSopenharmony_ci let "g_lowmem_s=$lowmem_s / $g_pgsize" 150f08c3bdfSopenharmony_ci tmp=`cat /proc/iomem | grep "System RAM" | grep 100000- | awk -F "-" '{print $2}' | awk '{print $1}'` 151f08c3bdfSopenharmony_ci lowmem_e=`printf "%i" "0x$tmp"` 152f08c3bdfSopenharmony_ci let "g_lowmem_e=$lowmem_e / $g_pgsize" 153f08c3bdfSopenharmony_ci log "low mem: 0x100000 (pfn: $g_lowmem_s) ~ 0x$tmp (pfn: $g_lowmem_e)" 154f08c3bdfSopenharmony_ci 155f08c3bdfSopenharmony_ci highmem_s=`printf "%i" 0x100000000` # start pfn of highmem > 4G 156f08c3bdfSopenharmony_ci let "g_highmem_s=$highmem_s / $g_pgsize" 157f08c3bdfSopenharmony_ci tmp=`cat /proc/iomem | grep "System RAM" | grep 100000000- | awk -F "-" '{print $2}' | awk '{print $1}'` 158f08c3bdfSopenharmony_ci if [ -n "$tmp" ]; then 159f08c3bdfSopenharmony_ci highmem_e=`printf "%i" "0x$tmp"` 160f08c3bdfSopenharmony_ci let "g_highmem_e=$highmem_e / $g_pgsize" 161f08c3bdfSopenharmony_ci log "high mem: 0x100000000 (pfn: $g_highmem_s) ~ 0x$tmp (pfn: $g_highmem_e)" 162f08c3bdfSopenharmony_ci fi 163f08c3bdfSopenharmony_ci 164f08c3bdfSopenharmony_ci maxmem=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'` 165f08c3bdfSopenharmony_ci let "g_maxpfn= $maxmem / 4" 166f08c3bdfSopenharmony_ci log "max pfn number: g_maxpfn = $g_maxpfn" 167f08c3bdfSopenharmony_ci} 168f08c3bdfSopenharmony_ci 169f08c3bdfSopenharmony_cisetup_errinj() 170f08c3bdfSopenharmony_ci{ 171f08c3bdfSopenharmony_ci local dev_major= 172f08c3bdfSopenharmony_ci local dev_minor= 173f08c3bdfSopenharmony_ci local rc=0 174f08c3bdfSopenharmony_ci 175f08c3bdfSopenharmony_ci if [ $g_soft_offline -eq 1 ]; then 176f08c3bdfSopenharmony_ci [ -f "$g_debugfs/hwpoison/corrupt-filter-enable" ] && echo 0 > $g_debugfs/hwpoison/corrupt-filter-enable 177f08c3bdfSopenharmony_ci return 178f08c3bdfSopenharmony_ci fi 179f08c3bdfSopenharmony_ci if [ $g_madvise -eq 1 ]; then 180f08c3bdfSopenharmony_ci [ -f "$g_debugfs/hwpoison/corrupt-filter-enable" ] && echo 0 > $g_debugfs/hwpoison/corrupt-filter-enable 181f08c3bdfSopenharmony_ci # to avoid unexpected page-state changing in background while testing. 182f08c3bdfSopenharmony_ci echo 70 > /proc/sys/vm/dirty_background_ratio 183f08c3bdfSopenharmony_ci echo 70 > /proc/sys/vm/dirty_ratio 184f08c3bdfSopenharmony_ci echo 1000000 > /proc/sys/vm/dirty_expire_centisecs 185f08c3bdfSopenharmony_ci return 186f08c3bdfSopenharmony_ci fi 187f08c3bdfSopenharmony_ci dev_major=0x`/usr/bin/stat --format=%t $g_dev` > /dev/null 2>&1 188f08c3bdfSopenharmony_ci [ $? -ne 0 ] && rc=1 189f08c3bdfSopenharmony_ci dev_minor=0x`/usr/bin/stat --format=%T $g_dev` > /dev/null 2>&1 190f08c3bdfSopenharmony_ci [ $? -ne 0 ] && rc=1 191f08c3bdfSopenharmony_ci [ $rc -eq 1 ] && invalid "invalid device: no inode # can be found" 192f08c3bdfSopenharmony_ci echo $dev_major > $g_debugfs/hwpoison/corrupt-filter-dev-major 193f08c3bdfSopenharmony_ci echo $dev_minor > $g_debugfs/hwpoison/corrupt-filter-dev-minor 194f08c3bdfSopenharmony_ci [ $g_pgtype = "all" -a -f "$g_debugfs/hwpoison/corrupt-filter-flags-mask" ] && echo 0 > $g_debugfs/hwpoison/corrupt-filter-flags-mask 195f08c3bdfSopenharmony_ci [ -f "$g_debugfs/hwpoison/corrupt-filter-enable" ] && echo 1 > $g_debugfs/hwpoison/corrupt-filter-enable 196f08c3bdfSopenharmony_ci return 197f08c3bdfSopenharmony_ci} 198f08c3bdfSopenharmony_ci 199f08c3bdfSopenharmony_cisetup_fs() 200f08c3bdfSopenharmony_ci{ 201f08c3bdfSopenharmony_ci local mkfs="mkfs.$g_fstype" 202f08c3bdfSopenharmony_ci local mkfs_opts="-q" 203f08c3bdfSopenharmony_ci local mount_opts 204f08c3bdfSopenharmony_ci 205f08c3bdfSopenharmony_ci [ $g_fstype = reiserfs ] && mkfs="mkreiserfs" 206f08c3bdfSopenharmony_ci [ $g_fstype = ocfs2 ] && mkfs_opts="$mkfs_opts -M local" 207f08c3bdfSopenharmony_ci [ $g_fstype = cifs ] && mount_opts="-o password=""" 208f08c3bdfSopenharmony_ci mkdir -p $g_testdir || err "cannot mkdir $g_testdir" 209f08c3bdfSopenharmony_ci if [ $g_nomkfs -eq 0 -a $g_netfs -eq 0 ]; then 210f08c3bdfSopenharmony_ci silent_exec which $mkfs || err "mkfs: unsupported fstype: $g_fstype" 211f08c3bdfSopenharmony_ci if [ $g_force -eq 0 -a $g_fstype != "ocfs2" ]; then 212f08c3bdfSopenharmony_ci echo -n "test will format $g_dev to $g_fstype, continue [y/n]? " 213f08c3bdfSopenharmony_ci read in 214f08c3bdfSopenharmony_ci [ $in = 'y' -o $in = "yes" -o $in = 'Y' ] || err "$mkfs on $g_dev is cancelled" 215f08c3bdfSopenharmony_ci fi 216f08c3bdfSopenharmony_ci begin "-- $mkfs $g_dev" 217f08c3bdfSopenharmony_ci if [ $g_fstype = "vfat" -o $g_fstype = "msdos" -o $g_fstype = "btrfs" ]; then 218f08c3bdfSopenharmony_ci mkfs_opts="" 219f08c3bdfSopenharmony_ci elif [ $g_fstype = "xfs" ]; then 220f08c3bdfSopenharmony_ci mkfs_opts="-f" 221f08c3bdfSopenharmony_ci fi 222f08c3bdfSopenharmony_ci [ $g_fstype = ocfs2 ] && echo -n "test will format $g_dev to $g_fstype, continue [y/n]? " 223f08c3bdfSopenharmony_ci silent_exec $mkfs $mkfs_opts $g_dev || err "cannot $mkfs $mkfs_opts on $g_dev" 224f08c3bdfSopenharmony_ci end "-- $mkfs $g_dev" 225f08c3bdfSopenharmony_ci fi 226f08c3bdfSopenharmony_ci if [ $g_netfs -eq 0 ]; then 227f08c3bdfSopenharmony_ci silent_exec mount -t $g_fstype $g_dev $g_testdir || err "cannot mount $g_fstype fs: $g_dev to $g_testdir" 228f08c3bdfSopenharmony_ci else 229f08c3bdfSopenharmony_ci silent_exec mount -t $g_fstype $mount_opts $g_netdev $g_testdir || err "cannot mount $g_fstype $mount_opts fs: $g_netdev to $g_testdir" 230f08c3bdfSopenharmony_ci fi 231f08c3bdfSopenharmony_ci} 232f08c3bdfSopenharmony_ci 233f08c3bdfSopenharmony_cicheck_env() 234f08c3bdfSopenharmony_ci{ 235f08c3bdfSopenharmony_ci check_debugfs 236f08c3bdfSopenharmony_ci g_debugfs=`mount | grep debugfs | cut -d ' ' -f3` 237f08c3bdfSopenharmony_ci [ -z "$g_tty" ] && invalid "$g_tty does not exist" 238f08c3bdfSopenharmony_ci if [ $g_test -eq 0 ]; then 239f08c3bdfSopenharmony_ci if [ $g_fstype = "nfs" -o $g_fstype = "cifs" ]; then 240f08c3bdfSopenharmony_ci g_netfs=1 241f08c3bdfSopenharmony_ci [ -z $g_netdev ] && invalid "net device is not specified" 242f08c3bdfSopenharmony_ci fi 243f08c3bdfSopenharmony_ci [ -z "$g_dev" ] && invalid "device is not specified" 244f08c3bdfSopenharmony_ci [ -b $g_dev ] || invalid "invalid device: $g_dev" 245f08c3bdfSopenharmony_ci if [ $g_netfs -eq 0 ]; then 246f08c3bdfSopenharmony_ci df | grep $g_dev > /dev/null 2>&1 && invalid "device $g_dev has been mounted by others" 247f08c3bdfSopenharmony_ci else 248f08c3bdfSopenharmony_ci df | grep $g_netdev > /dev/null 2>&1 && invalid "device $g_netdev has been mounted by others" 249f08c3bdfSopenharmony_ci fi 250f08c3bdfSopenharmony_ci fi 251f08c3bdfSopenharmony_ci [ -d $g_bindir ] || invalid "no bin subdir there" 252f08c3bdfSopenharmony_ci if [ $g_madvise -eq 0 -o $g_recycle -ne 0 ]; then 253f08c3bdfSopenharmony_ci silent_exec which $g_pagetool || invalid "no $g_pagetool tool on the system" 254f08c3bdfSopenharmony_ci g_pagetool=`which $g_pagetool` 255f08c3bdfSopenharmony_ci dbp "Found the tool: $g_pagetool" 256f08c3bdfSopenharmony_ci fi 257f08c3bdfSopenharmony_ci if [ $g_pfninj -eq 1 ]; then 258f08c3bdfSopenharmony_ci if [ $g_soft_offline -eq 1 ]; then 259f08c3bdfSopenharmony_ci [ -f $g_sysfs_mem/soft_offline_page ] || invalid "pls. ensure soft_offline_page is enabled" 260f08c3bdfSopenharmony_ci else 261f08c3bdfSopenharmony_ci #if hwpoison_inject is a module, it is ensured to have been loaded 262f08c3bdfSopenharmony_ci modinfo hwpoison_inject > /dev/null 2>&1 263f08c3bdfSopenharmony_ci if [ $? -eq 0 ]; then 264f08c3bdfSopenharmony_ci [ -d $g_debugfs/hwpoison/ ] || modprobe hwpoison_inject 265f08c3bdfSopenharmony_ci [ $? -eq 0 ] || invalid "module hwpoison_inject isn't supported ?" 266f08c3bdfSopenharmony_ci fi 267f08c3bdfSopenharmony_ci fi 268f08c3bdfSopenharmony_ci fi 269f08c3bdfSopenharmony_ci [ $g_recycle -ne 0 ] && { 270f08c3bdfSopenharmony_ci [ -f $g_debugfs/hwpoison/unpoison-pfn ] || invalid "pls. insmod hwpoison_inject module with unpoison-pfn support" 271f08c3bdfSopenharmony_ci } 272f08c3bdfSopenharmony_ci if [ $g_apei -eq 1 ]; then 273f08c3bdfSopenharmony_ci #if einj is a module, it is ensured to have been loaded 274f08c3bdfSopenharmony_ci modinfo einj > /dev/null 2>&1 275f08c3bdfSopenharmony_ci if [ $? -eq 0 ]; then 276f08c3bdfSopenharmony_ci [ -d $g_debugfs/apei/einj ] || modprobe einj 277f08c3bdfSopenharmony_ci [ $? -eq 0 ] || invalid "module apei_inj isn't supported ?" 278f08c3bdfSopenharmony_ci fi 279f08c3bdfSopenharmony_ci fi 280f08c3bdfSopenharmony_ci [ -d $g_ltproot -a -f $g_ltppan ] || invalid "no ltp-pan on the machine: $g_ltppan" 281f08c3bdfSopenharmony_ci if [ $g_runltp -eq 1 ]; then 282f08c3bdfSopenharmony_ci [ -d $g_ltproot -a -f $g_ltproot/runltp ] || invalid "no runltp on the machine" 283f08c3bdfSopenharmony_ci fi 284f08c3bdfSopenharmony_ci [ $g_duration -eq 0 ] && invalid "test duration is set as 0 second" 285f08c3bdfSopenharmony_ci} 286f08c3bdfSopenharmony_ci 287f08c3bdfSopenharmony_cisetup_log() 288f08c3bdfSopenharmony_ci{ 289f08c3bdfSopenharmony_ci mkdir -p $g_resultdir 290f08c3bdfSopenharmony_ci rm -rf $g_logdir 291f08c3bdfSopenharmony_ci mkdir -p $g_logdir 292f08c3bdfSopenharmony_ci echo "# hwpoison.sh $g_parameter" > $g_logfile 293f08c3bdfSopenharmony_ci echo "# hwpoison.sh $g_parameter" > $g_result 294f08c3bdfSopenharmony_ci [ $g_test -eq 0 ] && clear > $g_tty 295f08c3bdfSopenharmony_ci echo "# hwpoison.sh $g_parameter" > $g_tty 296f08c3bdfSopenharmony_ci} 297f08c3bdfSopenharmony_ci 298f08c3bdfSopenharmony_cisetup_env() 299f08c3bdfSopenharmony_ci{ 300f08c3bdfSopenharmony_ci begin "setup test environment" 301f08c3bdfSopenharmony_ci mkdir -p $g_casedir 302f08c3bdfSopenharmony_ci check_env 303f08c3bdfSopenharmony_ci setup_errinj 304f08c3bdfSopenharmony_ci setup_meminfo 305f08c3bdfSopenharmony_ci trap "cleanup" 0 306f08c3bdfSopenharmony_ci [ $g_test -eq 0 ] && setup_fs 307f08c3bdfSopenharmony_ci export PATH="${PATH}:$g_bindir" 308f08c3bdfSopenharmony_ci end "setup test environment" 309f08c3bdfSopenharmony_ci} 310f08c3bdfSopenharmony_ci 311f08c3bdfSopenharmony_cirun_ltp() 312f08c3bdfSopenharmony_ci{ 313f08c3bdfSopenharmony_ci local ltp_failed=$g_logdir/ltp/ltp_failed 314f08c3bdfSopenharmony_ci local ltp_log=$g_logdir/ltp/ltp_log 315f08c3bdfSopenharmony_ci local ltp_output=$g_logdir/ltp/ltp_output 316f08c3bdfSopenharmony_ci local ltp_tmp=$g_testdir/ltp_tmp 317f08c3bdfSopenharmony_ci 318f08c3bdfSopenharmony_ci begin "launch ltp workload in background" 319f08c3bdfSopenharmony_ci mkdir -p $g_logdir/ltp 320f08c3bdfSopenharmony_ci echo -n "" > $ltp_failed 321f08c3bdfSopenharmony_ci echo -n "" > $ltp_log 322f08c3bdfSopenharmony_ci echo -n "" > $ltp_output 323f08c3bdfSopenharmony_ci mkdir -p $ltp_tmp 324f08c3bdfSopenharmony_ci silent_exec_background $g_ltproot/runltp -d $ltp_tmp -l $ltp_log -o $ltp_output -r $g_ltproot -t ${g_duration}s -C $ltp_failed 325f08c3bdfSopenharmony_ci g_pid_ltp=$! 326f08c3bdfSopenharmony_ci end "launch ltp workload in background (pid: $g_pid_ltp)" 327f08c3bdfSopenharmony_ci} 328f08c3bdfSopenharmony_ci 329f08c3bdfSopenharmony_ciltp_result() 330f08c3bdfSopenharmony_ci{ 331f08c3bdfSopenharmony_ci local num=0; 332f08c3bdfSopenharmony_ci local ltp_failed=$g_logdir/ltp/ltp_failed 333f08c3bdfSopenharmony_ci local ltp_output=$g_logdir/ltp/ltp_output 334f08c3bdfSopenharmony_ci 335f08c3bdfSopenharmony_ci [ -f $ltp_failed ] || { 336f08c3bdfSopenharmony_ci result "\tltp -- error: no ltp result there" 337f08c3bdfSopenharmony_ci result "\t log: $ltp_output" 338f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 339f08c3bdfSopenharmony_ci return 340f08c3bdfSopenharmony_ci } 341f08c3bdfSopenharmony_ci num=`wc -l $ltp_failed | awk '{print $1}'` 342f08c3bdfSopenharmony_ci if [ $num -ne 0 ]; then 343f08c3bdfSopenharmony_ci result "\tltp -- $num case(s) failed" 344f08c3bdfSopenharmony_ci result "\t log: $ltp_output" 345f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 346f08c3bdfSopenharmony_ci else 347f08c3bdfSopenharmony_ci result "\tltp -- all tests pass" 348f08c3bdfSopenharmony_ci fi 349f08c3bdfSopenharmony_ci} 350f08c3bdfSopenharmony_ci 351f08c3bdfSopenharmony_ci 352f08c3bdfSopenharmony_cifs_metadata() 353f08c3bdfSopenharmony_ci{ 354f08c3bdfSopenharmony_ci local dir=$g_logdir/fs_metadata 355f08c3bdfSopenharmony_ci local result=$dir/fs_metadata.result 356f08c3bdfSopenharmony_ci local log=$dir/fs_metadata.log 357f08c3bdfSopenharmony_ci local pan_log=$dir/pan_log 358f08c3bdfSopenharmony_ci local pan_output=$dir/pan_output 359f08c3bdfSopenharmony_ci local pan_zoo=$dir/pan_zoo 360f08c3bdfSopenharmony_ci local pan_failed=$dir/pan_failed 361f08c3bdfSopenharmony_ci local tmp=$g_testdir/fs_metadata 362f08c3bdfSopenharmony_ci local threads= 363f08c3bdfSopenharmony_ci local node_number=5 364f08c3bdfSopenharmony_ci local tree_depth=6 365f08c3bdfSopenharmony_ci 366f08c3bdfSopenharmony_ci if [ $g_children -eq 0 ]; then 367f08c3bdfSopenharmony_ci let "threads= $g_duration / 720" 368f08c3bdfSopenharmony_ci else 369f08c3bdfSopenharmony_ci threads=$g_children 370f08c3bdfSopenharmony_ci fi 371f08c3bdfSopenharmony_ci [ $threads -gt 10 ] && threads=10 && node_number=6 372f08c3bdfSopenharmony_ci [ $threads -eq 0 ] && threads=1 373f08c3bdfSopenharmony_ci 374f08c3bdfSopenharmony_ci begin "launch fs_metadata workload" 375f08c3bdfSopenharmony_ci mkdir -p $dir 376f08c3bdfSopenharmony_ci echo -n "" > $pan_failed 377f08c3bdfSopenharmony_ci echo -n "" > $pan_log 378f08c3bdfSopenharmony_ci echo -n "" > $pan_output 379f08c3bdfSopenharmony_ci echo -n "" > $pan_zoo 380f08c3bdfSopenharmony_ci log "setup fs_metadata test environment" 381f08c3bdfSopenharmony_ci silent_exec_background rm -rf $tmp 382f08c3bdfSopenharmony_ci mkdir -p $tmp || err "cannot create dir: $tmp" 383f08c3bdfSopenharmony_ci 384f08c3bdfSopenharmony_ci echo "fs_metadata fs-metadata.sh $tree_depth $node_number $threads $g_duration $result $tmp $log" > $g_casedir/fs_metadata 385f08c3bdfSopenharmony_ci dbp "g_ltppan -n fs_metadata -a $pan_zoo -f $g_casedir/fs_metadata -o $pan_output -l $pan_log -C $pan_failed &" 386f08c3bdfSopenharmony_ci silent_exec_background $g_ltppan -n fs_metadata -a $pan_zoo -f $g_casedir/fs_metadata -o $pan_output -l $pan_log -C $pan_failed 387f08c3bdfSopenharmony_ci g_pid_fsmeta=$! 388f08c3bdfSopenharmony_ci sleep $g_interval 389f08c3bdfSopenharmony_ci silent_exec grep "abort" $log && err "failed to launch fs_metadata workload, it might be due to insufficient disk space, pls read $log for details!" 390f08c3bdfSopenharmony_ci end "launch fs_metadata workload (pid: $g_pid_fsmeta)" 391f08c3bdfSopenharmony_ci} 392f08c3bdfSopenharmony_ci 393f08c3bdfSopenharmony_cifs_metadata_result() 394f08c3bdfSopenharmony_ci{ 395f08c3bdfSopenharmony_ci local fail_num=0; 396f08c3bdfSopenharmony_ci local pass_num=0; 397f08c3bdfSopenharmony_ci local dir=$g_logdir/fs_metadata 398f08c3bdfSopenharmony_ci local result=$dir/fs_metadata.result 399f08c3bdfSopenharmony_ci local log=$dir/fs_metadata.log 400f08c3bdfSopenharmony_ci 401f08c3bdfSopenharmony_ci [ -f $result ] || { 402f08c3bdfSopenharmony_ci result "\tfs_metadata -- error: no result there" 403f08c3bdfSopenharmony_ci result "\t details: $log" 404f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 405f08c3bdfSopenharmony_ci return 406f08c3bdfSopenharmony_ci } 407f08c3bdfSopenharmony_ci fail_num=`grep FAIL $result | awk -F : '{print $NF}'` 408f08c3bdfSopenharmony_ci pass_num=`grep PASS $result | awk -F : '{print $NF}'` 409f08c3bdfSopenharmony_ci [ -z "$fail_num" ] && fail_num=0 && pass_num=0 410f08c3bdfSopenharmony_ci if [ $fail_num -ne 0 ]; then 411f08c3bdfSopenharmony_ci result "\tfs_metadata -- $fail_num tests failed, $pass_num tests pass." 412f08c3bdfSopenharmony_ci result "\t details: $result" 413f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 414f08c3bdfSopenharmony_ci else 415f08c3bdfSopenharmony_ci if [ $pass_num -eq 0 ]; then 416f08c3bdfSopenharmony_ci result "\tfs_metadata -- no test finished" 417f08c3bdfSopenharmony_ci result "\t details: $log" 418f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 419f08c3bdfSopenharmony_ci else 420f08c3bdfSopenharmony_ci result "\tfs_metadata -- all $pass_num tests got pass" 421f08c3bdfSopenharmony_ci fi 422f08c3bdfSopenharmony_ci fi 423f08c3bdfSopenharmony_ci 424f08c3bdfSopenharmony_ci return 425f08c3bdfSopenharmony_ci} 426f08c3bdfSopenharmony_ci 427f08c3bdfSopenharmony_ci# fs_specific workload, TBD 428f08c3bdfSopenharmony_cifs_specific() 429f08c3bdfSopenharmony_ci{ 430f08c3bdfSopenharmony_ci begin "launch $g_fstype specific workload" 431f08c3bdfSopenharmony_ci 432f08c3bdfSopenharmony_ci touch $g_logdir/fs_specific 433f08c3bdfSopenharmony_ci# $g_ltppan -n fs_specific -a $g_logdir/fs_specific -f $g_casedir/fs_specific -t ${g_duration}s & 434f08c3bdfSopenharmony_ci end "launch $g_fstype specific workload" 435f08c3bdfSopenharmony_ci} 436f08c3bdfSopenharmony_ci 437f08c3bdfSopenharmony_cipage_poisoning() 438f08c3bdfSopenharmony_ci{ 439f08c3bdfSopenharmony_ci local dir=$g_logdir/page_poisoning 440f08c3bdfSopenharmony_ci local pan_failed=$dir/pan_failed 441f08c3bdfSopenharmony_ci local pan_log=$dir/pan_log 442f08c3bdfSopenharmony_ci local pan_output=$dir/pan_output 443f08c3bdfSopenharmony_ci local tmp=$g_testdir/page_poisoning 444f08c3bdfSopenharmony_ci local pan_zoo=$dir/pan_zoo 445f08c3bdfSopenharmony_ci local result=$dir/page_poisoning.result 446f08c3bdfSopenharmony_ci local log=$dir/page_poisoning.log 447f08c3bdfSopenharmony_ci local opts= 448f08c3bdfSopenharmony_ci 449f08c3bdfSopenharmony_ci begin "-- launch page_poisoning test" 450f08c3bdfSopenharmony_ci mkdir -p $dir 451f08c3bdfSopenharmony_ci echo -n "" > $pan_failed 452f08c3bdfSopenharmony_ci echo -n "" > $pan_log 453f08c3bdfSopenharmony_ci echo -n "" > $pan_output 454f08c3bdfSopenharmony_ci echo -n "" > $pan_zoo 455f08c3bdfSopenharmony_ci echo -n "" > $log 456f08c3bdfSopenharmony_ci echo -n "" > $result 457f08c3bdfSopenharmony_ci mkdir -p $tmp || err "cannot create dir: $tmp" 458f08c3bdfSopenharmony_ci 459f08c3bdfSopenharmony_ci [ $g_children -ne 0 ] && opts="-i $g_children" 460f08c3bdfSopenharmony_ci 461f08c3bdfSopenharmony_ci echo "page_poisoning page-poisoning -l $log -r $result -t $tmp $opts" > $g_casedir/page_poisoning 462f08c3bdfSopenharmony_ci dbp "$g_ltppan -n page_poisoning -a $pan_zoo -f $g_casedir/page_poisoning -t ${g_duration}s -o $pan_output -l $pan_log -C $pan_failed &" 463f08c3bdfSopenharmony_ci silent_exec_background $g_ltppan -n page_poisoning -a $pan_zoo -f $g_casedir/page_poisoning -t ${g_duration}s -o $pan_output -l $pan_log -C $pan_failed 464f08c3bdfSopenharmony_ci g_pid_madv=$! 465f08c3bdfSopenharmony_ci end "-- launch page_poisoning test (pid: $g_pid_madv)" 466f08c3bdfSopenharmony_ci} 467f08c3bdfSopenharmony_ci 468f08c3bdfSopenharmony_cipage_poisoning_result() 469f08c3bdfSopenharmony_ci{ 470f08c3bdfSopenharmony_ci local fail_num=0 471f08c3bdfSopenharmony_ci local pass_num=0 472f08c3bdfSopenharmony_ci local dir=$g_logdir/page_poisoning 473f08c3bdfSopenharmony_ci local result=$dir/page_poisoning.result 474f08c3bdfSopenharmony_ci local log=$dir/page_poisoning.log 475f08c3bdfSopenharmony_ci 476f08c3bdfSopenharmony_ci [ -f $result ] || { 477f08c3bdfSopenharmony_ci result "\tpage_poisoning -- error: no result file there" 478f08c3bdfSopenharmony_ci result "\t details: $log" 479f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 480f08c3bdfSopenharmony_ci return 481f08c3bdfSopenharmony_ci } 482f08c3bdfSopenharmony_ci fail_num=`grep FAILED $result | wc -l | awk '{print $1}'` 483f08c3bdfSopenharmony_ci pass_num=`grep PASS $result | wc -l | awk '{print $1}'` 484f08c3bdfSopenharmony_ci if [ $fail_num -ne 0 ]; then 485f08c3bdfSopenharmony_ci result "\tpage_poisoning -- $fail_num tests failed, $pass_num tests pass." 486f08c3bdfSopenharmony_ci result "\t details: $result" 487f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 488f08c3bdfSopenharmony_ci else 489f08c3bdfSopenharmony_ci if [ $pass_num -eq 0 ]; then 490f08c3bdfSopenharmony_ci result "\tpage_poisoning -- no case finished" 491f08c3bdfSopenharmony_ci result "\t details: $log" 492f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 493f08c3bdfSopenharmony_ci else 494f08c3bdfSopenharmony_ci result "\tpage_poisoning -- all $pass_num tests got pass" 495f08c3bdfSopenharmony_ci fi 496f08c3bdfSopenharmony_ci fi 497f08c3bdfSopenharmony_ci 498f08c3bdfSopenharmony_ci return 499f08c3bdfSopenharmony_ci} 500f08c3bdfSopenharmony_ci 501f08c3bdfSopenharmony_cirun_workloads() 502f08c3bdfSopenharmony_ci{ 503f08c3bdfSopenharmony_ci fs_metadata 504f08c3bdfSopenharmony_ci #fs_specific 505f08c3bdfSopenharmony_ci return 506f08c3bdfSopenharmony_ci} 507f08c3bdfSopenharmony_ci 508f08c3bdfSopenharmony_ci_pfn_unpoison() 509f08c3bdfSopenharmony_ci{ 510f08c3bdfSopenharmony_ci local pg=$1 511f08c3bdfSopenharmony_ci 512f08c3bdfSopenharmony_ci echo $pg > $g_debugfs/hwpoison/unpoison-pfn 513f08c3bdfSopenharmony_ci dbp "echo $pg > $g_debugfs/hwpoison/unpoison-pfn" 514f08c3bdfSopenharmony_ci} 515f08c3bdfSopenharmony_ci 516f08c3bdfSopenharmony_cipfn_unpoison() 517f08c3bdfSopenharmony_ci{ 518f08c3bdfSopenharmony_ci local pg_list= 519f08c3bdfSopenharmony_ci local pg=0 520f08c3bdfSopenharmony_ci local pfn=0 521f08c3bdfSopenharmony_ci local cur= 522f08c3bdfSopenharmony_ci local i=0 523f08c3bdfSopenharmony_ci local inj=_pfn_unpoison 524f08c3bdfSopenharmony_ci 525f08c3bdfSopenharmony_ci pg_list=`$g_pagetool -NLrb hwpoison | grep -v offset | cut -f1` 526f08c3bdfSopenharmony_ci for pg in $pg_list 527f08c3bdfSopenharmony_ci do 528f08c3bdfSopenharmony_ci $inj 0x$pg > /dev/null 2>&1 529f08c3bdfSopenharmony_ci done 530f08c3bdfSopenharmony_ci} 531f08c3bdfSopenharmony_ci 532f08c3bdfSopenharmony_cishow_progress() 533f08c3bdfSopenharmony_ci{ 534f08c3bdfSopenharmony_ci local cur= 535f08c3bdfSopenharmony_ci local rest=0 536f08c3bdfSopenharmony_ci local percent=0 537f08c3bdfSopenharmony_ci local next=0 538f08c3bdfSopenharmony_ci local msg="hwpoison page error injection" 539f08c3bdfSopenharmony_ci 540f08c3bdfSopenharmony_ci [ $g_soft_offline -eq 1 ] && msg="page soft offline" 541f08c3bdfSopenharmony_ci 542f08c3bdfSopenharmony_ci cur=`date +%s` 543f08c3bdfSopenharmony_ci [ "$cur" -ge "$g_time_e" ] && return 544f08c3bdfSopenharmony_ci rest=`expr $g_time_e - $cur` 545f08c3bdfSopenharmony_ci let "percent= ($g_duration - $rest) * 100 / $g_duration" 546f08c3bdfSopenharmony_ci [ $percent -eq 0 ] && return 547f08c3bdfSopenharmony_ci if [ $g_recycle -ne 0 ]; then 548f08c3bdfSopenharmony_ci let "g_last=(($percent-$g_percent)*$g_duration)+$g_last" 549f08c3bdfSopenharmony_ci [ $g_last -ge $g_recycle ] && { 550f08c3bdfSopenharmony_ci g_last=0 551f08c3bdfSopenharmony_ci pfn_unpoison 552f08c3bdfSopenharmony_ci } 553f08c3bdfSopenharmony_ci fi 554f08c3bdfSopenharmony_ci [ $percent -gt 10 ] && let "next= $percent - 10" 555f08c3bdfSopenharmony_ci [ $g_percent -ne 0 -a $g_percent -gt $next ] && return 556f08c3bdfSopenharmony_ci g_percent=$percent 557f08c3bdfSopenharmony_ci log "$msg: $g_percent% pages done" 558f08c3bdfSopenharmony_ci} 559f08c3bdfSopenharmony_ci 560f08c3bdfSopenharmony_ci_pfn_hwpoison() 561f08c3bdfSopenharmony_ci{ 562f08c3bdfSopenharmony_ci local pfn=$1 563f08c3bdfSopenharmony_ci 564f08c3bdfSopenharmony_ci echo $pfn > $g_debugfs/hwpoison/corrupt-pfn 565f08c3bdfSopenharmony_ci dbp "echo $pfn > $g_debugfs/hwpoison/corrupt-pfn" 566f08c3bdfSopenharmony_ci} 567f08c3bdfSopenharmony_ci 568f08c3bdfSopenharmony_ci_pfn_soft_offline() 569f08c3bdfSopenharmony_ci{ 570f08c3bdfSopenharmony_ci local pfn=$1 571f08c3bdfSopenharmony_ci local i 572f08c3bdfSopenharmony_ci local j 573f08c3bdfSopenharmony_ci local paddr 574f08c3bdfSopenharmony_ci 575f08c3bdfSopenharmony_ci i=`printf "%i" $pfn` 576f08c3bdfSopenharmony_ci let "j=$i * $g_pgsize" 577f08c3bdfSopenharmony_ci paddr=`printf "0x%x" $j` 578f08c3bdfSopenharmony_ci echo $paddr > $g_sysfs_mem/soft_offline_page 579f08c3bdfSopenharmony_ci dbp "echo $paddr > $g_sysfs_mem/soft_offline_page" 580f08c3bdfSopenharmony_ci} 581f08c3bdfSopenharmony_ci 582f08c3bdfSopenharmony_cipfn_inj() 583f08c3bdfSopenharmony_ci{ 584f08c3bdfSopenharmony_ci local pg_list= 585f08c3bdfSopenharmony_ci local pg=0 586f08c3bdfSopenharmony_ci local pfn=0 587f08c3bdfSopenharmony_ci local cur= 588f08c3bdfSopenharmony_ci local i=0 589f08c3bdfSopenharmony_ci local inj=_pfn_hwpoison 590f08c3bdfSopenharmony_ci 591f08c3bdfSopenharmony_ci [ $g_soft_offline -eq 1 ] && inj=_pfn_soft_offline 592f08c3bdfSopenharmony_ci if [ $g_pgtype = "all" ]; then 593f08c3bdfSopenharmony_ci pfn=$g_lowmem_s # start from 1M. 594f08c3bdfSopenharmony_ci while [ "$pfn" -lt "$g_maxpfn" ] 595f08c3bdfSopenharmony_ci do 596f08c3bdfSopenharmony_ci pg=`printf "%x" $pfn` 597f08c3bdfSopenharmony_ci $inj 0x$pg > /dev/null 2>&1 598f08c3bdfSopenharmony_ci pfn=`expr $pfn + 1` 599f08c3bdfSopenharmony_ci [ $pfn -gt $g_lowmem_e ] && pfn=$g_highmem_s 600f08c3bdfSopenharmony_ci [ $pfn -gt $g_highmem_e ] && break 601f08c3bdfSopenharmony_ci i=`expr $i + 1` 602f08c3bdfSopenharmony_ci if [ $i -eq $g_progress ]; then 603f08c3bdfSopenharmony_ci cur=`date +%s` 604f08c3bdfSopenharmony_ci [ "$cur" -ge "$g_time_e" ] && break 605f08c3bdfSopenharmony_ci show_progress 606f08c3bdfSopenharmony_ci i=0 607f08c3bdfSopenharmony_ci fi 608f08c3bdfSopenharmony_ci done 609f08c3bdfSopenharmony_ci else 610f08c3bdfSopenharmony_ci silent_exec $g_pagetool -Nrb $g_pgtype || err "unsupported pagetype, pls. refer to command: $g_pagetool -h" 611f08c3bdfSopenharmony_ci pg_list=`$g_pagetool -NLrb $g_pgtype | grep -v offset | cut -f1` 612f08c3bdfSopenharmony_ci for pg in $pg_list 613f08c3bdfSopenharmony_ci do 614f08c3bdfSopenharmony_ci $inj 0x$pg > /dev/null 2>&1 615f08c3bdfSopenharmony_ci i=`expr $i + 1` 616f08c3bdfSopenharmony_ci if [ $i -eq $g_progress ]; then 617f08c3bdfSopenharmony_ci cur=`date +%s` 618f08c3bdfSopenharmony_ci [ "$cur" -ge "$g_time_e" ] && break 619f08c3bdfSopenharmony_ci show_progress 620f08c3bdfSopenharmony_ci i=0 621f08c3bdfSopenharmony_ci fi 622f08c3bdfSopenharmony_ci done 623f08c3bdfSopenharmony_ci fi 624f08c3bdfSopenharmony_ci} 625f08c3bdfSopenharmony_ci 626f08c3bdfSopenharmony_ci_apei_inj() 627f08c3bdfSopenharmony_ci{ 628f08c3bdfSopenharmony_ci local pfn=`printf "%x" $1` 629f08c3bdfSopenharmony_ci local type=$2 630f08c3bdfSopenharmony_ci 631f08c3bdfSopenharmony_ci echo $type > $g_debugfs/apei/einj/error_type 632f08c3bdfSopenharmony_ci echo "0x${pfn}000" > $g_debugfs/apei/err_inj/error_address 633f08c3bdfSopenharmony_ci echo "1" > $g_debugfs/apei/einj/error_inject 634f08c3bdfSopenharmony_ci} 635f08c3bdfSopenharmony_ci 636f08c3bdfSopenharmony_ciapei_ewb_ucr() 637f08c3bdfSopenharmony_ci{ 638f08c3bdfSopenharmony_ci _apei_inj $1 0x2 639f08c3bdfSopenharmony_ci} 640f08c3bdfSopenharmony_ci 641f08c3bdfSopenharmony_ciapei_mem_ucr() 642f08c3bdfSopenharmony_ci{ 643f08c3bdfSopenharmony_ci _apei_inj $1 0x10 644f08c3bdfSopenharmony_ci} 645f08c3bdfSopenharmony_ci 646f08c3bdfSopenharmony_ciapei_inj() 647f08c3bdfSopenharmony_ci{ 648f08c3bdfSopenharmony_ci local pg_list= 649f08c3bdfSopenharmony_ci local pg= 650f08c3bdfSopenharmony_ci local cur= 651f08c3bdfSopenharmony_ci local i=0 652f08c3bdfSopenharmony_ci 653f08c3bdfSopenharmony_ci pg_list=`$g_pagetool -NLrb $g_pgtype | grep -v offset | cut -f1` 654f08c3bdfSopenharmony_ci for pg in $pg_list 655f08c3bdfSopenharmony_ci do 656f08c3bdfSopenharmony_ci apei_mem_ucr $pg 657f08c3bdfSopenharmony_ci i=`expr $i + 1` 658f08c3bdfSopenharmony_ci if [ $i -eq $g_progress ]; then 659f08c3bdfSopenharmony_ci cur=`date +%s` 660f08c3bdfSopenharmony_ci [ "$cur" -ge "$g_time_e" ] && break 661f08c3bdfSopenharmony_ci show_progress 662f08c3bdfSopenharmony_ci i=0 663f08c3bdfSopenharmony_ci fi 664f08c3bdfSopenharmony_ci done 665f08c3bdfSopenharmony_ci 666f08c3bdfSopenharmony_ci return 667f08c3bdfSopenharmony_ci} 668f08c3bdfSopenharmony_ci 669f08c3bdfSopenharmony_cierr_inject() 670f08c3bdfSopenharmony_ci{ 671f08c3bdfSopenharmony_ci local cur= 672f08c3bdfSopenharmony_ci local i=0 673f08c3bdfSopenharmony_ci local msg="hwpoison page error injection" 674f08c3bdfSopenharmony_ci local MSG="inject HWPOISON error to pages" 675f08c3bdfSopenharmony_ci 676f08c3bdfSopenharmony_ci if [ $g_soft_offline -eq 1 ]; then 677f08c3bdfSopenharmony_ci msg="page soft offline" 678f08c3bdfSopenharmony_ci MSG="soft OFFLINE pages" 679f08c3bdfSopenharmony_ci fi 680f08c3bdfSopenharmony_ci if [ $g_madvise -eq 1 ]; then 681f08c3bdfSopenharmony_ci begin "$MSG thru madvise syscall" 682f08c3bdfSopenharmony_ci else 683f08c3bdfSopenharmony_ci begin "$MSG ($g_pgtype)" 684f08c3bdfSopenharmony_ci fi 685f08c3bdfSopenharmony_ci let "g_progress=$g_duration * 10" 686f08c3bdfSopenharmony_ci g_time_s=`date +%s` 687f08c3bdfSopenharmony_ci g_time_e=`expr $g_time_s + $g_duration` 688f08c3bdfSopenharmony_ci cur=$g_time_s 689f08c3bdfSopenharmony_ci if [ $g_madvise -eq 1 ]; then 690f08c3bdfSopenharmony_ci page_poisoning 691f08c3bdfSopenharmony_ci log "$msg: 0% pages done" 692f08c3bdfSopenharmony_ci show_progress 693f08c3bdfSopenharmony_ci else 694f08c3bdfSopenharmony_ci log "$msg: 0% pages done" 695f08c3bdfSopenharmony_ci fi 696f08c3bdfSopenharmony_ci while [ "$cur" -lt "$g_time_e" ] 697f08c3bdfSopenharmony_ci do 698f08c3bdfSopenharmony_ci if [ $g_madvise -eq 0 ]; then 699f08c3bdfSopenharmony_ci show_progress 700f08c3bdfSopenharmony_ci [ $g_apei -eq 1 ] && apei_inj 701f08c3bdfSopenharmony_ci [ $g_pfninj -eq 1 ] && pfn_inj 702f08c3bdfSopenharmony_ci else 703f08c3bdfSopenharmony_ci if [ $i -eq $g_progress ]; then 704f08c3bdfSopenharmony_ci show_progress 705f08c3bdfSopenharmony_ci i=0 706f08c3bdfSopenharmony_ci fi 707f08c3bdfSopenharmony_ci i=`expr $i + 1` 708f08c3bdfSopenharmony_ci fi 709f08c3bdfSopenharmony_ci cur=`date +%s` 710f08c3bdfSopenharmony_ci done 711f08c3bdfSopenharmony_ci log "$msg: 100% pages done" 712f08c3bdfSopenharmony_ci # wait workloads to be finished. 713f08c3bdfSopenharmony_ci sleep $g_interval 714f08c3bdfSopenharmony_ci 715f08c3bdfSopenharmony_ci if [ $g_madvise -eq 1 ]; then 716f08c3bdfSopenharmony_ci end "$MSG thru madvise syscall" 717f08c3bdfSopenharmony_ci else 718f08c3bdfSopenharmony_ci end "$MSG ($g_pgtype)" 719f08c3bdfSopenharmony_ci fi 720f08c3bdfSopenharmony_ci} 721f08c3bdfSopenharmony_ci 722f08c3bdfSopenharmony_cifsck_err() 723f08c3bdfSopenharmony_ci{ 724f08c3bdfSopenharmony_ci local dir=$g_logdir/fsck 725f08c3bdfSopenharmony_ci local result=$dir/fsck.result 726f08c3bdfSopenharmony_ci local log=$dir/fsck.log 727f08c3bdfSopenharmony_ci 728f08c3bdfSopenharmony_ci echo "FAILED: $@" > $result 729f08c3bdfSopenharmony_ci echo "FAILED: $@" > $log 730f08c3bdfSopenharmony_ci} 731f08c3bdfSopenharmony_ci 732f08c3bdfSopenharmony_cifsck_pass() 733f08c3bdfSopenharmony_ci{ 734f08c3bdfSopenharmony_ci local dir=$g_logdir/fsck 735f08c3bdfSopenharmony_ci local result=$dir/fsck.result 736f08c3bdfSopenharmony_ci local log=$dir/fsck.log 737f08c3bdfSopenharmony_ci 738f08c3bdfSopenharmony_ci echo "PASS: $@" > $result 739f08c3bdfSopenharmony_ci echo "PASS: $@" > $log 740f08c3bdfSopenharmony_ci} 741f08c3bdfSopenharmony_ci 742f08c3bdfSopenharmony_cirun_fsck() 743f08c3bdfSopenharmony_ci{ 744f08c3bdfSopenharmony_ci local dir=$g_logdir/fsck 745f08c3bdfSopenharmony_ci local result=$dir/fsck.result 746f08c3bdfSopenharmony_ci local log=$dir/fsck.log 747f08c3bdfSopenharmony_ci local fsck=fsck.$g_fstype 748f08c3bdfSopenharmony_ci local opts="" 749f08c3bdfSopenharmony_ci 750f08c3bdfSopenharmony_ci mkdir -p $dir 751f08c3bdfSopenharmony_ci echo -n "" > $log 752f08c3bdfSopenharmony_ci echo -n "" > $result 753f08c3bdfSopenharmony_ci 754f08c3bdfSopenharmony_ci [ $g_fstype = "btrfs" ] && fsck="btrfsck" 755f08c3bdfSopenharmony_ci [ $g_fstype = "reiserfs" ] && { 756f08c3bdfSopenharmony_ci fsck="reiserfsck" 757f08c3bdfSopenharmony_ci opts="-y" 758f08c3bdfSopenharmony_ci } 759f08c3bdfSopenharmony_ci begin "launch $fsck on $g_dev to check test result" 760f08c3bdfSopenharmony_ci silent_exec which $fsck || { 761f08c3bdfSopenharmony_ci fsck_err "fsck: unsupported fstype: $g_fstype" 762f08c3bdfSopenharmony_ci return 763f08c3bdfSopenharmony_ci } 764f08c3bdfSopenharmony_ci fs_sync 765f08c3bdfSopenharmony_ci silent_exec umount -f $g_dev || sleep $g_interval 766f08c3bdfSopenharmony_ci df | grep $g_dev > /dev/null 2>&1 767f08c3bdfSopenharmony_ci if [ $? -eq 0 ]; then 768f08c3bdfSopenharmony_ci silent_exec umount $g_dev || { 769f08c3bdfSopenharmony_ci fsck_err "cannot umount $g_dev to do $fsck" 770f08c3bdfSopenharmony_ci return 771f08c3bdfSopenharmony_ci } 772f08c3bdfSopenharmony_ci fi 773f08c3bdfSopenharmony_ci $fsck $opts $g_dev || fsck_err "err #$? while $fsck on $g_dev" 774f08c3bdfSopenharmony_ci silent_exec mount -t $g_fstype $g_dev $g_testdir || { 775f08c3bdfSopenharmony_ci fsck_err "cannot mount $g_testdir back after fsck_check" 776f08c3bdfSopenharmony_ci return 777f08c3bdfSopenharmony_ci } 778f08c3bdfSopenharmony_ci fsck_pass "$fsck got pass on $g_dev" 779f08c3bdfSopenharmony_ci end "launch $fsck on $g_dev to check test result" 780f08c3bdfSopenharmony_ci} 781f08c3bdfSopenharmony_ci 782f08c3bdfSopenharmony_cifsck_result() 783f08c3bdfSopenharmony_ci{ 784f08c3bdfSopenharmony_ci local dir=$g_logdir/fsck 785f08c3bdfSopenharmony_ci local result=$dir/fsck.result 786f08c3bdfSopenharmony_ci local log=$dir/fsck.log 787f08c3bdfSopenharmony_ci local fail_num=0; 788f08c3bdfSopenharmony_ci local pass_num=0; 789f08c3bdfSopenharmony_ci [ -f $result ] || { 790f08c3bdfSopenharmony_ci result "\tfsck.$g_fstype -- no result found" 791f08c3bdfSopenharmony_ci result "\t details: $log" 792f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 793f08c3bdfSopenharmony_ci return 794f08c3bdfSopenharmony_ci } 795f08c3bdfSopenharmony_ci 796f08c3bdfSopenharmony_ci fail_num=`grep FAILED $result | wc -l | awk '{print $1}'` 797f08c3bdfSopenharmony_ci pass_num=`grep PASS $result | wc -l | awk '{print $1}'` 798f08c3bdfSopenharmony_ci if [ $fail_num -ne 0 ]; then 799f08c3bdfSopenharmony_ci result "\tfsck.$g_fstype -- failed" 800f08c3bdfSopenharmony_ci result "\t log: $log" 801f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 802f08c3bdfSopenharmony_ci else 803f08c3bdfSopenharmony_ci if [ $pass_num -eq 0 ]; then 804f08c3bdfSopenharmony_ci result "\tfsck.$g_fstype -- not executed" 805f08c3bdfSopenharmony_ci result "\t log: $log" 806f08c3bdfSopenharmony_ci g_failed=`expr $g_failed + 1` 807f08c3bdfSopenharmony_ci else 808f08c3bdfSopenharmony_ci result "\tfsck.$g_fstype -- fsck on $g_dev got pass" 809f08c3bdfSopenharmony_ci fi 810f08c3bdfSopenharmony_ci fi 811f08c3bdfSopenharmony_ci} 812f08c3bdfSopenharmony_ci 813f08c3bdfSopenharmony_ciresult_check() 814f08c3bdfSopenharmony_ci{ 815f08c3bdfSopenharmony_ci begin "-- collecting test result" 816f08c3bdfSopenharmony_ci result "#############################################" 817f08c3bdfSopenharmony_ci result "result summary:" 818f08c3bdfSopenharmony_ci if [ $g_madvise -eq 1 ]; then 819f08c3bdfSopenharmony_ci page_poisoning_result 820f08c3bdfSopenharmony_ci else 821f08c3bdfSopenharmony_ci fs_metadata_result 822f08c3bdfSopenharmony_ci [ $g_runltp -eq 1 ] && ltp_result 823f08c3bdfSopenharmony_ci fi 824f08c3bdfSopenharmony_ci [ $g_netfs -eq 0 -a $g_test -eq 0 ] && fsck_result 825f08c3bdfSopenharmony_ci result "" 826f08c3bdfSopenharmony_ci result "totally $g_failed task-groups report failures" 827f08c3bdfSopenharmony_ci result "#############################################" 828f08c3bdfSopenharmony_ci end "-- collecting test result" 829f08c3bdfSopenharmony_ci} 830f08c3bdfSopenharmony_ci 831f08c3bdfSopenharmony_ciusage() 832f08c3bdfSopenharmony_ci{ 833f08c3bdfSopenharmony_ci echo "Usage: ./hwpoison.sh -d /dev/device [-options] [arguments]" 834f08c3bdfSopenharmony_ci echo 835f08c3bdfSopenharmony_ci echo "Stress Testing for Linux MCA High Level Handlers: " 836f08c3bdfSopenharmony_ci echo -e "\t-c console\t: target tty console to print test log" 837f08c3bdfSopenharmony_ci echo -e "\t-d device\t: target block device to run test on" 838f08c3bdfSopenharmony_ci echo -e "\t-f fstype\t: filesystem type to be tested" 839f08c3bdfSopenharmony_ci echo -e "\t-i interval\t: sleep interval (default is $g_interval seconds)" 840f08c3bdfSopenharmony_ci echo -e "\t-l logfile\t: log file" 841f08c3bdfSopenharmony_ci echo -e "\t-n netdev\t: target network disk to run test on" 842f08c3bdfSopenharmony_ci echo -e "\t-o ltproot\t: ltp root directory (default is $g_ltproot/)" 843f08c3bdfSopenharmony_ci echo -e "\t-p pagetype\t: page type to inject error " 844f08c3bdfSopenharmony_ci echo -e "\t-r result\t: result file" 845f08c3bdfSopenharmony_ci echo -e "\t-s pagesize\t: page size on the system (default is $g_pgsize bytes)" 846f08c3bdfSopenharmony_ci echo -e "\t-t duration\t: test duration time (default is $g_duration seconds)" 847f08c3bdfSopenharmony_ci echo -e "\t-A \t\t: use APEI to inject error" 848f08c3bdfSopenharmony_ci echo -e "\t-C children\t: process num of workloads" 849f08c3bdfSopenharmony_ci echo -e "\t-F \t\t: execute as force mode, no interaction with user" 850f08c3bdfSopenharmony_ci echo -e "\t-L \t\t: run ltp in background" 851f08c3bdfSopenharmony_ci echo -e "\t-M \t\t: run page_poisoning test thru madvise syscall" 852f08c3bdfSopenharmony_ci echo -e "\t-N \t\t: do not mkfs target block device" 853f08c3bdfSopenharmony_ci echo -e "\t-R recyle\t: automatically unpoison pages after running recyle seconds" 854f08c3bdfSopenharmony_ci echo -e "\t-S \t\t: test soft page offline" 855f08c3bdfSopenharmony_ci echo -e "\t-T \t\t: test mode, run test in local dir other than on target device" 856f08c3bdfSopenharmony_ci echo -e "\t-V \t\t: verbose mode, show debug info" 857f08c3bdfSopenharmony_ci echo -e "\t-h \t\t: print this page" 858f08c3bdfSopenharmony_ci echo 859f08c3bdfSopenharmony_ci echo -e "device:" 860f08c3bdfSopenharmony_ci echo -e "\tthis is a mandatory argument. typically, it's a disk partition." 861f08c3bdfSopenharmony_ci echo -e "\tall temporary files will be created on this device." 862f08c3bdfSopenharmony_ci echo -e "\terror injector will just inject errors to the pages associated" 863f08c3bdfSopenharmony_ci echo -e "\twith this device (except for the testing thru madvise syscall)." 864f08c3bdfSopenharmony_ci echo 865f08c3bdfSopenharmony_ci echo -e "pagetype:" 866f08c3bdfSopenharmony_ci echo -e "\tdefault page type:" 867f08c3bdfSopenharmony_ci echo -e "\t $g_pgtype" 868f08c3bdfSopenharmony_ci echo -e "\tfor more details, pls. try \`page-types -h\`." 869f08c3bdfSopenharmony_ci echo -e "\tsee the definition of \"bits-spec\"." 870f08c3bdfSopenharmony_ci echo 871f08c3bdfSopenharmony_ci echo -e "console:" 872f08c3bdfSopenharmony_ci echo -e "\ttest can print output to the console you specified." 873f08c3bdfSopenharmony_ci echo -e "\te.g. '-c /dev/tty1'" 874f08c3bdfSopenharmony_ci echo 875f08c3bdfSopenharmony_ci 876f08c3bdfSopenharmony_ci exit 0 877f08c3bdfSopenharmony_ci} 878f08c3bdfSopenharmony_ci 879f08c3bdfSopenharmony_cifs_sync() 880f08c3bdfSopenharmony_ci{ 881f08c3bdfSopenharmony_ci log "now to sync up the disk under testing, might need several minutes ..." 882f08c3bdfSopenharmony_ci sync 883f08c3bdfSopenharmony_ci} 884f08c3bdfSopenharmony_ci 885f08c3bdfSopenharmony_cistop_children() 886f08c3bdfSopenharmony_ci{ 887f08c3bdfSopenharmony_ci begin "-- cleaning up remaining tasks in background" 888f08c3bdfSopenharmony_ci if [ -n "$g_pid_madv" ]; then 889f08c3bdfSopenharmony_ci silent_exec ps $g_pid_madv 890f08c3bdfSopenharmony_ci [ $? -eq 0 ] && { 891f08c3bdfSopenharmony_ci kill -15 $g_pid_madv > /dev/null 2>&1 892f08c3bdfSopenharmony_ci sleep $g_interval 893f08c3bdfSopenharmony_ci } 894f08c3bdfSopenharmony_ci fi 895f08c3bdfSopenharmony_ci if [ -n "$g_pid_fsmeta" ]; then 896f08c3bdfSopenharmony_ci silent_exec ps $g_pid_fsmeta 897f08c3bdfSopenharmony_ci [ $? -eq 0 ] && { 898f08c3bdfSopenharmony_ci kill -15 $g_pid_fsmeta > /dev/null 2>&1 899f08c3bdfSopenharmony_ci sleep $g_interval 900f08c3bdfSopenharmony_ci } 901f08c3bdfSopenharmony_ci fi 902f08c3bdfSopenharmony_ci if [ -n "$g_pid_ltp" ]; then 903f08c3bdfSopenharmony_ci silent_exec ps $g_pid_ltp 904f08c3bdfSopenharmony_ci [ $? -eq 0 ] && { 905f08c3bdfSopenharmony_ci kill -15 $g_pid_ltp > /dev/null 2>&1 906f08c3bdfSopenharmony_ci sleep $g_interval 907f08c3bdfSopenharmony_ci } 908f08c3bdfSopenharmony_ci fi 909f08c3bdfSopenharmony_ci end "-- cleaning up remaining tasks in background" 910f08c3bdfSopenharmony_ci} 911f08c3bdfSopenharmony_ci 912f08c3bdfSopenharmony_cicleanup() 913f08c3bdfSopenharmony_ci{ 914f08c3bdfSopenharmony_ci log "!!! EXIT signal received, need to exit testing now. !!!" 915f08c3bdfSopenharmony_ci begin "preparing to complete testing" 916f08c3bdfSopenharmony_ci stop_children 917f08c3bdfSopenharmony_ci fs_sync 918f08c3bdfSopenharmony_ci result_check 919f08c3bdfSopenharmony_ci if [ $g_netfs -eq 0 ]; then 920f08c3bdfSopenharmony_ci df | grep $g_dev > /dev/null 2>&1 && silent_exec umount -f $g_dev 921f08c3bdfSopenharmony_ci else 922f08c3bdfSopenharmony_ci df | grep $g_netdev > /dev/null 2>&1 && silent_exec umount -f $g_netdev 923f08c3bdfSopenharmony_ci fi 924f08c3bdfSopenharmony_ci if [ $g_madvise -eq 1 ]; then 925f08c3bdfSopenharmony_ci echo $g_vm_dirty_background_ratio > /proc/sys/vm/dirty_background_ratio 926f08c3bdfSopenharmony_ci echo $g_vm_dirty_ratio > /proc/sys/vm/dirty_ratio 927f08c3bdfSopenharmony_ci echo $g_vm_dirty_expire_centisecs > /proc/sys/vm/dirty_expire_centisecs 928f08c3bdfSopenharmony_ci fi 929f08c3bdfSopenharmony_ci end "preparing to complete testing" 930f08c3bdfSopenharmony_ci log "!!! Linux HWPOISON stress testing DONE !!!" 931f08c3bdfSopenharmony_ci log "result: $g_result" 932f08c3bdfSopenharmony_ci log "log: $g_logfile" 933f08c3bdfSopenharmony_ci if [ $g_failed -ne 0 ]; then 934f08c3bdfSopenharmony_ci exit 1 935f08c3bdfSopenharmony_ci else 936f08c3bdfSopenharmony_ci exit 0 937f08c3bdfSopenharmony_ci fi 938f08c3bdfSopenharmony_ci} 939f08c3bdfSopenharmony_ci 940f08c3bdfSopenharmony_ciselect_injector() 941f08c3bdfSopenharmony_ci{ 942f08c3bdfSopenharmony_ci# for test mode, apei injector is not supported. 943f08c3bdfSopenharmony_ci if [ $g_test -eq 1 ]; then 944f08c3bdfSopenharmony_ci [ $g_apei -eq 1 ] && g_apei=0 945f08c3bdfSopenharmony_ci if [ $g_madvise -eq 1 ]; then 946f08c3bdfSopenharmony_ci g_pfninj=0 947f08c3bdfSopenharmony_ci else 948f08c3bdfSopenharmony_ci g_soft_offline=1 949f08c3bdfSopenharmony_ci fi 950f08c3bdfSopenharmony_ci fi 951f08c3bdfSopenharmony_ci 952f08c3bdfSopenharmony_ci# for non-test mode, apei injector is 1st priority. 953f08c3bdfSopenharmony_ci if [ $g_apei -eq 1 ]; then 954f08c3bdfSopenharmony_ci g_pfninj=0 955f08c3bdfSopenharmony_ci g_madvise=0 956f08c3bdfSopenharmony_ci fi 957f08c3bdfSopenharmony_ci 958f08c3bdfSopenharmony_ci if [ $g_madvise -eq 1 ]; then 959f08c3bdfSopenharmony_ci g_pfninj=0 960f08c3bdfSopenharmony_ci fi 961f08c3bdfSopenharmony_ci} 962f08c3bdfSopenharmony_ci 963f08c3bdfSopenharmony_cig_children=0 # child process num for each workload. 964f08c3bdfSopenharmony_ci # 0 means using default child process num of each workload. 965f08c3bdfSopenharmony_cig_dev= 966f08c3bdfSopenharmony_cig_debugfs= 967f08c3bdfSopenharmony_cig_netdev= 968f08c3bdfSopenharmony_cig_fstype=ext3 969f08c3bdfSopenharmony_cig_netfs=0 970f08c3bdfSopenharmony_cig_nomkfs=0 971f08c3bdfSopenharmony_cig_force=0 972f08c3bdfSopenharmony_cilet "g_duration=120" 973f08c3bdfSopenharmony_cig_interval=5 974f08c3bdfSopenharmony_cig_runltp=0 975f08c3bdfSopenharmony_cig_ltproot="/ltp" 976f08c3bdfSopenharmony_cig_ltppan="$g_ltproot/pan/ltp-pan" 977f08c3bdfSopenharmony_cig_pagetool="page-types" 978f08c3bdfSopenharmony_cig_madvise=0 979f08c3bdfSopenharmony_cig_apei=0 980f08c3bdfSopenharmony_cig_pfninj=1 981f08c3bdfSopenharmony_cig_rootdir=`pwd` 982f08c3bdfSopenharmony_cig_bindir=$g_rootdir/bin 983f08c3bdfSopenharmony_cig_casedir=$g_rootdir/runtest 984f08c3bdfSopenharmony_cig_logdir=$g_rootdir/log 985f08c3bdfSopenharmony_cig_testdir=$g_rootdir/hwpoison 986f08c3bdfSopenharmony_cig_resultdir=$g_rootdir/result 987f08c3bdfSopenharmony_cig_logfile=$g_resultdir/hwpoison.log 988f08c3bdfSopenharmony_cig_result=$g_resultdir/hwpoison.result 989f08c3bdfSopenharmony_cig_failed=0 990f08c3bdfSopenharmony_cig_time_s= 991f08c3bdfSopenharmony_cig_time_e= 992f08c3bdfSopenharmony_cig_tty=`tty` 993f08c3bdfSopenharmony_cig_pid_madv= 994f08c3bdfSopenharmony_cig_pid_fsmeta= 995f08c3bdfSopenharmony_cig_pid_ltp= 996f08c3bdfSopenharmony_cig_progress= 997f08c3bdfSopenharmony_cig_percent=0 998f08c3bdfSopenharmony_cig_pgtype="lru,referenced,readahead,swapcache,swapbacked,anonymous" 999f08c3bdfSopenharmony_cig_pgsize=4096 # page size on the system 1000f08c3bdfSopenharmony_cig_maxpfn= # maxpfn on the system 1001f08c3bdfSopenharmony_cig_highmem_s= # start pfn of highmem 1002f08c3bdfSopenharmony_cig_highmem_e= # end pfn of highmem 1003f08c3bdfSopenharmony_cig_lowmem_s= # start pfn of mem < 4G 1004f08c3bdfSopenharmony_cig_lowmem_e= # end pfn of mem < 4G 1005f08c3bdfSopenharmony_cig_sysfs_mem="/sys/devices/system/memory" 1006f08c3bdfSopenharmony_cig_soft_offline=0 1007f08c3bdfSopenharmony_cig_test=0 1008f08c3bdfSopenharmony_ci 1009f08c3bdfSopenharmony_ci# recyle poisoned page 1010f08c3bdfSopenharmony_cig_recycle=0 1011f08c3bdfSopenharmony_cig_last=0 1012f08c3bdfSopenharmony_ci 1013f08c3bdfSopenharmony_ci# madvise injector specific global variable 1014f08c3bdfSopenharmony_cig_vm_dirty_background_ratio=`cat /proc/sys/vm/dirty_background_ratio` 1015f08c3bdfSopenharmony_cig_vm_dirty_ratio=`cat /proc/sys/vm/dirty_ratio` 1016f08c3bdfSopenharmony_cig_vm_dirty_expire_centisecs=`cat /proc/sys/vm/dirty_expire_centisecs` 1017f08c3bdfSopenharmony_ci 1018f08c3bdfSopenharmony_ci# test parameters 1019f08c3bdfSopenharmony_cig_parameter=$@ 1020f08c3bdfSopenharmony_ci 1021f08c3bdfSopenharmony_ciwhile getopts ":c:d:f:hi:l:n:o:p:r:s:t:C:LMR:STAFNV" option 1022f08c3bdfSopenharmony_cido 1023f08c3bdfSopenharmony_ci case $option in 1024f08c3bdfSopenharmony_ci c) g_tty=$OPTARG;; 1025f08c3bdfSopenharmony_ci d) g_dev=$OPTARG;; 1026f08c3bdfSopenharmony_ci f) g_fstype=$OPTARG;; 1027f08c3bdfSopenharmony_ci l) g_logfile=$OPTARG;; 1028f08c3bdfSopenharmony_ci t) g_duration=$OPTARG;; 1029f08c3bdfSopenharmony_ci i) g_interval=$OPTARG;; 1030f08c3bdfSopenharmony_ci n) g_netdev=$OPTARG;; 1031f08c3bdfSopenharmony_ci o) g_ltproot=$OPTARG 1032f08c3bdfSopenharmony_ci g_ltppan="$g_ltproot/pan/ltp-pan";; 1033f08c3bdfSopenharmony_ci p) g_pgtype=$OPTARG;; 1034f08c3bdfSopenharmony_ci s) g_pgsize=$OPTARG;; 1035f08c3bdfSopenharmony_ci r) g_result=$OPTARG;; 1036f08c3bdfSopenharmony_ci C) g_children=$OPTARG;; 1037f08c3bdfSopenharmony_ci L) g_runltp=1;; 1038f08c3bdfSopenharmony_ci M) g_madvise=1;; 1039f08c3bdfSopenharmony_ci R) g_recycle=$OPTARG;; 1040f08c3bdfSopenharmony_ci S) g_soft_offline=1;; 1041f08c3bdfSopenharmony_ci T) g_test=1;; 1042f08c3bdfSopenharmony_ci A) g_apei=1;; 1043f08c3bdfSopenharmony_ci F) g_force=1;; 1044f08c3bdfSopenharmony_ci N) g_nomkfs=1;; 1045f08c3bdfSopenharmony_ci V) DEBUG=1;; 1046f08c3bdfSopenharmony_ci h) usage;; 1047f08c3bdfSopenharmony_ci *) invalid "invalid option";; 1048f08c3bdfSopenharmony_ci esac 1049f08c3bdfSopenharmony_cidone 1050f08c3bdfSopenharmony_ci 1051f08c3bdfSopenharmony_ciselect_injector 1052f08c3bdfSopenharmony_cisetup_log 1053f08c3bdfSopenharmony_cilog "!!! Linux HWPOISON stress testing starts NOW !!!" 1054f08c3bdfSopenharmony_cilog "!!! test will run about $g_duration seconds !!!" 1055f08c3bdfSopenharmony_cisetup_env 1056f08c3bdfSopenharmony_ciif [ $g_madvise -eq 0 ]; then 1057f08c3bdfSopenharmony_ci [ $g_runltp -eq 1 ] && run_ltp 1058f08c3bdfSopenharmony_ci run_workloads 1059f08c3bdfSopenharmony_cifi 1060f08c3bdfSopenharmony_cierr_inject 1061f08c3bdfSopenharmony_ci[ $g_netfs -eq 0 -a $g_test -eq 0 ] && run_fsck 1062