0

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

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#L497.

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;
}
  • 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 – dippynark Jun 10 '18 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.