oprofile_start.sh has the option of scaling the sampling of PMU events
by some factor. The reasoning is that oprofile introduces high overhead
when sampling at it's maximum rate - somewhere between 8% and 14%
depending on the workload. However, the minimum sampling rate for CPU
cycles and events such as DTLB misses are significantly different. CPU
cycles may know need to be scaled by a factor of 4 and DTLB misses by a
factor of 16 to get acceptable performance overhead of profiling.

This patch allows CPU cycles and events to be scaled by separate values.

Signed-off-by: Mel Gorman <m...@csn.ul.ie>
--- 
 oprofile_map_events.pl |   19 +++++++++++++------
 oprofile_start.sh      |   28 +++++++++++++++-------------
 2 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/oprofile_map_events.pl b/oprofile_map_events.pl
index 5fc4faf..2aff660 100755
--- a/oprofile_map_events.pl
+++ b/oprofile_map_events.pl
@@ -14,7 +14,8 @@ use strict;
 my ($arch, $cputype);
 my $opt_verbose;
 my $opt_event;
-my $opt_factor=1;
+my $opt_cycle_factor=1;
+my $opt_event_factor=1;
 my $p = "oprofile_map_events.pl";
 
 my $oprofile_event;
@@ -50,9 +51,10 @@ $map_event_name{"ppc64##970MP##l1l2cache_miss"} = 
"PM_DATA_FROM_MEM_GRP50:1000";
 $map_event_name{"ppc64##power5##dtlb_miss"} = "PM_DTLB_MISS_GRP44:100000";
 
 GetOptions(
-       'verbose'               =>      \$opt_verbose,
-       'sample-factor|s=s'     =>      \$opt_factor,
-       'event|e=s'             =>      \$opt_event,
+       'verbose'                       =>      \$opt_verbose,
+       'sample-cycle-factor|c=n'       =>      \$opt_cycle_factor,
+       'sample-event-factor|e=n'       =>      \$opt_event_factor,
+       'event|e=s'                     =>      \$opt_event,
        );
 setVerbose if $opt_verbose;
 
@@ -94,9 +96,14 @@ if ($oprofile_event eq "") {
 }
 
 # Apply the sampling factor if specified
-if ($opt_factor != 1) {
+if ($opt_cycle_factor != 1 || $opt_event_factor != 1) {
        my ($event, $sample, $mask) = split(/:/, $oprofile_event);
-       $sample *= $opt_factor;
+
+       if ($opt_event eq "timer") {
+               $sample *= $opt_cycle_factor;
+       } else {
+               $sample *= $opt_event_factor;
+       }
        if ($mask eq "") {
                $oprofile_event = "$event:$sample";
        } else {
diff --git a/oprofile_start.sh b/oprofile_start.sh
index d17e2f1..b8067bd 100755
--- a/oprofile_start.sh
+++ b/oprofile_start.sh
@@ -6,12 +6,13 @@ usage() {
        echo This script starts the oprofile daemon
        echo
        echo "Usage: oprofile_start.sh [options]"
-       echo "    --event         High-level oprofile event to track"
-       echo "    --vmlinux       Path to vmlinux"
-       echo "    --sample-factor Factor which to slow down sampling by"
-       echo "    --systemmap     Guess"
-       echo "    -v, --vmr       VMRegress install directory (default: 
$VMREGRESS_DIR)"
-       echo "    -h, --help     Print this help message"
+       echo "    --event               High-level oprofile event to track"
+       echo "    --vmlinux             Path to vmlinux"
+       echo "    --sample-cycle-factor Factor which to slow down CPU cycle 
sampling by"
+       echo "    --sample-event-factor Factor which to slow down event 
sampling by"
+       echo "    --systemmap           Guess"
+       echo "    -v, --vmr             VMRegress install directory (default: 
$VMREGRESS_DIR)"
+       echo "    -h, --help            Print this help message"
        echo
        exit
 }
@@ -23,17 +24,18 @@ VMLINUX=/boot/vmlinux-`uname -r`
 SYSTEMMAP=/boot/System.map-`uname -r`
 FACTOR=
 export PATH=$SCRIPTROOT:$PATH
-ARGS=`getopt -o hv: --long help,vmr:,event:,vmlinux:,systemmap:,sample-factor: 
-n oprofile_start.sh -- "$@"`
+ARGS=`getopt -o hv: --long 
help,vmr:,event:,vmlinux:,systemmap:,sample-event-factor:,sample-cycle-factor: 
-n oprofile_start.sh -- "$@"`
 
 # Cycle through arguements
 eval set -- "$ARGS"
 while true ; do
   case "$1" in
-       -v|--vmr)        VMREGRESS_DIR="$2"; shift 2;;
-       --event)         EVENTS="$EVENTS $2"; shift 2;;
-       --vmlinux)       VMLINUX=$2; shift 2;;
-       --sample-factor) FACTOR="--sample-factor $2"; shift 2;;
-       --systemmap)     SYSTEMMAP=$2; shift 2;;
+       -v|--vmr)              VMREGRESS_DIR="$2"; shift 2;;
+       --event)               EVENTS="$EVENTS $2"; shift 2;;
+       --vmlinux)             VMLINUX=$2; shift 2;;
+       --sample-cycle-factor) CYCLE_FACTOR="--sample-cycle-factor $2"; shift 
2;;
+       --sample-event-factor) EVENT_FACTOR="--sample-event-factor $2"; shift 
2;;
+       --systemmap)           SYSTEMMAP=$2; shift 2;;
         -h|--help) usage;;
         *) shift 1; break;;
   esac
@@ -41,7 +43,7 @@ done
 
 # Map the events
 for EVENT in $EVENTS; do
-       LOWLEVEL_EVENT="$LOWLEVEL_EVENT --event `oprofile_map_events.pl $FACTOR 
--event $EVENT`"
+       LOWLEVEL_EVENT="$LOWLEVEL_EVENT --event `oprofile_map_events.pl 
$EVENT_FACTOR $CYCLE_FACTOR --event $EVENT`"
        if [ $? -ne 0 ]; then
                echo Failed to map event $EVENT to low-level oprofile event. 
Verbose output follows
                oprofile_map_events.pl --event $EVENT --verbose

------------------------------------------------------------------------------
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to