diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 02:08:10 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 02:08:10 +0000 |
commit | e5856a7a015a8a4d790b51136881a32364ee912a (patch) | |
tree | c96a355ab2e2f663770f4c123244b28031a82b52 /chrome/app | |
parent | 8a0590e6696b0a6377cfc4cb71fa66beeef047d6 (diff) | |
download | chromium_src-e5856a7a015a8a4d790b51136881a32364ee912a.zip chromium_src-e5856a7a015a8a4d790b51136881a32364ee912a.tar.gz chromium_src-e5856a7a015a8a4d790b51136881a32364ee912a.tar.bz2 |
Linux: Adjust /proc/pid/oom_adj to sacrifice plugin and renderer processes to the OOM killer.
BUG=29752
TEST=During out of memory conditions, Linux kernel picks a plugin/renderer over the browser process.
Review URL: http://codereview.chromium.org/467058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34222 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app')
-rw-r--r-- | chrome/app/chrome_dll_main.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc index 3531e80..e78cec7 100644 --- a/chrome/app/chrome_dll_main.cc +++ b/chrome/app/chrome_dll_main.cc @@ -245,6 +245,37 @@ static void SetUpGLibLogHandler() { NULL); } } + +static void AdjustLinuxOOMScore(const std::string& process_type) { + const int kMiscScore = 7; + const int kPluginScore = 10; + int score = -1; + + if (process_type == switches::kPluginProcess) { + score = kPluginScore; + } else if (process_type == switches::kUtilityProcess || + process_type == switches::kWorkerProcess) { + score = kMiscScore; + } else if (process_type == switches::kProfileImportProcess) { + NOTIMPLEMENTED(); +#ifndef DISABLE_NACL + } else if (process_type == switches::kNaClProcess) { + score = kPluginScore; +#endif + } else if (process_type == switches::kZygoteProcess || + process_type.empty()) { + // Pass - browser / zygote process stays at 0. + } else if (process_type == switches::kExtensionProcess || + process_type == switches::kRendererProcess) { + // Set in chrome/browser/zygote_host_linux.cc. + NOTREACHED() << "process type " << process_type + << "should go through the zygote."; + } else { + NOTREACHED() << "Unknown process type"; + } + if (score > -1) + base::AdjustOOMScore(base::GetCurrentProcId(), score); +} #endif // defined(OS_LINUX) // Register the invalid param handler and pure call handler to be able to @@ -601,6 +632,12 @@ int ChromeMain(int argc, char** argv) { MainFunctionParams main_params(parsed_command_line, sandbox_wrapper, &autorelease_pool); + // Note: If you are adding a new process type below, be sure to adjust the + // AdjustLinuxOOMScore function too. +#if defined(OS_LINUX) + AdjustLinuxOOMScore(process_type); +#endif + // TODO(port): turn on these main() functions as they've been de-winified. int rv = -1; if (process_type == switches::kRendererProcess) { |