remove redundant kioctx->users ref count
PATCH 1/1 remove redundant kioctx->users ref count
In the ioctx destroy path, both exit_aio and io_destroy calls wait_for_all_aios(). And in that function, it won't return until there are no outstanding kiocb, tracked by ctx->reqs_active. So the ref counting on kioctx for every individual kiocb is overly excessive. We know we won't perform last put_ioctx when releasing Kiocb. This should clear out the cache line conflict mentioned in earlier post.
fs/aio.c +1 -8
@@ -423,7 +422,6 @@ static struct kiocb fastcall *__aio_get_ ring =kmap_atomic (ctx->ring_info.ring_pages[0 ],KM_USER0 );if (ctx->reqs_active <aio_ring_avail (&ctx->ring_info, ring)) {list_add (&req->ki_list, &ctx->active_reqs); -get_ioctx (ctx); ctx->reqs_active++; okay =1 ; }
@@ -534,8 +532,6 @@ int fastcall aio_put_req(struct kiocb *rspin_lock_irq (&ctx->ctx_lock); ret =__aio_put_req (ctx, req);spin_unlock_irq (&ctx->ctx_lock); -if (ret) -put_ioctx (ctx);return ret; }
@@ -791,8 +787,7 @@ static int __aio_run_iocbs(struct kioctx*/ iocb->ki_users++;/* grab extra reference */ aio_run_iocb (iocb); -if (__aio_put_req (ctx, iocb))/* drop extra ref */ -put_ioctx (ctx); +__aio_put_req (ctx, iocb); }if (!list_empty (&ctx->run_list))return 1 ;
@@ -1015,9 +1010,6 @@ put_rq:if (waitqueue_active (&ctx->wait))wake_up (&ctx->wait); -if (ret) -put_ioctx (ctx); -return ret; }
Benjamin LaHaise
maintainerfs/aio.c put_rq: · line 1014
Quoted 9 lines · Kenneth W
fs/aio.c +0
-3@@ -1015,9 +1010,6 @@ put_rq:if (waitqueue_active (&ctx->wait))wake_up (&ctx->wait); -if (ret) -put_ioctx (ctx); -return ret; }
This part makes me worry -- at this point we no longer have anything pinning the ioctx, yet we touch ->wait after dropping the lock. The only way around this is if rcu is introduced in the final free of an ioctx to ensure the structure remains around for a sufficient grace period.
-ben
Signature · 2 lines
"Time is of no importance, Mr. President, only life is important." Don't Email: <[email protected]>.