aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvantika Mathur <mathur@linux.vnet.ibm.com>2010-03-25 19:33:26 -0700
committerEric B Munson <ebmunson@us.ibm.com>2010-03-27 08:05:03 +0000
commitc8f1ace12520bea756b01e50ea0ec6a07324b3ed (patch)
tree1fb8688e20031dcf25ec238315f12fd6709d08d5
parenta4567119311ea7e4112be60b704b5aa066b35764 (diff)
downloadlibhugetlbfs-c8f1ace12520bea756b01e50ea0ec6a07324b3ed.tar.gz
cpupcstat - cache tlbmiss-cost value
Currently, cpupcstat runs tlbmiss_cost.sh every run to get the tlbmiss cost used to calculate % time spent servicing tlb misses. This patch changes cpupcstat to cache the tlbmiss cost in a local file, tlbmisscost. If the cache file exists, it uses the cached value. If the file does not exist, it runs tlbmiss_cost.sh to generate cost, uses this value and caches the result for later runs. If the user specifies a file using the --cost-config, uses the tlbmiss cost stored in this file. Signed-off-by: Avantika Mathur <mathur@us.ibm.com> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
-rwxr-xr-xcpupcstat25
1 files changed, 16 insertions, 9 deletions
diff --git a/cpupcstat b/cpupcstat
index 2de14cf..251ec1f 100755
--- a/cpupcstat
+++ b/cpupcstat
@@ -37,6 +37,7 @@ my $collector;
my $miss_scale = 0;
my $ins_scale = 0;
my $cyc_scale = 0;
+my $tlbcost_cache = "$Bin/tlbmisscost";
sub start_target()
{
@@ -116,7 +117,7 @@ sub run_profile()
if ($instruct_ratio) {
printf("%24s\n", "Instructions/TLB Miss\n");
$ins_scale = $collector->samples("instructions");
- } elsif ($cycle_ratio) {
+ } elsif ($cycle_ratio || $service) {
printf("%24s\n", "Cycles/TLB Miss\n");
$cyc_scale = $collector->samples("timer");
} else {
@@ -264,14 +265,6 @@ $misses = 0;
$kern_misses = 0;
run_profile();
-if ($config) {
- open(DAT, $config) || die "Failed to open $config\n";
- my $data = <DAT>;
- close(DAT);
- ($data,$cost_in_cycles) = split(/\=/, $data);
- chomp($cost_in_cycles);
-}
-
if ($misses > 0) {
print("\n$target saw $misses total DTLB miss samples over ",
"$time_elapsed seconds\n");
@@ -290,6 +283,17 @@ if ($misses > 0) {
}
if ($service && $cycles > 0) {
+ if ( !$config && -e $tlbcost_cache ) {
+ $config = $tlbcost_cache;
+ }
+ if ($config) {
+ open(DAT, $config) || die "Failed to open $config\n";
+ my $data = <DAT>;
+ close(DAT);
+ ($data,$cost_in_cycles) = split(/\=/, $data);
+ chomp($cost_in_cycles);
+ }
+
if ($cost_in_cycles <= 0) {
my $cost_script = `which tlbmiss_cost.sh`;
if ($cost_script eq "") {
@@ -298,6 +302,9 @@ if ($misses > 0) {
my $data = `$cost_script`;
($data,$cost_in_cycles) = split(/\=/, $data);
chomp($cost_in_cycles);
+ open (DAT, ">$tlbcost_cache");
+ print DAT "TLB_MISS_COST=$cost_in_cycles";
+ close (DAT);
}
my $total_cost = $cost_in_cycles * $misses;
print("$target spent ",