From: Leon Romanovsky <leonro@nvidia.com>
To: Jim Harris <jim.harris@samsung.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>,
Alex Williamson <alex.williamson@redhat.com>,
"bhelgaas@google.com" <bhelgaas@google.com>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"ben@nvidia.com" <ben@nvidia.com>,
"pierre.cregut@orange.com" <pierre.cregut@orange.com>
Subject: Re: Locking between vfio hot-remove and pci sysfs sriov_numvfs
Date: Wed, 13 Dec 2023 08:55:40 +0200 [thread overview]
Message-ID: <20231213065540.GL4870@unreal> (raw)
In-Reply-To: <ZXjRvfu9urCcyEmN@ubuntu>
On Tue, Dec 12, 2023 at 09:34:43PM +0000, Jim Harris wrote:
> On Mon, Dec 11, 2023 at 09:20:06AM +0200, Leon Romanovsky wrote:
> > On Sun, Dec 10, 2023 at 03:05:49PM -0400, Jason Gunthorpe wrote:
> > > On Fri, Dec 08, 2023 at 08:09:34PM +0000, Jim Harris wrote:
> > > >
> > > > The store() side still keeps the device_lock(), it just also acquires this
> > > > new sriov lock. So store() side should observe zero differences. The only
> > > > difference is now the show() side can acquire just the more-granular lock,
> > > > since it is only trying to synchronize on sriov->num_VFs with the store()
> > > > side. But maybe I'm missing something subtle here...
> > >
> > > Oh if that is the only goal then probably a READ_ONCE is fine
>
> IIUC, the synchronization was to block readers of sriov_numvfs if a writer was
> in process of the driver->sriov_configure(). Presumably sriov_configure()
> can take a long time, and it was better to block the sysfs read rather than
> return a stale value.
Nothing prevents from user to write to sriov_numvfs in one thread and
read from another thread. User will get stale value anyway.
>
> > I would say that worth to revert the patch
> > 35ff867b7657 ("PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes")
> > as there is no such promise that netdev devices (as presented in script
> > https://bugzilla.kernel.org/show_bug.cgi?id=202991), which have different
> > lifetime model will be only after sysfs changes in PF.
>
> But I guess you're saying using the sysfs change as any kind of indicator
> is wrong to begin with.
Yes
>
> > netlink event means netdev FOO is ready and if someone needs to follow
> > after sriov_numvfs, he/she should listen to sysfs events.
> >
> > In addition, I would do this change:
> >
> > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> > index 25dbe85c4217..3b768e20c7ab 100644
> > --- a/drivers/pci/iov.c
> > +++ b/drivers/pci/iov.c
> > @@ -683,8 +683,8 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
> > if (rc)
> > goto err_pcibios;
> >
> > - kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE);
> > iov->num_VFs = nr_virtfn;
> > + kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE);
>
> Ack. I'll post patches for both of these suggestions.
Thanks
next prev parent reply other threads:[~2023-12-13 6:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20231207223824uscas1p27dd91f0af56cda282cd28046cc981fe9@uscas1p2.samsung.com>
2023-12-07 22:38 ` Locking between vfio hot-remove and pci sysfs sriov_numvfs Jim Harris
2023-12-07 23:21 ` Alex Williamson
2023-12-07 23:48 ` Jason Gunthorpe
2023-12-08 17:07 ` Jim Harris
2023-12-08 19:41 ` Jason Gunthorpe
2023-12-08 20:09 ` Jim Harris
2023-12-10 19:05 ` Jason Gunthorpe
2023-12-11 7:20 ` Leon Romanovsky
2023-12-12 21:34 ` Jim Harris
2023-12-13 6:55 ` Leon Romanovsky [this message]
2023-12-08 17:38 ` Jim Harris
2023-12-08 17:41 ` Jason Gunthorpe
2023-12-08 17:59 ` Jim Harris
2023-12-08 18:01 ` Jason Gunthorpe
2023-12-08 18:12 ` Alex Williamson
2023-12-08 19:43 ` 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=20231213065540.GL4870@unreal \
--to=leonro@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=ben@nvidia.com \
--cc=bhelgaas@google.com \
--cc=jgg@nvidia.com \
--cc=jim.harris@samsung.com \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=pierre.cregut@orange.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.