From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [RFC 07/11] io_uring: run io_uring task_works on TIF_NOTIFY_SIGNAL
Date: Thu, 21 Apr 2022 14:44:20 +0100 [thread overview]
Message-ID: <c312834681e9a60c847cbc189a35bd8382e8f4db.1650548192.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Now TIF_NOTIFY_SIGNAL can mean not only normal task_work but also
io_uring specific task requests. Make sure to run them when needed.
TODO: add hot path when not having io_uring tw items
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io-wq.c | 1 +
fs/io_uring.c | 1 +
include/linux/task_work.h | 1 +
kernel/entry/kvm.c | 1 +
kernel/signal.c | 2 ++
5 files changed, 6 insertions(+)
diff --git a/fs/io-wq.c b/fs/io-wq.c
index 32aeb2c581c5..35d8c2b46699 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -523,6 +523,7 @@ static bool io_flush_signals(void)
if (unlikely(test_thread_flag(TIF_NOTIFY_SIGNAL))) {
__set_current_state(TASK_RUNNING);
clear_notify_signal();
+ io_uring_task_work_run();
if (task_work_pending(current))
task_work_run();
return true;
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 8d5aff1ecb4c..22dcd2fb9687 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2798,6 +2798,7 @@ static inline bool io_run_task_work(void)
if (test_thread_flag(TIF_NOTIFY_SIGNAL) || task_work_pending(current)) {
__set_current_state(TASK_RUNNING);
clear_notify_signal();
+ io_uring_task_work_run();
if (task_work_pending(current))
task_work_run();
return true;
diff --git a/include/linux/task_work.h b/include/linux/task_work.h
index 0c5fc557ecd9..66852f4a2ca0 100644
--- a/include/linux/task_work.h
+++ b/include/linux/task_work.h
@@ -4,6 +4,7 @@
#include <linux/list.h>
#include <linux/sched.h>
+#include <linux/io_uring.h>
typedef void (*task_work_func_t)(struct callback_head *);
diff --git a/kernel/entry/kvm.c b/kernel/entry/kvm.c
index 9d09f489b60e..46d7d23d3cc6 100644
--- a/kernel/entry/kvm.c
+++ b/kernel/entry/kvm.c
@@ -10,6 +10,7 @@ static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work)
if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) {
clear_notify_signal();
+ io_uring_task_work_run();
if (task_work_pending(current))
task_work_run();
}
diff --git a/kernel/signal.c b/kernel/signal.c
index 30cd1ca43bcd..8d46c4b63204 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2357,6 +2357,7 @@ int ptrace_notify(int exit_code, unsigned long message)
int signr;
BUG_ON((exit_code & (0x7f | ~0xffff)) != SIGTRAP);
+ io_uring_task_work_run();
if (unlikely(task_work_pending(current)))
task_work_run();
@@ -2637,6 +2638,7 @@ bool get_signal(struct ksignal *ksig)
int signr;
clear_notify_signal();
+ io_uring_task_work_run();
if (unlikely(task_work_pending(current)))
task_work_run();
--
2.36.0
next prev parent reply other threads:[~2022-04-21 13:45 UTC|newest]
Thread overview: 14+ 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 ` [RFC 06/11] task_work: add helper for signalling a task Pavel Begunkov
2022-04-21 13:44 ` Pavel Begunkov [this message]
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
[not found] ` <[email protected]>
2022-04-22 8:45 ` [RFC 00/11] io_uring specific task_work infra 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=c312834681e9a60c847cbc189a35bd8382e8f4db.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