linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] workqueue: misc cleanup
@ 2015-05-20  6:41 Lai Jiangshan
  2015-05-20  6:41 ` [PATCH 1/3] workqueue: remove the declaration of copy_workqueue_attrs() Lai Jiangshan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Lai Jiangshan @ 2015-05-20  6:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lai Jiangshan, Tejun Heo

patch1&2 are simple cleaups and reflect to recently changes.

patch3 just moves code.


Cc: Tejun Heo <tj@kernel.org>

Lai Jiangshan (3):
  workqueue: remove the declaration of copy_workqueue_attrs()
  workqueue: remove the lock from wq_sysfs_prep_attrs()
  workqueue: move flush_scheduled_work() to workqueue.h

 include/linux/workqueue.h | 30 +++++++++++++++++++++++++++++-
 kernel/workqueue.c        | 36 ++----------------------------------
 2 files changed, 31 insertions(+), 35 deletions(-)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] workqueue: remove the declaration of copy_workqueue_attrs()
  2015-05-20  6:41 [PATCH 0/3] workqueue: misc cleanup Lai Jiangshan
@ 2015-05-20  6:41 ` Lai Jiangshan
  2015-05-20  6:41 ` [PATCH 2/3] workqueue: remove the lock from wq_sysfs_prep_attrs() Lai Jiangshan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Lai Jiangshan @ 2015-05-20  6:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lai Jiangshan, Tejun Heo

This pre-declaration was unneeded since a previous refactor patch
6ba94429c8e7 ("workqueue: Reorder sysfs code").

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 kernel/workqueue.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ee5bf95..a04a9cd3 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -337,8 +337,6 @@ struct workqueue_struct *system_freezable_power_efficient_wq __read_mostly;
 EXPORT_SYMBOL_GPL(system_freezable_power_efficient_wq);
 
 static int worker_thread(void *__worker);
-static void copy_workqueue_attrs(struct workqueue_attrs *to,
-				 const struct workqueue_attrs *from);
 static void workqueue_sysfs_unregister(struct workqueue_struct *wq);
 
 #define CREATE_TRACE_POINTS
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] workqueue: remove the lock from wq_sysfs_prep_attrs()
  2015-05-20  6:41 [PATCH 0/3] workqueue: misc cleanup Lai Jiangshan
  2015-05-20  6:41 ` [PATCH 1/3] workqueue: remove the declaration of copy_workqueue_attrs() Lai Jiangshan
