lkml.org 
[lkml]   [2014]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH/RFC] workqueue: allow rescuer thread to do more work.
Hello, Neil.

On Wed, Oct 29, 2014 at 05:26:08PM +1100, NeilBrown wrote:
> Hi Tejun,
> I haven't tested this patch yet so this really is an 'RFC'.
> In general ->nr_active should only be accessed under the pool->lock,
> but a miss-read here will at most cause a very occasional 100ms delay so
> shouldn't be a big problem. The only thread likely to change ->nr_active is
> this thread, so such a delay would be extremely unlikely.
>
> Thanks,
> NeilBrown
>
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 09b685daee3d..d0a8b101c5d9 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -2244,16 +2244,18 @@ repeat:
> spin_lock_irq(&pool->lock);
> rescuer->pool = pool;
>
> - /*
> - * Slurp in all works issued via this workqueue and
> - * process'em.
> - */
> - WARN_ON_ONCE(!list_empty(&rescuer->scheduled));
> - list_for_each_entry_safe(work, n, &pool->worklist, entry)
> - if (get_work_pwq(work) == pwq)
> - move_linked_works(work, scheduled, &n);
> + do {
> + /*
> + * Slurp in all works issued via this workqueue and
> + * process'em.
> + */
> + WARN_ON_ONCE(!list_empty(&rescuer->scheduled));
> + list_for_each_entry_safe(work, n, &pool->worklist, entry)
> + if (get_work_pwq(work) == pwq)
> + move_linked_works(work, scheduled, &n);
>
> - process_scheduled_works(rescuer);
> + process_scheduled_works(rescuer);
> + } while (need_more_worker(pool) && pwq->nr_active);

need_more_worker(pool) is always true for unbound pools as long as
there are work items queued, so the above condition may stay true
longer than it needs to. Given that workder depletion is pool-wide
event, maybe it'd make sense to trigger rescuers immediately while
workers are in short supply? e.g. while there's a manager stuck in
maybe_create_worker() with the mayday timer already triggered?

Thanks.

--
tejun


\
 
 \ /
  Last update: 2014-10-29 16:01    [W:1.542 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site