[sheepdog] [PATCH 1/2] work: allow worker threads to call suspend_worker_threads()
MORITA Kazutaka
morita.kazutaka at gmail.com
Fri Aug 30 16:14:52 CEST 2013
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
With this patch, if we call suspend_worker_threads() in a worker
thread, the function suspends the other worker threads and the main
thread.
This prepares for the next patch.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
lib/work.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/work.c b/lib/work.c
index 6933e1a..f19e315 100644
--- a/lib/work.c
+++ b/lib/work.c
@@ -165,6 +165,8 @@ void suspend_worker_threads(void)
}
FOR_EACH_BIT(tid, tid_map, tid_max) {
+ if (tid == gettid())
+ continue;
if (unlikely(tkill(tid, SIGUSR2) < 0))
panic("%m");
}
@@ -175,6 +177,8 @@ void suspend_worker_threads(void)
* yet (then, the thread doesn't recieve SIGUSR2).
*/
FOR_EACH_BIT(tid, tid_map, tid_max) {
+ if (tid == gettid())
+ continue;
eventfd_xread(ack_efd);
}
}
@@ -185,6 +189,8 @@ void resume_worker_threads(void)
int nr_threads = 0, tid;
FOR_EACH_BIT(tid, tid_map, tid_max) {
+ if (tid == gettid())
+ continue;
nr_threads++;
}
@@ -323,6 +329,7 @@ int init_work_queue(size_t (*get_nr_nodes)(void))
tid_max = TID_MAX_DEFAULT;
tid_map = alloc_bitmap(NULL, 0, tid_max);
+ set_bit(getpid(), tid_map);
resume_efd = eventfd(0, EFD_SEMAPHORE);
ack_efd = eventfd(0, EFD_SEMAPHORE);
--
1.7.9.5
More information about the sheepdog
mailing list