From: Jan Kara <jack@suse.cz>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-aio@kvack.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 8/8] aio: support for IO polling
Date: Thu, 22 Nov 2018 12:13:51 +0100 [thread overview]
Message-ID: <20181122111351.GD9840@quack2.suse.cz> (raw)
In-Reply-To: <20181120171953.1258-9-axboe@kernel.dk>
On Tue 20-11-18 10:19:53, Jens Axboe wrote:
> +/*
> + * We can't just wait for polled events to come to us, we have to actively
> + * find and complete them.
> + */
> +static void aio_iopoll_reap_events(struct kioctx *ctx)
> +{
> + if (!(ctx->flags & IOCTX_FLAG_IOPOLL))
> + return;
> +
> + while (!list_empty_careful(&ctx->poll_submitted) ||
> + !list_empty(&ctx->poll_completing)) {
> + unsigned int nr_events = 0;
> +
> + __aio_iopoll_check(ctx, NULL, &nr_events, 1, UINT_MAX);
> + }
> +}
> +
> +static int aio_iopoll_check(struct kioctx *ctx, long min_nr, long nr,
> + struct io_event __user *event)
> +{
> + unsigned int nr_events = 0;
> + int ret = 0;
> +
> + /* * Only allow one thread polling at a time */
> + if (test_and_set_bit(0, &ctx->getevents_busy))
> + return -EBUSY;
> +
> + while (!nr_events || !need_resched()) {
> + int tmin = 0;
> +
> + if (nr_events < min_nr)
> + tmin = min_nr - nr_events;
> +
> + ret = __aio_iopoll_check(ctx, event, &nr_events, tmin, nr);
> + if (ret <= 0)
> + break;
> + ret = 0;
> + }
> +
> + clear_bit(0, &ctx->getevents_busy);
> + return nr_events ? nr_events : ret;
> +}
Hum, what if userspace calls io_destroy() while another process is polling
for events on the same kioctx? It seems we'd be reaping events from two
processes in parallel in that case which will result in various
"interesting" effects like ctx->poll_completing list corruption...
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2018-11-22 11:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-20 17:19 [PATCHSET v2] Support for polled aio Jens Axboe
2018-11-20 17:19 ` [PATCH 1/8] fs: add file_operations ->iopoll() handler Jens Axboe
2018-11-20 17:19 ` [PATCH 2/8] block: wire up block device ->iopoll() Jens Axboe
2018-11-20 17:19 ` [PATCH 3/8] iomap/xfs: wire up file_operations ->iopoll() Jens Axboe
2018-11-21 9:15 ` Benny Halevy
2018-11-21 13:27 ` Jens Axboe
2018-11-20 17:19 ` [PATCH 4/8] aio: use assigned completion handler Jens Axboe
2018-11-20 17:19 ` [PATCH 5/8] aio: fix failure to put the file pointer Jens Axboe
2018-11-20 17:19 ` [PATCH 6/8] aio: add io_setup2() system call Jens Axboe
2018-11-20 17:19 ` [PATCH 7/8] aio: separate out ring reservation from req allocation Jens Axboe
2018-11-20 17:19 ` [PATCH 8/8] aio: support for IO polling Jens Axboe
2018-11-21 11:12 ` Benny Halevy
2018-11-21 13:26 ` Jens Axboe
2018-11-21 13:51 ` Benny Halevy
2018-11-22 11:13 ` Jan Kara [this message]
2018-11-22 21:01 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181122111351.GD9840@quack2.suse.cz \
--to=jack@suse.cz \
--cc=axboe@kernel.dk \
--cc=linux-aio@kvack.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.