Re: [PATCH] mdev: Send uevents around parent device registration

From: Cornelia Huck
Date: Mon Jul 01 2019 - 04:06:40 EST


On Fri, 28 Jun 2019 09:56:08 -0600
Alex Williamson <alex.williamson@xxxxxxxxxx> wrote:

> On Thu, 27 Jun 2019 10:19:14 +0200
> Cornelia Huck <cohuck@xxxxxxxxxx> wrote:
>
> > On Wed, 26 Jun 2019 08:27:58 -0600
> > Alex Williamson <alex.williamson@xxxxxxxxxx> wrote:

> > > @@ -243,6 +247,8 @@ void mdev_unregister_device(struct device *dev)
> > > up_write(&parent->unreg_sem);
> > >
> > > mdev_put_parent(parent);
> > > +
> > > + kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
> >
> > I'm wondering whether we should indicate this uevent earlier: Once we
> > have detached from the parent list, we're basically done for all
> > practical purposes. So maybe move this right before we grab the
> > unreg_sem?
>
> That would make it a "this thing is about to go away" (ie.
> "unregistering") rather than "this thing is gone" ("unregistered"). I
> was aiming for the latter as the former just seems like it might make
> userspace race to remove devices. Note that I don't actually make use
> of this event in mdevctl currently, so we could maybe save it for
> later, but the symmetry seemed preferable. Thanks,
>
> Alex

Fair enough. I was thinking about signaling that it does not make much
sense to register new devices after that point, but if that might
trigger userspace to actually try and remove devices, not much is
gained.