diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 20:53:17 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 20:53:17 +0000 |
commit | 1dcae06794d4875c9566ffdd5b335594ec3746a0 (patch) | |
tree | d9c341e873302205cd0854a3c0a02bdac80c2edf /base/process_util.h | |
parent | ab312f8e72b10eb20bdeef6bd79eb36ad995a05b (diff) | |
download | chromium_src-1dcae06794d4875c9566ffdd5b335594ec3746a0.zip chromium_src-1dcae06794d4875c9566ffdd5b335594ec3746a0.tar.gz chromium_src-1dcae06794d4875c9566ffdd5b335594ec3746a0.tar.bz2 |
Revert 97724 - 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.
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/7671033
TBR=gspencer@google.com
Review URL: http://codereview.chromium.org/7685030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97728 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util.h')
-rw-r--r-- | base/process_util.h | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/base/process_util.h b/base/process_util.h index 106fbb1..b98e266 100644 --- a/base/process_util.h +++ b/base/process_util.h @@ -173,22 +173,13 @@ BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process); // Exposed for testing. BASE_EXPORT int ParseProcStatCPU(const std::string& input); -// The command line switch used for supplying the OOM adjustment score -// to the setuid sandbox. -extern const char kAdjustOOMScoreSwitch[]; - -// The maximum allowed value for the OOM score. -const int kMaxOomScore = 1000; - -// This adjusts /proc/<pid>/oom_score_adj so the Linux OOM killer will -// prefer to kill certain process types over others. The range for the -// adjustment is [-1000, 1000], with [0, 1000] being user accessible. -// If the Linux system doesn't support the newer oom_score_adj range -// of [0, 1000], then we revert to using the older oom_adj, and -// translate the given value into [0, 15]. Some aliasing of values -// may occur in that case, of course. +static const char kAdjustOOMScoreSwitch[] = "--adjust-oom-score"; + +// This adjusts /proc/process/oom_adj so the Linux OOM killer will prefer +// certain process types over others. The range for the adjustment is +// [-17,15], with [0,15] being user accessible. BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); -#endif // defined(OS_LINUX) +#endif #if defined(OS_POSIX) // Returns the ID for the parent of the given process. @@ -198,7 +189,7 @@ BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); // given multimap. Only call this function in a child process where you know // that there aren't any other threads. BASE_EXPORT void CloseSuperfluousFds(const InjectiveMultimap& saved_map); -#endif // defined(OS_POSIX) +#endif // TODO(evan): rename these to use StudlyCaps. typedef std::vector<std::pair<std::string, std::string> > environment_vector; @@ -214,7 +205,7 @@ struct LaunchOptions { #else environ(NULL), fds_to_remap(NULL), new_process_group(false), clone_flags(0) -#endif // !defined(OS_WIN) +#endif {} // If true, wait for the process to complete. @@ -257,7 +248,7 @@ struct LaunchOptions { // If non-zero, start the process using clone(), using flags as provided. int clone_flags; -#endif // !defined(OS_WIN) +#endif }; // Launch a process via the command line |cmdline|. @@ -344,7 +335,7 @@ BASE_EXPORT bool GetAppOutputRestricted(const CommandLine& cl, // |*exit_code|. BASE_EXPORT bool GetAppOutputWithExitCode(const CommandLine& cl, std::string* output, int* exit_code); -#endif // defined(OS_POSIX) +#endif // Used to filter processes by process ID. class ProcessFilter { @@ -381,12 +372,12 @@ BASE_EXPORT bool KillProcess(ProcessHandle process, int exit_code, bool wait); // Attempts to kill the process group identified by |process_group_id|. Returns // true on success. BASE_EXPORT bool KillProcessGroup(ProcessHandle process_group_id); -#endif // defined(OS_POSIX) +#endif #if defined(OS_WIN) BASE_EXPORT bool KillProcessById(ProcessId process_id, int exit_code, bool wait); -#endif // defined(OS_WIN) +#endif // Get the termination status of the process by interpreting the // circumstances of the child process' death. |exit_code| is set to @@ -641,7 +632,7 @@ class BASE_EXPORT ProcessMetrics { explicit ProcessMetrics(ProcessHandle process); #else ProcessMetrics(ProcessHandle process, PortProvider* port_provider); -#endif // defined(OS_MACOSX) +#endif // !defined(OS_MACOSX) ProcessHandle process_; @@ -660,7 +651,7 @@ class BASE_EXPORT ProcessMetrics { #elif defined(OS_POSIX) // Jiffie count at the last_time_ we updated. int last_cpu_; -#endif // defined(OS_POSIX) +#endif // defined(OS_MACOSX) DISALLOW_COPY_AND_ASSIGN(ProcessMetrics); }; @@ -683,7 +674,7 @@ struct SystemMemoryInfoKB { // Fills in the provided |meminfo| structure. Returns true on success. // Exposed for memory debugging widget. BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); -#endif // defined(OS_LINUX) +#endif // Returns the memory committed by the system in KBytes. // Returns 0 if it can't compute the commit charge. @@ -708,8 +699,8 @@ BASE_EXPORT void EnableTerminationOnOutOfMemory(); #if defined(OS_MACOSX) // Exposed for testing. BASE_EXPORT malloc_zone_t* GetPurgeableZone(); -#endif // defined(OS_MACOSX) -#endif // !defined(OS_WIN) +#endif +#endif // Enables stack dump to console output on exception and signals. // When enabled, the process will quit immediately. This is meant to be used in |