diff for duplicates of <20170530185231.GA13412@castle> diff --git a/a/1.txt b/N1/1.txt index 8b13789..d28e4e1 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -1 +1,194 @@ +>From c57e3674efc609f8364f5e228a2c1309cfe99901 Mon Sep 17 00:00:00 2001 +From: Roman Gushchin <guro@fb.com> +Date: Tue, 23 May 2017 17:37:55 +0100 +Subject: [PATCH v2] mm,oom: add tracepoints for oom reaper-related events +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 + +Signed-off-by: Roman Gushchin <guro@fb.com> +Cc: Michal 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> +Cc: kernel-team@fb.com +Cc: linux-kernel@vger.kernel.org +Cc: linux-mm@kvack.org +--- + include/trace/events/oom.h | 80 ++++++++++++++++++++++++++++++++++++++++++++++ + mm/oom_kill.c | 7 ++++ + 2 files changed, 87 insertions(+) + +diff --git a/include/trace/events/oom.h b/include/trace/events/oom.h +index 38baeb2..c3c19d4 100644 +--- a/include/trace/events/oom.h ++++ b/include/trace/events/oom.h +@@ -70,6 +70,86 @@ TRACE_EVENT(reclaim_retry_zone, + __entry->wmark_check) + ); + ++TRACE_EVENT(mark_victim, ++ TP_PROTO(int pid), ++ ++ TP_ARGS(pid), ++ ++ TP_STRUCT__entry( ++ __field(int, pid) ++ ), ++ ++ TP_fast_assign( ++ __entry->pid = pid; ++ ), ++ ++ TP_printk("pid=%d", __entry->pid) ++); ++ ++TRACE_EVENT(wake_reaper, ++ TP_PROTO(int pid), ++ ++ TP_ARGS(pid), ++ ++ TP_STRUCT__entry( ++ __field(int, pid) ++ ), ++ ++ TP_fast_assign( ++ __entry->pid = pid; ++ ), ++ ++ TP_printk("pid=%d", __entry->pid) ++); ++ ++TRACE_EVENT(start_task_reaping, ++ TP_PROTO(int pid), ++ ++ TP_ARGS(pid), ++ ++ TP_STRUCT__entry( ++ __field(int, pid) ++ ), ++ ++ TP_fast_assign( ++ __entry->pid = pid; ++ ), ++ ++ TP_printk("pid=%d", __entry->pid) ++); ++ ++TRACE_EVENT(finish_task_reaping, ++ TP_PROTO(int pid), ++ ++ TP_ARGS(pid), ++ ++ TP_STRUCT__entry( ++ __field(int, pid) ++ ), ++ ++ TP_fast_assign( ++ __entry->pid = pid; ++ ), ++ ++ TP_printk("pid=%d", __entry->pid) ++); ++ ++TRACE_EVENT(skip_task_reaping, ++ TP_PROTO(int pid), ++ ++ TP_ARGS(pid), ++ ++ TP_STRUCT__entry( ++ __field(int, pid) ++ ), ++ ++ TP_fast_assign( ++ __entry->pid = pid; ++ ), ++ ++ TP_printk("pid=%d", __entry->pid) ++); ++ + #ifdef CONFIG_COMPACTION + TRACE_EVENT(compact_retry, + +diff --git a/mm/oom_kill.c b/mm/oom_kill.c +index 04c9143..409b685 100644 +--- a/mm/oom_kill.c ++++ b/mm/oom_kill.c +@@ -490,6 +490,7 @@ static bool __oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm) + + if (!down_read_trylock(&mm->mmap_sem)) { + ret = false; ++ trace_skip_task_reaping(tsk->pid); + goto unlock_oom; + } + +@@ -500,9 +501,12 @@ static bool __oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm) + */ + if (!mmget_not_zero(mm)) { + up_read(&mm->mmap_sem); ++ trace_skip_task_reaping(tsk->pid); + goto unlock_oom; + } + ++ trace_start_task_reaping(tsk->pid); ++ + /* + * Tell all users of get_user/copy_from_user etc... that the content + * is no longer stable. No barriers really needed because unmapping +@@ -544,6 +548,7 @@ static bool __oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm) + * put the oom_reaper out of the way. + */ + mmput_async(mm); ++ trace_finish_task_reaping(tsk->pid); + unlock_oom: + mutex_unlock(&oom_lock); + return ret; +@@ -615,6 +620,7 @@ static void wake_oom_reaper(struct task_struct *tsk) + tsk->oom_reaper_list = oom_reaper_list; + oom_reaper_list = tsk; + spin_unlock(&oom_reaper_lock); ++ trace_wake_reaper(tsk->pid); + wake_up(&oom_reaper_wait); + } + +@@ -666,6 +672,7 @@ static void mark_oom_victim(struct task_struct *tsk) + */ + __thaw_task(tsk); + atomic_inc(&oom_victims); ++ trace_mark_victim(tsk->pid); + } + + /** +-- +2.7.4 diff --git a/a/content_digest b/N1/content_digest index 7cece72..212bc65 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -9,10 +9,204 @@ "Cc\0Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>" Johannes Weiner <hannes@cmpxchg.org> Vladimir Davydov <vdavydov.dev@gmail.com> - kernel-team@fb.com - linux-kernel@vger.kernel.org - " linux-mm@kvack.org\0" + <kernel-team@fb.com> + <linux-kernel@vger.kernel.org> + " <linux-mm@kvack.org>\0" "\00:1\0" "b\0" + ">From c57e3674efc609f8364f5e228a2c1309cfe99901 Mon Sep 17 00:00:00 2001\n" + "From: Roman Gushchin <guro@fb.com>\n" + "Date: Tue, 23 May 2017 17:37:55 +0100\n" + "Subject: [PATCH v2] mm,oom: add tracepoints for oom reaper-related events\n" + "\n" + "During the debugging of the problem described in\n" + "https://lkml.org/lkml/2017/5/17/542 and fixed by Tetsuo Handa\n" + "in https://lkml.org/lkml/2017/5/19/383 , I've found that\n" + "the existing debug output is not really useful to understand\n" + "issues related to the oom reaper.\n" + "\n" + "So, I assume, that adding some tracepoints might help with\n" + "debugging of similar issues.\n" + "\n" + "Trace the following events:\n" + "1) a process is marked as an oom victim,\n" + "2) a process is added to the oom reaper list,\n" + "3) the oom reaper starts reaping process's mm,\n" + "4) the oom reaper finished reaping,\n" + "5) the oom reaper skips reaping.\n" + "\n" + "How it works in practice? Below is an example which show\n" + "how the problem mentioned above can be found: one process is added\n" + "twice to the oom_reaper list:\n" + "\n" + "$ cd /sys/kernel/debug/tracing\n" + "$ echo \"oom:mark_victim\" > set_event\n" + "$ echo \"oom:wake_reaper\" >> set_event\n" + "$ echo \"oom:skip_task_reaping\" >> set_event\n" + "$ echo \"oom:start_task_reaping\" >> set_event\n" + "$ echo \"oom:finish_task_reaping\" >> set_event\n" + "$ cat trace_pipe\n" + " allocate-502 [001] .... 91.836405: mark_victim: pid=502\n" + " allocate-502 [001] .N.. 91.837356: wake_reaper: pid=502\n" + " allocate-502 [000] .N.. 91.871149: wake_reaper: pid=502\n" + " oom_reaper-23 [000] .... 91.871177: start_task_reaping: pid=502\n" + " oom_reaper-23 [000] .N.. 91.879511: finish_task_reaping: pid=502\n" + " oom_reaper-23 [000] .... 91.879580: skip_task_reaping: pid=502\n" + "\n" + "Signed-off-by: Roman Gushchin <guro@fb.com>\n" + "Cc: Michal Hocko <mhocko@suse.com>\n" + "Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>\n" + "Cc: Johannes Weiner <hannes@cmpxchg.org>\n" + "Cc: Vladimir Davydov <vdavydov.dev@gmail.com>\n" + "Cc: kernel-team@fb.com\n" + "Cc: linux-kernel@vger.kernel.org\n" + "Cc: linux-mm@kvack.org\n" + "---\n" + " include/trace/events/oom.h | 80 ++++++++++++++++++++++++++++++++++++++++++++++\n" + " mm/oom_kill.c | 7 ++++\n" + " 2 files changed, 87 insertions(+)\n" + "\n" + "diff --git a/include/trace/events/oom.h b/include/trace/events/oom.h\n" + "index 38baeb2..c3c19d4 100644\n" + "--- a/include/trace/events/oom.h\n" + "+++ b/include/trace/events/oom.h\n" + "@@ -70,6 +70,86 @@ TRACE_EVENT(reclaim_retry_zone,\n" + " \t\t\t__entry->wmark_check)\n" + " );\n" + " \n" + "+TRACE_EVENT(mark_victim,\n" + "+\tTP_PROTO(int pid),\n" + "+\n" + "+\tTP_ARGS(pid),\n" + "+\n" + "+\tTP_STRUCT__entry(\n" + "+\t\t__field(int, pid)\n" + "+\t),\n" + "+\n" + "+\tTP_fast_assign(\n" + "+\t\t__entry->pid = pid;\n" + "+\t),\n" + "+\n" + "+\tTP_printk(\"pid=%d\", __entry->pid)\n" + "+);\n" + "+\n" + "+TRACE_EVENT(wake_reaper,\n" + "+\tTP_PROTO(int pid),\n" + "+\n" + "+\tTP_ARGS(pid),\n" + "+\n" + "+\tTP_STRUCT__entry(\n" + "+\t\t__field(int, pid)\n" + "+\t),\n" + "+\n" + "+\tTP_fast_assign(\n" + "+\t\t__entry->pid = pid;\n" + "+\t),\n" + "+\n" + "+\tTP_printk(\"pid=%d\", __entry->pid)\n" + "+);\n" + "+\n" + "+TRACE_EVENT(start_task_reaping,\n" + "+\tTP_PROTO(int pid),\n" + "+\n" + "+\tTP_ARGS(pid),\n" + "+\n" + "+\tTP_STRUCT__entry(\n" + "+\t\t__field(int, pid)\n" + "+\t),\n" + "+\n" + "+\tTP_fast_assign(\n" + "+\t\t__entry->pid = pid;\n" + "+\t),\n" + "+\n" + "+\tTP_printk(\"pid=%d\", __entry->pid)\n" + "+);\n" + "+\n" + "+TRACE_EVENT(finish_task_reaping,\n" + "+\tTP_PROTO(int pid),\n" + "+\n" + "+\tTP_ARGS(pid),\n" + "+\n" + "+\tTP_STRUCT__entry(\n" + "+\t\t__field(int, pid)\n" + "+\t),\n" + "+\n" + "+\tTP_fast_assign(\n" + "+\t\t__entry->pid = pid;\n" + "+\t),\n" + "+\n" + "+\tTP_printk(\"pid=%d\", __entry->pid)\n" + "+);\n" + "+\n" + "+TRACE_EVENT(skip_task_reaping,\n" + "+\tTP_PROTO(int pid),\n" + "+\n" + "+\tTP_ARGS(pid),\n" + "+\n" + "+\tTP_STRUCT__entry(\n" + "+\t\t__field(int, pid)\n" + "+\t),\n" + "+\n" + "+\tTP_fast_assign(\n" + "+\t\t__entry->pid = pid;\n" + "+\t),\n" + "+\n" + "+\tTP_printk(\"pid=%d\", __entry->pid)\n" + "+);\n" + "+\n" + " #ifdef CONFIG_COMPACTION\n" + " TRACE_EVENT(compact_retry,\n" + " \n" + "diff --git a/mm/oom_kill.c b/mm/oom_kill.c\n" + "index 04c9143..409b685 100644\n" + "--- a/mm/oom_kill.c\n" + "+++ b/mm/oom_kill.c\n" + "@@ -490,6 +490,7 @@ static bool __oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)\n" + " \n" + " \tif (!down_read_trylock(&mm->mmap_sem)) {\n" + " \t\tret = false;\n" + "+\t\ttrace_skip_task_reaping(tsk->pid);\n" + " \t\tgoto unlock_oom;\n" + " \t}\n" + " \n" + "@@ -500,9 +501,12 @@ static bool __oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)\n" + " \t */\n" + " \tif (!mmget_not_zero(mm)) {\n" + " \t\tup_read(&mm->mmap_sem);\n" + "+\t\ttrace_skip_task_reaping(tsk->pid);\n" + " \t\tgoto unlock_oom;\n" + " \t}\n" + " \n" + "+\ttrace_start_task_reaping(tsk->pid);\n" + "+\n" + " \t/*\n" + " \t * Tell all users of get_user/copy_from_user etc... that the content\n" + " \t * is no longer stable. No barriers really needed because unmapping\n" + "@@ -544,6 +548,7 @@ static bool __oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)\n" + " \t * put the oom_reaper out of the way.\n" + " \t */\n" + " \tmmput_async(mm);\n" + "+\ttrace_finish_task_reaping(tsk->pid);\n" + " unlock_oom:\n" + " \tmutex_unlock(&oom_lock);\n" + " \treturn ret;\n" + "@@ -615,6 +620,7 @@ static void wake_oom_reaper(struct task_struct *tsk)\n" + " \ttsk->oom_reaper_list = oom_reaper_list;\n" + " \toom_reaper_list = tsk;\n" + " \tspin_unlock(&oom_reaper_lock);\n" + "+\ttrace_wake_reaper(tsk->pid);\n" + " \twake_up(&oom_reaper_wait);\n" + " }\n" + " \n" + "@@ -666,6 +672,7 @@ static void mark_oom_victim(struct task_struct *tsk)\n" + " \t */\n" + " \t__thaw_task(tsk);\n" + " \tatomic_inc(&oom_victims);\n" + "+\ttrace_mark_victim(tsk->pid);\n" + " }\n" + " \n" + " /**\n" + "-- \n" + 2.7.4 -a7d616b28b5c0b6708d23cdd3f4071abf6268c28ed11206812e9ba9e206982f2 +3d3bf45a68df6c2610a3ab09c54bed888c35920f54bd6f41000a652385cd76e5
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.