Thread (2 messages) 2 messages, 2 authors, 2021-08-07

Re: [RFC PATCH v2 04/10] perf workqueue: add threadpool execute and wait functions

From: Namhyung Kim <namhyung@kernel.org>
Date: 2021-08-07 02:56:28
Also in: lkml

On Fri, Jul 30, 2021 at 8:34 AM Riccardo Mancini [off-list ref] wrote:
This patch adds:
 - threadpool__execute: assigns a task to the threads to execute
   asynchronously.
 - threadpool__wait: waits for the task to complete on all threads.
Furthermore, testing for these new functions is added.

This patch completes the threadpool.

Signed-off-by: Riccardo Mancini <redacted>
---
[SNIP]
+/**
+ * threadpool__wake_thread - send wake msg to @thread
+ *
+ * This function does not wait for the thread to actually wake
+ * NB: call only from main thread!
+ */
+static int threadpool__wake_thread(struct threadpool_entry *thread)
Same here.  You can pass pool and idx instead.

Thanks,
Namhyung

+{
+       int res;
+       enum threadpool_msg msg = THREADPOOL_MSG__WAKE;
+
+       res = writen(thread->pipes.cmd[1], &msg, sizeof(msg));
+       if (res < 0) {
+               pr_debug2("threadpool: error sending wake msg: %s\n", strerror(errno));
+               return -THREADPOOL_ERROR__WRITEPIPE;
+       }
+
+       pr_debug2("threadpool: sent wake msg %s to tid=%d\n",
+               threadpool_msg_tags[msg], thread->tid);
+       return 0;
+}
+
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help