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

Unified Diff: chrome/browser/zygote_host_linux.cc

Issue 3235007: This adds periodic OOM score adjustment, based on the last access time (Closed)
Patch Set: Final review changes Created 10 years, 4 months 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
« no previous file with comments | « chrome/browser/zygote_host_linux.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/zygote_host_linux.cc
diff --git a/chrome/browser/zygote_host_linux.cc b/chrome/browser/zygote_host_linux.cc
index f01bcf11620bb0a9a83e778fbef159f41d9f0637..ac98f5a2b6bc41f4a2b0e4bd76d75331d84d5551 100644
--- a/chrome/browser/zygote_host_linux.cc
+++ b/chrome/browser/zygote_host_linux.cc
@@ -236,6 +236,13 @@ pid_t ZygoteHost::ForkRenderer(
return base::kNullProcessHandle;
}
+ const int kRendererScore = 5;
+ AdjustRendererOOMScore(pid, kRendererScore);
+
+ return pid;
+}
+
+void ZygoteHost::AdjustRendererOOMScore(base::ProcessHandle pid, int score) {
// 1) You can't change the oom_adj of a non-dumpable process (EPERM) unless
// you're root. Because of this, we can't set the oom_adj from the browser
// process.
@@ -268,27 +275,23 @@ pid_t ZygoteHost::ForkRenderer(
selinux_valid = true;
}
- const int kRendererScore = 5;
if (using_suid_sandbox_ && !selinux) {
base::ProcessHandle sandbox_helper_process;
- base::file_handle_mapping_vector dummy_map;
std::vector<std::string> adj_oom_score_cmdline;
adj_oom_score_cmdline.push_back(sandbox_binary_);
adj_oom_score_cmdline.push_back(base::kAdjustOOMScoreSwitch);
adj_oom_score_cmdline.push_back(base::Int64ToString(pid));
- adj_oom_score_cmdline.push_back(base::IntToString(kRendererScore));
+ adj_oom_score_cmdline.push_back(base::IntToString(score));
CommandLine adj_oom_score_cmd(adj_oom_score_cmdline);
- if (base::LaunchApp(adj_oom_score_cmdline, dummy_map, false,
+ if (base::LaunchApp(adj_oom_score_cmd, false, true,
&sandbox_helper_process)) {
ProcessWatcher::EnsureProcessGetsReaped(sandbox_helper_process);
}
} else if (!using_suid_sandbox_) {
- if (!base::AdjustOOMScore(pid, kRendererScore))
- LOG(ERROR) << "Failed to adjust OOM score of renderer";
+ if (!base::AdjustOOMScore(pid, score))
+ LOG(ERROR) << "Failed to adjust OOM score of renderer with pid " << pid;
}
-
- return pid;
}
void ZygoteHost::EnsureProcessTerminated(pid_t process) {
« no previous file with comments | « chrome/browser/zygote_host_linux.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698