* [PATCH] io_uring/rsrc: Move lockdep assert from io_free_rsrc_node() to caller
@ 2025-01-20 16:21 Jann Horn
2025-01-20 18:07 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Jann Horn @ 2025-01-20 16:21 UTC (permalink / raw)
To: Jens Axboe, Pavel Begunkov; +Cc: io-uring, linux-kernel, Jann Horn
Checking for lockdep_assert_held(&ctx->uring_lock) in io_free_rsrc_node()
means that the assertion is only checked when the resource drops to zero
references.
Move the lockdep assertion up into the caller io_put_rsrc_node() so that it
instead happens on every reference count decrement.
Signed-off-by: Jann Horn <[email protected]>
---
io_uring/rsrc.c | 2 --
io_uring/rsrc.h | 3 +++
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index a5fc035af8ff910d423930d7c662cc0e1a9f8444..af39b69eb4fde8b6e478e71c36dc04d3eec1b6d1 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -444,8 +444,6 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
void io_free_rsrc_node(struct io_ring_ctx *ctx, struct io_rsrc_node *node)
{
- lockdep_assert_held(&ctx->uring_lock);
-
if (node->tag)
io_post_aux_cqe(ctx, node->tag, 0, 0);
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 5cd00b7baef8b03dd5f4a3aacee859b37db98e9b..190f7ee45de933b39a8c4d33dc86f687e338eb16 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -2,6 +2,8 @@
#ifndef IOU_RSRC_H
#define IOU_RSRC_H
+#include <linux/lockdep.h>
+
#define IO_NODE_ALLOC_CACHE_MAX 32
#define IO_RSRC_TAG_TABLE_SHIFT (PAGE_SHIFT - 3)
@@ -80,6 +82,7 @@ static inline struct io_rsrc_node *io_rsrc_node_lookup(struct io_rsrc_data *data
static inline void io_put_rsrc_node(struct io_ring_ctx *ctx, struct io_rsrc_node *node)
{
+ lockdep_assert_held(&ctx->uring_lock);
if (node && !--node->refs)
io_free_rsrc_node(ctx, node);
}
---
base-commit: e8153972dea537f1ae3ac45355fe3b2b3cbf59bf
change-id: 20250120-uring-lockdep-assert-earlier-264e039fafe5
--
Jann Horn <[email protected]>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] io_uring/rsrc: Move lockdep assert from io_free_rsrc_node() to caller
2025-01-20 16:21 [PATCH] io_uring/rsrc: Move lockdep assert from io_free_rsrc_node() to caller Jann Horn
@ 2025-01-20 18:07 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2025-01-20 18:07 UTC (permalink / raw)
To: Pavel Begunkov, Jann Horn; +Cc: io-uring, linux-kernel
On Mon, 20 Jan 2025 17:21:57 +0100, Jann Horn wrote:
> Checking for lockdep_assert_held(&ctx->uring_lock) in io_free_rsrc_node()
> means that the assertion is only checked when the resource drops to zero
> references.
> Move the lockdep assertion up into the caller io_put_rsrc_node() so that it
> instead happens on every reference count decrement.
>
>
> [...]
Applied, thanks!
[1/1] io_uring/rsrc: Move lockdep assert from io_free_rsrc_node() to caller
commit: 8c4b2fd5908d2260dfac8d4b74aae1bb5deea379
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-20 18:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-20 16:21 [PATCH] io_uring/rsrc: Move lockdep assert from io_free_rsrc_node() to caller Jann Horn
2025-01-20 18:07 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox