On 5/27/21 10:51 PM, Noah Goldstein wrote: > On Mon, May 24, 2021 at 7:51 PM Pavel Begunkov <asml.silence@xxxxxxxxx> wrote: [...] >> >> - percpu_counter_add(¤t->io_uring->inflight, nr); >> - refcount_add(nr, ¤t->usage); >> + tctx = current->io_uring; >> + tctx->cached_refs -= nr; >> + if (unlikely(tctx->cached_refs < 0)) { >> + unsigned int refill = -tctx->cached_refs + IO_TCTX_REFS_CACHE_NR; > > Might be cleared to use: > > unsigned int refill = IO_TCTX_REFS_CACHE_NR - tctx->cached_refs; ======================================================================= Did think about it, but left as is to emphasize that it's negative and we convert it to positive, so all operations are with positive (and unsigned due to C rules). Code generation will be same. >> + >> + percpu_counter_add(&tctx->inflight, refill); >> + refcount_add(refill, ¤t->usage); >> + tctx->cached_refs += refill; >> + } >> io_submit_state_start(&ctx->submit_state, nr); >> -- Pavel Begunkov