io_uring: switch to atomic_t for io_kiocb reference count
authorJens Axboe <axboe@kernel.dk>
Wed, 24 Feb 2021 20:32:30 +0000 (13:32 -0700)
committerJens Axboe <axboe@kernel.dk>
Sun, 4 Apr 2021 21:27:19 +0000 (15:27 -0600)
commitdf8b62dbb7fdb258e63358b8651c49c67e5d4030
tree89dd793c856ca15c10f26b3825dd4ee629d42f86
parent70add487ddcee2c7bae08b43a1c0ef53574f34f7
io_uring: switch to atomic_t for io_kiocb reference count

io_uring manipulates references twice for each request, and hence is very
sensitive to performance of the reference count. This commit borrows a
trick from:

commit f958d7b528b1b40c44cfda5eabe2d82760d868c3
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Thu Apr 11 10:06:20 2019 -0700

    mm: make page ref count overflow check tighter and more explicit

and switches to atomic_t for references, while still retaining overflow
and underflow checks.

This is good for a 2-3% increase in peak IOPS on a single core. Before:

IOPS=2970879, IOS/call=31/31, inflight=128 (128)
IOPS=2952597, IOS/call=31/31, inflight=128 (128)
IOPS=2943904, IOS/call=31/31, inflight=128 (128)
IOPS=2930006, IOS/call=31/31, inflight=96 (96)

and after:

IOPS=3054354, IOS/call=31/31, inflight=128 (128)
IOPS=3059038, IOS/call=31/31, inflight=128 (128)
IOPS=3060320, IOS/call=31/31, inflight=128 (128)
IOPS=3068256, IOS/call=31/31, inflight=96 (96)

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c