From: Izik Eidus <ieidus@redhat.com>
To: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Andrea Arcangeli <aarcange@redhat.com>,
linux-kernel@vger.kernel.org, Rik van Riel <riel@redhat.com>,
nickpiggin@yahoo.com.au
Subject: Re: running get_user_pages() from kernel thread
Date: Tue, 16 Jun 2009 22:20:56 +0300 [thread overview]
Message-ID: <4A37F098.2060208@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0906161930050.24878@sister.anvils>
Hugh Dickins wrote:
> On Tue, 16 Jun 2009, Andrea Arcangeli wrote:
>
>> On Tue, Jun 16, 2009 at 09:05:27PM +0300, Izik Eidus wrote:
>>
>>> So the question is: is this thing is by desgin? (that kernel thread cant
>>> call get_user_pages???), should i use something like switch_mm()??
>>>
>> I think switch_mm trick should be used for page faults, but gup
>> shouldn't require it because it gets the 'mm' as parameter and the
>> current->mm has to be irrelevant. current->mm is only relevant for
>> gup-fast (obviously :). So I think the only bit that needs fixing is
>> grab_swap_token to not run if current->mm is null.
>>
>
> Looks like Izik and I hit the same problem (otherwise running well):
> I too decided we needn't do more than avoid the issue in grab_swap_token.
> (I've a feeling someone has hit this issue before with some other thread,
> though I've no idea which - does RHEL include a patch like this perhaps?).
>
> [PATCH] mm: grab_swap_token back out if no mm
>
> If a kthread happens to use get_user_pages() on an mm (as KSM does),
> there's a chance that it will end up trying to read in a swap page,
> and oops in grab_swap_token() because the kthread has no mm:
> nothing clever, just avoid that case.
>
> Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
> ---
>
> mm/thrash.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> --- 2.6.30-mm1/mm/thrash.c 2007-07-09 00:32:17.000000000 +0100
> +++ linux/mm/thrash.c 2009-06-15 19:44:53.000000000 +0100
> @@ -30,6 +30,9 @@ void grab_swap_token(void)
> {
> int current_interval;
>
> + if (!current->mm) /* kthread doing get_user_pages on an mm */
> + return;
> +
> global_faults++;
>
> current_interval = global_faults - current->mm->faultstamp;
>
Good, This solve another issue that you probably dont hit beacuse you
work with the madvise version:
the .release call back of the file_operations strcture will call to:
ksm_sma_release() that will call to remove_slot_from_hash_and_tree()
that will do the silly break_cow() call (even that the prcoesses just
die!!!)
Now beacuse that exit_mm() will set tsk->mm = NULL before the .release
will get called, we will trigger this path even without the kernel
thread context.
(I prepred patch that just avoid the break_cow() from the .release
context, but it isnt needed with this patch)
(You shouldnt have that specific problem in the madvise() version
beacuse we dont have this .release callback anymore, but we still do
there useless break_cow() calls, considering the fact that the process
just die, this break_cow() calls should be made only when the user ask
specifically to stop merging pages i guess...,
I will send patch that will make it work more logical on top of your
patches as soon as you send something)
Thanks.
next prev parent reply other threads:[~2009-06-16 19:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-16 18:05 running get_user_pages() from kernel thread Izik Eidus
2009-06-16 18:13 ` Andrea Arcangeli
2009-06-16 18:38 ` Hugh Dickins
2009-06-16 18:55 ` Rik van Riel
2009-06-16 19:45 ` Hugh Dickins
2009-06-16 20:38 ` Andrea Arcangeli
2009-06-16 21:02 ` Hugh Dickins
2009-06-16 21:19 ` Rik van Riel
2009-06-16 19:20 ` Izik Eidus [this message]
2009-06-16 20:45 ` Hugh Dickins
2009-06-16 21:25 ` Izik Eidus
2009-06-16 20:08 ` Johannes Weiner
2009-06-16 20:57 ` Hugh Dickins
2009-06-16 21:50 ` [patch 1/2] mm: make swap token dummies static inlines Johannes Weiner
2009-06-16 21:55 ` Rik van Riel
2009-06-16 21:50 ` [patch 2/2] mm: remove task assumptions from swap token Johannes Weiner
2009-06-16 21:56 ` Rik van Riel
2009-06-17 2:00 ` Minchan Kim
2009-06-17 8:31 ` Johannes Weiner
2009-06-16 21:52 ` running get_user_pages() from kernel thread Johannes Weiner
2009-06-21 13:02 ` [PATCH] mm: pass mm to grab_swap_token Hugh Dickins
2009-06-22 0:32 ` Minchan Kim
2009-06-16 21:16 ` running get_user_pages() from kernel thread Rik van Riel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A37F098.2060208@redhat.com \
--to=ieidus@redhat.com \
--cc=aarcange@redhat.com \
--cc=hugh.dickins@tiscali.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
--cc=riel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox