From: John L. <mov...@us...> - 2003-10-15 04:08:25
|
Update of /cvsroot/oprofile/oprofile/utils In directory sc8-pr-cvs1:/tmp/cvs-serv1781/utils Modified Files: opcontrol Log Message: merge some more code, ~50 lines of opcontrol Index: opcontrol =================================================================== RCS file: /cvsroot/oprofile/oprofile/utils/opcontrol,v retrieving revision 1.90 retrieving revision 1.91 diff -u -p -d -r1.90 -r1.91 --- opcontrol 15 Oct 2003 03:49:37 -0000 1.90 +++ opcontrol 15 Oct 2003 04:08:22 -0000 1.91 @@ -751,75 +751,46 @@ do_setup() { } -# initialise sysctl parameters -do_sysctl_setup_24() { - if [ $BUF_SIZE != 0 ]; then - $SYSCTL -w dev.oprofile.bufsize=$BUF_SIZE - fi - if [ $NOTE_SIZE != 0 ]; then - $SYSCTL -w dev.oprofile.notesize=$NOTE_SIZE +# set a sysctl/oprofilefs parameter +set_param() +{ + if test "$KERNEL_SUPPORT" = "yes"; then + echo $2 >$MOUNT/$1 + else + $SYSCTL -w dev.oprofile.$1=$2 fi +} - if test "$IS_TIMER" = 1; then + +# set a sysctl/oprofilefs counter parameter +set_ctr_param() +{ + # no such thing for perfmon + if test "$IS_PERFMON" = "yes"; then return fi - # use the default setup if none set - if test "$NR_CHOSEN" = 0; then - CHOSEN_EVENTS[0]=$DEFAULT_EVENT - NR_CHOSEN=1 - HW_CTRS=`$OP_HELP --check-events $DEFAULT_EVENT` - echo "Using default event: ${CHOSEN_EVENTS[0]}" + if test "$KERNEL_SUPPORT" = "yes"; then + echo $3 >$MOUNT/$1/$2 + else + $SYSCTL -w dev.oprofile.$1.$2=$3 fi - - # Necessary in this case : - # opcontrol ctr0-on ctr1-on then opcontrol ctr0-on - for f in $OP_COUNTERS ; do - $SYSCTL -w dev.oprofile.$f.enabled=0 - $SYSCTL -w dev.oprofile.$f.event=0 - $SYSCTL -w dev.oprofile.$f.count=0 - done - - verify_counters - - for f in `seq 0 $((NR_CHOSEN - 1))`; do - if test "${CHOSEN_EVENTS[$f]}" != ""; then - EVENT=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $1}'` - EVENT_VAL=`$OP_HELP $EVENT` - COUNT=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $2}'` - UNIT_MASK=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $3}'` - KERNEL=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $4}'` - USER=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $5}'` - CTR=`echo $HW_CTRS | awk "{print \\$$((f + 1))}"` - if test -z "$UNIT_MASK"; then - TMPEVENT="$EVENT:$COUNT" - UNIT_MASK=`$OP_HELP --unit-mask $TMPEVENT` - fi - if test -z "$KERNEL"; then - KERNEL=1 - fi - if test -z "$USER"; then - USER=1 - fi - if test "$EVENT" = "RTC_INTERRUPTS"; then - $SYSCTL -w dev.oprofile.rtc_value=$COUNT - else - $SYSCTL -w dev.oprofile.$CTR.enabled=1 - $SYSCTL -w dev.oprofile.$CTR.event=$EVENT_VAL - $SYSCTL -w dev.oprofile.$CTR.count=$COUNT - $SYSCTL -w dev.oprofile.$CTR.kernel=$KERNEL - $SYSCTL -w dev.oprofile.$CTR.user=$USER - $SYSCTL -w dev.oprofile.$CTR.unit_mask=$UNIT_MASK - fi - fi - done } -# initialise sysctl parameters -do_sysctl_setup_25() { +do_param_setup() +{ + # different names if [ $BUF_SIZE != 0 ]; then - echo $BUF_SIZE >$MOUNT/buffer_size + if test "$KERNEL_SUPPORT" = "yes"; then + echo $BUF_SIZE >$MOUNT/buffer_size + else + $SYSCTL -w dev.oprofile.bufsize=$BUF_SIZE + fi + fi + + if [ $NOTE_SIZE != 0 ]; then + set_param notesize $NOTE_SIZE fi if test "$IS_TIMER" = 1; then @@ -834,21 +805,17 @@ do_sysctl_setup_25() { echo "Using default event: ${CHOSEN_EVENTS[0]}" fi - # no such thing for perfmon - if test "$IS_PERFMON" = yes; then - return - fi - # Necessary in this case : # opcontrol ctr0-on ctr1-on then opcontrol ctr0-on for f in $OP_COUNTERS ; do - echo 0 >$MOUNT/$f/enabled - echo 0 >$MOUNT/$f/event - echo 0 >$MOUNT/$f/count + set_ctr_param $f enabled 0 + set_ctr_param $f event 0 + set_ctr_param $f count 0 done verify_counters + OPROFILED_EVENTS= for f in `seq 0 $((NR_CHOSEN - 1))`; do if test "${CHOSEN_EVENTS[$f]}" != ""; then EVENT=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $1}'` @@ -869,40 +836,15 @@ do_sysctl_setup_25() { USER=1 fi if test "$EVENT" = "RTC_INTERRUPTS"; then - echo $COUNT >$MOUNT/rtc_value + set_param rtc_value $COUNT + $SYSCTL -w dev.oprofile.rtc_value=$COUNT else - echo 1 >$MOUNT/$CTR/enabled - echo $EVENT_VAL >$MOUNT/$CTR/event - echo $COUNT >$MOUNT/$CTR/count - echo $KERNEL >$MOUNT/$CTR/kernel - echo $USER >$MOUNT/$CTR/user - echo $UNIT_MASK >$MOUNT/$CTR/unit_mask - fi - fi - done -} - - -get_events() { - OPROFILED_EVENTS= - for f in `seq 0 $((NR_CHOSEN - 1))`; do - if test "${CHOSEN_EVENTS[$f]}" != ""; then - EVENT=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $1}'` - EVENT_VAL=`$OP_HELP $EVENT` - COUNT=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $2}'` - UNIT_MASK=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $3}'` - KERNEL=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $4}'` - USER=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $5}'` - CTR=`echo $HW_CTRS | awk "{print \\$$((f + 1))}"` - if test -z "$UNIT_MASK"; then - TMPEVENT="$EVENT:$COUNT" - UNIT_MASK=`$OP_HELP --unit-mask $TMPEVENT` - fi - if test -z "$KERNEL"; then - KERNEL=1 - fi - if test -z "$USER"; then - USER=1 + set_ctr_param $CTR enabled 1 + set_ctr_param $CTR event $EVENT_VAL + set_ctr_param $CTR count $COUNT + set_ctr_param $CTR kernel $KERNEL + set_ctr_param $CTR user $USER + set_ctr_param $CTR unit_mask $UNIT_MASK fi OPROFILED_EVENTS=${OPROFILED_EVENTS}$EVENT:$EVENT_VAL: OPROFILED_EVENTS=${OPROFILED_EVENTS}$CTR:$COUNT:$UNIT_MASK: @@ -912,15 +854,6 @@ get_events() { } -do_sysctl_setup() { - if test "$KERNEL_SUPPORT" = "yes"; then - do_sysctl_setup_25 - else - do_sysctl_setup_24 - fi -} - - do_start_daemon() { if test -f "$LOCK_FILE"; then @@ -937,7 +870,7 @@ do_start_daemon() { do_load_setup check_valid_args get_kernel_range - do_sysctl_setup + do_param_setup OPD_ARGS=" \ --separate-lib=$SEPARATE_LIB \ @@ -945,7 +878,6 @@ do_start_daemon() { --separate-thread=$SEPARATE_THREAD \ --separate-cpu=$SEPARATE_CPU" - get_events OPD_ARGS="$OPD_ARGS --events=$OPROFILED_EVENTS" if [ "$VMLINUX" = "none" ]; then |