Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a79d40e9 authored by Jens Axboe's avatar Jens Axboe
Browse files

aio: only use blk plugs for > 2 depth submissions



Plugging is meant to optimize submission of a string of IOs, if we don't
have more than 2 being submitted, don't bother setting up a plug.

Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 2bc4ca9b
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -70,6 +70,12 @@ struct aio_ring {
	struct io_event		io_events[0];
}; /* 128 bytes + ring size */

/*
 * Plugging is meant to work with larger batches of IOs. If we don't
 * have more than the below, then don't bother setting up a plug.
 */
#define AIO_PLUG_THRESHOLD	2

#define AIO_RING_PAGES	8

struct kioctx_table {
@@ -1921,6 +1927,7 @@ SYSCALL_DEFINE3(io_submit, aio_context_t, ctx_id, long, nr,
	if (nr > ctx->nr_events)
		nr = ctx->nr_events;

	if (nr > AIO_PLUG_THRESHOLD)
		blk_start_plug(&plug);
	for (i = 0; i < nr; i++) {
		struct iocb __user *user_iocb;
@@ -1934,6 +1941,7 @@ SYSCALL_DEFINE3(io_submit, aio_context_t, ctx_id, long, nr,
		if (ret)
			break;
	}
	if (nr > AIO_PLUG_THRESHOLD)
		blk_finish_plug(&plug);

	percpu_ref_put(&ctx->users);
@@ -1961,6 +1969,7 @@ COMPAT_SYSCALL_DEFINE3(io_submit, compat_aio_context_t, ctx_id,
	if (nr > ctx->nr_events)
		nr = ctx->nr_events;

	if (nr > AIO_PLUG_THRESHOLD)
		blk_start_plug(&plug);
	for (i = 0; i < nr; i++) {
		compat_uptr_t user_iocb;
@@ -1974,6 +1983,7 @@ COMPAT_SYSCALL_DEFINE3(io_submit, compat_aio_context_t, ctx_id,
		if (ret)
			break;
	}
	if (nr > AIO_PLUG_THRESHOLD)
		blk_finish_plug(&plug);

	percpu_ref_put(&ctx->users);