From 37aea5e4e06d30267c01ae3d078be34fb07fcfd3 Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Tue, 22 Mar 2016 20:55:20 +0100 Subject: rename st_trace -> st-trace-schedule Let's use consistent tool names... --- st-trace-schedule | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ st_trace | 105 ------------------------------------------------------ 2 files changed, 105 insertions(+), 105 deletions(-) create mode 100755 st-trace-schedule delete mode 100755 st_trace diff --git a/st-trace-schedule b/st-trace-schedule new file mode 100755 index 0000000..680772e --- /dev/null +++ b/st-trace-schedule @@ -0,0 +1,105 @@ +#!/bin/bash + +PATH_TO_SCRIPT=`dirname $0` +function find_helper() +{ + IN_PATH=`which $1` + REL_TO_PATH="$PATH_TO_SCRIPT/$2" + if [ -z "$IN_PATH" ] && [ ! -z "$PATH_TO_SCRIPT" ] && [ -x "$PATH_TO_SCRIPT/$1" ] + then + echo "$PATH_TO_SCRIPT/$1" + elif [ -z "$IN_PATH" ] && [ ! -z "$PATH_TO_SCRIPT" ] && [ -x "$REL_TO_PATH/$1" ] + then + echo "$REL_TO_PATH/$1" + else + echo "$IN_PATH" + fi +} + +function die() +{ + echo "Error: $*" + exit 1 +} + + +[ -z "$FTCAT" ] && FTCAT=`find_helper ftcat ../ft_tools` +[ -z "$FTCAT" ] && die "Can't find 'ftcat' utility." +[ -z "$FTDEV" ] && FTDEV=/dev/litmus/sched_trace + +if [ "$1" == "-s" ] +then + AUTO=1 + shift +fi + +PIDS="" + +# signal that we're done gathering data and clean up +on_finish() +{ + echo "Ending Trace..." + kill $PIDS + wait $PIDS + + exit 0 +} + +# register shutdown signal handler +trap 'on_finish' SIGUSR1 + + + +# Setup up sched_trace tracing. + +# works for sparc64 and Intel x86 if all CPUs are online +NUM_CPUS=`egrep -c '^processor|online' /proc/cpuinfo` + +# Trace ID Key: +# 501 - sched_trace_task_name +# 502 - sched_trace_task_param +# 503 - sched_trace_task_release +# 504 - sched_trace_task_switch_to +# 505 - sched_trace_task_switch_away +# 506 - sched_trace_task_completion +# 507 - sched_trace_task_block +# 508 - sched_trace_task_resume +# 509 - sched_trace_action +# 510 - sched_trace_sys_release +ST_IDS="501 502 503 504 505 506 507 508 509 510" + +DIR=`mktemp -d` || die "mktemp failed" + +TAG=$1 +PIDS="" +COUNT=0 +for x in `seq 0 $(($NUM_CPUS - 1))` +do + TARGET="st-${TAG}_cpu=${x}.bin" + echo -n "CPU $x: " + $FTCAT -p "$DIR/cpu${x}.pid" "$FTDEV$x" $ST_IDS > "$TARGET" & + PIDS="$PIDS $!" + echo $! "> $TARGET [$?]" + COUNT=$((COUNT + 1)) +done + +READY=`ls $DIR/*.pid | wc -l` +while [[ $READY != $COUNT ]] +do + sleep 0.5 + READY=`ls $DIR/*.pid | wc -l` +done + +rm $DIR/*.pid +rmdir $DIR + +if [[ $AUTO != 1 ]] +then + echo "Press Enter to end tracing..." + read + on_finish +else + # wait for SIGUSR1 to terminate + echo "Waiting for SIGUSR1 to end tracing..." + wait $PIDS +fi diff --git a/st_trace b/st_trace deleted file mode 100755 index 680772e..0000000 --- a/st_trace +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash - -PATH_TO_SCRIPT=`dirname $0` -function find_helper() -{ - IN_PATH=`which $1` - REL_TO_PATH="$PATH_TO_SCRIPT/$2" - if [ -z "$IN_PATH" ] && [ ! -z "$PATH_TO_SCRIPT" ] && [ -x "$PATH_TO_SCRIPT/$1" ] - then - echo "$PATH_TO_SCRIPT/$1" - elif [ -z "$IN_PATH" ] && [ ! -z "$PATH_TO_SCRIPT" ] && [ -x "$REL_TO_PATH/$1" ] - then - echo "$REL_TO_PATH/$1" - else - echo "$IN_PATH" - fi -} - -function die() -{ - echo "Error: $*" - exit 1 -} - - -[ -z "$FTCAT" ] && FTCAT=`find_helper ftcat ../ft_tools` -[ -z "$FTCAT" ] && die "Can't find 'ftcat' utility." -[ -z "$FTDEV" ] && FTDEV=/dev/litmus/sched_trace - -if [ "$1" == "-s" ] -then - AUTO=1 - shift -fi - -PIDS="" - -# signal that we're done gathering data and clean up -on_finish() -{ - echo "Ending Trace..." - kill $PIDS - wait $PIDS - - exit 0 -} - -# register shutdown signal handler -trap 'on_finish' SIGUSR1 - - - -# Setup up sched_trace tracing. - -# works for sparc64 and Intel x86 if all CPUs are online -NUM_CPUS=`egrep -c '^processor|online' /proc/cpuinfo` - -# Trace ID Key: -# 501 - sched_trace_task_name -# 502 - sched_trace_task_param -# 503 - sched_trace_task_release -# 504 - sched_trace_task_switch_to -# 505 - sched_trace_task_switch_away -# 506 - sched_trace_task_completion -# 507 - sched_trace_task_block -# 508 - sched_trace_task_resume -# 509 - sched_trace_action -# 510 - sched_trace_sys_release -ST_IDS="501 502 503 504 505 506 507 508 509 510" - -DIR=`mktemp -d` || die "mktemp failed" - -TAG=$1 -PIDS="" -COUNT=0 -for x in `seq 0 $(($NUM_CPUS - 1))` -do - TARGET="st-${TAG}_cpu=${x}.bin" - echo -n "CPU $x: " - $FTCAT -p "$DIR/cpu${x}.pid" "$FTDEV$x" $ST_IDS > "$TARGET" & - PIDS="$PIDS $!" - echo $! "> $TARGET [$?]" - COUNT=$((COUNT + 1)) -done - -READY=`ls $DIR/*.pid | wc -l` -while [[ $READY != $COUNT ]] -do - sleep 0.5 - READY=`ls $DIR/*.pid | wc -l` -done - -rm $DIR/*.pid -rmdir $DIR - -if [[ $AUTO != 1 ]] -then - echo "Press Enter to end tracing..." - read - on_finish -else - # wait for SIGUSR1 to terminate - echo "Waiting for SIGUSR1 to end tracing..." - wait $PIDS -fi -- cgit v1.2.2