How should a driver shutdown a taskqueue on detach?

Konstantin Belousov kostikbel at gmail.com
Thu Jul 2 07:08:39 UTC 2015


On Wed, Jul 01, 2015 at 06:28:49PM -0400, Ryan Stone wrote:
> On Wed, Jul 1, 2015 at 5:32 PM, Konstantin Belousov <kostikbel at gmail.com>
> wrote:
> 
> > Do you mean, you want some KPI like
> >         boolean taskqueue_is_draining(struct taskqueue *p);
> > so that e.g. executed task could see if it is executing in the
> > shutdown state ?
> 
> 
> I'd prefer a KPI that stops a taskqueue from accepting new tasks (and drops
> attempts to enqueue on the floor).  Then I could do something like:
> 
> taskqueue_stop()
> disable_interrupts()
> taskqueue_drain_all()
> taskqueue_free()

Having taskqueue_enqueue() which could silently (?) not enqueue the given
task is huge and IMO risky change to the KPI.  If doing it, I think
that there should be a new function to enqueue, which is allowed to
fail, unlike taskqueue_enqueue().

BTW, the man page for taskqueue(9) is wrong, taskqueue_enqueue(9)
always succeed now and always returns 0 (ignoring the ushort overflow).


More information about the freebsd-current mailing list