mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@amd.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bjorn Helgaas <bhelgaas@google.com>,
	David Woodhouse <dwmw@amazon.co.uk>,
	Kai-Heng Feng <kai.heng.feng@canonical.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	Santosh Shukla <santosh.shukla@amd.com>,
	"Nikunj A. Dadhania" <nikunj@amd.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [RFC PATCH] PCI: Add quirk to always map ivshmem as write-back
Date: Fri, 18 Jul 2025 11:58:22 +1000	[thread overview]
Message-ID: <d004a5c9-fbd9-4298-89ab-292524ae3ad6@amd.com> (raw)
In-Reply-To: <opdpelyb26bzp723lyxljjb2dmxgunkcjlvpkxgbrxaxhoycv6@eigu7etse3g7>



On 26/6/25 02:28, Manivannan Sadhasivam wrote:
> On Tue, Jun 24, 2025 at 11:42:47AM +1000, Alexey Kardashevskiy wrote:
>> Ping? Thanks,
>>
>>
>> On 12/6/25 18:27, Alexey Kardashevskiy wrote:
>>> Wrong email for Nikunj :) And I missed the KVM ml. Sorry for the noise.
>>>
>>>
>>> On 12/6/25 18:22, Alexey Kardashevskiy wrote:
>>>> QEMU Inter-VM Shared Memory (ivshmem) is designed to share a memory
>>>> region between guest and host. The host creates a file, passes it to QEMU
>>>> which it presents to the guest via PCI BAR#2. The guest userspace
>>>> can map /sys/bus/pci/devices/0000:01:02.3/resource2(_wc) to use the region
>>>> without having the guest driver for the device at all.
>>>>
>>>> The problem with this, since it is a PCI resource, the PCI sysfs
>>>> reasonably enforces:
>>>> - no caching when mapped via "resourceN" (PTE::PCD on x86) or
>>>> - write-through when mapped via "resourceN_wc" (PTE::PWT on x86).
>>>>
>>>> As the result, the host writes are seen by the guest immediately
>>>> (as the region is just a mapped file) but it takes quite some time for
>>>> the host to see non-cached guest writes.
>>>>
>>>> Add a quirk to always map ivshmem's BAR2 as cacheable (==write-back) as
>>>> ivshmem is backed by RAM anyway.
>>>> (Re)use already defined but not used IORESOURCE_CACHEABLE flag.
>>>>
> 
> It just makes me nervous to change the sematics of the sysfs attribute, even if
> the user knows what it is expecting.

On 1) Intel 2) without VFIO, the user already gets this semantic. Which seems... alright?

> Now the "resourceN_wc" essentially becomes
> "resourceN_wb", which goes against the rule of sysfs I'm afraid.

What is this rule?

> 
>>>> This does not affect other ways of mapping a PCI BAR, a driver can use
>>>> memremap() for this functionality.
>>>>
>>>> Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
>>>> ---
>>>>
>>>> What is this IORESOURCE_CACHEABLE for actually?
>>>>
>>>> Anyway, the alternatives are:
>>>>
>>>> 1. add a new node in sysfs - "resourceN_wb" - for mapping as writeback
>>>> but this requires changing existing (and likely old) userspace tools;
>>>>
> 
> I guess this would the cleanest approach. The old tools can continue to suffer
> from the performance issue and the new tools can work more faster.

Well yes but the only possible user of this is going to be ivshmem as every other cache coherent thing has a driver which can pick any sort of caching policy, and nobody will ever want a slow ivshmem because there will be no added benefit. I can send a patch if we get consensus on this though. Thanks,


-- 
Alexey


  reply	other threads:[~2025-07-18  1:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-12  8:22 Alexey Kardashevskiy
2025-06-12  8:27 ` Alexey Kardashevskiy
2025-06-24  1:42   ` Alexey Kardashevskiy
2025-06-25 16:28     ` Manivannan Sadhasivam
2025-07-18  1:58       ` Alexey Kardashevskiy [this message]
2025-09-12 16:49 ` Borislav Petkov
2025-09-15  7:43   ` Alexey Kardashevskiy
2025-09-17 18:38     ` Borislav Petkov

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=d004a5c9-fbd9-4298-89ab-292524ae3ad6@amd.com \
    --to=aik@amd.com \
    --cc=bhelgaas@google.com \
    --cc=dwmw@amazon.co.uk \
    --cc=kai.heng.feng@canonical.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=nikunj@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=santosh.shukla@amd.com \
    --cc=seanjc@google.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

all inboxes | Powered by JetHome®