From: Gautham R Shenoy <ego@in.ibm.com>
To: akpm@linux-foundation.org, paulmck@us.ibm.com,
torvalds@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, vatsa@in.ibm.com,
Oleg Nesterov <oleg@tv-sign.ru>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
mingo@elte.hu, dipankar@in.ibm.com, dino@in.ibm.com,
masami.hiramatsu.pt@hitachi.com
Subject: [PATCH 6/8] Make non-singlethreaded workqueues freezeable by default
Date: Mon, 2 Apr 2007 11:11:07 +0530 [thread overview]
Message-ID: <20070402054107.GF12962@in.ibm.com> (raw)
In-Reply-To: <20070402053457.GA9076@in.ibm.com>
This patch
o Makes all non-singlethreaded workqueues freezeable by default.
o Introduces a new API for creating freeze_exempted workqueues.
o Uses the combination of cancel_delayed_work and cancel_work_sync
in Slab during DOWN_PREPARE instead of cancel_rearming_delayed work,
which tries to flush_workqueue in vain, in a frozen context.
Note:
o The singlethreaded workqueues will not be frozen.
Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Johannes Berg <johannes@sipsolutions.net>
--
include/linux/workqueue.h | 12 +++++-------
kernel/workqueue.c | 35 ++++++++++++++++++++++++++---------
mm/slab.c | 10 +++-------
3 files changed, 34 insertions(+), 23 deletions(-)
Index: linux-2.6.21-rc5/include/linux/workqueue.h
===================================================================
--- linux-2.6.21-rc5.orig/include/linux/workqueue.h
+++ linux-2.6.21-rc5/include/linux/workqueue.h
@@ -9,7 +9,6 @@
#include <linux/linkage.h>
#include <linux/bitops.h>
#include <asm/atomic.h>
-
struct workqueue_struct;
struct work_struct;
@@ -112,12 +111,11 @@ struct execute_work {
clear_bit(WORK_STRUCT_PENDING, work_data_bits(work))
-extern struct workqueue_struct *__create_workqueue(const char *name,
- int singlethread,
- int freezeable);
-#define create_workqueue(name) __create_workqueue((name), 0, 0)
-#define create_freezeable_workqueue(name) __create_workqueue((name), 0, 1)
-#define create_singlethread_workqueue(name) __create_workqueue((name), 1, 0)
+extern struct workqueue_struct *create_workqueue(const char *name);
+
+extern struct workqueue_struct *create_freeze_exempted_workqueue(const char *name, int freeze_exempt_events);
+
+extern struct workqueue_struct *create_singlethread_workqueue(const char *name);
extern void destroy_workqueue(struct workqueue_struct *wq);
Index: linux-2.6.21-rc5/kernel/workqueue.c
===================================================================
--- linux-2.6.21-rc5.orig/kernel/workqueue.c
+++ linux-2.6.21-rc5/kernel/workqueue.c
@@ -64,7 +64,7 @@ struct workqueue_struct {
struct list_head list;
const char *name;
int singlethread;
- int freezeable; /* Freeze threads during suspend */
+ int freeze_exempt_events; /* Events not to freeze! */
};
/* All the per-cpu workqueues on the system, for hotplug cpu to add/remove
@@ -294,8 +294,7 @@ static int worker_thread(void *__cwq)
DEFINE_WAIT(wait);
struct k_sigaction sa;
- if (!cwq->wq->freezeable)
- freezer_exempt(FE_ALL);
+ freezer_exempt(cwq->wq->freeze_exempt_events);
/*
* We inherited MPOL_INTERLEAVE from the booting kernel.
@@ -310,8 +309,7 @@ static int worker_thread(void *__cwq)
do_sigaction(SIGCHLD, &sa, (struct k_sigaction *)0);
for (;;) {
- if (cwq->wq->freezeable)
- try_to_freeze();
+ try_to_freeze();
prepare_to_wait(&cwq->more_work, &wait, TASK_INTERRUPTIBLE);
if (cwq->status == CWQ_RUNNING && list_empty(&cwq->worklist))
@@ -656,8 +654,9 @@ static int create_workqueue_thread(struc
return 0;
}
-struct workqueue_struct *__create_workqueue(const char *name,
- int singlethread, int freezeable)
+static struct workqueue_struct *__create_workqueue(const char *name,
+ int singlethread,
+ int freeze_exempt_events)
{
struct workqueue_struct *wq;
struct cpu_workqueue_struct *cwq;
@@ -675,7 +674,7 @@ struct workqueue_struct *__create_workqu
wq->name = name;
wq->singlethread = singlethread;
- wq->freezeable = freezeable;
+ wq->freeze_exempt_events = freeze_exempt_events;
INIT_LIST_HEAD(&wq->list);
if (singlethread) {
@@ -700,7 +699,25 @@ struct workqueue_struct *__create_workqu
}
return wq;
}
-EXPORT_SYMBOL_GPL(__create_workqueue);
+
+struct workqueue_struct *create_workqueue(const char *name)
+{
+ return __create_workqueue(name, 0, FE_NONE);
+}
+EXPORT_SYMBOL_GPL(create_workqueue);
+
+struct workqueue_struct *create_freeze_exempted_workqueue(const char *name,
+ int freeze_exempt_events)
+{
+ return __create_workqueue(name, 0, freeze_exempt_events);
+}
+EXPORT_SYMBOL_GPL(create_freeze_exempted_workqueue);
+
+struct workqueue_struct *create_singlethread_workqueue(const char *name)
+{
+ return __create_workqueue(name, 1, FE_ALL);
+}
+EXPORT_SYMBOL_GPL(create_singlethread_workqueue);
static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu)
{
Index: linux-2.6.21-rc5/mm/slab.c
===================================================================
--- linux-2.6.21-rc5.orig/mm/slab.c
+++ linux-2.6.21-rc5/mm/slab.c
@@ -1277,13 +1277,9 @@ static int __cpuinit cpuup_callback(stru
break;
#ifdef CONFIG_HOTPLUG_CPU
case CPU_DOWN_PREPARE:
- /*
- * Shutdown cache reaper. Note that the cache_chain_mutex is
- * held so that if cache_reap() is invoked it cannot do
- * anything expensive but will only modify reap_work
- * and reschedule the timer.
- */
- cancel_rearming_delayed_work(&per_cpu(reap_work, cpu));
+ /* we are in a frozen context. So this should be safe.*/
+ cancel_delayed_work(&per_cpu(reap_work, cpu));
+ cancel_work_sync(&per_cpu(reap_work, cpu).work);
/* Now the cache_reaper is guaranteed to be not running. */
per_cpu(reap_work, cpu).work.func = NULL;
break;
--
Gautham R Shenoy
Linux Technology Center
IBM India.
"Freedom comes with a price tag of responsibility, which is still a bargain,
because Freedom is priceless!"
next prev parent reply other threads:[~2007-04-02 5:41 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-02 5:34 [RFC] Cpu-hotplug: Using the Process Freezer (try2) Gautham R Shenoy
2007-04-02 5:37 ` [PATCH 1/8] Enhance process freezer interface for usage beyond software suspend Gautham R Shenoy
2007-04-02 13:56 ` Pavel Machek
2007-04-02 20:48 ` Rafael J. Wysocki
2007-04-02 20:51 ` Pavel Machek
2007-04-06 14:34 ` Rafael J. Wysocki
2007-04-06 22:20 ` Nigel Cunningham
2007-04-07 9:33 ` Rafael J. Wysocki
2007-04-07 9:47 ` Nigel Cunningham
2007-04-09 3:04 ` Gautham R Shenoy
2007-04-03 7:59 ` Gautham R Shenoy
2007-04-05 9:46 ` Oleg Nesterov
2007-04-05 10:59 ` Gautham R Shenoy
2007-04-05 11:30 ` Oleg Nesterov
2007-04-02 5:37 ` [PATCH 2/8] Make process freezer reentrant Gautham R Shenoy
2007-04-05 9:53 ` Oleg Nesterov
2007-04-05 10:19 ` Gautham R Shenoy
2007-04-02 5:38 ` [PATCH 3/8] Use process freezer for cpu-hotplug Gautham R Shenoy
2007-04-05 10:53 ` Oleg Nesterov
2007-04-05 12:14 ` Gautham R Shenoy
2007-04-05 13:34 ` Oleg Nesterov
2007-04-06 17:27 ` Nathan Lynch
2007-04-06 17:34 ` Ingo Molnar
2007-04-06 17:47 ` Nathan Lynch
2007-04-06 22:22 ` Nigel Cunningham
2007-04-14 18:48 ` Pavel Machek
2007-04-02 5:39 ` [PATCH 4/8] Rip out lock_cpu_hotplug() Gautham R Shenoy
2007-04-02 5:40 ` [PATCH 5/8] __cpu_up: use singlethreaded workqueue Gautham R Shenoy
2007-04-05 12:08 ` Oleg Nesterov
2007-04-02 5:41 ` Gautham R Shenoy [this message]
2007-04-05 11:57 ` [PATCH 6/8] Make non-singlethreaded workqueues freezeable by default Oleg Nesterov
2007-04-05 20:06 ` Andrew Morton
2007-04-02 5:42 ` [PATCH 7/8] Clean up workqueue.c with respect to the freezer based cpu-hotplug Gautham R Shenoy
2007-04-03 11:47 ` Oleg Nesterov
2007-04-03 13:59 ` Srivatsa Vaddagiri
2007-04-03 15:03 ` Oleg Nesterov
2007-04-03 17:18 ` Srivatsa Vaddagiri
2007-04-04 15:28 ` Oleg Nesterov
2007-04-04 17:49 ` Srivatsa Vaddagiri
2007-04-05 12:20 ` Oleg Nesterov
2007-04-12 2:22 ` Srivatsa Vaddagiri
2007-04-12 10:01 ` Gautham R Shenoy
2007-04-12 16:00 ` Oleg Nesterov
2007-04-13 9:46 ` Gautham R Shenoy
2007-04-02 5:42 ` [PATCH 8/8] Make kernel threads freezeable for cpu-hotplug Gautham R Shenoy
2007-04-02 6:16 ` [RFC] Cpu-hotplug: Using the Process Freezer (try2) Ingo Molnar
2007-04-02 9:28 ` Srivatsa Vaddagiri
2007-04-02 11:18 ` Ingo Molnar
2007-04-02 12:42 ` Srivatsa Vaddagiri
2007-04-02 14:16 ` Gautham R Shenoy
2007-04-02 18:56 ` Ingo Molnar
2007-04-03 12:56 ` Srivatsa Vaddagiri
2007-04-03 14:15 ` Gautham R Shenoy
2007-04-03 19:25 ` Rafael J. Wysocki
2007-04-04 3:15 ` Srivatsa Vaddagiri
2007-04-04 10:04 ` Ingo Molnar
2007-04-04 10:41 ` Gautham R Shenoy
2007-04-04 11:49 ` Ingo Molnar
2007-04-04 12:24 ` Gautham R Shenoy
2007-04-02 11:19 ` Gautham R Shenoy
2007-04-02 11:27 ` Ingo Molnar
2007-04-02 22:12 ` Rafael J. Wysocki
2007-04-02 13:22 ` Pavel Machek
2007-04-03 12:01 ` Gautham R Shenoy
2007-04-03 19:34 ` Rafael J. Wysocki
2007-04-03 20:24 ` Andrew Morton
2007-04-04 10:06 ` utrace merge Ingo Molnar
2007-04-04 10:36 ` Christoph Hellwig
2007-04-04 18:41 ` Andrew Morton
2007-04-03 14:01 ` [RFC] Cpu-hotplug: Using the Process Freezer (try2) Gautham R Shenoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070402054107.GF12962@in.ibm.com \
--to=ego@in.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=dino@in.ibm.com \
--cc=dipankar@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=paulmck@us.ibm.com \
--cc=rjw@sisk.pl \
--cc=torvalds@linux-foundation.org \
--cc=vatsa@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox