On 7/14/19 8:34 PM, Zhengyuan Liu wrote: > > On 7/14/19 5:43 AM, Jens Axboe wrote: >> On 7/12/19 9:58 PM, Zhengyuan Liu wrote: >>> sq->cached_sq_head and cq->cached_cq_tail are both unsigned int. >>> if cached_sq_head gets overflowed before cached_cq_tail, then we >>> may miss a barrier req. As cached_cq_tail moved always following >>> cached_sq_head, the NQ should be enough. >> This (and the previous patch) looks fine to me, just wondering if >> you had a test case showing this issue? >> > Hi. > > Actually I don't have a real test case, but I have emulated a test case > and showed the issue. > > Let's preset those count to close overflowed status at the begin: > > @@ -2979,6 +2987,10 @@ static int io_allocate_scq_urings(struct > io_ring_ctx *ctx, > cq_ring->ring_entries = p->cq_entries; > ctx->cq_mask = cq_ring->ring_mask; > ctx->cq_entries = cq_ring->ring_entries; > + > + ctx->cached_sq_head = ctx->sq_ring->r.head = > ctx->sq_ring->r.tail = 0xfffffff8; > + ctx->cached_cq_tail = ctx->cq_ring->r.head = > ctx->cq_ring->r.tail = 0xfffffff8 > + > return 0; > } > > And queue serveral sqes following a io_uring_enter like this: > > write1 write2 ... write8 barrier write9 write10 > > Then we can miss the barrier almost every time. No problem, just curious if you had a test case, since then I'd add it to the arsenal. I've applied this one, thank you. -- Jens Axboe