Bug 1203834 - Fix's rapl's handling of unsupported power domains. r=glandium.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 10 Sep 2015 23:12:20 -0700
changeset 294512 44d375dd46bb6119a5ab2a8807bd985791494daf
parent 294511 970df36511268cb5f7cafff94e00f7d485d934d7
child 294513 0831bdc0a4358ba605934700f793b8acab4904b0
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1203834
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1203834 - Fix's rapl's handling of unsupported power domains. r=glandium. The "gpu" and "ram" domains aren't supported by all platforms. rapl has a special constant |kUnsupported_j| to represent this on Linux, but I accidentally have a minus sign in front of it in several places, which means that instead of printing "n/a" for unsupported planes we always print "1.0". I think this happened because I used to hardwire -1 in there and then I later changed it to a constant but forgot to remove the minus signs. It sure would be nice to have automated testing for this stuff, but I don't see how to do it.
tools/power/rapl.cpp
--- a/tools/power/rapl.cpp
+++ b/tools/power/rapl.cpp
@@ -385,22 +385,22 @@ public:
     // Energy measurements come in multiples of 1/(2^ESU).
     uint32_t energyStatusUnits = (mPkes->pkg_power_unit >> 8) & 0x1f;
     double joulesPerTick = ((double)1 / (1 << energyStatusUnits));
 
     aPkg_J   = Joules(mPkes->pkg_energy - mPrevPkgTicks, joulesPerTick);
     aCores_J = Joules(mPkes->pp0_energy - mPrevPp0Ticks, joulesPerTick);
     aGpu_J   = mIsGpuSupported
              ? Joules(mPkes->pp1_energy - mPrevPp1Ticks, joulesPerTick)
-             : -kUnsupported_j;
+             : kUnsupported_j;
     aRam_J   = mIsRamSupported
              ? Joules(mPkes->ddr_energy - mPrevDdrTicks,
                       mHasRamUnitsQuirk ? kQuirkyRamJoulesPerTick
                                         : joulesPerTick)
-             : -kUnsupported_j;
+             : kUnsupported_j;
 
     mPrevPkgTicks = mPkes->pkg_energy;
     mPrevPp0Ticks = mPkes->pp0_energy;
     if (mIsGpuSupported) {
       mPrevPp1Ticks = mPkes->pp1_energy;
     }
     if (mIsRamSupported) {
       mPrevDdrTicks = mPkes->ddr_energy;
@@ -513,17 +513,17 @@ public:
     if (mIsSupported) {
       close(mFd);
     }
   }
 
   double EnergyEstimate()
   {
     if (!mIsSupported) {
-      return -kUnsupported_j;
+      return kUnsupported_j;
     }
 
     uint64_t thisTicks;
     if (read(mFd, &thisTicks, sizeof(uint64_t)) != sizeof(uint64_t)) {
       Abort("read() failed");
     }
 
     uint64_t ticks = thisTicks - mPrevTicks;