diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2008-10-13 17:50:09 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-10-21 19:00:25 -0400 |
commit | 0d557dc97f4bb501f086a03d0f00b99a7855d794 (patch) | |
tree | be717fc70de4fc76f48cf4f4f3cebc3b8569d798 | |
parent | a802dd0eb5fc97a50cf1abb1f788a8f6cc5db635 (diff) |
workqueue: introduce create_rt_workqueue
create_rt_workqueue will create a real time prioritized workqueue.
This is needed for the conversion of stop_machine to a workqueue based
implementation.
This patch adds yet another parameter to __create_workqueue_key to tell
it that we want an rt workqueue.
However it looks like we rather should have something like "int type"
instead of singlethread, freezable and rt.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | include/linux/workqueue.h | 18 | ||||
-rw-r--r-- | kernel/workqueue.c | 7 |
2 files changed, 16 insertions, 9 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 5c158c477ac7..89a5a1231ffb 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h | |||
@@ -149,11 +149,11 @@ struct execute_work { | |||
149 | 149 | ||
150 | extern struct workqueue_struct * | 150 | extern struct workqueue_struct * |
151 | __create_workqueue_key(const char *name, int singlethread, | 151 | __create_workqueue_key(const char *name, int singlethread, |
152 | int freezeable, struct lock_class_key *key, | 152 | int freezeable, int rt, struct lock_class_key *key, |
153 | const char *lock_name); | 153 | const char *lock_name); |
154 | 154 | ||
155 | #ifdef CONFIG_LOCKDEP | 155 | #ifdef CONFIG_LOCKDEP |
156 | #define __create_workqueue(name, singlethread, freezeable) \ | 156 | #define __create_workqueue(name, singlethread, freezeable, rt) \ |
157 | ({ \ | 157 | ({ \ |
158 | static struct lock_class_key __key; \ | 158 | static struct lock_class_key __key; \ |
159 | const char *__lock_name; \ | 159 | const char *__lock_name; \ |
@@ -164,17 +164,19 @@ __create_workqueue_key(const char *name, int singlethread, | |||
164 | __lock_name = #name; \ | 164 | __lock_name = #name; \ |
165 | \ | 165 | \ |
166 | __create_workqueue_key((name), (singlethread), \ | 166 | __create_workqueue_key((name), (singlethread), \ |
167 | (freezeable), &__key, \ | 167 | (freezeable), (rt), &__key, \ |
168 | __lock_name); \ | 168 | __lock_name); \ |
169 | }) | 169 | }) |
170 | #else | 170 | #else |
171 | #define __create_workqueue(name, singlethread, freezeable) \ | 171 | #define __create_workqueue(name, singlethread, freezeable, rt) \ |
172 | __create_workqueue_key((name), (singlethread), (freezeable), NULL, NULL) | 172 | __create_workqueue_key((name), (singlethread), (freezeable), (rt), \ |
173 | NULL, NULL) | ||
173 | #endif | 174 | #endif |
174 | 175 | ||
175 | #define create_workqueue(name) __create_workqueue((name), 0, 0) | 176 | #define create_workqueue(name) __create_workqueue((name), 0, 0, 0) |
176 | #define create_freezeable_workqueue(name) __create_workqueue((name), 1, 1) | 177 | #define create_rt_workqueue(name) __create_workqueue((name), 0, 0, 1) |
177 | #define create_singlethread_workqueue(name) __create_workqueue((name), 1, 0) | 178 | #define create_freezeable_workqueue(name) __create_workqueue((name), 1, 1, 0) |
179 | #define create_singlethread_workqueue(name) __create_workqueue((name), 1, 0, 0) | ||
178 | 180 | ||
179 | extern void destroy_workqueue(struct workqueue_struct *wq); | 181 | extern void destroy_workqueue(struct workqueue_struct *wq); |
180 | 182 | ||
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 714afad46539..f928f2a87b9b 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -62,6 +62,7 @@ struct workqueue_struct { | |||
62 | const char *name; | 62 | const char *name; |
63 | int singlethread; | 63 | int singlethread; |
64 | int freezeable; /* Freeze threads during suspend */ | 64 | int freezeable; /* Freeze threads during suspend */ |
65 | int rt; | ||
65 | #ifdef CONFIG_LOCKDEP | 66 | #ifdef CONFIG_LOCKDEP |
66 | struct lockdep_map lockdep_map; | 67 | struct lockdep_map lockdep_map; |
67 | #endif | 68 | #endif |
@@ -766,6 +767,7 @@ init_cpu_workqueue(struct workqueue_struct *wq, int cpu) | |||
766 | 767 | ||
767 | static int create_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu) | 768 | static int create_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu) |
768 | { | 769 | { |
770 | struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; | ||
769 | struct workqueue_struct *wq = cwq->wq; | 771 | struct workqueue_struct *wq = cwq->wq; |
770 | const char *fmt = is_single_threaded(wq) ? "%s" : "%s/%d"; | 772 | const char *fmt = is_single_threaded(wq) ? "%s" : "%s/%d"; |
771 | struct task_struct *p; | 773 | struct task_struct *p; |
@@ -781,7 +783,8 @@ static int create_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu) | |||
781 | */ | 783 | */ |
782 | if (IS_ERR(p)) | 784 | if (IS_ERR(p)) |
783 | return PTR_ERR(p); | 785 | return PTR_ERR(p); |
784 | 786 | if (cwq->wq->rt) | |
787 | sched_setscheduler_nocheck(p, SCHED_FIFO, ¶m); | ||
785 | cwq->thread = p; | 788 | cwq->thread = p; |
786 | 789 | ||
787 | return 0; | 790 | return 0; |
@@ -801,6 +804,7 @@ static void start_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu) | |||
801 | struct workqueue_struct *__create_workqueue_key(const char *name, | 804 | struct workqueue_struct *__create_workqueue_key(const char *name, |
802 | int singlethread, | 805 | int singlethread, |
803 | int freezeable, | 806 | int freezeable, |
807 | int rt, | ||
804 | struct lock_class_key *key, | 808 | struct lock_class_key *key, |
805 | const char *lock_name) | 809 | const char *lock_name) |
806 | { | 810 | { |
@@ -822,6 +826,7 @@ struct workqueue_struct *__create_workqueue_key(const char *name, | |||
822 | lockdep_init_map(&wq->lockdep_map, lock_name, key, 0); | 826 | lockdep_init_map(&wq->lockdep_map, lock_name, key, 0); |
823 | wq->singlethread = singlethread; | 827 | wq->singlethread = singlethread; |
824 | wq->freezeable = freezeable; | 828 | wq->freezeable = freezeable; |
829 | wq->rt = rt; | ||
825 | INIT_LIST_HEAD(&wq->list); | 830 | INIT_LIST_HEAD(&wq->list); |
826 | 831 | ||
827 | if (singlethread) { | 832 | if (singlethread) { |