Skip to content

Commit f755a04

Browse files
kosakitorvalds
authored andcommitted
oom: use pte pages in OOM score
PTE pages eat up memory just like anything else, but we do not account for them in any way in the OOM scores. They are also _guaranteed_ to get freed up when a process is OOM killed, while RSS is not. Reported-by: Dave Hansen <[email protected]> Signed-off-by: KOSAKI Motohiro <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Cc: Oleg Nesterov <[email protected]> Acked-by: David Rientjes <[email protected]> Cc: <[email protected]> [2.6.36+] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 0dcecae commit f755a04

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mm/oom_kill.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,13 @@ unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
172172

173173
/*
174174
* The baseline for the badness score is the proportion of RAM that each
175-
* task's rss and swap space use.
175+
* task's rss, pagetable and swap space use.
176176
*/
177-
points = (get_mm_rss(p->mm) + get_mm_counter(p->mm, MM_SWAPENTS)) * 1000 /
178-
totalpages;
177+
points = get_mm_rss(p->mm) + p->mm->nr_ptes;
178+
points += get_mm_counter(p->mm, MM_SWAPENTS);
179+
180+
points *= 1000;
181+
points /= totalpages;
179182
task_unlock(p);
180183

181184
/*

0 commit comments

Comments
 (0)