diff options
author | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-23 17:58:21 +0000 |
---|---|---|
committer | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-23 17:58:21 +0000 |
commit | 03eb9d27a79f876a039ca30eba54d1155ab5500b (patch) | |
tree | 91c377e970b5e117c09f657a01a172e5bf993709 /content/browser/zygote_host_linux.cc | |
parent | c25c7be488ea694d9173374b985e73a5a6eed867 (diff) | |
download | chromium_src-03eb9d27a79f876a039ca30eba54d1155ab5500b.zip chromium_src-03eb9d27a79f876a039ca30eba54d1155ab5500b.tar.gz chromium_src-03eb9d27a79f876a039ca30eba54d1155ab5500b.tar.bz2 |
Trying again to land OOM priority manager changes.
First landing failed because of an obscure problem with building
linux_shared. This change passes the linux_shared trybot (and
linux and linux_chromeos trybots).
Changing OOM range to 0, 1000 and tweaking OOM algorithm.
With this change, we now use the newer oom_score_adj file (with
fallback to oom_adj when on a system that doesn't support it) so that
we can take advantage of a finer range ([0, 1000] instead of [0, 15]).
Also tweaked the OOM priority manager to prioritize things in a
slightly different order, preferring (even more) not to kill tabs that
the user has currently selected.
Original review: http://codereview.chromium.org/7671033/
BUG=chromium-os:18421, chromium:65009
TEST=Ran on device, observed OOM adj values, forced OOM conditions to
watch kills.
Review URL: http://codereview.chromium.org/7708020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/zygote_host_linux.cc')
-rw-r--r-- | content/browser/zygote_host_linux.cc | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/content/browser/zygote_host_linux.cc b/content/browser/zygote_host_linux.cc index 42ee6da..dc2fc4e 100644 --- a/content/browser/zygote_host_linux.cc +++ b/content/browser/zygote_host_linux.cc @@ -272,28 +272,35 @@ pid_t ZygoteHost::ForkRequest( return base::kNullProcessHandle; } - const int kRendererScore = 5; - AdjustRendererOOMScore(pid, kRendererScore); + // This is just a starting score for a renderer or extension (the + // only types of processes that will be started this way). It will + // get adjusted as time goes on. (This is the same value as + // chrome::kLowestRendererOomScore in chrome/chrome_constants.h, but + // that's not something we can include here.) + const int kLowestRendererOomScore = 300; + AdjustRendererOOMScore(pid, kLowestRendererOomScore); 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. + // 1) You can't change the oom_score_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. // - // 2) We can't set the oom_adj before entering the sandbox because the - // zygote is in the sandbox and the zygote is as critical as the browser - // process. Its oom_adj value shouldn't be changed. + // 2) We can't set the oom_score_adj before entering the sandbox + // because the zygote is in the sandbox and the zygote is as + // critical as the browser process. Its oom_adj value shouldn't + // be changed. // - // 3) A non-dumpable process can't even change its own oom_adj because it's - // root owned 0644. The sandboxed processes don't even have /proc, but one - // could imagine passing in a descriptor from outside. + // 3) A non-dumpable process can't even change its own oom_score_adj + // because it's root owned 0644. The sandboxed processes don't + // even have /proc, but one could imagine passing in a descriptor + // from outside. // // So, in the normal case, we use the SUID binary to change it for us. // However, Fedora (and other SELinux systems) don't like us touching other - // process's oom_adj values + // process's oom_score_adj (or oom_adj) values // (https://bugzilla.redhat.com/show_bug.cgi?id=581256). // // The offical way to get the SELinux mode is selinux_getenforcemode, but I @@ -319,9 +326,13 @@ void ZygoteHost::AdjustRendererOOMScore(base::ProcessHandle pid, int score) { if (IsHeapProfilerRunning()) return; #endif + // The command line switch used for supplying the OOM adjustment score + // to the setuid sandbox. + static const char kAdjustOOMScoreSwitch[] = "--adjust-oom-score"; + 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(kAdjustOOMScoreSwitch); adj_oom_score_cmdline.push_back(base::Int64ToString(pid)); adj_oom_score_cmdline.push_back(base::IntToString(score)); |