From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [RFC 06/11] task_work: add helper for signalling a task
Date: Thu, 21 Apr 2022 14:44:19 +0100 [thread overview]
Message-ID: <12c006fc159c885a44e8b773b14b3c935ff8abb7.1650548192.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Extract a task_work_notify() helper from task_work_add(), so we can use
it in the future.
Signed-off-by: Pavel Begunkov <[email protected]>
---
include/linux/task_work.h | 3 +++
kernel/task_work.c | 33 +++++++++++++++++++--------------
2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/include/linux/task_work.h b/include/linux/task_work.h
index 897494b597ba..0c5fc557ecd9 100644
--- a/include/linux/task_work.h
+++ b/include/linux/task_work.h
@@ -27,6 +27,9 @@ static inline bool task_work_pending(struct task_struct *task)
int task_work_add(struct task_struct *task, struct callback_head *twork,
enum task_work_notify_mode mode);
+void task_work_notify(struct task_struct *task,
+ enum task_work_notify_mode notify);
+
struct callback_head *task_work_cancel_match(struct task_struct *task,
bool (*match)(struct callback_head *, void *data), void *data);
struct callback_head *task_work_cancel(struct task_struct *, task_work_func_t);
diff --git a/kernel/task_work.c b/kernel/task_work.c
index c59e1a49bc40..cce8a7ca228f 100644
--- a/kernel/task_work.c
+++ b/kernel/task_work.c
@@ -5,6 +5,24 @@
static struct callback_head work_exited; /* all we need is ->next == NULL */
+void task_work_notify(struct task_struct *task,
+ enum task_work_notify_mode notify)
+{
+ switch (notify) {
+ case TWA_NONE:
+ break;
+ case TWA_RESUME:
+ set_notify_resume(task);
+ break;
+ case TWA_SIGNAL:
+ set_notify_signal(task);
+ break;
+ default:
+ WARN_ON_ONCE(1);
+ break;
+ }
+}
+
/**
* task_work_add - ask the @task to execute @work->func()
* @task: the task which should run the callback
@@ -44,20 +62,7 @@ int task_work_add(struct task_struct *task, struct callback_head *work,
work->next = head;
} while (cmpxchg(&task->task_works, head, work) != head);
- switch (notify) {
- case TWA_NONE:
- break;
- case TWA_RESUME:
- set_notify_resume(task);
- break;
- case TWA_SIGNAL:
- set_notify_signal(task);
- break;
- default:
- WARN_ON_ONCE(1);
- break;
- }
-
+ task_work_notify(task, notify);
return 0;
}
--
2.36.0
next prev parent reply other threads:[~2022-04-21 13:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-21 13:44 [RFC 00/11] io_uring specific task_work infra Pavel Begunkov
2022-04-21 13:44 ` [RFC 01/11] io_uring: optimise io_req_task_work_add Pavel Begunkov
2022-04-21 13:44 ` [RFC 02/11] io_uringg: add io_should_fail_tw() helper Pavel Begunkov
2022-04-21 13:44 ` [RFC 03/11] io_uring: ban tw queue for exiting processes Pavel Begunkov
2022-04-21 13:44 ` [RFC 04/11] io_uring: don't take ctx refs in tctx_task_work() Pavel Begunkov
2022-04-21 13:44 ` [RFC 05/11] io_uring: add dummy io_uring_task_work_run() Pavel Begunkov
2022-04-21 13:44 ` Pavel Begunkov [this message]
2022-04-21 13:44 ` [RFC 07/11] io_uring: run io_uring task_works on TIF_NOTIFY_SIGNAL Pavel Begunkov
2022-04-21 13:44 ` [RFC 08/11] io_uring: wire io_uring specific task work Pavel Begunkov
2022-04-21 13:44 ` [RFC 09/11] io_uring: refactor io_run_task_work() Pavel Begunkov
2022-04-21 13:44 ` [RFC 10/11] io_uring: remove priority tw list Pavel Begunkov
2022-04-21 13:44 ` [RFC 11/11] io_uring: lock-free task_work stack Pavel Begunkov
2022-04-21 14:50 ` [RFC 00/11] io_uring specific task_work infra Pavel Begunkov
2022-04-22 8:45 ` Hao Xu
2022-04-22 11:54 ` Pavel Begunkov
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=12c006fc159c885a44e8b773b14b3c935ff8abb7.1650548192.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/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