Bug 785171 - Support OOM adjustment via /proc/<pid>/oom_score_adj. r=dhylands

The interface /proc/<pid>/oom_score_adj has been added as a replacement for /proc/<pid>/oom_adj. It
is now supported and used by default within Gonk. If oom_scrore_adj is not available, the code falls
back to the old interface.
This commit is contained in:
Thomas Zimmermann 2012-09-14 11:52:07 -07:00
parent b528bd795a
commit b4126e3818

View File

@ -907,10 +907,17 @@ SetProcessPriority(int aPid, ProcessPriority aPriority)
aPid, clampedOomScoreAdj));
}
int oomAdj = oomAdjOfOomScoreAdj(clampedOomScoreAdj);
// We try the newer interface first, and fall back to the older interface
// on failure.
WriteToFile(nsPrintfCString("/proc/%d/oom_adj", aPid).get(),
nsPrintfCString("%d", oomAdj).get());
if (!WriteToFile(nsPrintfCString("/proc/%d/oom_score_adj", aPid).get(),
nsPrintfCString("%d", clampedOomScoreAdj).get()))
{
int oomAdj = oomAdjOfOomScoreAdj(clampedOomScoreAdj);
WriteToFile(nsPrintfCString("/proc/%d/oom_adj", aPid).get(),
nsPrintfCString("%d", oomAdj).get());
}
}
int32_t nice = 0;