summaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-06-01 03:16:17 +0000
committerRalf Baechle <ralf@linux-mips.org>1997-06-01 03:16:17 +0000
commitd8d9b8f76f22b7a16a83e261e64f89ee611f49df (patch)
tree3067bc130b80d52808e6390c9fc7fc087ec1e33c /mm/swapfile.c
parent19c9bba94152148523ba0f7ef7cffe3d45656b11 (diff)
Initial revision
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 91221a415..32a5ed8b0 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -298,24 +298,25 @@ static int unuse_process(struct mm_struct * mm, unsigned int type, unsigned long
*/
static int try_to_unuse(unsigned int type)
{
- int nr;
unsigned long page = get_free_page(GFP_KERNEL);
+ struct task_struct *p;
if (!page)
return -ENOMEM;
- nr = 0;
- while (nr < NR_TASKS) {
- struct task_struct * p = task[nr];
- if (p) {
- if (unuse_process(p->mm, type, page)) {
- page = get_free_page(GFP_KERNEL);
- if (!page)
- return -ENOMEM;
- continue;
- }
+again:
+ read_lock(&tasklist_lock);
+ for_each_task(p) {
+ read_unlock(&tasklist_lock);
+ if(unuse_process(p->mm, type, page)) {
+ page = get_free_page(GFP_KERNEL);
+ if(!page)
+ return -ENOMEM;
+ goto again;
}
- nr++;
+ read_lock(&tasklist_lock);
}
+ read_unlock(&tasklist_lock);
+
free_page(page);
return 0;
}