Re: [PATCH 06/12] workqueue: destroy_worker() can only destory idle worker not just created worker
On Thu, Sep 27, 2012 at 01:20:37AM +0800, Lai Jiangshan wrote: > After we reimpletment hotplug code, we will not destroy just newly > created worker, all created worker will enter idle soon. > And destroy_worker() is not used to destroy just newly created worker, > it always destory idle worker, so we need to fix destroy_worker() > and update the comments. > > Signed-off-by: Lai Jiangshan > --- > kernel/workqueue.c | 14 +++--- > 1 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/kernel/workqueue.c b/kernel/workqueue.c > index 6c339bf..fe3b1d3 100644 > --- a/kernel/workqueue.c > +++ b/kernel/workqueue.c > @@ -1756,8 +1756,7 @@ static struct worker *alloc_worker(void) > * @pool: pool the new worker will belong to > * > * Create a new worker which is bound to @pool. The returned worker > - * can be started by calling start_worker() or destroyed using > - * destroy_worker(). > + * can be started by calling start_worker(); > * > * CONTEXT: > * Might sleep. Does GFP_KERNEL allocations. > @@ -1847,7 +1846,7 @@ static void start_worker(struct worker *worker) > } > > /** > - * destroy_worker - destroy a workqueue worker > + * destroy_worker - destroy a idle workqueue worker > * @worker: worker to be destroyed > * > * Destroy @worker and adjust @gcwq stats accordingly. > @@ -1864,11 +1863,12 @@ static void destroy_worker(struct worker *worker) > /* sanity check frenzy */ > BUG_ON(worker->current_work); > BUG_ON(!list_empty(>scheduled)); > + BUG_ON(!(worker->flags & WORKER_STARTED)); > + BUG_ON(!(worker->flags & WORKER_IDLE)); > + BUG_ON(list_empty(>entry)); Let's go for WARN_ON() at least for the new ones. Or let's convert all BUG()s to WARN_ON[_ONCE]() beforehand. Thanks. -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 06/12] workqueue: destroy_worker() can only destory idle worker not just created worker
After we reimpletment hotplug code, we will not destroy just newly created worker, all created worker will enter idle soon. And destroy_worker() is not used to destroy just newly created worker, it always destory idle worker, so we need to fix destroy_worker() and update the comments. Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 6c339bf..fe3b1d3 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1756,8 +1756,7 @@ static struct worker *alloc_worker(void) * @pool: pool the new worker will belong to * * Create a new worker which is bound to @pool. The returned worker - * can be started by calling start_worker() or destroyed using - * destroy_worker(). + * can be started by calling start_worker(); * * CONTEXT: * Might sleep. Does GFP_KERNEL allocations. @@ -1847,7 +1846,7 @@ static void start_worker(struct worker *worker) } /** - * destroy_worker - destroy a workqueue worker + * destroy_worker - destroy a idle workqueue worker * @worker: worker to be destroyed * * Destroy @worker and adjust @gcwq stats accordingly. @@ -1864,11 +1863,12 @@ static void destroy_worker(struct worker *worker) /* sanity check frenzy */ BUG_ON(worker->current_work); BUG_ON(!list_empty(>scheduled)); + BUG_ON(!(worker->flags & WORKER_STARTED)); + BUG_ON(!(worker->flags & WORKER_IDLE)); + BUG_ON(list_empty(>entry)); - if (worker->flags & WORKER_STARTED) - pool->nr_workers--; - if (worker->flags & WORKER_IDLE) - pool->nr_idle--; + pool->nr_workers--; + pool->nr_idle--; list_del_init(>entry); worker->flags |= WORKER_DIE; -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 06/12] workqueue: destroy_worker() can only destory idle worker not just created worker
After we reimpletment hotplug code, we will not destroy just newly created worker, all created worker will enter idle soon. And destroy_worker() is not used to destroy just newly created worker, it always destory idle worker, so we need to fix destroy_worker() and update the comments. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 6c339bf..fe3b1d3 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1756,8 +1756,7 @@ static struct worker *alloc_worker(void) * @pool: pool the new worker will belong to * * Create a new worker which is bound to @pool. The returned worker - * can be started by calling start_worker() or destroyed using - * destroy_worker(). + * can be started by calling start_worker(); * * CONTEXT: * Might sleep. Does GFP_KERNEL allocations. @@ -1847,7 +1846,7 @@ static void start_worker(struct worker *worker) } /** - * destroy_worker - destroy a workqueue worker + * destroy_worker - destroy a idle workqueue worker * @worker: worker to be destroyed * * Destroy @worker and adjust @gcwq stats accordingly. @@ -1864,11 +1863,12 @@ static void destroy_worker(struct worker *worker) /* sanity check frenzy */ BUG_ON(worker-current_work); BUG_ON(!list_empty(worker-scheduled)); + BUG_ON(!(worker-flags WORKER_STARTED)); + BUG_ON(!(worker-flags WORKER_IDLE)); + BUG_ON(list_empty(worker-entry)); - if (worker-flags WORKER_STARTED) - pool-nr_workers--; - if (worker-flags WORKER_IDLE) - pool-nr_idle--; + pool-nr_workers--; + pool-nr_idle--; list_del_init(worker-entry); worker-flags |= WORKER_DIE; -- 1.7.7.6 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 06/12] workqueue: destroy_worker() can only destory idle worker not just created worker
On Thu, Sep 27, 2012 at 01:20:37AM +0800, Lai Jiangshan wrote: After we reimpletment hotplug code, we will not destroy just newly created worker, all created worker will enter idle soon. And destroy_worker() is not used to destroy just newly created worker, it always destory idle worker, so we need to fix destroy_worker() and update the comments. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 6c339bf..fe3b1d3 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1756,8 +1756,7 @@ static struct worker *alloc_worker(void) * @pool: pool the new worker will belong to * * Create a new worker which is bound to @pool. The returned worker - * can be started by calling start_worker() or destroyed using - * destroy_worker(). + * can be started by calling start_worker(); * * CONTEXT: * Might sleep. Does GFP_KERNEL allocations. @@ -1847,7 +1846,7 @@ static void start_worker(struct worker *worker) } /** - * destroy_worker - destroy a workqueue worker + * destroy_worker - destroy a idle workqueue worker * @worker: worker to be destroyed * * Destroy @worker and adjust @gcwq stats accordingly. @@ -1864,11 +1863,12 @@ static void destroy_worker(struct worker *worker) /* sanity check frenzy */ BUG_ON(worker-current_work); BUG_ON(!list_empty(worker-scheduled)); + BUG_ON(!(worker-flags WORKER_STARTED)); + BUG_ON(!(worker-flags WORKER_IDLE)); + BUG_ON(list_empty(worker-entry)); Let's go for WARN_ON() at least for the new ones. Or let's convert all BUG()s to WARN_ON[_ONCE]() beforehand. Thanks. -- tejun -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/