All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: peterx@redhat.com, wexu@redhat.com, qemu-devel@nongnu.org,
	vkaplans@redhat.com, pbonzini@redhat.com,
	cornelia.huck@de.ibm.com
Subject: Re: [Qemu-devel] [PATCH V2 07/11] virtio-pci: address space translation service (ATS) support
Date: Fri, 11 Nov 2016 11:26:12 +0800	[thread overview]
Message-ID: <da48d393-11fc-9231-7ad7-4228a725c5ec@redhat.com> (raw)
In-Reply-To: <20161110192959-mutt-send-email-mst@kernel.org>



On 2016年11月11日 01:32, Michael S. Tsirkin wrote:
> On Fri, Nov 04, 2016 at 02:48:20PM +0800, Jason Wang wrote:
>>
>> On 2016年11月04日 03:49, Michael S. Tsirkin wrote:
>>> On Thu, Nov 03, 2016 at 05:27:19PM +0800, Jason Wang wrote:
>>>>> This patches enable the Address Translation Service support for virtio
>>>>> pci devices. This is needed for a guest visible Device IOTLB
>>>>> implementation and will be required by vhost device IOTLB API
>>>>> implementation for intel IOMMU.
>>>>>
>>>>> Cc: Michael S. Tsirkin<mst@redhat.com>
>>>>> Signed-off-by: Jason Wang<jasowang@redhat.com>
>>> I'd like to understand why do you think this is strictly required.
>>> Won't setting CM bit in the IOMMU do the trick.
>> ATS was chosen for performance. Since there're many problems for CM:
>>
>> - CM was slow (10%-20% slower on real hardware for things like netperf)
>> because of each transition between non-present and present mapping needs an
>> explicit invalidation. It may slow down the whole VM.
>> - Without ATS/Device IOTLB, IOMMU becomes a bottleneck because of contending
>> of IOTLB entries. (What we can do in this case is in fact userspace IOTLB
>> snooping, this could be done even without CM).
>> It was natural to think of ATS when designing interface between IOMMU and
>> device/remote IOTLBs. Do you see any drawbacks on ATS here?
>>
>> Thanks
> In fact at this point I'm confused. Any mapping needs to be programmed
> in the IOMMU. We need to implement this correctly.
> Once we do why do we need ATS?
> I think what you need is map/unmap notifiers that Aviv is working on.
> No?

Let me clarify, device IOTLB API can work without ATS or CM. So there're 
three ways to do:

1) without ATS or CM support, the function could be implemented through:
1.1: asking for qemu help if there's an IOTLB miss in vhost
1.2: snooping the userspace IOTLB invalidation (present to non-present 
mapping) and update device IOTLB

2) with CM enabled, the only thing we can add is snooping the 
non-present to present mapping and update the device IOTLB. This is not 
a requirement since we still can get this through asking qemu's(1.2) help.

3) with ATS enabled, guest knows the existence of device IOTLB, and 
device IOTLB entires needs to be flushed explicitly by guest. In this 
case there's no need to snoop the ordinary IOTLB invalidation in 1.2. We 
just need to snoop the device IOTLB specific invalidation request from 
guest.

All the above 3 methods work very well, but let's have a look at 
performance impact:

- Method 1 (without CM or ATS), the performance is not the best since 
guest does not know about the existence of remote IOTLB, this means the 
flush of device IOTLB entry could not be done on demand. One example is 
some IOMMU driver (e.g intel) tends to optimize the IOTLB invalidations 
by issuing a global invalidation periodically. We need to flush the 
device IOTLB too in this case. Thus we can notice some jitter (because 
of IOTLB miss).

- Method 2 (with CM but without ATS) seems to be the worst case. It has 
not only all problems above a but also a new one: each transition needs 
to notify the device explicitly. Even if dpdk use static mappings, all 
other devices in the VM use dynamic ones which slows down the whole the 
system. According to the test, CM is about 10%-20% slower in real hardware.

- Method 3 (ATS) can give the best performance, all the problems have 
gone since guest can flush the device IOTLB entry on demand. It was 
defined by spec and was designed to solve the issues just like what we 
meet here, and was supported by modern IOMMUs.

And what's even better, implementing ATS turns out less than 100 lines 
of codes. And it was much more easier to  be enabled on other IOMMU (AMD 
IOMMU only needs 20 lines of codes). All other ways (I started and have 
codes for method 1 for intel IOMMU) need lots of work specific to each 
kind of IOMMU.

Consider so much advantages by just adding so small lines of codes. I 
don't see why we don't need ATS (for the IOOMUs that supports it).

Thanks

>
>
>>> Also, could you remind me pls - can guests just disable ATS?
>>>
>>> What happens then?
>>>
>>>

  reply	other threads:[~2016-11-11  3:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-03  9:27 [Qemu-devel] [PATCH V2 00/11] vhost device IOTLB support Jason Wang
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 01/11] intel_iommu: fixing source id during IOTLB hash key calculation Jason Wang
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 02/11] virtio: convert to use DMA api Jason Wang
2016-11-03 19:46   ` Michael S. Tsirkin
2016-11-04  6:36     ` Jason Wang
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 03/11] intel_iommu: name vtd address space with devfn Jason Wang
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 04/11] intel_iommu: allocate new key when creating new address space Jason Wang
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 05/11] exec: introduce address_space_get_iotlb_entry() Jason Wang
2016-11-03 17:03   ` Paolo Bonzini
2016-11-04  6:33     ` Jason Wang
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 06/11] intel_iommu: support device iotlb descriptor Jason Wang
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 07/11] virtio-pci: address space translation service (ATS) support Jason Wang
2016-11-03 19:49   ` Michael S. Tsirkin
2016-11-04  6:48     ` Jason Wang
2016-11-10 17:32       ` Michael S. Tsirkin
2016-11-11  3:26         ` Jason Wang [this message]
2016-11-11  3:49           ` Michael S. Tsirkin
2016-11-11  4:24             ` Jason Wang
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 08/11] acpi: add ATSR for q35 Jason Wang
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 09/11] memory: handle alias for iommu notifier Jason Wang
2016-11-03 16:55   ` Paolo Bonzini
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 10/11] memory: handle alias in memory_region_is_iommu() Jason Wang
2016-11-03 16:56   ` Paolo Bonzini
2016-11-03  9:27 ` [Qemu-devel] [PATCH V2 11/11] vhost_net: device IOTLB support Jason Wang
2016-11-03  9:48 ` [Qemu-devel] [PATCH V2 00/11] vhost " no-reply

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=da48d393-11fc-9231-7ad7-4228a725c5ec@redhat.com \
    --to=jasowang@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vkaplans@redhat.com \
    --cc=wexu@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.