Skip to content

Commit f3af38d

Browse files
Nick PigginLinus Torvalds
authored andcommitted
[PATCH] oom: cleanup messages
Clean up the OOM killer messages to be more consistent. Signed-off-by: Nick Piggin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c33e0fc commit f3af38d

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

mm/oom_kill.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static struct task_struct *select_bad_process(unsigned long *ppoints)
264264
* flag though it's unlikely that we select a process with CAP_SYS_RAW_IO
265265
* set.
266266
*/
267-
static void __oom_kill_task(struct task_struct *p, const char *message)
267+
static void __oom_kill_task(struct task_struct *p, int verbose)
268268
{
269269
if (is_init(p)) {
270270
WARN_ON(1);
@@ -278,10 +278,8 @@ static void __oom_kill_task(struct task_struct *p, const char *message)
278278
return;
279279
}
280280

281-
if (message) {
282-
printk(KERN_ERR "%s: Killed process %d (%s).\n",
283-
message, p->pid, p->comm);
284-
}
281+
if (verbose)
282+
printk(KERN_ERR "Killed process %d (%s)\n", p->pid, p->comm);
285283

286284
/*
287285
* We give our sacrificial lamb high priority and access to
@@ -294,7 +292,7 @@ static void __oom_kill_task(struct task_struct *p, const char *message)
294292
force_sig(SIGKILL, p);
295293
}
296294

297-
static int oom_kill_task(struct task_struct *p, const char *message)
295+
static int oom_kill_task(struct task_struct *p)
298296
{
299297
struct mm_struct *mm;
300298
struct task_struct *g, *q;
@@ -321,15 +319,15 @@ static int oom_kill_task(struct task_struct *p, const char *message)
321319
return 1;
322320
} while_each_thread(g, q);
323321

324-
__oom_kill_task(p, message);
322+
__oom_kill_task(p, 1);
325323

326324
/*
327325
* kill all processes that share the ->mm (i.e. all threads),
328-
* but are in a different thread group
326+
* but are in a different thread group.
329327
*/
330328
do_each_thread(g, q) {
331329
if (q->mm == mm && q->tgid != p->tgid)
332-
__oom_kill_task(q, message);
330+
__oom_kill_task(q, 1);
333331
} while_each_thread(g, q);
334332

335333
return 0;
@@ -346,21 +344,22 @@ static int oom_kill_process(struct task_struct *p, unsigned long points,
346344
* its children or threads, just set TIF_MEMDIE so it can die quickly
347345
*/
348346
if (p->flags & PF_EXITING) {
349-
__oom_kill_task(p, NULL);
347+
__oom_kill_task(p, 0);
350348
return 0;
351349
}
352350

353-
printk(KERN_ERR "Out of Memory: Kill process %d (%s) score %li"
354-
" and children.\n", p->pid, p->comm, points);
351+
printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
352+
message, p->pid, p->comm, points);
353+
355354
/* Try to kill a child first */
356355
list_for_each(tsk, &p->children) {
357356
c = list_entry(tsk, struct task_struct, sibling);
358357
if (c->mm == p->mm)
359358
continue;
360-
if (!oom_kill_task(c, message))
359+
if (!oom_kill_task(c))
361360
return 0;
362361
}
363-
return oom_kill_task(p, message);
362+
return oom_kill_task(p);
364363
}
365364

366365
static BLOCKING_NOTIFIER_HEAD(oom_notify_list);

0 commit comments

Comments
 (0)