From: Jike Song <jike.song@intel.com>
To: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
kwankhede@nvidia.com, cjia@nvidia.com, kevin.tian@intel.com,
kvm@vger.kernel.org
Subject: Re: [v3 4/5] vfio: implement APIs to set/put kvm to/from vfio group
Date: Wed, 09 Nov 2016 11:07:31 +0800 [thread overview]
Message-ID: <582292F3.5000209@intel.com> (raw)
In-Reply-To: <bee1a8f8-24fa-f198-6d9f-29282391c260@linux.intel.com>
On 11/09/2016 10:52 AM, Xiao Guangrong wrote:
>
>
> On 11/09/2016 10:28 AM, Jike Song wrote:
>> On 11/08/2016 02:28 AM, Alex Williamson wrote:
>>> On Mon, 7 Nov 2016 19:10:37 +0100
>>> Paolo Bonzini <pbonzini@redhat.com> wrote:
>>>> On 07/11/2016 19:04, Alex Williamson wrote:
>>>>>>> +struct kvm *vfio_group_get_kvm(struct vfio_group *group)
>>>>>>> +{
>>>>>>> + struct kvm *kvm = NULL;
>>>>> Unnecessary initialization.
>>>>>
>>>>>>> +
>>>>>>> + mutex_lock(&group->udata.lock);
>>>>>>> +
>>>>>>> + kvm = group->udata.kvm;
>>>>>>> + if (kvm)
>>>>>>> + kvm_get_kvm(kvm);
>>>>>>> +
>>>>>>> + mutex_unlock(&group->udata.lock);
>>>>>>> +
>>>>>>> + return kvm;
>>>>>>> +}
>>>>>>> +EXPORT_SYMBOL_GPL(vfio_group_get_kvm);
>>>>>
>>>>> How are kvm references acquired through vfio_group_get_kvm() ever
>>>>> released?
>>>>
>>>> They are released with kvm_put_kvm, but it's done in the vendor driver
>>>> so that VFIO core doesn't have a dependency on kvm.ko.
>>>
>>> We could do a symbol_get() to avoid that so we could have a balanced
>>> get/put through one interface.
>>>
>>>>> Can the reference become invalid?
>>>>
>>>> No, this is guaranteed by virt/kvm/vfio.c + the udata.lock mutex (which
>>>> probably should be renamed...).
>>>
>>> The caller gets a reference to kvm, but there's no guarantee that the
>>> association of that kvm reference to the group stays valid. Once we're
>>> outside of that mutex, we might as well consider that kvm:group
>>> association stale.
>>>
>>>>> The caller may still hold
>>>>> a kvm references, but couldn't the group be detached from one kvm
>>>>> instance and re-attached to another?
>>>>
>>>> Can this be handled by the vendor driver? Does it get a callback when
>>>> it's detached from a KVM instance?
>>>
>>> The only release callback through vfio is when the user closes the
>>> device, the code in this series is the full extent of vfio awareness of
>>> kvm. Thanks,
>>
>> Hi Alex,
>>
>> Thanks for the comments, I'm composing a notifier chain in vfio-group,
>> hopefully that can address current concerns.
>>
>> However, as for the vfio awareness of kvm, implementing notifiers doesn't
>> seem better for that? Do you think if somehow, we are able to figure out
>> a programmatic method in qemu, to trigger intel vGPU related quirks, would
>> still be a better choice?
>
> I do not think so,,, communicating VFIO with KVM should be generic as it may
> have more users in the future except KVMGT.
>
> I think notification is worth to try - vendor driver can register its
> callbacks into vfio-group which get called when KVM binds/unbinds with VFIO
>
Certainly it's worthy, I agree :-)
Just being anxious about how could the kvm awareness in vfio be avoided ...
--
Thanks,
Jike
next prev parent reply other threads:[~2016-11-09 3:14 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-31 6:35 [v3 0/5] plumb kvm/vfio to allow getting kvm from vfio_group Jike Song
2016-10-31 6:35 ` [v3 1/5] vfio: Rearrange functions to get vfio_group from dev Jike Song
2016-10-31 6:35 ` [v3 2/5] vfio: export functions to get vfio_group from device and put it Jike Song
2016-10-31 6:35 ` [v3 3/5] KVM: move kvm_get_kvm to kvm_host.h Jike Song
2016-10-31 8:33 ` Paolo Bonzini
2016-10-31 6:35 ` [v3 4/5] vfio: implement APIs to set/put kvm to/from vfio group Jike Song
2016-11-07 18:04 ` Alex Williamson
2016-11-07 18:10 ` Paolo Bonzini
2016-11-07 18:28 ` Alex Williamson
2016-11-07 20:45 ` Paolo Bonzini
2016-11-09 12:49 ` Jike Song
2016-11-09 13:06 ` Xiao Guangrong
2016-11-09 13:31 ` Paolo Bonzini
2016-11-09 14:00 ` Xiao Guangrong
2016-11-09 14:28 ` Paolo Bonzini
2016-11-10 4:13 ` Jike Song
2016-11-09 17:53 ` Alex Williamson
2016-11-10 4:10 ` Jike Song
2016-11-10 6:04 ` Jike Song
2016-11-10 15:37 ` Alex Williamson
2016-11-11 7:29 ` Jike Song
2016-11-14 10:19 ` Jike Song
2016-11-14 15:52 ` Alex Williamson
2016-11-09 2:28 ` Jike Song
2016-11-09 2:52 ` Xiao Guangrong
2016-11-09 3:07 ` Jike Song [this message]
2016-10-31 6:35 ` [v3 5/5] KVM: set/clear kvm to/from vfio group during add/delete Jike Song
2016-10-31 8:33 ` Paolo Bonzini
2016-10-31 7:06 ` [v3 0/5] plumb kvm/vfio to allow getting kvm from vfio_group Xiao Guangrong
2016-10-31 7:24 ` Jike Song
2016-10-31 7:24 ` Xiao Guangrong
2016-10-31 7:30 ` Jike Song
2016-10-31 7:35 ` Xiao Guangrong
2016-11-02 1:06 ` Jike Song
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=582292F3.5000209@intel.com \
--to=jike.song@intel.com \
--cc=alex.williamson@redhat.com \
--cc=cjia@nvidia.com \
--cc=guangrong.xiao@linux.intel.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=pbonzini@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).