• Roman Gushchin's avatar
    mm/oom_kill.c: add tracepoints for oom reaper-related events · 422580c3
    Roman Gushchin authored
    During the debugging of the problem described in
    https://lkml.org/lkml/2017/5/17/542 and fixed by Tetsuo Handa in
    https://lkml.org/lkml/2017/5/19/383 , I've found that the existing debug
    output is not really useful to understand issues related to the oom
    reaper.
    
    So, I assume, that adding some tracepoints might help with debugging of
    similar issues.
    
    Trace the following events:
     1) a process is marked as an oom victim,
     2) a process is added to the oom reaper list,
     3) the oom reaper starts reaping process's mm,
     4) the oom reaper finished reaping,
     5) the oom reaper skips reaping.
    
    How it works in practice? Below is an example which show how the problem
    mentioned above can be found: one process is added twice to the
    oom_reaper list:
    
      $ cd /sys/kernel/debug/tracing
      $ echo "oom:mark_victim" > set_event
      $ echo "oom:wake_reaper" >> set_event
      $ echo "oom:skip_task_reaping" >> set_event
      $ echo "oom:start_task_reaping" >> set_event
      $ echo "oom:finish_task_reaping" >> set_event
      $ cat trace_pipe
              allocate-502   [001] ....    91.836405: mark_victim: pid=502
              allocate-502   [001] .N..    91.837356: wake_reaper: pid=502
              allocate-502   [000] .N..    91.871149: wake_reaper: pid=502
            oom_reaper-23    [000] ....    91.871177: start_task_reaping: pid=502
            oom_reaper-23    [000] .N..    91.879511: finish_task_reaping: pid=502
            oom_reaper-23    [000] ....    91.879580: skip_task_reaping: pid=502
    
    Link: http://lkml.kernel.org/r/20170530185231.GA13412@castleSigned-off-by: default avatarRoman Gushchin <guro@fb.com>
    Acked-by: default avatarMichal Hocko <mhocko@suse.com>
    Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    422580c3
oom_kill.c 28.8 KB