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 requires 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 70if tst_kvcmp -lt "3.12"; then 71 rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \ 72 srcu_sync srcu_expedited sched_sync sched_expedited" 73 74 if tst_kvcmp -lt "3.11"; then 75 rcu_type="$rcu_type srcu_raw srcu_raw_sync" 76 fi 77fi 78 79TST_TOTAL=$(echo "$rcu_type" | wc -w) 80 81est_time=`echo "scale=2; $test_time * $TST_TOTAL / 60 " | bc` 82tst_resm TINFO "estimate time $est_time min" 83 84for type in $rcu_type; do 85 86 tst_resm TINFO "$type: running $test_time sec..." 87 88 modprobe rcutorture nfakewriters=$num_writers \ 89 stat_interval=60 test_no_idle_hz=1 shuffle_interval=3 \ 90 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 \ 91 fqs_stutter=3 test_boost=1 test_boost_interval=7 \ 92 test_boost_duration=4 shutdown_secs=0 \ 93 stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 \ 94 onoff_interval=0 onoff_holdoff=0 torture_type=$type \ 95 > /dev/null 2>&1 || tst_brkm TBROK "failed to load module" 96 97 sleep $test_time 98 99 rmmod rcutorture > /dev/null 2>&1 || \ 100 tst_brkm TBROK "failed to unload module" 101 102 # check module status in dmesg 103 result_str=`dmesg | sed -nE '$s/.*End of test: ([A-Z]+):.*/\1/p'` 104 if [ "$result_str" = "SUCCESS" ]; then 105 tst_resm TPASS "$type: completed" 106 else 107 tst_resm TFAIL "$type: $result_str, see dmesg" 108 fi 109done 110 111tst_exit 112