[PATCH 1/3] tracehook: Add a return value to tracehook_notify_signal

From: Olivier Langlois
Date: Sun Aug 22 2021 - 17:06:01 EST


The return value indicates if task_work_run has been called.
This knowledge can be of value to the caller. In particular, it allows
io_uring to easily replace calls to io_run_task_work with
tracehook_notify_signal when clearing TIF_NOTIFY_SIGNAL is needed.

Signed-off-by: Olivier Langlois <olivier@xxxxxxxxxxxxxx>
---
include/linux/tracehook.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index 3e80c4bc66f7..1f778ed9c6e2 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -204,12 +204,16 @@ static inline void tracehook_notify_resume(struct pt_regs *regs)
* is currently used by TWA_SIGNAL based task_work, which requires breaking
* wait loops to ensure that task_work is noticed and run.
*/
-static inline void tracehook_notify_signal(void)
+static inline bool tracehook_notify_signal(void)
{
+ bool ret;
+
clear_thread_flag(TIF_NOTIFY_SIGNAL);
smp_mb__after_atomic();
- if (current->task_works)
+ ret = current->task_works;
+ if (ret)
task_work_run();
+ return ret;
}

/*
--
2.32.0