Respondendo a minha própria pergunta. Eu usei o SystemTap para conectar-se ao killer da OOM:
#!/usr/bin/env stap
%{
#include <linux/cgroup.h>
%}
function find_mem_cgroup:string(task:long) %{
struct cgroup *cgrp;
struct task_struct *tsk = (struct task_struct *)((long)THIS->task);
/* Initialize with an empty value */
strcpy(THIS->__retvalue, "NULL");
cgroup_lock();
cgrp = task_cgroup(tsk, mem_cgroup_subsys_id);
if (cgrp)
cgroup_path(cgrp, THIS->__retvalue, MAXSTRINGLEN);
cgroup_unlock();
%}
probe kernel.function("oom_kill_task") {
cgroup = find_mem_cgroup($p)
exename = kernel_string($p->comm)
printf("pid\t%d\tmem-cgroup\t%s\texe-name\t%s\n", $p->pid, cgroup, exename)
}
Funciona assim:
cyberax@cybnb:~/work/shell$ sudo stap -g oom.stap pid 3966 mem-cgroup /task1/1/ exe-name oom_generator.p