linux 内存分析(二)

休眠前和唤醒后, 通过echo m > /proc/sysrq-trigger  命令保存两次内存快照,然后对比,可以找出些异常点.

Subject: [PATCH] mm: dump all user tasks rss and score_adj debug message in
 sysrq interface

---
 drivers/tty/sysrq.c |    2 +-
 include/linux/mm.h  |    2 +-
 mm/oom_kill.c       |    6 ++++++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 0064738..93e52a1 100755
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -301,10 +301,10 @@ static struct sysrq_key_op sysrq_ftrace_dump_op = {
 #else
 #define sysrq_ftrace_dump_op (*(struct sysrq_key_op *)NULL)
 #endif
-
 static void sysrq_handle_showmem(int key)
 {
  show_mem(0);
+ dump_user_task();
 }
 static struct sysrq_key_op sysrq_showmem_op = {
  .handler = sysrq_handle_showmem,
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fb504ad..b7b1450 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1620,7 +1620,7 @@ extern atomic_long_t mce_bad_pages;
 extern int soft_offline_page(struct page *page, int flags);
 
 extern void dump_page(struct page *page);
-
+extern void dump_user_task(void);
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS)
 extern void clear_huge_page(struct page *page,
        unsigned long addr,
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 597ecac..99ddd08 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -780,3 +780,9 @@ void pagefault_out_of_memory(void)
  if (!test_thread_flag(TIF_MEMDIE))
   schedule_timeout_uninterruptible(1);
 }
+
+void dump_user_task(void)
+{
+ dump_tasks(NULL, NULL);
+}
+EXPORT_SYMBOL(dump_user_task);
--
1.7.5.4

 

 

你可能感兴趣的:(linux 内存分析(二))