Bug 959966: prevent the preallocated process from being killed by the lowmem killer by rasing its priority. r=khuey,gsvelto

This commit is contained in:
Cervantes Yu 2014-03-13 15:24:42 +08:00
parent e35977b215
commit 53aa9fe207
7 changed files with 25 additions and 3 deletions

View File

@ -650,6 +650,9 @@ pref("hal.processPriorityManager.gonk.MASTER.OomScoreAdjust", 0);
pref("hal.processPriorityManager.gonk.MASTER.KillUnderKB", 4096);
pref("hal.processPriorityManager.gonk.MASTER.Nice", 0);
pref("hal.processPriorityManager.gonk.PREALLOC.OomScoreAdjust", 67);
pref("hal.processPriorityManager.gonk.PREALLOC.Nice", 18);
pref("hal.processPriorityManager.gonk.FOREGROUND_HIGH.OomScoreAdjust", 67);
pref("hal.processPriorityManager.gonk.FOREGROUND_HIGH.KillUnderKB", 5120);
pref("hal.processPriorityManager.gonk.FOREGROUND_HIGH.Nice", 0);

View File

@ -61,7 +61,7 @@ function runTest()
// Ensure that the preallocated process initially gets BACKGROUND priority.
// That's it.
expectProcessCreated().then(function(childID) {
return expectPriorityChange(childID, 'BACKGROUND');
return expectPriorityChange(childID, 'PREALLOC');
}).then(function() {
cleanUp();
SimpleTest.finish();

View File

@ -448,7 +448,7 @@ ContentParent::PreallocateAppProcess()
new ContentParent(/* app = */ nullptr,
/* isForBrowserElement = */ false,
/* isForPreallocated = */ true,
PROCESS_PRIORITY_BACKGROUND);
PROCESS_PRIORITY_PREALLOC);
process->Init();
return process.forget();
}
@ -1464,7 +1464,7 @@ ContentParent::ContentParent(ContentParent* aTemplate,
// memory priority, which it has inherited from this process.
ProcessPriority priority;
if (IsPreallocated()) {
priority = PROCESS_PRIORITY_BACKGROUND;
priority = PROCESS_PRIORITY_PREALLOC;
} else {
priority = PROCESS_PRIORITY_FOREGROUND;
}

View File

@ -945,6 +945,10 @@ ParticularProcessPriorityManager::ComputePriority()
ProcessCPUPriority
ParticularProcessPriorityManager::ComputeCPUPriority()
{
if (mPriority == PROCESS_PRIORITY_PREALLOC) {
return PROCESS_CPU_PRIORITY_LOW;
}
if (mPriority >= PROCESS_PRIORITY_FOREGROUND_HIGH) {
return PROCESS_CPU_PRIORITY_NORMAL;
}

View File

@ -884,6 +884,8 @@ ProcessPriorityToString(ProcessPriority aPriority)
switch (aPriority) {
case PROCESS_PRIORITY_MASTER:
return "MASTER";
case PROCESS_PRIORITY_PREALLOC:
return "PREALLOC";
case PROCESS_PRIORITY_FOREGROUND_HIGH:
return "FOREGROUND_HIGH";
case PROCESS_PRIORITY_FOREGROUND:
@ -934,6 +936,13 @@ ProcessPriorityToString(ProcessPriority aPriority,
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";

View File

@ -84,6 +84,9 @@ enum ProcessPriority {
PROCESS_PRIORITY_BACKGROUND_HOMESCREEN,
PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE,
PROCESS_PRIORITY_FOREGROUND_KEYBOARD,
// The special class for the preallocated process, high memory priority but
// low CPU priority.
PROCESS_PRIORITY_PREALLOC,
// Any priority greater than or equal to FOREGROUND is considered
// "foreground" for the purposes of priority testing, for example
// CurrentProcessIsForeground().

View File

@ -1258,6 +1258,9 @@ EnsureKernelLowMemKillerParamsSet()
nsPrintfCString("hal.processPriorityManager.gonk.%s.KillUnderKB",
ProcessPriorityToString(priority)).get(),
&killUnderKB))) {
// ProcessPriority values like PROCESS_PRIORITY_FOREGROUND_KEYBOARD,
// which has only OomScoreAdjust but lacks KillUnderMB value, will not
// create new LMK parameters.
continue;
}