Skip to content

Commit bc448e8

Browse files
Michal Hockotorvalds
authored andcommitted
mm, oom_reaper: report success/failure
Inform about the successful/failed oom_reaper attempts and dump all the held locks to tell us more who is blocking the progress. [akpm@linux-foundation.org: fix CONFIG_MMU=n build] Signed-off-by: Michal Hocko <mhocko@suse.com> Cc: Andrea Argangeli <andrea@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Mel Gorman <mgorman@suse.de> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Rik van Riel <riel@redhat.com> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 36324a9 commit bc448e8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

mm/oom_kill.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ static DECLARE_WAIT_QUEUE_HEAD(oom_victims_wait);
410410

411411
bool oom_killer_disabled __read_mostly;
412412

413+
#define K(x) ((x) << (PAGE_SHIFT-10))
414+
413415
#ifdef CONFIG_MMU
414416
/*
415417
* OOM Reaper kernel thread which tries to reap the memory used by the OOM
@@ -479,6 +481,11 @@ static bool __oom_reap_task(struct task_struct *tsk)
479481
&details);
480482
}
481483
tlb_finish_mmu(&tlb, 0, -1);
484+
pr_info("oom_reaper: reaped process %d (%s), now anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
485+
task_pid_nr(tsk), tsk->comm,
486+
K(get_mm_counter(mm, MM_ANONPAGES)),
487+
K(get_mm_counter(mm, MM_FILEPAGES)),
488+
K(get_mm_counter(mm, MM_SHMEMPAGES)));
482489
up_read(&mm->mmap_sem);
483490

484491
/*
@@ -495,14 +502,21 @@ static bool __oom_reap_task(struct task_struct *tsk)
495502
return ret;
496503
}
497504

505+
#define MAX_OOM_REAP_RETRIES 10
498506
static void oom_reap_task(struct task_struct *tsk)
499507
{
500508
int attempts = 0;
501509

502510
/* Retry the down_read_trylock(mmap_sem) a few times */
503-
while (attempts++ < 10 && !__oom_reap_task(tsk))
511+
while (attempts++ < MAX_OOM_REAP_RETRIES && !__oom_reap_task(tsk))
504512
schedule_timeout_idle(HZ/10);
505513

514+
if (attempts > MAX_OOM_REAP_RETRIES) {
515+
pr_info("oom_reaper: unable to reap pid:%d (%s)\n",
516+
task_pid_nr(tsk), tsk->comm);
517+
debug_show_all_locks();
518+
}
519+
506520
/* Drop a reference taken by wake_oom_reaper */
507521
put_task_struct(tsk);
508522
}
@@ -649,7 +663,6 @@ static bool process_shares_mm(struct task_struct *p, struct mm_struct *mm)
649663
return false;
650664
}
651665

652-
#define K(x) ((x) << (PAGE_SHIFT-10))
653666
/*
654667
* Must be called while holding a reference to p, which will be released upon
655668
* returning.

0 commit comments

Comments
 (0)