linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Bharath Vedartham <linux.bhar@gmail.com>
Cc: Radim Krcmar <rkrcmar@redhat.com>, kvm <kvm@vger.kernel.org>,
	 linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	khalid.aziz@oracle.com
Subject: Re: [Question-kvm] Can hva_to_pfn_fast be executed in interrupt context?
Date: Thu, 15 Aug 2019 20:26:43 +0200	[thread overview]
Message-ID: <CABgObfbQOS28cG_9Ca_2OXbLmDy_hwUkuqPnzJG5=FZ5sEYGfA@mail.gmail.com> (raw)
In-Reply-To: <20190815171834.GA14342@bharath12345-Inspiron-5559>

[-- Attachment #1: Type: text/plain, Size: 2050 bytes --]

Oh, I see. Sorry I didn't understand the question. In the case of KVM,
there's simply no code that runs in interrupt context and needs to use
virtual addresses.

In fact, there's no code that runs in interrupt context at all. The only
code that deals with host interrupts in a virtualization host is in VFIO,
but all it needs to do is signal an eventfd.

Paolo


Il gio 15 ago 2019, 19:18 Bharath Vedartham <linux.bhar@gmail.com> ha
scritto:

> On Tue, Aug 13, 2019 at 10:17:09PM +0200, Paolo Bonzini wrote:
> > On 13/08/19 21:14, Bharath Vedartham wrote:
> > > Hi all,
> > >
> > > I was looking at the function hva_to_pfn_fast(in virt/kvm/kvm_main)
> which is
> > > executed in an atomic context(even in non-atomic context, since
> > > hva_to_pfn_fast is much faster than hva_to_pfn_slow).
> > >
> > > My question is can this be executed in an interrupt context?
> >
> > No, it cannot for the reason you mention below.
> >
> > Paolo
> hmm.. Well I expected the answer to be kvm specific.
> Because I observed a similar use-case for a driver (sgi-gru) where
> we want to retrive the physical address of a virtual address. This was
> done in atomic and non-atomic context similar to hva_to_pfn_fast and
> hva_to_pfn_slow. __get_user_pages_fast(for atomic case)
> would not work as the driver could execute in interrupt context.
>
> The driver manually walked the page tables to handle this issue.
>
> Since kvm is a widely used piece of code, I asked this question to know
> how kvm handled this issue.
>
> Thank you for your time.
>
> Thank you
> Bharath
> > > The motivation for this question is that in an interrupt context, we
> cannot
> > > assume "current" to be the task_struct of the process of interest.
> > > __get_user_pages_fast assume current->mm when walking the process page
> > > tables.
> > >
> > > So if this function hva_to_pfn_fast can be executed in an
> > > interrupt context, it would not be safe to retrive the pfn with
> > > __get_user_pages_fast.
> > >
> > > Thoughts on this?
> > >
> > > Thank you
> > > Bharath
> > >
> >
>

[-- Attachment #2: Type: text/html, Size: 2745 bytes --]

  reply	other threads:[~2019-08-15 18:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13 19:14 [Question-kvm] Can hva_to_pfn_fast be executed in interrupt context? Bharath Vedartham
2019-08-13 20:17 ` Paolo Bonzini
2019-08-15 17:18   ` Bharath Vedartham
2019-08-15 18:26     ` Paolo Bonzini [this message]
2019-08-20 16:08       ` Bharath Vedartham

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='CABgObfbQOS28cG_9Ca_2OXbLmDy_hwUkuqPnzJG5=FZ5sEYGfA@mail.gmail.com' \
    --to=pbonzini@redhat.com \
    --cc=khalid.aziz@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux.bhar@gmail.com \
    --cc=rkrcmar@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).