Skip to contentSkip to conversation

memory_hotplug: drop spurious calls to flush_scheduled_work()

PATCH In review Tejun Heo 6 participants 11 messages Oct 15, 2010 – Oct 20, 2010

Subsystems (3)
lore
Share & tools
lore

Tejun Heo

author maintainer
#0 lore raw

PATCH 1/1 memory_hotplug: drop spurious calls to flush_scheduled_work()

lru_add_drain_all() uses schedule_on_each_cpu() which is synchronous. There is no reason to call flush_scheduled_work() after lru_add_drain_all(). Drop the spurious calls.

This is to prepare for the deprecation and removal of flush_scheduled_work().

---
 mm/memory_hotplug.c |    2 --
 1 file changed, 2 deletions(-)
mm/memory_hotplug.c +0 -2
Index: work/mm/memory_hotplug.c
===================================================================
@@ -840,7 +840,6 @@ repeat:
 	ret = 0;
 	if (drain) {
 		lru_add_drain_all();
-		flush_scheduled_work();
 		cond_resched();
 		drain_all_pages();
 	}
@@ -862,7 +861,6 @@ repeat:
 	}
 	/* drain all zone's lru pagevec, this is asyncronous... */
 	lru_add_drain_all();
-	flush_scheduled_work();
 	yield();
 	/* drain pcp pages , this is synchrouns. */
 	drain_all_pages();
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Fri, 15 Oct 2010 17:25:15 +0200 Tejun Heo <[email protected]> wrote:

lru_add_drain_all() uses schedule_on_each_cpu() which is synchronous. There is no reason to call flush_scheduled_work() after lru_add_drain_all(). Drop the spurious calls.

This is to prepare for the deprecation and removal of flush_scheduled_work().

author maintainer
#2 lore raw

Hello,

Quoted 7 lines · KAMEZAWA Hiroyuki
Quoted 4 lines · On Fri, 15 Oct 2010 17:25:15 +0200 Tejun Heo <[email protected]> wrote:

lru_add_drain_all() uses schedule_on_each_cpu() which is synchronous. There is no reason to call flush_scheduled_work() after lru_add_drain_all(). Drop the spurious calls.

Quoted 5 lines
Quoted 4 lines

This is to prepare for the deprecation and removal of flush_scheduled_work().

Through which tree should this be routed? Shall I route this via the wq tree?

Thank you.

Signature · 1 line
tejun
Reviewed-by on v1 1/1
#5 lore raw
In reply to Tejun Heo
Quoted 8 lines · Tejun Heo

lru_add_drain_all() uses schedule_on_each_cpu() which is synchronous. There is no reason to call flush_scheduled_work() after lru_add_drain_all().  Drop the spurious calls.

This is to prepare for the deprecation and removal of flush_scheduled_work().

Signature · 2 lines
Kind regards,
Minchan Kim
Acked-by on v1 1/1
#6 lore raw
In reply to Tejun Heo
Quoted 4 lines · Tejun Heo

lru_add_drain_all() uses schedule_on_each_cpu() which is synchronous. There is no reason to call flush_scheduled_work() after lru_add_drain_all(). Drop the spurious calls.

This looks correct.

I suspect this call to flush_scheduled_work() existed because it is easy to interpret the documentation of schedule_on_each_cpu to mean it is an asynchronous call. Maybe something like the following?

==== CUT HERE ====
workqueue: Clarify that schedule_on_each_cpu is synchronous

The documentation for schedule_on_each_cpu() states that it calls a function on each online CPU from keventd. This can easily be interpreted as an asyncronous call because the description does not mention that flush_work is called. Clarify that it is synchronous.

---
 kernel/workqueue.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
