lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Fri, 11 Jul 2014 11:02:52 -0400 From: Tejun Heo <tj@...nel.org> To: Lai Jiangshan <laijs@...fujitsu.com> Cc: linux-kernel@...r.kernel.org Subject: Re: [PATCH 2/3] workqueue: remove the guarantee and the retrying of maybe_create_worker() On Fri, Jul 11, 2014 at 12:01:04AM +0800, Lai Jiangshan wrote: > maybe_create_worker() has a strong guarantee that there has at least > one idle worker on return from this function. This guarantee is guaranteed > via the check and the retrying in this function. > > But the caller (worker_thread()) also has the same check and retrying, > so the guarantee is not really required and the check and the retrying in > maybe_create_worker() are unnecessary and redundant. > > So we remove the guarantee as well as the check and the retrying. The caller > takes responsibility to retry when needed. > > The only trade-off is that the mayday timer will be removed and re-added > across retrying. Since retrying is expected as rare case, the trade-off > is acceptible. > > Signed-off-by: Lai Jiangshan <laijs@...fujitsu.com> > --- > kernel/workqueue.c | 49 ++++++++++++++++++------------------------------- > 1 files changed, 18 insertions(+), 31 deletions(-) > > diff --git a/kernel/workqueue.c b/kernel/workqueue.c > index 92f7ea0c..4fdd6d0 100644 > --- a/kernel/workqueue.c > +++ b/kernel/workqueue.c > @@ -1875,14 +1875,17 @@ static void pool_mayday_timeout(unsigned long __pool) > * @pool: pool to create a new worker for > * > * Create a new worker for @pool if necessary. @pool is guaranteed to > - * have at least one idle worker on return from this function. If > - * creating a new worker takes longer than MAYDAY_INTERVAL, mayday is > + * make some progresses on return from this function. Hmmm.... not really. > + * 1) success to create a new idle worker. Or Another work item can race and occupy that worker before this worker regrabs pool->lock, which is safe because > + * 2) cool down a while after it failed. Or > + * 3) condition changed (no longer need to create worker) after it failed. > + * In any case, the caller will recheck the condition and retry when needed, > + * so this function doesn't need to retry. the caller checks the condition again but the above 1/2/3 are confusing at best. ... > + worker = create_worker(pool); > + if (worker) { > + del_timer_sync(&pool->mayday_timer); > + spin_lock_irq(&pool->lock); > + start_worker(worker); > + return; > + } > > + if (need_to_create_worker(pool)) > schedule_timeout_interruptible(CREATE_COOLDOWN); Ugh, so we're now inserting delay in the inner function and looping from the outside? That's messy. I'd prefer removing the outer loop instead. Thanks. -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists