tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Run timers in workqueue



On Thu, Jul 7, 2016 at 10:34 AM, Ryota Ozaki <ozaki-r%netbsd.org@localhost> wrote:
> Hi,
>
> Timers (such as nd6_timer) typically free/destroy
> some data in callout (softint). If we apply psz/psref
> for such data, we cannot do free/destroy process in
> there because synchronization of psz/psref cannot
> be used in softint.
>
> So I propose to run such timers in workqueue. The
> change is straightforward; a timer's callout just
> calls workqueue_enqueue and workqueue's work does
> the exactly same as the original callout does.
>
> Here is a patch:
>   http://www.netbsd.org/~ozaki-r/timer-workqueue.diff
>
> The patch applies the proposal to nd6_timer,
> rt_timer_work, ipflow_slowtimo and ip6flow_slowtimo,
> which are needed by my local changes for MP-ification.
> Other timers would be migrated to workqueue if necessary.
>
> Any comments or suggestions?

I taught that doing workqueue_enqueue a work twice (i.e.,
call workqueue_enqueue before a previous task is scheduled)
isn't allowed. For nd6_timer and rt_timer_timer, this
doesn't happen because callout_reset is called only
from workqueue's work. OTOH, ip{,6}flow_slowtimo's callout
can be called before its work starts and completes
because the callout is periodically called regardless of
completion of the work.

http://www.netbsd.org/~ozaki-r/timer-workqueue-fix.diff

The patch fixes the issue by simply adding a flag that
indicates a work is enqueued but not finished.
workqueue_enqueue is only called if the flag indicates
that no work is enqueued.

Is the fix is correct?

Thanks,
  ozaki-r


Home | Main Index | Thread Index | Old Index