kernel/workqueue.c +5 -3
index f77afd9..07cba1e 100644
@@ -2592,13 +2592,15 @@ int schedule_delayed_work_on(int cpu,
 EXPORT_SYMBOL(schedule_delayed_work_on);
 
 /**
- * schedule_on_each_cpu - call a function on each online CPU from keventd
+ * schedule_on_each_cpu - Call a function on each online CPU via keventd and wait for completion
  * @func: the function to call
  *
+ * schedule_on_each_cpu executes a given callback function on each CPU via keventd
+ * and blocks until each callback has completed. schedule_on_each_cpu() is very
+ * slow.
+ *
  * Returns zero on success.
  * Returns -ve errno on failure.
- *
- * schedule_on_each_cpu() is very slow.
  */
 int schedule_on_each_cpu(work_func_t func)
 {
#3 lore raw
In reply to Tejun Heo
Quoted 10 lines · On Mon, 18 Oct 2010 07:03:37 +0200 Tejun Heo <[email protected]> wrote:

Hello,

Quoted 7 lines · KAMEZAWA Hiroyuki
Quoted 4 lines · On Fri, 15 Oct 2010 17:25:15 +0200 Tejun Heo <[email protected]> wrote:

lru_add_drain_all() uses schedule_on_each_cpu() which is synchronous. There is no reason to call flush_scheduled_work() after lru_add_drain_all(). Drop the spurious calls.

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

This is to prepare for the deprecation and removal of flush_scheduled_work().

Through which tree should this be routed? Shall I route this via the wq tree?

please.

Thank,
-Kame

Reviewed-by
#7 lore raw
In reply to Mel Gorman
Quoted 37 lines · Tejun Heo
Quoted 4 lines

lru_add_drain_all() uses schedule_on_each_cpu() which is synchronous. There is no reason to call flush_scheduled_work() after lru_add_drain_all(). Drop the spurious calls.

This looks correct.

I suspect this call to flush_scheduled_work() existed because it is easy to interpret the documentation of schedule_on_each_cpu to mean it is an asynchronous call. Maybe something like the following?

==== CUT HERE ====
workqueue: Clarify that schedule_on_each_cpu is synchronous

The documentation for schedule_on_each_cpu() states that it calls a function on each online CPU from keventd. This can easily be interpreted as an asyncronous call because the description does not mention that flush_work is called. Clarify that it is synchronous.

---
 kernel/workqueue.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
kernel/workqueue.c +1 -1
index f77afd9..07cba1e 100644
@@ -2592,13 +2592,15 @@ int schedule_delayed_work_on(int cpu,
 EXPORT_SYMBOL(schedule_delayed_work_on);
 
 /**
- * schedule_on_each_cpu - call a function on each online CPU from keventd
+ * schedule_on_each_cpu - Call a function on each online CPU via keventd and wait for completion

kernel/workqueue.c int schedule_delayed_work_on(int cpu, · line 2601

Quoted 10 lines
kernel/workqueue.c +4 -2
  * @func: the function to call
  *
+ * schedule_on_each_cpu executes a given callback function on each CPU via keventd
+ * and blocks until each callback has completed. schedule_on_each_cpu() is very
+ * slow.
+ *
  * Returns zero on success.
  * Returns -ve errno on failure.
- *
- * schedule_on_each_cpu() is very slow.

Nice!

author maintainer
#8 lore raw

PATCH 1/1 workqueue: Clarify that schedule_on_each_cpu is synchronous

The documentation for schedule_on_each_cpu() states that it calls a function on each online CPU from keventd. This can easily be interpreted as an asyncronous call because the description does not mention that flush_work is called. Clarify that it is synchronous.

tj: rephrased a bit

---
Commited somewhat rephrased version. Thank you.

 kernel/workqueue.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
kernel/workqueue.c +6 -4
index 2c6871c..eb5c197 100644
@@ -2676,13 +2676,15 @@ int schedule_delayed_work_on(int cpu,
 EXPORT_SYMBOL(schedule_delayed_work_on);
 
 /**
- * schedule_on_each_cpu - call a function on each online CPU from keventd
+ * schedule_on_each_cpu - execute a function synchronously on each online CPU
  * @func: the function to call
  *
- * Returns zero on success.
- * Returns -ve errno on failure.
- *
+ * schedule_on_each_cpu() executes @func on each online CPU using the
+ * system workqueue and blocks until all CPUs have completed.
  * schedule_on_each_cpu() is very slow.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
  */
 int schedule_on_each_cpu(work_func_t func)
 {
Signature · 1 line
1.7.1
author maintainer Applied
#4 lore raw
In reply to KAMEZAWA Hiroyuki
Quoted 4 lines · KAMEZAWA Hiroyuki
Quoted 3 lines

Through which tree should this be routed? Shall I route this via the wq tree?

please.

Applied to wq#for-next. Thank you.

Signature · 1 line
tejun
Reviewed-by on v1 1/1
#9 lore raw

Re: [PATCH wq#for-next] workqueue: Clarify that schedule_on_each_cpu is synchronous

In reply to Tejun Heo
Quoted 10 lines · On Tue, 19 Oct 2010 11:18:46 +0200 Tejun Heo <[email protected]> wrote:

The documentation for schedule_on_each_cpu() states that it calls a function on each online CPU from keventd. This can easily be interpreted as an asyncronous call because the description does not mention that flush_work is called. Clarify that it is synchronous.

tj: rephrased a bit

Reviewed-by on v1 1/1
#10 lore raw

Re: [PATCH wq#for-next] workqueue: Clarify that schedule_on_each_cpu is synchronous

In reply to Tejun Heo
Quoted 10 lines · Tejun Heo

The documentation for schedule_on_each_cpu() states that it calls a function on each online CPU from keventd. This can easily be interpreted as an asyncronous call because the description does not mention that flush_work is called. Clarify that it is synchronous.

tj: rephrased a bit

Nice comment!