From: Christoph Lameter 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 Signed-off-by: Andrew Morton --- include/linux/sched.h | 1 + mm/pdflush.c | 2 +- mm/vmscan.c | 6 ++---- 3 files changed, 4 insertions(+), 5 deletions(-) diff -puN include/linux/sched.h~swap-migration-v5-pf_swapwrite-to-allow-writing-to-swap include/linux/sched.h --- devel/include/linux/sched.h~swap-migration-v5-pf_swapwrite-to-allow-writing-to-swap 2005-11-14 21:35:27.000000000 -0800 +++ devel-akpm/include/linux/sched.h 2005-11-14 21:35:27.000000000 -0800 @@ -909,6 +909,7 @@ do { if (atomic_dec_and_test(&(tsk)->usa #define PF_BORROWED_MM 0x00400000 /* I am a kthread doing use_mm */ #define PF_RANDOMIZE 0x00800000 /* randomize virtual address space */ #define PF_HOTPLUG_CPU 0x01000000 /* Currently performing CPU hotplug */ +#define PF_SWAPWRITE 0x02000000 /* Allowed to write to swap */ /* * Only the _current_ task can read/write to tsk->flags, but other diff -puN mm/pdflush.c~swap-migration-v5-pf_swapwrite-to-allow-writing-to-swap mm/pdflush.c --- devel/mm/pdflush.c~swap-migration-v5-pf_swapwrite-to-allow-writing-to-swap 2005-11-14 21:35:27.000000000 -0800 +++ devel-akpm/mm/pdflush.c 2005-11-14 21:35:27.000000000 -0800 @@ -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); diff -puN mm/vmscan.c~swap-migration-v5-pf_swapwrite-to-allow-writing-to-swap mm/vmscan.c --- devel/mm/vmscan.c~swap-migration-v5-pf_swapwrite-to-allow-writing-to-swap 2005-11-14 21:35:27.000000000 -0800 +++ devel-akpm/mm/vmscan.c 2005-11-14 21:35:27.000000000 -0800 @@ -263,9 +263,7 @@ static inline int is_page_cache_freeable 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; @@ -1284,7 +1282,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 ( ; ; ) { _