[PATCH 6.1 078/473] io_uring: dont use TIF_NOTIFY_SIGNAL to test for availability of task_work

Greg Kroah-Hartman
2024-06-06T14:13:20Z

From: Jens Axboe <axboe@kernel.dk>

[ Upstream commit 6434ec0186b80c734aa7a2acf95f75f5c6dd943b ]

Use task_work_pending() as a better test for whether we have task_work
or not, TIF_NOTIFY_SIGNAL is only valid if the any of the task_work
items had been queued with TWA_SIGNAL as the notification mechanism.
Hence task_work_pending() is a more reliable check.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: 22537c9f7941 ("io_uring: use the right type for work_llist empty check")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
io_uring/io_uring.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
index 59e6f755f12c6..9e74f7968e059 100644
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -275,8 +275,7 @@ static inline int io_run_task_work(void)

static inline bool io_task_work_pending(struct io_ring_ctx *ctx)
{
- return test_thread_flag(TIF_NOTIFY_SIGNAL) ||
- !wq_list_empty(&ctx->work_llist);
+ return task_work_pending(current) || !wq_list_empty(&ctx->work_llist);
}

static inline int io_run_task_work_ctx(struct io_ring_ctx *ctx)
--
2.43.0