[PATCH] Swap Migration V5: PF_SWAPWRITE to allow writing to swap
authorChristoph Lameter <clameter@sgi.com>
Sun, 8 Jan 2006 09:00:47 +0000 (01:00 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 9 Jan 2006 04:12:41 +0000 (20:12 -0800)
Add PF_SWAPWRITE to control a processes permission to write to swap.

- Use PF_SWAPWRITE in may_write_to_queue() instead of checking for kswapd
  and pdflush

- Set PF_SWAPWRITE flag for kswapd and pdflush

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/sched.h
mm/pdflush.c
mm/vmscan.c

index 7da33619d5d02c78a8f86be4c2e26ca55f3801c2..a74662077d607233d72ce15be70e971e89753412 100644 (file)
@@ -895,6 +895,7 @@ do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0)
 #define PF_SYNCWRITE   0x00200000      /* I am doing a sync write */
 #define PF_BORROWED_MM 0x00400000      /* I am a kthread doing use_mm */
 #define PF_RANDOMIZE   0x00800000      /* randomize virtual address space */
+#define PF_SWAPWRITE   0x01000000      /* Allowed to write to swap */
 
 /*
  * Only the _current_ task can read/write to tsk->flags, but other
index 52822c98c489c36bc30e24871eef936766b5c784..c4b6d0afd73605cdc446a1cd9fc75aca8afb3693 100644 (file)
@@ -90,7 +90,7 @@ struct pdflush_work {
 
 static int __pdflush(struct pdflush_work *my_work)
 {
-       current->flags |= PF_FLUSHER;
+       current->flags |= PF_FLUSHER | PF_SWAPWRITE;
        my_work->fn = NULL;
        my_work->who = current;
        INIT_LIST_HEAD(&my_work->list);
index 261a56ee11b690b8e182fbbe84a0b42c097c446f..6c30a8c59795ca024556d1ed30a13238e8aaeddb 100644 (file)
@@ -268,9 +268,7 @@ static inline int is_page_cache_freeable(struct page *page)
 
 static int may_write_to_queue(struct backing_dev_info *bdi)
 {
-       if (current_is_kswapd())
-               return 1;
-       if (current_is_pdflush())       /* This is unlikely, but why not... */
+       if (current->flags & PF_SWAPWRITE)
                return 1;
        if (!bdi_write_congested(bdi))
                return 1;
@@ -1299,7 +1297,7 @@ static int kswapd(void *p)
         * us from recursively trying to free more memory as we're
         * trying to free the first piece of memory in the first place).
         */
-       tsk->flags |= PF_MEMALLOC|PF_KSWAPD;
+       tsk->flags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD;
 
        order = 0;
        for ( ; ; ) {