Bug 1119277 - Remove the process CPU priority parameter and simplify all the associated code. r=khuey, r=dhylands
authorGabriele Svelto <gsvelto@mozilla.com>
Thu, 26 Feb 2015 12:43:22 +0100
changeset 261499 44e25e482ff46ebc94ccc4dd3f0cb9443136e029
parent 261498 8b91b1efaffacfe7092ad7297b3291584d54797e
child 261500 63364da8765fdbab7194aabe4f802a1c50cd4e91
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, dhylands
bugs1119277
milestone39.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 1119277 - Remove the process CPU priority parameter and simplify all the associated code. r=khuey, r=dhylands
dom/browser-element/mochitest/browserElementTestHelpers.js
dom/browser-element/mochitest/priority/CAUTION
dom/browser-element/mochitest/priority/mochitest.ini
dom/browser-element/mochitest/priority/test_HighPriorityDowngrade.html
dom/browser-element/mochitest/priority/test_HighPriorityDowngrade2.html
dom/browser-element/mochitest/priority/test_Preallocated.html
dom/ipc/ProcessPriorityManager.cpp
hal/Hal.cpp
hal/Hal.h
hal/HalTypes.h
hal/fallback/FallbackProcessPriority.cpp
hal/gonk/GonkHal.cpp
hal/sandbox/SandboxHal.cpp
--- a/dom/browser-element/mochitest/browserElementTestHelpers.js
+++ b/dom/browser-element/mochitest/browserElementTestHelpers.js
@@ -106,97 +106,83 @@ const browserElementTestHelpers = {
   'emptyPage1': 'http://example.com' + _getPath() + '/file_empty.html',
   'emptyPage2': 'http://example.org' + _getPath() + '/file_empty.html',
   'emptyPage3': 'http://test1.example.org' + _getPath() + '/file_empty.html',
   'focusPage': 'http://example.org' + _getPath() + '/file_focus.html',
 };
 
 // Returns a promise which is resolved when a subprocess is created.  The
 // argument to resolve() is the childID of the subprocess.
-function expectProcessCreated(/* optional */ initialPriority,
-                              /* optional */ initialCPUPriority) {
+function expectProcessCreated(/* optional */ initialPriority) {
   return new Promise(function(resolve, reject) {
     var observed = false;
     browserElementTestHelpers.addProcessPriorityObserver(
       "process-created",
       function(subject, topic, data) {
         // Don't run this observer twice, so we don't ok(true) twice.  (It's fine
         // to resolve a promise twice; the second resolve() call does nothing.)
         if (observed) {
           return;
         }
         observed = true;
 
         var childID = parseInt(data);
         ok(true, 'Got new process, id=' + childID);
         if (initialPriority) {
-          expectPriorityChange(childID, initialPriority, initialCPUPriority).then(function() {
+          expectPriorityChange(childID, initialPriority).then(function() {
             resolve(childID);
           });
         } else {
           resolve(childID);
         }
       }
     );
   });
 }
 
 // Just like expectProcessCreated(), except we'll call ok(false) if a second
 // process is created.
-function expectOnlyOneProcessCreated(/* optional */ initialPriority,
-                                     /* optional */ initialCPUPriority) {
-  var p = expectProcessCreated(initialPriority, initialCPUPriority);
+function expectOnlyOneProcessCreated(/* optional */ initialPriority) {
+  var p = expectProcessCreated(initialPriority);
   p.then(function() {
     expectProcessCreated().then(function(childID) {
       ok(false, 'Got unexpected process creation, childID=' + childID);
     });
   });
   return p;
 }
 
 // Returns a promise which is resolved or rejected the next time the process
-// childID changes its priority.  We resolve if the (priority, CPU priority)
-// tuple matches (expectedPriority, expectedCPUPriority) and we reject
-// otherwise.
-//
-// expectedCPUPriority is an optional argument; if it's not specified, we
-// resolve if priority matches expectedPriority.
+// childID changes its priority. We resolve if the priority matches
+// expectedPriority, and we reject otherwise.
 
-function expectPriorityChange(childID, expectedPriority,
-                              /* optional */ expectedCPUPriority) {
+function expectPriorityChange(childID, expectedPriority) {
   return new Promise(function(resolve, reject) {
     var observed = false;
     browserElementTestHelpers.addProcessPriorityObserver(
       'process-priority-set',
       function(subject, topic, data) {
         if (observed) {
           return;
         }
 
-        var [id, priority, cpuPriority] = data.split(":");
+        var [id, priority] = data.split(":");
         if (id != childID) {
           return;
         }
 
         // Make sure we run the is() calls in this observer only once, otherwise
         // we'll expect /every/ priority change to match expectedPriority.
         observed = true;
 
         is(priority, expectedPriority,
            'Expected priority of childID ' + childID +
            ' to change to ' + expectedPriority);
 
-        if (expectedCPUPriority) {
-          is(cpuPriority, expectedCPUPriority,
-             'Expected CPU priority of childID ' + childID +
-             ' to change to ' + expectedCPUPriority);
-        }
-
-        if (priority == expectedPriority &&
-            (!expectedCPUPriority || expectedCPUPriority == cpuPriority)) {
+        if (priority == expectedPriority) {
           resolve();
         } else {
           reject();
         }
       }
     );
   });
 }
@@ -207,23 +193,24 @@ function expectPriorityChange(childID, e
 
 function expectPriorityWithBackgroundLRUSet(childID, expectedBackgroundLRU) {
   return new Promise(function(resolve, reject) {
 
     browserElementTestHelpers.addProcessPriorityObserver(
       'process-priority-with-background-LRU-set',
       function(subject, topic, data) {
 
-        var [id, priority, cpuPriority, backgroundLRU] = data.split(":");
+        var [id, priority, backgroundLRU] = data.split(":");
         if (id != childID) {
           return;
         }
 
         is(backgroundLRU, expectedBackgroundLRU,
-           'Expected backgroundLRU ' + backgroundLRU + ' of childID ' + childID +
+           'Expected backgroundLRU ' + backgroundLRU +
+           ' of childID ' + childID +
            ' to change to ' + expectedBackgroundLRU);
 
         if (backgroundLRU == expectedBackgroundLRU) {
           resolve();
         } else {
           reject();
         }
       }
deleted file mode 100644
--- a/dom/browser-element/mochitest/priority/CAUTION
+++ /dev/null
@@ -1,15 +0,0 @@
-A word to the wise:
-
-You must ensure that if your test finishes successfully, no processes have
-priority FOREGROUND_HIGH.
-
-If you don't do this, expect to see tests randomly fail with mysterious
-FOREGROUND --> FOREGROUND priority transitions.
-
-What's happening in this case is that your FOREGROUND_HIGH process lives until
-the beginning of the next test.  This causes the process started by the next
-test to have low CPU priority.  Then the FOREGROUND_HIGH process dies, because
-its iframe gets GC'ed, and we transition the new test's process from low CPU
-priority to regular CPU priority.
-
-Ouch.
--- a/dom/browser-element/mochitest/priority/mochitest.ini
+++ b/dom/browser-element/mochitest/priority/mochitest.ini
@@ -5,18 +5,16 @@ skip-if = toolkit != "gtk2" || ((buildap
 # Note: ../browserElementTestHelpers.js makes all tests in this directory OOP,
 # because testing the process-priority manager without OOP frames does not make
 # much sense.
 
 [test_Simple.html]
 [test_Visibility.html]
 [test_HighPriority.html]
 support-files = file_HighPriority.html
-[test_HighPriorityDowngrade.html]
-[test_HighPriorityDowngrade2.html]
 [test_Background.html]
 [test_BackgroundLRU.html]
 [test_Audio.html]
 support-files = file_Audio.html silence.ogg
 [test_Keyboard.html]
 [test_MultipleFrames.html]
 support-files = file_MultipleFrames.html
 [test_Preallocated.html]
deleted file mode 100644
--- a/dom/browser-element/mochitest/priority/test_HighPriorityDowngrade.html
+++ /dev/null
@@ -1,81 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-Test that high-priority processes downgrade the CPU priority of regular
-processes.
--->
-<head>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="application/javascript;version=1.7">
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-browserElementTestHelpers.addPermission();
-browserElementTestHelpers.enableProcessPriorityManager();
-SpecialPowers.addPermission("embed-apps", true, document);
-
-var iframe = null;
-var childID = null;
-
-function runTest() {
-  var iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', true);
-
-  iframe.src = browserElementTestHelpers.emptyPage1;
-
-  var highPriorityIframe = null;
-  var childID = null;
-  var lock = null;
-  var p = null;
-
-  expectProcessCreated('FOREGROUND', 'CPU_NORMAL').then(function(chid) {
-    childID = chid;
-  }).then(function() {
-    // Create a new, high-priority iframe.
-    highPriorityIframe = document.createElement('iframe');
-    highPriorityIframe.setAttribute('mozbrowser', true);
-    highPriorityIframe.setAttribute('expecting-system-message', true);
-    highPriorityIframe.setAttribute('mozapptype', 'critical');
-    highPriorityIframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
-    highPriorityIframe.src = browserElementTestHelpers.emptyPage2;
-
-    p = expectPriorityChange(childID, 'FOREGROUND', 'CPU_LOW');
-
-    document.body.appendChild(highPriorityIframe);
-
-    return p;
-  }).then(function() {
-    return expectPriorityChange(childID, 'FOREGROUND', 'CPU_NORMAL');
-  }).then(function() {
-    p = expectPriorityChange(childID, 'FOREGROUND', 'CPU_LOW');
-    lock = navigator.requestWakeLock('high-priority');
-    return p;
-  }).then(function() {
-    p = expectPriorityChange(childID, 'FOREGROUND', 'CPU_NORMAL');
-    lock.unlock();
-    return p;
-  }).then(SimpleTest.finish);
-
-  document.body.appendChild(iframe);
-}
-
-addEventListener('testready', function() {
-  SpecialPowers.pushPrefEnv(
-    {set: [
-      /* Cause the CPU wake lock taken on behalf of the high-priority process
-       * to time out after 1s. */
-       ["dom.ipc.systemMessageCPULockTimeoutSec", 1],
-       ["dom.wakelock.enabled", true]
-    ]},
-    runTest);
-});
-
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/priority/test_HighPriorityDowngrade2.html
+++ /dev/null
@@ -1,76 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-Test that high-priority processes downgrade the CPU priority of regular
-processes.
-
-This is just like test_HighPriorityDowngrade, except instead of waiting for the
-high-priority process's wake lock to expire, we kill the process by removing
-its iframe from the DOM.
--->
-<head>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="application/javascript;version=1.7">
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-browserElementTestHelpers.addPermission();
-browserElementTestHelpers.enableProcessPriorityManager();
-SpecialPowers.addPermission("embed-apps", true, document);
-
-function runTest() {
-  var iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', true);
-
-  iframe.src = browserElementTestHelpers.emptyPage1;
-
-  var highPriorityIframe = null;
-  var childID = null;
-
-  expectProcessCreated('FOREGROUND', 'CPU_NORMAL').then(function(chid) {
-    childID = chid;
-  }).then(function() {
-    // Create a new, high-priority iframe.
-    highPriorityIframe = document.createElement('iframe');
-    highPriorityIframe.setAttribute('mozbrowser', true);
-    highPriorityIframe.setAttribute('expecting-system-message', true);
-    highPriorityIframe.setAttribute('mozapptype', 'critical');
-    highPriorityIframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
-    highPriorityIframe.src = browserElementTestHelpers.emptyPage2;
-
-    var p = Promise.all(
-      [expectPriorityChange(childID, 'FOREGROUND', 'CPU_LOW'),
-       expectMozbrowserEvent(highPriorityIframe, 'loadend')]
-    );
-
-    document.body.appendChild(highPriorityIframe);
-
-    return p;
-  }).then(function() {
-    // Killing the high-priority iframe should cause our CPU priority to go back
-    // up to regular.
-    var p = expectPriorityChange(childID, 'FOREGROUND', 'CPU_NORMAL');
-    document.body.removeChild(highPriorityIframe);
-    return p;
-  }).then(SimpleTest.finish);
-
-  document.body.appendChild(iframe);
-}
-
-addEventListener('testready', function() {
-  // Cause the CPU wake lock taken on behalf of the high-priority process never
-  // to time out during this test.
-  SpecialPowers.pushPrefEnv(
-    {set: [["dom.ipc.systemMessageCPULockTimeoutSec", 1000]]},
-    runTest);
-});
-
-</script>
-</body>
-</html>
--- a/dom/browser-element/mochitest/priority/test_Preallocated.html
+++ b/dom/browser-element/mochitest/priority/test_Preallocated.html
@@ -48,17 +48,17 @@ function runTest()
     ok(false, "dom.ipc.processPrelaunch.enabled must be " +
               "false for this test to work.");
     SimpleTest.finish();
     return;
   }
 
   // Ensure that the preallocated process initially gets BACKGROUND priority.
   // That's it.
-  expectProcessCreated('PREALLOC', 'CPU_LOW').then(function() {
+  expectProcessCreated('PREALLOC').then(function() {
     // We need to set the pref asynchoronously or the preallocated process won't
     // be shut down.
     SimpleTest.executeSoon(function(){
       cleanUp();
       SimpleTest.finish();
     });
   });
 }
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -134,23 +134,16 @@ public:
   /**
    * If a magic testing-only pref is set, notify the observer service on the
    * given topic with the given data.  This is used for testing
    */
   void FireTestOnlyObserverNotification(const char* aTopic,
                                         const nsACString& aData = EmptyCString());
 
   /**
-   * Does some process, other than the one handled by aParticularManager, have
-   * priority FOREGROUND_HIGH?
-   */
-  bool OtherProcessHasHighPriority(
-    ParticularProcessPriorityManager* aParticularManager);
-
-  /**
    * Does one of the child processes have priority FOREGROUND_HIGH?
    */
   bool ChildProcessHasHighPriority();
 
   /**
    * This must be called by a ParticularProcessPriorityManager when it changes
    * its priority.
    */
@@ -177,17 +170,16 @@ private:
 
   void Init();
 
   already_AddRefed<ParticularProcessPriorityManager>
   GetParticularProcessPriorityManager(ContentParent* aContentParent);
 
   void ObserveContentParentCreated(nsISupports* aContentParent);
   void ObserveContentParentDestroyed(nsISupports* aSubject);
-  void ResetAllCPUPriorities();
 
   nsDataHashtable<nsUint64HashKey, nsRefPtr<ParticularProcessPriorityManager> >
     mParticularManagers;
 
   bool mHighPriority;
   nsTHashtable<nsUint64HashKey> mHighPriorityChildIDs;
 };
 
@@ -262,49 +254,36 @@ public:
   void OnAudioChannelProcessChanged(nsISupports* aSubject);
   void OnRemoteBrowserFrameShown(nsISupports* aSubject);
   void OnTabParentDestroyed(nsISupports* aSubject);
   void OnFrameloaderVisibleChanged(nsISupports* aSubject);
   void OnChannelConnected(nsISupports* aSubject);
 
   ProcessPriority CurrentPriority();
   ProcessPriority ComputePriority();
-  ProcessCPUPriority ComputeCPUPriority(ProcessPriority aPriority);
 
   void ScheduleResetPriority(const char* aTimeoutPref);
   void ResetPriority();
   void ResetPriorityNow();
-  void ResetCPUPriorityNow();
-
-  /**
-   * This overload is equivalent to SetPriorityNow(aPriority,
-   * ComputeCPUPriority()).
-   */
-  void SetPriorityNow(ProcessPriority aPriority,
-                      uint32_t aBackgroundLRU = 0);
-
-  void SetPriorityNow(ProcessPriority aPriority,
-                      ProcessCPUPriority aCPUPriority,
-                      uint32_t aBackgroundLRU = 0);
+  void SetPriorityNow(ProcessPriority aPriority, uint32_t aBackgroundLRU = 0);
 
   void ShutDown();
 
 private:
   void FireTestOnlyObserverNotification(
     const char* aTopic,
     const nsACString& aData = EmptyCString());
 
   void FireTestOnlyObserverNotification(
     const char* aTopic,
     const char* aData = nullptr);
 
   ContentParent* mContentParent;
   uint64_t mChildID;
   ProcessPriority mPriority;
-  ProcessCPUPriority mCPUPriority;
   bool mHoldsCPUWakeLock;
   bool mHoldsHighPriorityWakeLock;
 
   /**
    * Used to implement NameWithComma().
    */
   nsAutoCString mNameWithComma;
 
@@ -434,18 +413,17 @@ ProcessPriorityManagerImpl::~ProcessPrio
 void
 ProcessPriorityManagerImpl::Init()
 {
   LOG("Starting up.  This is the master process.");
 
   // The master process's priority never changes; set it here and then forget
   // about it.  We'll manage only subprocesses' priorities using the process
   // priority manager.
-  hal::SetProcessPriority(getpid(), PROCESS_PRIORITY_MASTER,
-                          PROCESS_CPU_PRIORITY_NORMAL);
+  hal::SetProcessPriority(getpid(), PROCESS_PRIORITY_MASTER);
 
   nsCOMPtr<nsIObserverService> os = services::GetObserverService();
   if (os) {
     os->AddObserver(this, "ipc:content-created", /* ownsWeak */ false);
     os->AddObserver(this, "ipc:content-shutdown", /* ownsWeak */ false);
   }
 }
 
@@ -512,28 +490,16 @@ ProcessPriorityManagerImpl::ObserveConte
 {
   // Do nothing; it's sufficient to get the PPPM.  But assign to nsRefPtr so we
   // don't leak the already_AddRefed object.
   nsCOMPtr<nsIContentParent> cp = do_QueryInterface(aContentParent);
   nsRefPtr<ParticularProcessPriorityManager> pppm =
     GetParticularProcessPriorityManager(cp->AsContentParent());
 }
 
-static PLDHashOperator
-EnumerateParticularProcessPriorityManagers(
-  const uint64_t& aKey,
-  nsRefPtr<ParticularProcessPriorityManager> aValue,
-  void* aUserData)
-{
-  nsTArray<nsRefPtr<ParticularProcessPriorityManager> >* aArray =
-    static_cast<nsTArray<nsRefPtr<ParticularProcessPriorityManager> >*>(aUserData);
-  aArray->AppendElement(aValue);
-  return PL_DHASH_NEXT;
-}
-
 void
 ProcessPriorityManagerImpl::ObserveContentParentDestroyed(nsISupports* aSubject)
 {
   nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(aSubject);
   NS_ENSURE_TRUE_VOID(props);
 
   uint64_t childID = CONTENT_PROCESS_ID_UNKNOWN;
   props->GetPropertyAsUint64(NS_LITERAL_STRING("childID"), &childID);
@@ -543,122 +509,79 @@ ProcessPriorityManagerImpl::ObserveConte
   mParticularManagers.Get(childID, &pppm);
   if (pppm) {
     pppm->ShutDown();
 
     mParticularManagers.Remove(childID);
 
     if (mHighPriorityChildIDs.Contains(childID)) {
       mHighPriorityChildIDs.RemoveEntry(childID);
-
-      // We just lost a high-priority process; reset everyone's CPU priorities.
-      ResetAllCPUPriorities();
     }
   }
 }
 
-void
-ProcessPriorityManagerImpl::ResetAllCPUPriorities( void )
-{
-  nsTArray<nsRefPtr<ParticularProcessPriorityManager> > pppms;
-  mParticularManagers.EnumerateRead(
-    &EnumerateParticularProcessPriorityManagers,
-    &pppms);
-
-  for (uint32_t i = 0; i < pppms.Length(); i++) {
-    pppms[i]->ResetCPUPriorityNow();
-  }
-}
-
-bool
-ProcessPriorityManagerImpl::OtherProcessHasHighPriority(
-  ParticularProcessPriorityManager* aParticularManager)
-{
-  if (mHighPriority) {
-    return true;
-  } else if (mHighPriorityChildIDs.Contains(aParticularManager->ChildID())) {
-    return mHighPriorityChildIDs.Count() > 1;
-  }
-  return mHighPriorityChildIDs.Count() > 0;
-}
-
 bool
 ProcessPriorityManagerImpl::ChildProcessHasHighPriority( void )
 {
   return mHighPriorityChildIDs.Count() > 0;
 }
 
 void
 ProcessPriorityManagerImpl::NotifyProcessPriorityChanged(
   ParticularProcessPriorityManager* aParticularManager,
   ProcessPriority aOldPriority)
 {
-  // This priority change can only affect other processes' priorities if we're
-  // changing to/from FOREGROUND_HIGH.
+  /* We're interested only in changes to/from FOREGROUND_HIGH as we use we
+   * need to track high priority processes so that we can react to their
+   * presence. */
 
   if (aOldPriority < PROCESS_PRIORITY_FOREGROUND_HIGH &&
       aParticularManager->CurrentPriority() <
         PROCESS_PRIORITY_FOREGROUND_HIGH) {
 
     return;
   }
 
   if (aParticularManager->CurrentPriority() >=
       PROCESS_PRIORITY_FOREGROUND_HIGH) {
     mHighPriorityChildIDs.PutEntry(aParticularManager->ChildID());
   } else {
     mHighPriorityChildIDs.RemoveEntry(aParticularManager->ChildID());
   }
-
-  nsTArray<nsRefPtr<ParticularProcessPriorityManager> > pppms;
-  mParticularManagers.EnumerateRead(
-    &EnumerateParticularProcessPriorityManagers,
-    &pppms);
-
-  for (uint32_t i = 0; i < pppms.Length(); i++) {
-    if (pppms[i] != aParticularManager) {
-      pppms[i]->ResetCPUPriorityNow();
-    }
-  }
 }
 
 /* virtual */ void
 ProcessPriorityManagerImpl::Notify(const WakeLockInformation& aInfo)
 {
   /* The main process always has an ID of 0, if it is present in the wake-lock
    * information then we explicitly requested a high-priority wake-lock for the
    * main process. */
   if (aInfo.topic().EqualsLiteral("high-priority")) {
     if (aInfo.lockingProcesses().Contains((uint64_t)0)) {
       mHighPriority = true;
     } else {
       mHighPriority = false;
     }
 
-    /* The main process got a high-priority wakelock change; reset everyone's
-     * CPU priorities. */
-    ResetAllCPUPriorities();
-
     LOG("Got wake lock changed event. "
         "Now mHighPriorityParent = %d\n", mHighPriority);
   }
 }
 
 
 NS_IMPL_ISUPPORTS(ParticularProcessPriorityManager,
                   nsIObserver,
                   nsITimerCallback,
                   nsISupportsWeakReference);
 
 ParticularProcessPriorityManager::ParticularProcessPriorityManager(
   ContentParent* aContentParent)
   : mContentParent(aContentParent)
   , mChildID(aContentParent->ChildID())
   , mPriority(PROCESS_PRIORITY_UNKNOWN)
-  , mCPUPriority(PROCESS_CPU_PRIORITY_NORMAL)
   , mHoldsCPUWakeLock(false)
   , mHoldsHighPriorityWakeLock(false)
 {
   MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
   LOGP("Creating ParticularProcessPriorityManager.");
 }
 
 void
@@ -1010,72 +933,40 @@ ParticularProcessPriorityManager::Comput
     return PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE;
   }
 
   return HasAppType("homescreen") ?
          PROCESS_PRIORITY_BACKGROUND_HOMESCREEN :
          PROCESS_PRIORITY_BACKGROUND;
 }
 
-ProcessCPUPriority
-ParticularProcessPriorityManager::ComputeCPUPriority(ProcessPriority aPriority)
-{
-  if (aPriority == PROCESS_PRIORITY_PREALLOC) {
-    return PROCESS_CPU_PRIORITY_LOW;
-  }
-
-  if (aPriority >= PROCESS_PRIORITY_FOREGROUND_HIGH) {
-    return PROCESS_CPU_PRIORITY_NORMAL;
-  }
-
-  return ProcessPriorityManagerImpl::GetSingleton()->
-    OtherProcessHasHighPriority(this) ?
-    PROCESS_CPU_PRIORITY_LOW :
-    PROCESS_CPU_PRIORITY_NORMAL;
-}
-
-void
-ParticularProcessPriorityManager::ResetCPUPriorityNow()
-{
-  SetPriorityNow(mPriority);
-}
-
 void
 ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
                                                  uint32_t aBackgroundLRU)
 {
-  SetPriorityNow(aPriority, ComputeCPUPriority(aPriority), aBackgroundLRU);
-}
-
-void
-ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
-                                                 ProcessCPUPriority aCPUPriority,
-                                                 uint32_t aBackgroundLRU)
-{
   if (aPriority == PROCESS_PRIORITY_UNKNOWN) {
     MOZ_ASSERT(false);
     return;
   }
 
   if (aBackgroundLRU > 0 &&
       aPriority == PROCESS_PRIORITY_BACKGROUND &&
       mPriority == PROCESS_PRIORITY_BACKGROUND) {
-    hal::SetProcessPriority(Pid(), mPriority, mCPUPriority, aBackgroundLRU);
+    hal::SetProcessPriority(Pid(), mPriority, aBackgroundLRU);
 
     nsPrintfCString ProcessPriorityWithBackgroundLRU("%s:%d",
-      ProcessPriorityToString(mPriority, mCPUPriority),
-      aBackgroundLRU);
+      ProcessPriorityToString(mPriority), aBackgroundLRU);
 
     FireTestOnlyObserverNotification("process-priority-with-background-LRU-set",
       ProcessPriorityWithBackgroundLRU.get());
   }
 
   if (!mContentParent ||
       !ProcessPriorityManagerImpl::PrefsEnabled() ||
-      (mPriority == aPriority && mCPUPriority == aCPUPriority)) {
+      (mPriority == aPriority)) {
     return;
   }
 
   // If the prefs were disabled after this ParticularProcessPriorityManager was
   // created, we can at least avoid any further calls to
   // hal::SetProcessPriority.  Supporting dynamic enabling/disabling of the
   // ProcessPriorityManager is mostly for testing.
   if (!ProcessPriorityManagerImpl::PrefsEnabled()) {
@@ -1090,40 +981,37 @@ ParticularProcessPriorityManager::SetPri
 
   if (aPriority != PROCESS_PRIORITY_BACKGROUND &&
       mPriority == PROCESS_PRIORITY_BACKGROUND &&
       !IsPreallocated()) {
     ProcessPriorityManager::RemoveFromBackgroundLRUPool(mContentParent);
   }
 
   LOGP("Changing priority from %s to %s.",
-       ProcessPriorityToString(mPriority, mCPUPriority),
-       ProcessPriorityToString(aPriority, aCPUPriority));
+       ProcessPriorityToString(mPriority),
+       ProcessPriorityToString(aPriority));
 
   ProcessPriority oldPriority = mPriority;
 
   mPriority = aPriority;
-  mCPUPriority = aCPUPriority;
-  hal::SetProcessPriority(Pid(), mPriority, mCPUPriority);
+  hal::SetProcessPriority(Pid(), mPriority);
 
   if (oldPriority != mPriority) {
+    ProcessPriorityManagerImpl::GetSingleton()->
+      NotifyProcessPriorityChanged(this, oldPriority);
+
     unused << mContentParent->SendNotifyProcessPriorityChanged(mPriority);
   }
 
   if (aPriority < PROCESS_PRIORITY_FOREGROUND) {
     unused << mContentParent->SendFlushMemory(NS_LITERAL_STRING("low-memory"));
   }
 
   FireTestOnlyObserverNotification("process-priority-set",
-    ProcessPriorityToString(mPriority, mCPUPriority));
-
-  if (oldPriority != mPriority) {
-    ProcessPriorityManagerImpl::GetSingleton()->
-      NotifyProcessPriorityChanged(this, oldPriority);
-  }
+    ProcessPriorityToString(mPriority));
 }
 
 void
 ParticularProcessPriorityManager::ShutDown()
 {
   MOZ_ASSERT(mContentParent);
 
   UnregisterWakeLockObserver(this);
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -858,24 +858,22 @@ SetAlarm(int32_t aSeconds, int32_t aNano
   // It's pointless to program an alarm nothing is going to observe ...
   MOZ_ASSERT(sAlarmObserver);
   RETURN_PROXY_IF_SANDBOXED(SetAlarm(aSeconds, aNanoseconds), false);
 }
 
 void
 SetProcessPriority(int aPid,
                    ProcessPriority aPriority,
-                   ProcessCPUPriority aCPUPriority,
                    uint32_t aBackgroundLRU)
 {
   // n.b. The sandboxed implementation crashes; SetProcessPriority works only
   // from the main process.
   MOZ_ASSERT(aBackgroundLRU == 0 || aPriority == PROCESS_PRIORITY_BACKGROUND);
-  PROXY_IF_SANDBOXED(SetProcessPriority(aPid, aPriority, aCPUPriority,
-                                        aBackgroundLRU));
+  PROXY_IF_SANDBOXED(SetProcessPriority(aPid, aPriority, aBackgroundLRU));
 }
 
 void
 SetCurrentThreadPriority(hal::ThreadPriority aThreadPriority)
 {
   PROXY_IF_SANDBOXED(SetCurrentThreadPriority(aThreadPriority));
 }
 
@@ -915,99 +913,16 @@ ThreadPriorityToString(ThreadPriority aP
     case THREAD_PRIORITY_COMPOSITOR:
       return "COMPOSITOR";
     default:
       MOZ_ASSERT(false);
       return "???";
   }
 }
 
-// From HalTypes.h.
-const char*
-ProcessPriorityToString(ProcessPriority aPriority,
-                        ProcessCPUPriority aCPUPriority)
-{
-  // Sorry this is ugly.  At least it's all in one place.
-  //
-  // We intentionally fall through if aCPUPriority is invalid; we won't hit any
-  // of the if statements further down, so it's OK.
-
-  switch (aPriority) {
-  case PROCESS_PRIORITY_MASTER:
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
-      return "MASTER:CPU_NORMAL";
-    }
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
-      return "MASTER:CPU_LOW";
-    }
-  case PROCESS_PRIORITY_PREALLOC:
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
-      return "PREALLOC:CPU_NORMAL";
-    }
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
-      return "PREALLOC:CPU_LOW";
-    }
-  case PROCESS_PRIORITY_FOREGROUND_HIGH:
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
-      return "FOREGROUND_HIGH:CPU_NORMAL";
-    }
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
-      return "FOREGROUND_HIGH:CPU_LOW";
-    }
-  case PROCESS_PRIORITY_FOREGROUND:
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
-      return "FOREGROUND:CPU_NORMAL";
-    }
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
-      return "FOREGROUND:CPU_LOW";
-    }
-  case PROCESS_PRIORITY_FOREGROUND_KEYBOARD:
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
-      return "FOREGROUND_KEYBOARD:CPU_NORMAL";
-    }
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
-      return "FOREGROUND_KEYBOARD:CPU_LOW";
-    }
-  case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE:
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
-      return "BACKGROUND_PERCEIVABLE:CPU_NORMAL";
-    }
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
-      return "BACKGROUND_PERCEIVABLE:CPU_LOW";
-    }
-  case PROCESS_PRIORITY_BACKGROUND_HOMESCREEN:
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
-      return "BACKGROUND_HOMESCREEN:CPU_NORMAL";
-    }
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
-      return "BACKGROUND_HOMESCREEN:CPU_LOW";
-    }
-  case PROCESS_PRIORITY_BACKGROUND:
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
-      return "BACKGROUND:CPU_NORMAL";
-    }
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
-      return "BACKGROUND:CPU_LOW";
-    }
-  case PROCESS_PRIORITY_UNKNOWN:
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
-      return "UNKNOWN:CPU_NORMAL";
-    }
-    if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
-      return "UNKNOWN:CPU_LOW";
-    }
-  default:
-    // Fall through.  (|default| is here to silence warnings.)
-    break;
-  }
-
-  MOZ_ASSERT(false);
-  return "???";
-}
-
 static StaticAutoPtr<ObserverList<FMRadioOperationInformation> > sFMRadioObservers;
 static StaticAutoPtr<ObserverList<FMRadioRDSGroup> > sFMRadioRDSObservers;
 
 static void
 InitializeFMRadioObserver()
 {
   if (!sFMRadioObservers) {
     sFMRadioObservers = new ObserverList<FMRadioOperationInformation>;
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -463,31 +463,24 @@ void NotifyAlarmFired();
  * The alarm can be reprogrammed at any time.
  *
  * This API is currently only allowed to be used from non-sandboxed
  * contexts.
  */
 bool SetAlarm(int32_t aSeconds, int32_t aNanoseconds);
 
 /**
- * Set the priority of the given process.  A process's priority is a two-tuple
- * consisting of a hal::ProcessPriority value and a hal::ProcessCPUPriority
- * value.
- *
- * Two processes with the same ProcessCPUPriority value don't necessarily have
- * the same CPU priority; the CPU priority we assign to a process is a function
- * of its ProcessPriority and ProcessCPUPriority.
+ * Set the priority of the given process.
  *
  * Exactly what this does will vary between platforms.  On *nix we might give
  * background processes higher nice values.  On other platforms, we might
  * ignore this call entirely.
  */
 void SetProcessPriority(int aPid,
                         hal::ProcessPriority aPriority,
-                        hal::ProcessCPUPriority aCPUPriority,
                         uint32_t aLRU = 0);
 
 
 /**
  * Set the current thread's priority to appropriate platform-specific value for
  * given functionality. Instead of providing arbitrary priority numbers you
  * must specify a type of function like THREAD_PRIORITY_COMPOSITOR.
  */
--- a/hal/HalTypes.h
+++ b/hal/HalTypes.h
@@ -68,49 +68,38 @@ enum ProcessPriority {
   // "foreground" for the purposes of priority testing, for example
   // CurrentProcessIsForeground().
   PROCESS_PRIORITY_FOREGROUND,
   PROCESS_PRIORITY_FOREGROUND_HIGH,
   PROCESS_PRIORITY_MASTER,
   NUM_PROCESS_PRIORITY
 };
 
-enum ProcessCPUPriority {
-  PROCESS_CPU_PRIORITY_LOW,
-  PROCESS_CPU_PRIORITY_NORMAL,
-  NUM_PROCESS_CPU_PRIORITY
-};
-
 /**
  * Values that can be passed to hal::SetCurrentThreadPriority().  These should be
  * functional in nature, such as COMPOSITOR, instead of levels, like LOW/HIGH.
  * This allows us to tune our priority scheme for the system in one place such
  * that it makes sense holistically for the overall operating system.  On gonk
  * or android we may want different priority schemes than on windows, etc.
  */
 enum ThreadPriority {
   THREAD_PRIORITY_COMPOSITOR,
   NUM_THREAD_PRIORITY
 };
 
 /**
- * Convert a ProcessPriority enum value (with an optional ProcessCPUPriority)
- * to a string.  The strings returned by this function are statically
- * allocated; do not attempt to free one!
+ * Convert a ProcessPriority enum value to a string.  The strings returned by
+ * this function are statically allocated; do not attempt to free one!
  *
  * If you pass an unknown process priority, we fatally assert in debug
  * builds and otherwise return "???".
  */
 const char*
 ProcessPriorityToString(ProcessPriority aPriority);
 
-const char*
-ProcessPriorityToString(ProcessPriority aPriority,
-                        ProcessCPUPriority aCPUPriority);
-
 /**
  * Convert a ThreadPriority enum value to a string.  The strings returned by
  * this function are statically allocated; do not attempt to free one!
  *
  * If you pass an unknown process priority, we assert in debug builds
  * and otherwise return "???".
  */
 const char *
--- a/hal/fallback/FallbackProcessPriority.cpp
+++ b/hal/fallback/FallbackProcessPriority.cpp
@@ -8,18 +8,16 @@
 using namespace mozilla::hal;
 
 namespace mozilla {
 namespace hal_impl {
 
 void
 SetProcessPriority(int aPid,
                    ProcessPriority aPriority,
-                   ProcessCPUPriority aCPUPriority,
                    uint32_t aBackgroundLRU)
 {
   HAL_LOG("FallbackProcessPriority - SetProcessPriority(%d, %s, %u)\n",
-          aPid, ProcessPriorityToString(aPriority, aCPUPriority),
-          aBackgroundLRU);
+          aPid, ProcessPriorityToString(aPriority), aBackgroundLRU);
 }
 
 } // hal_impl
 } // namespace mozilla
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -1733,21 +1733,20 @@ EnsureKernelLowMemKillerParamsSet()
   if (os) {
     os->AddObserver(oomLogger, "ipc:content-shutdown", false);
   }
 }
 
 void
 SetProcessPriority(int aPid,
                    ProcessPriority aPriority,
-                   ProcessCPUPriority aCPUPriority,
                    uint32_t aBackgroundLRU)
 {
-  HAL_LOG("SetProcessPriority(pid=%d, priority=%d, cpuPriority=%d, LRU=%u)",
-          aPid, aPriority, aCPUPriority, aBackgroundLRU);
+  HAL_LOG("SetProcessPriority(pid=%d, priority=%d, LRU=%u)",
+          aPid, aPriority, aBackgroundLRU);
 
   // If this is the first time SetProcessPriority was called, set the kernel's
   // OOM parameters according to our prefs.
   //
   // We could/should do this on startup instead of waiting for the first
   // SetProcessPriorityCall.  But in practice, the master process needs to set
   // its priority early in the game, so we can reasonably rely on
   // SetProcessPriority being called early in startup.
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -352,17 +352,16 @@ SetAlarm(int32_t aSeconds, int32_t aNano
 {
   NS_RUNTIMEABORT("Alarms can't be programmed from sandboxed contexts.  Yet.");
   return false;
 }
 
 void
 SetProcessPriority(int aPid,
                    ProcessPriority aPriority,
-                   ProcessCPUPriority aCPUPriority,
                    uint32_t aBackgroundLRU)
 {
   NS_RUNTIMEABORT("Only the main process may set processes' priorities.");
 }
 
 void
 SetCurrentThreadPriority(ThreadPriority aThreadPriority)
 {