Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1961)

Unified Diff: chrome/app/chrome_dll_main.cc

Issue 467058: Linux: Adjust /proc/pid/oom_adj to sacrifice plugin and renderer processes to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/app/chrome_dll_main.cc
===================================================================
--- chrome/app/chrome_dll_main.cc (revision 34180)
+++ chrome/app/chrome_dll_main.cc (working copy)
@@ -245,6 +245,37 @@
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 @@
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) {

Powered by Google App Engine
This is Rietveld 408576698