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>
Mon, 22 Mar 2021 13:42:47 +0000 (07:42 -0600)
commitb99623f84b6ab9a368761130d421f9ef2171c10b
treefad294e1a38f1c083a370821fa492fc415ab9e69
parent7dc619bca1b6017c436126a85bce6b2a58ce1c7b
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