Skip to contentSkip to conversation

io_uring: don't hold fixed_file_data's lock when registering files

PATCH In review Xiaoguang Wang 2 participants 4 messages Sep 2, 2020 – Sep 3, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring: don't hold fixed_file_data's lock when registering files

While registering new files by IORING_REGISTER_FILES, there're not valid fixed_file_ref_node at the moment, so it's unnecessary to hold fixed_file_data's lock when registering files.

---
 fs/io_uring.c | 2 --
 1 file changed, 2 deletions(-)
fs/io_uring.c +0 -2
index 186072861af9..75841f3cb2f7 100644
@@ -7257,9 +7257,7 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
 	}
 
 	ctx->file_data->cur_refs = &ref_node->refs;
-	spin_lock(&ctx->file_data->lock);
 	list_add(&ref_node->node, &ctx->file_data->ref_list);
-	spin_unlock(&ctx->file_data->lock);
 	percpu_ref_get(&ctx->file_data->refs);
 	return ret;
 }
Signature · 1 line
2.17.2
maintainer
#1 lore raw
Quoted 3 lines · Xiaoguang Wang

While registering new files by IORING_REGISTER_FILES, there're not valid fixed_file_ref_node at the moment, so it's unnecessary to hold fixed_file_data's lock when registering files.

Even if that were the case (I haven't looked too closely at it yet), it would a) need a big comment explaining why, and b) some justification on why this would be a change we'd want to make.

On b, are you seeing any tangible differences with this?

Signature · 1 line
Jens Axboe
#2 lore raw

hi,

Quoted 10 lines · Xiaoguang Wang
Quoted 3 lines

While registering new files by IORING_REGISTER_FILES, there're not valid fixed_file_ref_node at the moment, so it's unnecessary to hold fixed_file_data's lock when registering files.

Even if that were the case (I haven't looked too closely at it yet), it would a) need a big comment explaining why, and b) some justification on why this would be a change we'd want to make.

On b, are you seeing any tangible differences with this?

No, just found this by reading source codes.

Regards,
Xiaoguang Wang

Quoted 1 line
maintainer
#3 lore raw
Quoted 7 lines · Xiaoguang Wang

hi,

Quoted 5 lines · Xiaoguang Wang
Quoted 3 lines

While registering new files by IORING_REGISTER_FILES, there're not valid fixed_file_ref_node at the moment, so it's unnecessary to hold fixed_file_data's lock when registering files.

Quoted 6 lines
Quoted 5 lines

Even if that were the case (I haven't looked too closely at it yet), it would a) need a big comment explaining why, and b) some justification on why this would be a change we'd want to make.

On b, are you seeing any tangible differences with this?

No, just found this by reading source codes.

OK, then I suggest we leave it as it is. The data race analyzers wouldn't be very happy with it either.

Signature · 1 line
Jens Axboe