Re: [PATCH 1/2][BUGFIX] oom: remove totalpage normalization from oom_badness()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: KAMEZAWA Hiroyuki
Date: Wednesday, August 25, 2010 - 5:39 pm

On Wed, 25 Aug 2010 03:25:25 -0700 (PDT)
David Rientjes <rientjes@google.com> wrote:

I'm now trying to write a userspace tool to calculate this, for me.
Then, could you update documentation ? 
==
3.2 /proc/<pid>/oom_score - Display current oom-killer score
-------------------------------------------------------------

This file can be used to check the current score used by the oom-killer is for
any given <pid>. Use it together with /proc/<pid>/oom_adj to tune which
process should be killed in an out-of-memory situation.
==

add a some documentation like:
==
(For system monitoring tool developpers, not for usual users.)
oom_score calculation is implemnentation dependent and can be modified without
any caution. But current logic is

oom_score = ((proc's rss + proc's swap) / (available ram + swap)) + oom_score_adj

proc's rss and swap can be obtained by /proc/<pid>/statm and available ram + swap
is dependent on the situation.
If the system is totaly under oom,
	available ram  == /proc/meminfo's MemTotal
	available swap == in most case == /proc/meminfo's SwapTotal
When you use memory cgroup,
	When swap is limited,  avaliable ram + swap == memory cgroup's memsw limit.
	When swap is unlimited, avaliable ram + swap = memory cgroup's memory limit + 
							SwapTotal

Then, please be careful that oom_score's order among tasks depends on the
situation. Assume 2 proceses A, B which has oom_score_adj of 300 and 0
 And A uses 200M, B uses 1G of memory under 4G system

 Under the 4G system.
 	A's socre = (200M *1000)/4G + 300 = 350
 	B's score = (1G * 1000)/4G = 250.

	 In the memory cgroup, it has 2G of resource.
	A's score = (200M * 1000)/2G + 300 = 400
	B's socre = (1G * 1000)/2G = 500

You shoudn't depend on /proc/<pid>/oom_score if you have to handle OOM under
cgroups and cpuset. But the logic is simple.
==

If you don't want, I'll add text and a sample tool to cgroup/memory.txt.


Thanks,
-Kame









--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 1/2][BUGFIX] oom: remove totalpage normalizatio ..., KAMEZAWA Hiroyuki, (Wed Aug 25, 5:39 pm)
Re: [PATCH 1/2][BUGFIX] oom: remove totalpage normalizatio ..., KAMEZAWA Hiroyuki, (Wed Aug 25, 6:03 pm)
Re: [PATCH 1/2][BUGFIX] oom: remove totalpage normalizatio ..., KAMEZAWA Hiroyuki, (Wed Aug 25, 6:11 pm)
Re: [PATCH 1/2][BUGFIX] oom: remove totalpage normalizatio ..., KAMEZAWA Hiroyuki, (Wed Aug 25, 8:20 pm)