Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1216675

Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses

From "Michael S. Tsirkin" <mst@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses
Date 2015-09-01 10:40 +0200
Message-ID <q3PgJ-1hp-1@gated-at.bofh.it> (permalink)
References (5 earlier) <q3KAq-2Z8-9@gated-at.bofh.it> <q3Lwt-4lF-1@gated-at.bofh.it> <q3LGa-4x7-11@gated-at.bofh.it> <q3NHY-7p5-1@gated-at.bofh.it> <q3P74-160-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Sep 01, 2015 at 04:22:22PM +0800, Jason Wang wrote:
> 
> 
> On 09/01/2015 02:54 PM, Michael S. Tsirkin wrote:
> > On Tue, Sep 01, 2015 at 12:47:36PM +0800, Jason Wang wrote:
> >>
> >> On 09/01/2015 12:31 PM, Michael S. Tsirkin wrote:
> >>> On Tue, Sep 01, 2015 at 11:33:43AM +0800, Jason Wang wrote:
> >>>> On 08/31/2015 07:33 PM, Michael S. Tsirkin wrote:
> >>>>> On Mon, Aug 31, 2015 at 04:03:59PM +0800, Jason Wang wrote:
> >>>>>>> On 08/31/2015 03:29 PM, Michael S. Tsirkin wrote:
> >>>>>>>>>>>>>>>>> Thinking more about this, invoking the 0-length write after
> >>>>>>>>>>>>>>>>>>>>>>>>> the != 0 length one would be better: it would mean we only
> >>>>>>>>>>>>>>>>>>>>>>>>> handle the userspace MMIO like this.
> >>>>>>>>>>>>>>>>> Right.
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>> Using current unittest. This patch is about 2.9% slower than before, and
> >>>>>>>>>>>>> invoking 0-length write after is still 1.1% slower (mmio-datamatch-eventfd).
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> /patch/result/-+%/
> >>>>>>>>>>>>> /base/2957/0/
> >>>>>>>>>>>>> /V3/3043/+2.9%/
> >>>>>>>>>>>>> /V3+invoking != 0 length first/2990/+1.1%/
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> So looks like the best method is not searching KVM_FAST_MMIO_BUS during
> >>>>>>>>>>>>> KVM_MMIO_BUS. Instead, let userspace to register both datamatch and
> >>>>>>>>>>>>> wildcard in this case. Does this sound good to you?
> >>>>>>>>> No - we can't change userspace.
> >>>>>>> Actually, the change was as simple as following. So I don't get the
> >>>>>>> reason why.
> >>>>> Because it's too late - we committed to a specific userspace ABI
> >>>>> when this was merged in kernel, we must maintain it.
> >>>> Ok ( Though I don't think it has real users for this now because it was
> >>>> actually broken).
> >>> It actually worked most of the time - you only trigger a use after free
> >>> on deregister.
> >>>
> >> It doesn't work for amd and intel machine without ept.
> > I thought it does :(
> >
> >>>>> Even if I thought yours is a good API (and I don't BTW - it's exposing
> >>>>> internal implementation details) it's too late to change it.
> >>>> I believe we should document the special treatment in kernel of zero
> >>>> length mmio eventfd in api.txt? If yes, is this an exposing? If not, how
> >>>> can userspace know the advantages of this and use it? For better API,
> >>>> probably we need another new flag just for fast mmio and obsolete
> >>>> current one by failing the assigning for zero length mmio eventfd.
> >>> I sent a patch to update api.txt already as part of
> >>> kvm: add KVM_CAP_IOEVENTFD_PF capability.
> >>> I should probably split it out.
> >>>
> >>> Sorry, I don't think the api change you propose makes sense - just fix the
> >>> crash in the existing one.
> >>>
> >> Ok, so I believe the fix should go:
> >>
> >> - having two ioeventfds when we want to assign zero length mmio eventfd
> > You mean the in-kernel data structures?
> 
> Yes.
> 
> >
> >> - change the kvm_io_bus_sort_cmp() and can handle zero length correctly
> > This one's for amd/non ept, right? I'd rather we implemented the
> > fast mmio optimization for these.
> 
> Agree, but we'd better fix it and backport it to stable first?

I would say fix it upstream first. Worry about stable later.  And I
don't see a lot of value in adding a temporary hack - it's not too much
work to just do the optimal thing directly.

But I won't nack a temporary solution if you insist.

-- 
MST
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V3 1/3] kvm: use kmalloc() instead of kzalloc() during iodev register/unregister Jason Wang <jasowang@redhat.com> - 2015-08-25 11:20 +0200
  [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two buses Jason Wang <jasowang@redhat.com> - 2015-08-25 11:20 +0200
    Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses Cornelia Huck <cornelia.huck@de.ibm.com> - 2015-08-25 13:00 +0200
    Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses "Michael S. Tsirkin" <mst@redhat.com> - 2015-08-25 13:40 +0200
    Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses "Michael S. Tsirkin" <mst@redhat.com> - 2015-08-25 14:00 +0200
      Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses Jason Wang <jasowang@redhat.com> - 2015-08-26 07:20 +0200
        Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses Jason Wang <jasowang@redhat.com> - 2015-08-31 05:20 +0200
          Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses "Michael S. Tsirkin" <mst@redhat.com> - 2015-08-31 09:30 +0200
            Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses Jason Wang <jasowang@redhat.com> - 2015-08-31 10:10 +0200
              Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses "Michael S. Tsirkin" <mst@redhat.com> - 2015-08-31 13:40 +0200
                Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses Jason Wang <jasowang@redhat.com> - 2015-09-01 05:40 +0200
                Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses "Michael S. Tsirkin" <mst@redhat.com> - 2015-09-01 06:40 +0200
                Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses Jason Wang <jasowang@redhat.com> - 2015-09-01 06:50 +0200
                Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses "Michael S. Tsirkin" <mst@redhat.com> - 2015-09-01 09:00 +0200
                Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses Jason Wang <jasowang@redhat.com> - 2015-09-01 10:30 +0200
                Re: [PATCH V3 2/3] kvm: don't register wildcard MMIO EVENTFD on two  buses "Michael S. Tsirkin" <mst@redhat.com> - 2015-09-01 10:40 +0200
  [PATCH V3 3/3] kvm: add tracepoint for fast mmio Jason Wang <jasowang@redhat.com> - 2015-08-25 11:20 +0200
    Re: [PATCH V3 3/3] kvm: add tracepoint for fast mmio "Michael S. Tsirkin" <mst@redhat.com> - 2015-08-25 13:40 +0200

csiph-web