Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 35603
b: refs/heads/master
c: 50ec3bb
h: refs/heads/master
i:
  35601: 7fc74d2
  35599: 323bfcc
v: v3
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed Sep 26, 2006
1 parent 74ebd7c commit 5b128f2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7887a3da753e1ba8244556cc9a2b38c815bfe256
refs/heads/master: 50ec3bbffbe8a96347c54832d48110a5bc9e9ff8
35 changes: 31 additions & 4 deletions trunk/mm/oom_kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,26 @@ static struct task_struct *select_bad_process(unsigned long *ppoints)
/*
* This is in the process of releasing memory so wait for it
* to finish before killing some other task by mistake.
*
* However, if p is the current task, we allow the 'kill' to
* go ahead if it is exiting: this will simply set TIF_MEMDIE,
* which will allow it to gain access to memory reserves in
* the process of exiting and releasing its resources.
* Otherwise we could get an OOM deadlock.
*/
releasing = test_tsk_thread_flag(p, TIF_MEMDIE) ||
p->flags & PF_EXITING;
if (releasing && !(p->flags & PF_DEAD))
if (releasing) {
/* PF_DEAD tasks have already released their mm */
if (p->flags & PF_DEAD)
continue;
if (p->flags & PF_EXITING && p == current) {
chosen = p;
*ppoints = ULONG_MAX;
break;
}
return ERR_PTR(-1UL);
}
if (p->flags & PF_SWAPOFF)
return p;

Expand Down Expand Up @@ -248,8 +263,11 @@ static void __oom_kill_task(struct task_struct *p, const char *message)
return;
}
task_unlock(p);
printk(KERN_ERR "%s: Killed process %d (%s).\n",

if (message) {
printk(KERN_ERR "%s: Killed process %d (%s).\n",
message, p->pid, p->comm);
}

/*
* We give our sacrificial lamb high priority and access to
Expand Down Expand Up @@ -300,8 +318,17 @@ static int oom_kill_process(struct task_struct *p, unsigned long points,
struct task_struct *c;
struct list_head *tsk;

printk(KERN_ERR "Out of Memory: Kill process %d (%s) score %li and "
"children.\n", p->pid, p->comm, points);
/*
* If the task is already exiting, don't alarm the sysadmin or kill
* its children or threads, just set TIF_MEMDIE so it can die quickly
*/
if (p->flags & PF_EXITING) {
__oom_kill_task(p, NULL);
return 0;
}

printk(KERN_ERR "Out of Memory: Kill process %d (%s) score %li"
" and children.\n", p->pid, p->comm, points);
/* Try to kill a child first */
list_for_each(tsk, &p->children) {
c = list_entry(tsk, struct task_struct, sibling);
Expand Down

0 comments on commit 5b128f2

Please sign in to comment.