2

Whilst reading both https://lwn.net/Articles/391222/ and http://man7.org/linux/man-pages/man5/proc.5.html I have come across the terms oom_score and badness. Both numbers have the same basic meaning; the higher they are, the more likely the associated task is to be OOM-killed when the host is under memory pressure.

What is the relationship (if any) between the two numbers?

EDIT: My guess is oom_score = max(badness + oom_score_adj, 0) but I haven't found any proof

1 Answer 1

3

It looks like it is:

oom_score = badness * 1000 / totalpages

based on the kernel code https://github.com/torvalds/linux/blob/master/fs/proc/base.c#L549.

static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task) { unsigned long totalpages = totalram_pages + total_swap_pages; unsigned long points = 0; points = oom_badness(task, NULL, NULL, totalpages) * 1000 / totalpages; seq_printf(m, "%lu\n", points); return 0; } 
2
  • Thanks - I feel the proc man page has a confusing description of badness within the /proc/[pid]/oom_score_adj section. I think in that description, the definition of badness is oom_score-oom_score_adj rather than the output of the badness function here Commented Jun 10, 2018 at 8:08
  • Fixed. Thanks @Eugene! Commented May 20, 2020 at 15:37

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.