From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Axboe Subject: Re: [PATCH 05/18] Add io_uring IO interface Date: Mon, 28 Jan 2019 18:31:04 -0700 Message-ID: <9170f97f-bea3-04b9-71db-a0f250d1f610@kernel.dk> References: <20190128213538.13486-1-axboe@kernel.dk> <20190128213538.13486-6-axboe@kernel.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Language: en-US Sender: owner-linux-aio@kvack.org To: Jann Horn Cc: linux-aio@kvack.org, linux-block@vger.kernel.org, linux-man , Linux API , hch@lst.de, jmoyer@redhat.com, Avi Kivity List-Id: linux-man@vger.kernel.org On 1/28/19 6:29 PM, Jann Horn wrote: > On Mon, Jan 28, 2019 at 10:35 PM Jens Axboe wrote: >> The submission queue (SQ) and completion queue (CQ) rings are shared >> between the application and the kernel. This eliminates the need to >> copy data back and forth to submit and complete IO. > [...] >> +static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx) >> +{ >> + struct io_kiocb *req; >> + >> + /* safe to use the non tryget, as we're inside ring ref already */ >> + percpu_ref_get(&ctx->refs); > > Is that true? In the path io_sq_thread() -> io_submit_sqes() -> > io_submit_sqe() -> io_get_req(), I don't see anything that's already > holding a reference for you. Is the worker thread holding a reference > somewhere that I'm missing? If the thread is alive, then the ctx is alive. Before we drop the last ref to the ctx (and kill it), we wait for the thread to exit. -- Jens Axboe -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to majordomo@kvack.org. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: aart@kvack.org