Re: [RFC v1 0/3] driver-core: add asynch module loading support

From: Tejun Heo
Date: Sun Aug 31 2014 - 07:38:29 EST


(cc'ing Rusty for module loading)

Hello,

On Sun, Aug 31, 2014 at 01:25:03PM +0200, David Herrmann wrote:
> On Sun, Aug 31, 2014 at 1:02 PM, Tejun Heo <tj@xxxxxxxxxx> wrote:
> > @@ -689,9 +704,23 @@ int bus_add_driver(struct device_driver *drv)
> >
> > klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers);
> > if (drv->bus->p->drivers_autoprobe) {
> > - error = driver_attach(drv);
> > - if (error)
> > - goto out_unregister;
> > + struct driver_attach_work *daw;

Oops, this probably should go inside the below if block.

> > +
> > + if (drv->owner) {
> > + daw = kzalloc(sizeof(*daw), GFP_KERNEL);
> > + if (!daw) {
> > + error = -ENOMEM;
> > + goto out_unregister;
> > + }
> > +
> > + INIT_WORK(&daw->work, driver_attach_workfn);
> > + daw->driver = drv;
> > + queue_work(driver_attach_wq, &daw->work);
>
> Doesn't this break on-demand cdev initialization? We currently call
> request_module() on open() for unclaimed major/minor combinations. If
> driver_attach() is no longer part of module_init(), there is no
> guarantee the driver created the cdev before request_module() returns.

Right, yeah, this really looks like something we'd need to switch per
insmod instance. It looks like driver core needs a generic parameter
to tell it to whether drive probing asynchronously to module loading
or not. Maybe we can add a generic driver param like
"driver_async_probe"?

> I actually like this "deferred attach" approach, so this is not meant
> as counter-argument. We just need to make sure to have a notion of
> "settled modules" so we know how long to wait after loading a module.

Another way could be making module-generic pollable file in the
module's sysfs dir to indicate "full init completion", which would map
to probing completion for drivers; however, given that we need to keep
the synchronous behavior by default for compatibility, I don't think
that buys us much.

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/