@ 2015-05-20  6:41 ` Lai Jiangshan
  2015-05-20  6:41 ` [PATCH 3/3] workqueue: move flush_scheduled_work() to workqueue.h Lai Jiangshan
  2015-05-21 21:27 ` [PATCH 0/3] workqueue: misc cleanup Tejun Heo
  3 siblings, 0 replies; 5+ messages in thread
From: Lai Jiangshan @ 2015-05-20  6:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lai Jiangshan, Tejun Heo

Reading to wq->unbound_attrs requires protection of either wq_pool_mutex
or wq->mutex, and wq_sysfs_prep_attrs() is called with wq_pool_mutex held,
so we don't need to grab wq->mutex here.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 kernel/workqueue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index a04a9cd3..81b0e0d 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4941,13 +4941,13 @@ static struct workqueue_attrs *wq_sysfs_prep_attrs(struct workqueue_struct *wq)
 {
 	struct workqueue_attrs *attrs;
 
+	lockdep_assert_held(&wq_pool_mutex);
+
 	attrs = alloc_workqueue_attrs(GFP_KERNEL);
 	if (!attrs)
 		return NULL;
 
-	mutex_lock(&wq->mutex);
 	copy_workqueue_attrs(attrs, wq->unbound_attrs);
-	mutex_unlock(&wq->mutex);
 	return attrs;
 }
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] workqueue: move flush_scheduled_work() to workqueue.h
  2015-05-20  6:41 [PATCH 0/3] workqueue: misc cleanup Lai Jiangshan
  2015-05-20  6:41 ` [PATCH 1/3] workqueue: remove the declaration of copy_workqueue_attrs() Lai Jiangshan
  2015-05-20  6:41 ` [PATCH 2/3] workqueue: remove the lock from wq_sysfs_prep_attrs() Lai Jiangshan
@ 2015-05-20  6:41 ` Lai Jiangshan
  2015-05-21 21:27 ` [PATCH 0/3] workqueue: misc cleanup Tejun Heo
  3 siblings, 0 replies; 5+ messages in thread
From: Lai Jiangshan @ 2015-05-20  6:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lai Jiangshan, Tejun Heo

flush_scheduled_work() is just a simple call to flush_work().

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 include/linux/workqueue.h | 30 +++++++++++++++++++++++++++++-
 kernel/workqueue.c        | 30 ------------------------------
 2 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 4618dd6..738b30b 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -435,7 +435,6 @@ extern bool mod_delayed_work_on(int cpu, struct workqueue_struct *wq,
 
 extern void flush_workqueue(struct workqueue_struct *wq);
 extern void drain_workqueue(struct workqueue_struct *wq);
-extern void flush_scheduled_work(void);
 
 extern int schedule_on_each_cpu(work_func_t func);
 
@@ -532,6 +531,35 @@ static inline bool schedule_work(struct work_struct *work)
 }
 
 /**
+ * flush_scheduled_work - ensure that any scheduled work has run to completion.
+ *
+ * Forces execution of the kernel-global workqueue and blocks until its
+ * completion.
+ *
+ * Think twice before calling this function!  It's very easy to get into
+ * trouble if you don't take great care.  Either of the following situations
+ * will lead to deadlock:
+ *
+ *	One of the work items currently on the workqueue needs to acquire
+ *	a lock held by your code or its caller.
+ *
+ *	Your code is running in the context of a work routine.
+ *
+ * They will be detected by lockdep when they occur, but the first might not
+ * occur very often.  It depends on what work items are on the workqueue and
+ * what locks they need, which you have no control over.
+ *
+ * In most situations flushing the entire workqueue is overkill; you merely
+ * need to know that a particular work item isn't queued and isn't running.
+ * In such cases you should use cancel_delayed_work_sync() or
+ * cancel_work_sync() instead.
+ */
+static inline void flush_scheduled_work(void)
+{
+	flush_workqueue(system_wq);
+}
+
+/**
  * schedule_delayed_work_on - queue work in global workqueue on CPU after delay
  * @cpu: cpu to use
  * @dwork: job to be done
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 81b0e0d..097fc48 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2959,36 +2959,6 @@ int schedule_on_each_cpu(work_func_t func)
 }
 
 /**
- * flush_scheduled_work - ensure that any scheduled work has run to completion.
- *
- * Forces execution of the kernel-global workqueue and blocks until its
- * completion.
- *
- * Think twice before calling this function!  It's very easy to get into
- * trouble if you don't take great care.  Either of the following situations
- * will lead to deadlock:
- *
- *	One of the work items currently on the workqueue needs to acquire
- *	a lock held by your code or its caller.
- *
- *	Your code is running in the context of a work routine.
- *
- * They will be detected by lockdep when they occur, but the first might not
- * occur very often.  It depends on what work items are on the workqueue and
- * what locks they need, which you have no control over.
- *
- * In most situations flushing the entire workqueue is overkill; you merely
- * need to know that a particular work item isn't queued and isn't running.
- * In such cases you should use cancel_delayed_work_sync() or
- * cancel_work_sync() instead.
- */
-void flush_scheduled_work(void)
-{
-	flush_workqueue(system_wq);
-}
-EXPORT_SYMBOL(flush_scheduled_work);
-
-/**
  * execute_in_process_context - reliably execute the routine with user context
  * @fn:		the function to execute
  * @ew:		guaranteed storage for the execute work structure (must
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] workqueue: misc cleanup
  2015-05-20  6:41 [PATCH 0/3] workqueue: misc cleanup Lai Jiangshan
                   ` (2 preceding siblings ...)
  2015-05-20  6:41 ` [PATCH 3/3] workqueue: move flush_scheduled_work() to workqueue.h Lai Jiangshan
@ 2015-05-21 21:27 ` Tejun Heo
  3 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2015-05-21 21:27 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: linux-kernel

On Wed, May 20, 2015 at 02:41:16PM +0800, Lai Jiangshan wrote:
> patch1&2 are simple cleaups and reflect to recently changes.
> 
> patch3 just moves code.

Applied 1-3 to wq/for-4.2.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-21 21:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20  6:41 [PATCH 0/3] workqueue: misc cleanup Lai Jiangshan
2015-05-20  6:41 ` [PATCH 1/3] workqueue: remove the declaration of copy_workqueue_attrs() Lai Jiangshan
2015-05-20  6:41 ` [PATCH 2/3] workqueue: remove the lock from wq_sysfs_prep_attrs() Lai Jiangshan
2015-05-20  6:41 ` [PATCH 3/3] workqueue: move flush_scheduled_work() to workqueue.h Lai Jiangshan
2015-05-21 21:27 ` [PATCH 0/3] workqueue: misc cleanup Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).