From: Tony Krowiak <akrowiak@linux.ibm.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Cornelia Huck <cohuck@redhat.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Harald Freudenberger <freude@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
linux-s390@vger.kernel.org, Halil Pasic <pasic@linux.ibm.com>,
Pierre Morel <pmorel@linux.ibm.com>,
"Raj, Ashok" <ashok.raj@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Daniel Vetter <daniel@ffwll.ch>, Christoph Hellwig <hch@lst.de>,
Leon Romanovsky <leonro@nvidia.com>,
Max Gurtovoy <mgurtovoy@nvidia.com>,
Tarun Gupta <targupta@nvidia.com>,
"Jason J . Herne" <jjherne@linux.ibm.com>
Subject: Re: [PATCH 06/12] vfio/ap_ops: Convert to use vfio_register_group_dev()
Date: Wed, 5 May 2021 09:07:03 -0400 [thread overview]
Message-ID: <289b3a23-6a0c-ac7c-48fb-785402cab385@linux.ibm.com> (raw)
In-Reply-To: <20210504160432.GB94750@nvidia.com>
On 5/4/21 12:04 PM, Jason Gunthorpe wrote:
> On Tue, May 04, 2021 at 09:58:45AM -0400, Tony Krowiak wrote:
>>
>> On 5/3/21 4:33 PM, Jason Gunthorpe wrote:
>>> On Mon, May 03, 2021 at 04:14:43PM -0400, Tony Krowiak wrote:
>>>
>>>> This case will occur whenever a user removes the mdev
>>>> by echoing a '1' into the mdev's sysfs 'remove' attribute
>>>> file. I'm not sure it can be considered graceful to take away
>>>> all of the crypto devices from a guest while it is running,
>>>> but there is a way to process the remove callback without
>>>> leaving things in a "weird, half-dead state".
>>> It is acceptable to just sleep here until whatever user controlled
>>> condition is resolved.
>>>
>>> Jason
>> I suppose we could do that, but the user that tried to remove
>> the mdev via its sysfs 'remove' attribute will be left sitting
>> there wondering why the operation didn't complete. That
>> could result in leaving the user hanging in perpetuity.
> Yes.
>
> If the driver can't implement a disconnection then that is
> unavoidable. What it does today by leaking memory under user control
> is not acceptable.
Based upon my observations of the behavior during a removal
of the mdev, memory is not leaked. If the fd for the mdev is
open when an attempt is made to remove it, the operation
will hang until the mdev fd is closed which happens when
either the guest is shut down or the mdev device is detached from
the guest. When the fd is closed, the mdev release callback is
invoked which nullifies the KVM pointer, so when the remove callback
is subsequently invoked, the mdev resources will be cleaned up.
Of course, I imagine there are other possibilities
for how an mdev can be removed, but in the normal course of
events, memory will not be leaked.
>
>> IMHO, the callback should continue to return an int and
>> the caller should display the error if a non-zero rc is
>> returned.
> Nope, there is a reason removal is not allowed to fail.. sysfs remove
> isn't the only reason the mdev driver could be destroyed, the
> underlying physical device could be unplugged or other things.
That may be true with other devices, but the matrix device is
not a real, physical device. Its sole purpose in life is to provide
an anchor for the mdev devices used to provide AP resources
to a guest; however, I get your point.
>
> Drivers need to implement a proper remove.
>
> Jason
next prev parent reply other threads:[~2021-05-05 13:07 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-23 23:02 [PATCH 00/12] Remove vfio_mdev.c, mdev_parent_ops and more Jason Gunthorpe
2021-04-23 23:02 ` [PATCH 01/12] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Jason Gunthorpe
2021-04-24 0:08 ` Randy Dunlap
2021-04-26 18:26 ` Jason Gunthorpe
2021-04-26 19:11 ` Randy Dunlap
2021-04-23 23:03 ` [PATCH 06/12] vfio/ap_ops: Convert to use vfio_register_group_dev() Jason Gunthorpe
2021-04-26 14:07 ` Christoph Hellwig
2021-04-26 17:48 ` Cornelia Huck
2021-04-26 18:10 ` Jason Gunthorpe
2021-04-26 23:41 ` Halil Pasic
2021-05-03 20:14 ` Tony Krowiak
2021-05-03 20:33 ` Jason Gunthorpe
2021-05-04 13:58 ` Tony Krowiak
2021-05-04 16:04 ` Jason Gunthorpe
2021-05-05 13:07 ` Tony Krowiak [this message]
2021-05-04 15:30 ` Cornelia Huck
2021-05-05 12:30 ` Tony Krowiak
2021-05-05 17:47 ` Jason Gunthorpe
2021-05-05 16:28 ` Tony Krowiak
2021-04-23 23:03 ` [PATCH 07/12] vfio/ccw: " Jason Gunthorpe
2021-04-23 23:03 ` [PATCH 10/12] vfio/mdev: Remove mdev_parent_ops Jason Gunthorpe
2021-04-26 14:19 ` Christoph Hellwig
2021-04-26 18:33 ` Jason Gunthorpe
2021-04-26 16:43 ` [PATCH 00/12] Remove vfio_mdev.c, mdev_parent_ops and more Christian Borntraeger
2021-04-26 17:42 ` Jason Gunthorpe
2021-04-27 7:33 ` Christian Borntraeger
2021-04-27 23:21 ` Jason Gunthorpe
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=289b3a23-6a0c-ac7c-48fb-785402cab385@linux.ibm.com \
--to=akrowiak@linux.ibm.com \
--cc=ashok.raj@intel.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=dan.j.williams@intel.com \
--cc=daniel@ffwll.ch \
--cc=freude@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hch@lst.de \
--cc=jgg@nvidia.com \
--cc=jjherne@linux.ibm.com \
--cc=leonro@nvidia.com \
--cc=linux-s390@vger.kernel.org \
--cc=mgurtovoy@nvidia.com \
--cc=pasic@linux.ibm.com \
--cc=pmorel@linux.ibm.com \
--cc=targupta@nvidia.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