1#!/bin/sh 2# Copyright (c) 2014-2015 Oracle and/or its affiliates. All Rights Reserved. 3# 4# This program is free software; you can redistribute it and/or 5# modify it under the terms of the GNU General Public License as 6# published by the Free Software Foundation; either version 2 of 7# the License, or (at your option) any later version. 8# 9# This program is distributed in the hope that it would be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program; if not, write the Free Software Foundation, 16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17# 18# Author: Alexey Kodanev <alexey.kodanev@oracle.com> 19# 20# One of the possible ways to test RCU is to use rcutorture kernel module. 21# The test requiers that kernel configured with CONFIG_RCU_TORTURE_TEST. 22# It runs rcutorture module using particular options and then inspects 23# dmesg output for module's test results. 24# For more information, please read Linux Documentation: RCU/torture.txt 25 26TCID="rcu_torture" 27TST_TOTAL=14 28TST_CLEANUP=cleanup 29 30. test.sh 31 32# default options 33test_time=60 34num_writers=5 35 36while getopts :ht:w: opt; do 37 case "$opt" in 38 h) 39 echo "Usage:" 40 echo "h help" 41 echo "t x time in seconds for each test-case" 42 echo "w x number of writers" 43 exit 0 44 ;; 45 t) test_time=$OPTARG ;; 46 w) num_writers=$OPTARG ;; 47 *) 48 tst_brkm TBROK "unknown option: $opt" 49 ;; 50 esac 51done 52 53cleanup() 54{ 55 tst_resm TINFO "cleanup" 56 rmmod rcutorture > /dev/null 2>&1 57} 58 59tst_require_root 60 61# check if module is present 62modprobe rcutorture > /dev/null 2>&1 || \ 63 tst_brkm TCONF "Test requires rcutorture module" 64rmmod rcutorture > /dev/null 2>&1 65 66trap cleanup INT 67 68rcu_type="rcu rcu_bh srcu sched" 69 70tst_kvercmp 3 12 0 71if [ $? -eq 0 ]; then 72 rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \ 73 srcu_sync srcu_expedited sched_sync sched_expedited" 74 75 tst_kvercmp 3 11 0 76 if [ $? -eq 0 ]; then 77 rcu_type="$rcu_type srcu_raw srcu_raw_sync" 78 fi 79fi 80 81TST_TOTAL=$(echo "$rcu_type" | wc -w) 82 83est_time=`echo "scale=2; $test_time * $TST_TOTAL / 60 " | bc` 84tst_resm TINFO "estimate time $est_time min" 85 86for type in $rcu_type; do 87 88 tst_resm TINFO "$type: running $test_time sec..." 89 90 modprobe rcutorture nfakewriters=$num_writers \ 91 stat_interval=60 test_no_idle_hz=1 shuffle_interval=3 \ 92 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 \ 93 fqs_stutter=3 test_boost=1 test_boost_interval=7 \ 94 test_boost_duration=4 shutdown_secs=0 \ 95 stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 \ 96 onoff_interval=0 onoff_holdoff=0 torture_type=$type \ 97 > /dev/null 2>&1 || tst_brkm TBROK "failed to load module" 98 99 sleep $test_time 100 101 rmmod rcutorture > /dev/null 2>&1 || \ 102 tst_brkm TBROK "failed to unload module" 103 104 # check module status in dmesg 105 result_str=`dmesg | sed -nE '$s/.*End of test: ([A-Z]+):.*/\1/p'` 106 if [ "$result_str" = "SUCCESS" ]; then 107 tst_resm TPASS "$type: completed" 108 else 109 tst_resm TFAIL "$type: $result_str, see dmesg" 110 fi 111done 112 113tst_exit 114