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 Signed-off-by: Dave Hansen --- 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-07-28 13:50:48.000000000 -0700 +++ memhotplug-dave/mm/thrash.c 2005-07-28 13:50:48.000000000 -0700 @@ -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; _