From: Edward Cree <ecree@solarflare.com>
To: Ethan Zhao <ethan.kernel@gmail.com>
Cc: Alexander Duyck <alexander.h.duyck@intel.com>,
linux-pci <linux-pci@vger.kernel.org>,
Don Dutile <ddutile@redhat.com>,
Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH] PCI: handle pci_sriov_set_totalvfs(dev, 0)
Date: Fri, 1 Aug 2014 12:51:42 +0100 [thread overview]
Message-ID: <53DB7F4E.2010407@solarflare.com> (raw)
In-Reply-To: <CABawtvMK=FrquFm-imovjjCV9YMj-fH1mWYd=5G=kpJccdETPQ@mail.gmail.com>
On 01/08/14 04:18, Ethan Zhao wrote:
> On Thu, Jul 31, 2014 at 11:56 PM, Edward Cree <ecree@solarflare.com> wrote:
>> Clearing dev->is_physfn in the driver probe routine isn't safe:
>> dev->sriov memory can get leaked, for example, as sriov_init will get
>> called at device add, but sriov_release won't be called at removal.
>>
> I think this memory leak bug doesn't exist.
>
> The dev->sriov memory was allocated when pci_device_add() called.
> whenever devices
> were hot-pluged into system or built-in devices were scanned while booting.
>
> The memory of dev->sriov is to be freed by kobject->kobject_release() when
> the device reference counter reaches zero when put_device() was called.
> for hot-plug, that is pciehp_unconfigure_device()....etc. but not in
> driver->remove().
>
Yes, but the problem is in pci_iov_release(), not how it gets called;
its code is
if (dev->is_physfn)
sriov_release(dev);
So if the device driver clears dev->is_physfn, and later on the device
is hot-unplugged, pci_iov_release() won't call sriov_release().
Thus any device driver that changes dev->is_physfn will, if the device
is hot-unplugged, leak dev->sriov.
Fortunately a quick grep shows no drivers doing this, so there's no
actual bug in existing code. It's just that we can't use this approach
to disable SR-IOV from the driver's probe routine.
-Edward
> put_device()
> kobject_put()
> kobject_release()
> kobject_cleanup()
> device_release()
> dev->release(dev)
> pci_release_dev()
> pci_release_capabilities()
> pci_iov_release()
> sriov_release(dev);
> kfree(dev->sriov);
The information contained in this message is confidential and is intended for the addressee(s) only. If you have received this message in error, please notify the sender immediately and delete the message. Unless you are an addressee (or authorized to receive for an addressee), you may not use, copy or disclose to anyone this message or any information contained in this message. The unauthorized use, disclosure, copying or alteration of this message is strictly prohibited.
next prev parent reply other threads:[~2014-08-01 11:51 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <53D9288B.5030302@solarflare.com>
2014-07-30 18:05 ` pci_sriov_set_totalvfs again Don Dutile
2014-07-30 18:24 ` Edward Cree
2014-07-30 21:14 ` Alexander Duyck
2014-07-31 12:07 ` Edward Cree
2014-07-31 14:24 ` [PATCH] PCI: handle pci_sriov_set_totalvfs(dev, 0) Edward Cree
2014-07-31 15:21 ` Alexander Duyck
2014-07-31 15:56 ` Edward Cree
2014-07-31 16:40 ` Alexander Duyck
2014-07-31 16:57 ` Edward Cree
2014-07-31 17:53 ` Don Dutile
2014-07-31 18:13 ` Edward Cree
2014-08-04 14:03 ` Edward Cree
2014-08-04 14:37 ` Alexander Duyck
2014-08-04 15:22 ` Edward Cree
2014-08-06 9:38 ` Don Dutile
2014-07-31 17:55 ` Alexander Duyck
2014-07-31 18:24 ` Edward Cree
2014-08-01 3:18 ` Ethan Zhao
2014-08-01 11:51 ` Edward Cree [this message]
2014-08-02 0:34 ` Ethan Zhao
2014-08-01 3:51 ` Ethan Zhao
2014-08-01 12:15 ` Edward Cree
2014-08-02 0:25 ` Ethan Zhao
2014-08-04 15:45 ` Edward Cree
2014-08-04 16:40 ` Alexander Duyck
2014-08-04 17:08 ` Edward Cree
2014-08-04 6:53 ` Sathya Perla
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=53DB7F4E.2010407@solarflare.com \
--to=ecree@solarflare.com \
--cc=alexander.h.duyck@intel.com \
--cc=bhelgaas@google.com \
--cc=ddutile@redhat.com \
--cc=ethan.kernel@gmail.com \
--cc=linux-pci@vger.kernel.org \
/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.