linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Arcangeli <aarcange@redhat.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	Avi Kivity <avi.kivity@gmail.com>, Gleb Natapov <gleb@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Dominik Dingel <dingel@linux.vnet.ibm.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] KVM: async_pf: kill the unnecessary use_mm/unuse_mm async_pf_execute()
Date: Mon, 28 Apr 2014 16:06:02 +0200	[thread overview]
Message-ID: <20140428140602.GC10488@redhat.com> (raw)
In-Reply-To: <20140423193228.GA3441@redhat.com>

Hi,

On Wed, Apr 23, 2014 at 09:32:28PM +0200, Oleg Nesterov wrote:
> On 04/22, Christian Borntraeger wrote:
> >
> > On 22/04/14 22:15, Christian Borntraeger wrote:
> > > On 21/04/14 15:25, Oleg Nesterov wrote:
> > >> async_pf_execute() has no reasons to adopt apf->mm, gup(current, mm)
> > >> should work just fine even if current has another or NULL ->mm.
> > >>
> > >> Recently kvm_async_page_present_sync() was added insedie the "use_mm"
> > >> section, but it seems that it doesn't need current->mm too.
> > >>
> > >> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> > >
> > > Indeed, use/unuse_mm should only be necessary for copy_to/from_user etc.
> > > This is fine for s390, but it seems that x86 kvm_arch_async_page_not_present
> > > might call apf_put_user which might call copy_to_user, so this is not ok, I guess.
> >
> > wanted to say kvm_arch_async_page_not_present, but I have to correct myself.
> > x86 does the "page is there" in the cpu loop, not in the worker. The cpu look
> > d oes have a valid mm. So this patch should be also ok.
> 
> Thanks ;)
> 
> Btw, I forgot to mention this in the changelog, but
> 
> > >> @@ -80,12 +80,10 @@ static void async_pf_execute(struct work_struct *work)
> > >>
> > >>  	might_sleep();
> > >>
> > >> -	use_mm(mm);
> > >>  	down_read(&mm->mmap_sem);
> > >>  	get_user_pages(current, mm, addr, 1, 1, 0, NULL, NULL);
> > >>  	up_read(&mm->mmap_sem);
> > >>  	kvm_async_page_present_sync(vcpu, apf);
> > >> -	unuse_mm(mm);
> 
> it can actually do
> 
> 	get_user_pages(NULL, mm, addr, 1, 1, 0, NULL, NULL);
> 
> "task" is only used to increment task_struct->xxx_flt. I don't think
> async_pf_execute() actually needs this (current is PF_WQ_WORKER after
> all), but I didn't dare to do another change in the code I can hardly
> understand.

Considering the faults would be randomly distributed among the kworker
threads my preference would also be for NULL instead of current.

ptrace and uprobes tends to be the only two places that look into
other mm with gup, ptrace knows the exact pid that it is triggering
the fault into, so it also can specify the correct task so the fault
goes in the right task struct. uprobes uses NULL.

  reply	other threads:[~2014-04-28 14:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-21 13:25 [PATCH 0/2] KVM: async_pf: use_mm/mm_users fixes Oleg Nesterov
2014-04-21 13:25 ` [PATCH 1/2] KVM: async_pf: kill the unnecessary use_mm/unuse_mm async_pf_execute() Oleg Nesterov
2014-04-22 20:15   ` Christian Borntraeger
2014-04-22 21:07     ` Christian Borntraeger
2014-04-23 19:32       ` Oleg Nesterov
2014-04-28 14:06         ` Andrea Arcangeli [this message]
2014-04-28 15:31           ` Paolo Bonzini
2014-04-21 13:26 ` [PATCH 2/2] KVM: async_pf: mm->mm_users can not pin apf->mm Oleg Nesterov
2014-04-22 20:24   ` Christian Borntraeger
2014-04-24 14:27 ` [PATCH 0/2] KVM: async_pf: use_mm/mm_users fixes Christian Borntraeger
2014-04-24 14:55   ` Oleg Nesterov
2014-04-28 11:06 ` Paolo Bonzini
2014-04-28 14:15   ` Andrea Arcangeli
2014-04-28 15:02     ` [PATCH 3/2] KVM: async_pf: change async_pf_execute() to use get_user_pages(tsk => NULL) Oleg Nesterov
2014-04-28 15:03       ` Oleg Nesterov
2014-04-28 15:27         ` Paolo Bonzini

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=20140428140602.GC10488@redhat.com \
    --to=aarcange@redhat.com \
    --cc=avi.kivity@gmail.com \
    --cc=borntraeger@de.ibm.com \
    --cc=dingel@linux.vnet.ibm.com \
    --cc=gleb@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=pbonzini@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;
as well as URLs for NNTP newsgroup(s).