Commit cca095e0 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] oom-kill: preferentially kill swapoff

From: Hugh Dickins <hugh@veritas.com>

The current behaviour is that once swapoff has filled memory, other tasks get
OOMkilled one by one until swapoff completes, or more likely hangs.  It is
better that swapoff be the first choice for OOMkill.

The patch changes the oom-killer so that it will kill off any
currently-running swapoff instance before killing any other task.

(Bit kludgy, couldn't think of a better way)
parent 6bf11a46
......@@ -465,6 +465,7 @@ do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0)
#define PF_FROZEN 0x00010000 /* frozen for system suspend */
#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */
#define PF_KSWAPD 0x00040000 /* I am kswapd */
#define PF_SWAPOFF 0x00080000 /* I am in swapoff */
#if CONFIG_SMP
extern void set_cpus_allowed(task_t *p, unsigned long new_mask);
......
......@@ -129,6 +129,8 @@ static struct task_struct * select_bad_process(void)
chosen = p;
maxpoints = points;
}
if (p->flags & PF_SWAPOFF)
return p;
}
while_each_thread(g, p);
return chosen;
......
......@@ -1058,7 +1058,9 @@ asmlinkage long sys_swapoff(const char __user * specialfile)
total_swap_pages -= p->pages;
p->flags &= ~SWP_WRITEOK;
swap_list_unlock();
current->flags |= PF_SWAPOFF;
err = try_to_unuse(type);
current->flags &= ~PF_SWAPOFF;
if (err) {
/* re-insert swap space back into swap_list */
swap_list_lock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment