

This patch makes grab_swap_token() do nothing if it is called
from a kernel thread. Because get_user_pages() might be called
from kernel threads though it doesn't have its own space.

A memory migrate kernel thread will call the function.
The thread is going to be introduced to migrate huge memory
regions like zones.


Signed-off-by: Hirokazu Takahashi <taka@valinux.co.jp>
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 memhotplug-dave/mm/thrash.c |    3 +++
 1 files changed, 3 insertions(+)

diff -puN mm/thrash.c~AA-PM-15-swap_token-kthread mm/thrash.c
--- memhotplug/mm/thrash.c~AA-PM-15-swap_token-kthread	2005-03-28 16:38:24.000000000 -0800
+++ memhotplug-dave/mm/thrash.c	2005-03-28 16:38:24.000000000 -0800
@@ -54,6 +54,9 @@ void grab_swap_token(void)
 	struct mm_struct *mm;
 	int reason;
 
+	if (current->mm == NULL)
+		return;
+
 	/* We have the token. Let others know we still need it. */
 	if (has_swap_token(current->mm)) {
 		current->mm->recent_pagein = 1;
_
