Skip to content

Commit 2839ab7

Browse files
thejhaxboe
authored andcommitted
io_uring/rsrc: Move lockdep assert from io_free_rsrc_node() to caller
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]> Link: https://lore.kernel.org/r/20250120-uring-lockdep-assert-earlier-v1-1-68d8e071a4bb@google.com Signed-off-by: Jens Axboe <[email protected]>
1 parent b73de0d commit 2839ab7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

io_uring/rsrc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,6 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
444444

445445
void io_free_rsrc_node(struct io_ring_ctx *ctx, struct io_rsrc_node *node)
446446
{
447-
lockdep_assert_held(&ctx->uring_lock);
448-
449447
if (node->tag)
450448
io_post_aux_cqe(ctx, node->tag, 0, 0);
451449

io_uring/rsrc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#ifndef IOU_RSRC_H
33
#define IOU_RSRC_H
44

5+
#include <linux/lockdep.h>
6+
57
#define IO_NODE_ALLOC_CACHE_MAX 32
68

79
#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
8082

8183
static inline void io_put_rsrc_node(struct io_ring_ctx *ctx, struct io_rsrc_node *node)
8284
{
85+
lockdep_assert_held(&ctx->uring_lock);
8386
if (node && !--node->refs)
8487
io_free_rsrc_node(ctx, node);
8588
}

0 commit comments

Comments
 (0)