1210753Srpaulo#!/bin/ksh 2210753Srpaulo# 3210753Srpaulo# CDDL HEADER START 4210753Srpaulo# 5210753Srpaulo# The contents of this file are subject to the terms of the 6210753Srpaulo# Common Development and Distribution License (the "License"). 7210753Srpaulo# You may not use this file except in compliance with the License. 8210753Srpaulo# 9210753Srpaulo# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10210753Srpaulo# or http://www.opensolaris.org/os/licensing. 11210753Srpaulo# See the License for the specific language governing permissions 12210753Srpaulo# and limitations under the License. 13210753Srpaulo# 14210753Srpaulo# When distributing Covered Code, include this CDDL HEADER in each 15210753Srpaulo# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16210753Srpaulo# If applicable, add the following below this CDDL HEADER, with the 17210753Srpaulo# fields enclosed by brackets "[]" replaced with your own identifying 18210753Srpaulo# information: Portions Copyright [yyyy] [name of copyright owner] 19210753Srpaulo# 20210753Srpaulo# CDDL HEADER END 21210753Srpaulo# 22210753Srpaulo 23210753Srpaulo# 24210753Srpaulo# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25210753Srpaulo# Use is subject to license terms. 26210753Srpaulo# 27210753Srpaulo 28210753Srpaulo# 29210753Srpaulo# This script verifies that we can fire a probe on each CPU that is in 30210753Srpaulo# an online state. 31210753Srpaulo# 32210753Srpaulo# The script will fail if: 33210753Srpaulo# 1) The system under test does not define the 'PAPI_tot_ins' event. 34210753Srpaulo# 35210753Srpaulo 36210753Srpauloif [ $# != 1 ]; then 37210753Srpaulo echo expected one argument: '<'dtrace-path'>' 38210753Srpaulo exit 2 39210753Srpaulofi 40210753Srpaulo 41210753Srpaulodtrace=$1 42210753Srpaulonumproc=`psrinfo | tail -1 | cut -f1` 43210753Srpaulocpu=0 44210753Srpaulodtraceout=/var/tmp/dtrace.out.$$ 45210753Srpauloscriptout=/var/tmp/script.out.$$ 46210753Srpaulo 47210753Srpaulospin() 48210753Srpaulo{ 49210753Srpaulo while [ 1 ]; do 50210753Srpaulo : 51210753Srpaulo done 52210753Srpaulo} 53210753Srpaulo 54210753Srpauloscript() 55210753Srpaulo{ 56210753Srpaulo $dtrace -o $dtraceout -s /dev/stdin <<EOF 57210753Srpaulo #pragma D option bufsize=128k 58210753Srpaulo #pragma D option quiet 59210753Srpaulo 60210753Srpaulo cpc:::PAPI_tot_ins-user-10000 61210753Srpaulo /cpus[cpu] != 1/ 62210753Srpaulo { 63210753Srpaulo cpus[cpu] = 1; 64210753Srpaulo @a[cpu] = count(); 65210753Srpaulo } 66210753Srpaulo 67210753Srpaulo tick-1s 68210753Srpaulo /n++ > 10/ 69210753Srpaulo { 70210753Srpaulo printa(@a); 71210753Srpaulo exit(0); 72210753Srpaulo } 73210753SrpauloEOF 74210753Srpaulo} 75210753Srpaulo 76210753Srpauloecho "" > $scriptout 77210753Srpaulowhile [ $cpu -le $numproc ] 78210753Srpaulodo 79210753Srpaulo if [ "`psrinfo -s $cpu 2> /dev/null`" -eq 1 ]; then 80210753Srpaulo printf "%9d %16d\n" $cpu 1 >> $scriptout 81210753Srpaulo spin & 82210753Srpaulo allpids[$cpu]=$! 83210753Srpaulo pbind -b $cpu $! 84210753Srpaulo fi 85210753Srpaulo cpu=$(($cpu+1)) 86210753Srpaulodone 87210753Srpauloecho "" >> $scriptout 88210753Srpaulo 89210753Srpauloscript 90210753Srpaulo 91210753Srpaulodiff $dtraceout $scriptout >/dev/null 2>&1 92210753Srpaulostatus=$? 93210753Srpaulo 94210753Srpaulo# kill off the spinner processes 95210753Srpaulocpu=0 96210753Srpaulowhile [ $cpu -le $numproc ] 97210753Srpaulodo 98210753Srpaulo if [ "`psrinfo -s $cpu 2> /dev/null`" -eq 1 ]; then 99210753Srpaulo kill ${allpids[$cpu]} 100210753Srpaulo fi 101210753Srpaulo cpu=$(($cpu+1)) 102210753Srpaulodone 103210753Srpaulo 104210753Srpaulorm $dtraceout 105210753Srpaulorm $scriptout 106210753Srpaulo 107210753Srpauloexit $status 108