Skip to content

Commit

Permalink
[vpsAdminOS] oom_kill exceptions for CT init & lxc
Browse files Browse the repository at this point in the history
OOM killer in vpsAdminOS container should never kill its init, as is true
for normal full Linux boxes.

Also let's make an exception for lxc-start responsible for the container's
lifetime.

Signed-off-by: Pavel Snajdr <snajpa@snajpa.net>
  • Loading branch information
snajpa committed Aug 7, 2020
1 parent 5ed6df0 commit bfc27e0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mm/oom_kill.c
Expand Up @@ -200,6 +200,8 @@ unsigned long oom_badness(struct task_struct *p, unsigned long totalpages)
{
long points;
long adj;
struct pid_namespace *ns;
pid_t ns_pid;

if (oom_unkillable_task(p))
return 0;
Expand All @@ -214,6 +216,21 @@ unsigned long oom_badness(struct task_struct *p, unsigned long totalpages)
* the middle of vfork
*/
adj = (long)p->signal->oom_score_adj;

ns = task_active_pid_ns(p);
ns_pid = task_pid_nr_ns(p, ns);

if (((p->cred->user_ns == &init_user_ns) &&
(ns == &init_pid_ns) &&
(strcmp(p->comm, "lxc-start") == 0)
) ||
((p->cred->user_ns->parent == &init_user_ns) &&
(ns != &init_pid_ns) &&
(ns_pid == 1)
)
)
adj = (long)OOM_SCORE_ADJ_MIN;

if (adj == OOM_SCORE_ADJ_MIN ||
test_bit(MMF_OOM_SKIP, &p->mm->flags) ||
in_vfork(p)) {
Expand Down

0 comments on commit bfc27e0

Please sign in to comment.