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)
#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);
chosen = p;
maxpoints = points;
}
+ if (p->flags & PF_SWAPOFF)
+ return p;
}
while_each_thread(g, p);
return chosen;
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();