Bug 836654 - Part 2: Add PROCESS_PRIORITY_FOREGROUND_HIGH. r=cjones
authorJustin Lebar <justin.lebar@gmail.com>
Thu, 14 Feb 2013 15:41:30 -0500
changeset 131838 fb43c5972c2c3973ef75cac87704d8242988a526
parent 131837 e74011e49190a0c13dd9d469bcf83def1b9cd81f
child 131839 6480e7d33c5a02b0ff083188b7976066b5b5dc40
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs836654
milestone21.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 836654 - Part 2: Add PROCESS_PRIORITY_FOREGROUND_HIGH. r=cjones
b2g/app/b2g.js
hal/Hal.cpp
hal/HalTypes.h
hal/gonk/GonkHal.cpp
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -547,28 +547,31 @@ pref("ui.showHideScrollbars", 1);
 pref("dom.ipc.processPriorityManager.enabled", true);
 pref("dom.ipc.processPriorityManager.backgroundGracePeriodMS", 1000);
 pref("dom.ipc.processPriorityManager.temporaryPriorityMS", 5000);
 
 // Kernel parameters for how processes are killed on low-memory.
 pref("gonk.systemMemoryPressureRecoveryPollMS", 5000);
 pref("hal.processPriorityManager.gonk.masterOomScoreAdjust", 0);
 pref("hal.processPriorityManager.gonk.masterKillUnderMB", 1);
-pref("hal.processPriorityManager.gonk.foregroundOomScoreAdjust", 67);
+pref("hal.processPriorityManager.gonk.foregroundHighOomScoreAdjust", 67);
+pref("hal.processPriorityManager.gonk.foregroundHighKillUnderMB", 3);
+pref("hal.processPriorityManager.gonk.foregroundOomScoreAdjust", 134);
 pref("hal.processPriorityManager.gonk.foregroundKillUnderMB", 4);
-pref("hal.processPriorityManager.gonk.backgroundPerceivableOomScoreAdjust", 134);
+pref("hal.processPriorityManager.gonk.backgroundPerceivableOomScoreAdjust", 200);
 pref("hal.processPriorityManager.gonk.backgroundPerceivableKillUnderMB", 5);
-pref("hal.processPriorityManager.gonk.backgroundHomescreenOomScoreAdjust", 200);
+pref("hal.processPriorityManager.gonk.backgroundHomescreenOomScoreAdjust", 267);
 pref("hal.processPriorityManager.gonk.backgroundHomescreenKillUnderMB", 5);
 pref("hal.processPriorityManager.gonk.backgroundOomScoreAdjust", 400);
 pref("hal.processPriorityManager.gonk.backgroundKillUnderMB", 8);
 pref("hal.processPriorityManager.gonk.notifyLowMemUnderMB", 10);
 
 // Niceness values (i.e., CPU priorities) for B2G processes.
 pref("hal.processPriorityManager.gonk.masterNice", 0);
+pref("hal.processPriorityManager.gonk.foregroundHighNice", 0);
 pref("hal.processPriorityManager.gonk.foregroundNice", 1);
 pref("hal.processPriorityManager.gonk.backgroundPerceivableNice", 10);
 pref("hal.processPriorityManager.gonk.backgroundHomescreenNice", 20);
 pref("hal.processPriorityManager.gonk.backgroundNice", 20);
 
 #ifndef DEBUG
 // Enable pre-launching content processes for improved startup time
 // (hiding latency).
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -848,16 +848,18 @@ SetProcessPriority(int aPid, ProcessPrio
 
 // From HalTypes.h.
 const char*
 ProcessPriorityToString(ProcessPriority aPriority)
 {
   switch (aPriority) {
   case PROCESS_PRIORITY_MASTER:
     return "MASTER";
+  case PROCESS_PRIORITY_FOREGROUND_HIGH:
+    return "FOREGROUND_HIGH";
   case PROCESS_PRIORITY_FOREGROUND:
     return "FOREGROUND";
   case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE:
     return "BACKGROUND_PERCEIVABLE";
   case PROCESS_PRIORITY_BACKGROUND_HOMESCREEN:
     return "BACKGROUND_HOMESCREEN";
   case PROCESS_PRIORITY_BACKGROUND:
     return "BACKGROUND";
--- a/hal/HalTypes.h
+++ b/hal/HalTypes.h
@@ -76,16 +76,17 @@ typedef Observer<SwitchEvent> SwitchObse
 enum ProcessPriority {
   PROCESS_PRIORITY_BACKGROUND,
   PROCESS_PRIORITY_BACKGROUND_HOMESCREEN,
   PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE,
   // Any priority greater than or equal to FOREGROUND is considered
   // "foreground" for the purposes of priority testing, for example
   // CurrentProcessIsForeground().
   PROCESS_PRIORITY_FOREGROUND,
+  PROCESS_PRIORITY_FOREGROUND_HIGH,
   PROCESS_PRIORITY_MASTER,
   NUM_PROCESS_PRIORITY
 };
 
 // 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 (or NUM_PROCESS_PRIORITY), we
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -1044,34 +1044,38 @@ EnsureKernelLowMemKillerParamsSet()
   // GonkMemoryPressureMonitoring.cpp.)
 
   // Build the adj and minfree strings.
   nsAutoCString adjParams;
   nsAutoCString minfreeParams;
 
   const char* priorityClasses[] = {
     "master",
+    "foregroundHigh",
     "foreground",
     "backgroundPerceivable",
     "backgroundHomescreen",
     "background"
   };
   for (size_t i = 0; i < NS_ARRAY_LENGTH(priorityClasses); i++) {
+    // The system doesn't function correctly if we're missing these prefs, so
+    // crash loudly.
+
     int32_t oomScoreAdj;
     if (!NS_SUCCEEDED(Preferences::GetInt(nsPrintfCString(
           "hal.processPriorityManager.gonk.%sOomScoreAdjust",
           priorityClasses[i]).get(), &oomScoreAdj))) {
-      continue;
+      MOZ_CRASH();
     }
 
     int32_t killUnderMB;
     if (!NS_SUCCEEDED(Preferences::GetInt(nsPrintfCString(
           "hal.processPriorityManager.gonk.%sKillUnderMB",
           priorityClasses[i]).get(), &killUnderMB))) {
-      continue;
+      MOZ_CRASH();
     }
 
     // adj is in oom_adj units.
     adjParams.AppendPrintf("%d,", OomAdjOfOomScoreAdj(oomScoreAdj));
 
     // minfree is in pages.
     minfreeParams.AppendPrintf("%d,", killUnderMB * 1024 * 1024 / PAGE_SIZE);
   }
@@ -1119,16 +1123,19 @@ SetProcessPriority(int aPid, ProcessPrio
     priorityStr = "backgroundHomescreen";
     break;
   case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE:
     priorityStr = "backgroundPerceivable";
     break;
   case PROCESS_PRIORITY_FOREGROUND:
     priorityStr = "foreground";
     break;
+  case PROCESS_PRIORITY_FOREGROUND_HIGH:
+    priorityStr = "foregroundHigh";
+    break;
   case PROCESS_PRIORITY_MASTER:
     priorityStr = "master";
     break;
   default:
     MOZ_NOT_REACHED();
   }
 
   // Notice that you can disable oom_adj and renice by deleting the prefs