I feel a little ashamed of adding another PF_flag for this, and it
may be done in other ways; but I've found none compellingly elegant.
And it would be enough for sys_swapoff to return failure rather than
be killed (along with any other tasks sharing its mm); but the OOMkill
mechanism gets the job done, I don't think we need complicate it.
--- swapoff2/include/linux/sched.h Mon Apr 14 13:05:34 2003
+++ swapoff3/include/linux/sched.h Thu Apr 17 18:33:00 2003
@@ -477,6 +477,7 @@
#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);
--- swapoff2/mm/oom_kill.c Tue Mar 25 08:06:56 2003
+++ swapoff3/mm/oom_kill.c Thu Apr 17 18:33:00 2003
@@ -129,6 +129,8 @@
chosen = p;
maxpoints = points;
}
+ if (p->flags & PF_SWAPOFF)
+ return p;
}
while_each_thread(g, p);
return chosen;
--- swapoff2/mm/swapfile.c Thu Apr 17 18:32:50 2003
+++ swapoff3/mm/swapfile.c Thu Apr 17 18:33:00 2003
@@ -1060,7 +1060,9 @@
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();
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/