On 5/15/19 12:47 AM, JackieLiu wrote: > Hello Jens Axboe > > Could we replace ctx->sq_mask/ctx->cq_mask with cq_ring->ring_mask > /sq_ring->ring_mask ? because it’s a constant and never change in > io_uring.c > > I found that ctx->sq_mask just used on > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/io_uring.c?h=v5.1#n1831 > > and we can replace like follow: > > - head = READ_ONCE(ring->array[head & ctx->sq_mask]); > + head = READ_ONCE(ring->array[head & ring->ring_mask]); > > If I understand incorrectly, please point out. We could, but we cache it in the kernel since the ring value could potentially be modified by the application. -- Jens Axboe