mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
io_uring/napi: clean up list traversal with list_for_each_entry_safe()
Switch both loops to the standard list_for_each_entry_safe() pattern and remove the explanatory comment. Signed-off-by: Anvik Loitongbam <permissiontogallop@gmail.com> Reviewed-by: Steven Rostedt <rostedt@goodmis.org> Link: https://patch.msgid.link/20261029144745.23792-1-permissiontogallop@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
3de16279b4
commit
e18504a4d3
|
|
@ -110,16 +110,10 @@ static int __io_napi_del_id(struct io_ring_ctx *ctx, unsigned int napi_id)
|
|||
|
||||
static void __io_napi_remove_stale(struct io_ring_ctx *ctx)
|
||||
{
|
||||
struct io_napi_entry *e;
|
||||
struct io_napi_entry *e, *next;
|
||||
|
||||
guard(spinlock)(&ctx->napi_lock);
|
||||
/*
|
||||
* list_for_each_entry_safe() is not required as long as:
|
||||
* 1. list_del_rcu() does not reset the deleted node next pointer
|
||||
* 2. kfree_rcu() delays the memory freeing until the next quiescent
|
||||
* state
|
||||
*/
|
||||
list_for_each_entry(e, &ctx->napi_list, list) {
|
||||
list_for_each_entry_safe(e, next, &ctx->napi_list, list) {
|
||||
if (time_after(jiffies, READ_ONCE(e->timeout))) {
|
||||
list_del_rcu(&e->list);
|
||||
hash_del_rcu(&e->node);
|
||||
|
|
@ -264,10 +258,10 @@ void io_napi_init(struct io_ring_ctx *ctx)
|
|||
*/
|
||||
void io_napi_free(struct io_ring_ctx *ctx)
|
||||
{
|
||||
struct io_napi_entry *e;
|
||||
struct io_napi_entry *e, *next;
|
||||
|
||||
guard(spinlock)(&ctx->napi_lock);
|
||||
list_for_each_entry(e, &ctx->napi_list, list) {
|
||||
list_for_each_entry_safe(e, next, &ctx->napi_list, list) {
|
||||
hash_del_rcu(&e->node);
|
||||
kfree_rcu(e, rcu);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user