From: Alex Williamson <alex.williamson@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: kvm@vger.kernel.org, David Gibson <david@gibson.dropbear.id.au>,
Eric Auger <eric.auger@redhat.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [RFC PATCH kernel] vfio-pci: Allow write combining
Date: Tue, 10 Oct 2017 20:42:56 -0600 [thread overview]
Message-ID: <20171010204256.309715ce@t450s.home> (raw)
In-Reply-To: <ba3257c6-b15c-b5ce-9015-53e5e2be65d6@ozlabs.ru>
On Wed, 11 Oct 2017 13:05:00 +1100
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> On 11/10/17 08:55, Alex Williamson wrote:
> > On Mon, 9 Oct 2017 13:50:00 +1100
> > Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> >
> >> At the moment the protection in VFIO MMIO mappings is forced to
> >> _PAGE_NON_IDEMPOTENT which means that write combining is not really
> >> available to the userspace even for prefetchable 64bit MMIO BARs.
> >>
> >> This replaces pgprot_noncached() with a platform specific
> >> phys_mem_access_prot() when available and depending on the platform
> >> the vm_page_prot may be set to _PAGE_TOLERANT allowing to exploit
> >> the write combining feature.
> >>
> >> The guest drivers still have to use _wc versions of
> >> the ioremap/pci_ioremap API to get write combininig working.
> >>
> >> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> >> ---
> >>
> >> This should allow DPDK and radix guests (x86, POWERPC, etc) to
> >> do write combining.
> >>
> >> POWERPC hash guests should not be affected by this change, it should
> >> work even without this.
> >> ---
> >> drivers/vfio/pci/vfio_pci.c | 7 ++++++-
> >> 1 file changed, 6 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> >> index f041b1a6cf66..014192b42724 100644
> >> --- a/drivers/vfio/pci/vfio_pci.c
> >> +++ b/drivers/vfio/pci/vfio_pci.c
> >> @@ -1156,8 +1156,13 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
> >> }
> >>
> >> vma->vm_private_data = vdev;
> >> - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> >> vma->vm_pgoff = (pci_resource_start(pdev, index) >> PAGE_SHIFT) + pgoff;
> >> +#ifdef __HAVE_PHYS_MEM_ACCESS_PROT
> >> + vma->vm_page_prot = phys_mem_access_prot(NULL, vma->vm_pgoff,
> >> + req_len, vma->vm_page_prot);
> >> +#else
> >> + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> >> +#endif
> >>
> >> return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
> >> req_len, vma->vm_page_prot);
> >
> > Are you testing __HAVE_PHYS_MEM_ACCESS_PROT because the version of
> > phys_mem_access_prot() defined in drivers/char/mem.c can dereference
> > @file and we're hoping that platforms we care about won't both define
> > __HAVE_PHYS_MEM_ACCESS_PROT and look at @file?
>
> No.
>
> That version in mem.c is static and not exported at all and I do not
> understand why it got this name. Every other instance of
> phys_mem_access_prot is accompanied by
>
> #define __HAVE_PHYS_MEM_ACCESS_PROT
I did miss that mem.c was static there, but I think the point is still
valid, file being NULL doesn't seem to be a universally expected option.
> But 3 instances (ia64, x86, mips) are not exported (arm, arm64, ppc are)
> and v2 of this will come with 3 more single line patches, if we decide to
> proceed.
>
> The only version which actually looks at @file is in
> arch/mips/loongson64/common/mem.c and I do not know what to do about it
> (can it do VFIO at all?), I could pass a file there but no actual code
> would use it anyway.
The question is not whether this particular platform could use vfio,
but instead is whether vfio is using the function correctly. That, I
really don't know.
But also...
arch/arm64/mm/mmu.c:
pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
unsigned long size, pgprot_t vma_prot)
{
if (!pfn_valid(pfn))
return pgprot_noncached(vma_prot);
else if (file->f_flags & O_SYNC)
return pgprot_writecombine(vma_prot);
return vma_prot;
}
Why do we get to ignore dereferencing file on an arch that we
definitely care about? Thanks,
Alex
next prev parent reply other threads:[~2017-10-11 2:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-09 2:50 [RFC PATCH kernel] vfio-pci: Allow write combining Alexey Kardashevskiy
2017-10-10 21:55 ` Alex Williamson
2017-10-11 2:05 ` Alexey Kardashevskiy
2017-10-11 2:42 ` Alex Williamson [this message]
2017-10-11 2:56 ` Alexey Kardashevskiy
2017-10-11 15:35 ` Benjamin Herrenschmidt
2017-10-16 5:54 ` Alexey Kardashevskiy
2017-10-16 6:00 ` David Gibson
2017-10-16 7:36 ` Alexey Kardashevskiy
2017-10-16 8:01 ` David Gibson
2017-11-06 5:44 ` Alexey Kardashevskiy
2017-11-14 2:23 ` David Gibson
2017-11-14 2:29 ` Benjamin Herrenschmidt
2017-11-14 16:28 ` Alex Williamson
2017-11-24 4:58 ` Alexey Kardashevskiy
2017-11-29 18:47 ` Alex Williamson
2017-11-30 4:20 ` David Gibson
2017-11-30 20:06 ` Benjamin Herrenschmidt
2017-10-16 8:38 ` Benjamin Herrenschmidt
2017-10-16 11:11 ` Alexey Kardashevskiy
2017-10-18 7:33 ` Benjamin Herrenschmidt
2017-10-18 9:00 ` Alexey Kardashevskiy
2017-10-18 14:21 ` Benjamin Herrenschmidt
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=20171010204256.309715ce@t450s.home \
--to=alex.williamson@redhat.com \
--cc=aik@ozlabs.ru \
--cc=benh@kernel.crashing.org \
--cc=david@gibson.dropbear.id.au \
--cc=eric.auger@redhat.com \
--cc=kvm@vger.kernel.org \
/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