[ List trimmed ]
Jeff Garzik wrote:
>
> Andrew Morton wrote:
> >
> > Jeff Garzik wrote:
> > >
> > > "David S. Miller" wrote:
> > > >
> > > > Andrew Morton writes:
> > > > > It'd need to be callable from interrupt context - otherwise
> > > > > each device/driver which has link status change interrupts
> > > > > will need to implement some form of interrupt->process context
> > > > > trick.
> > > >
> > > > Well, we could make the netif_carrier_*() implementation do the
> > > > "interrupt->process context" trick.
> > > >
> > > > Jamal can feel free to post what he has.
> > >
> > > If we have any problems with context we can always use schedule_task()
> >
> > Yep. With dev_hold() and dev_put() to avoid module removal
> > races. One would also have to be sure that the right things
> > happen if the interface is downed between the interrupt and
> > execution of the schedule_task() callback.
>
> Why not call MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT? It makes it much
> more obvious you are closing a race related to modules, and it goes away
> when the module is built into the kernel.
It'd best be done inside netif_carrier_*(). So there one
could use try_inc_mod_count(dev->owner). But that means
an rmmod would fail if there was an event outstanding.
With dev_hold(), which appears to be Alexey's answer to the
module horrors, the rmmod caller will simply block until the
callback has completed and will then see success, which is
what we'd prefer to have happen.
|