qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Keith Busch <keith.busch@intel.com>,
	qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	Max Reitz <mreitz@redhat.com>, Eric Blake <eblake@redhat.com>,
	alex.williamson@redhat.com, Markus Armbruster <armbru@redhat.com>,
	Karl Rister <krister@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v5 3/9] block: Add VFIO based NVMe driver
Date: Fri, 12 Jan 2018 09:44:29 +0000	[thread overview]
Message-ID: <20180112094429.GA7356@stefanha-x1.localdomain> (raw)
In-Reply-To: <20180112085555.14447-4-famz@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1831 bytes --]

On Fri, Jan 12, 2018 at 04:55:49PM +0800, Fam Zheng wrote:
> +    if (progress) {
> +        /* Notify the device so it can post more completions. */
> +        smp_mb_release();
> +        *q->cq.doorbell = cpu_to_le32(q->cq.head);
> +        if (!qemu_co_queue_empty(&q->free_req_queue)) {
> +            aio_bh_schedule_oneshot(s->aio_context, nvme_free_req_queue_cb, q);
> +        }

This is not thread-safe because the queue producer does:

1   qemu_mutex_unlock(&q->lock);
2   qemu_co_queue_wait(&q->free_req_queue, NULL);
3   qemu_mutex_lock(&q->lock);

We fail to call nvme_free_req_queue_cb() when if
(!qemu_co_queue_empty(&q->free_req_queue)) runs after 1 but before 2.

This is only an issue if one thread runs the queue producer and another
runs the consumer code.  I don't know if that will ever be the case,
even with multiqueue, but I wanted to point this out so you and Paolo
can decide.

> +static int nvme_file_open(BlockDriverState *bs, QDict *options, int flags,
> +                          Error **errp)
> +{
> +    const char *device;
> +    QemuOpts *opts;
> +    int namespace;
> +
> +    opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
> +    qemu_opts_absorb_qdict(opts, options, &error_abort);
> +    device = qemu_opt_get(opts, NVME_BLOCK_OPT_DEVICE);
> +    if (!device) {
> +        error_setg(errp, "'" NVME_BLOCK_OPT_DEVICE "' option is required");
> +        qemu_opts_del(opts);
> +        return -EINVAL;
> +    }
> +
> +    namespace = qemu_opt_get_number(opts, NVME_BLOCK_OPT_NAMESPACE, 1);
> +    nvme_init(bs, device, namespace, errp);
> +
> +    qemu_opts_del(opts);
> +    bs->supported_write_flags = BDRV_REQ_FUA;
> +    if (nvme_enable_disable_write_cache(bs, !(flags & BDRV_O_NOCACHE), errp)) {
> +        return -EINVAL;

Everything allocated in nvme_init() is leaked.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2018-01-12  9:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12  8:55 [Qemu-devel] [PATCH v5 0/9] block: Add VFIO based driver for NVMe device Fam Zheng
2018-01-12  8:55 ` [Qemu-devel] [PATCH v5 1/9] stubs: Add stubs for ram block API Fam Zheng
2018-01-12  8:55 ` [Qemu-devel] [PATCH v5 2/9] util: Introduce vfio helpers Fam Zheng
2018-01-12  8:55 ` [Qemu-devel] [PATCH v5 3/9] block: Add VFIO based NVMe driver Fam Zheng
2018-01-12  9:44   ` Stefan Hajnoczi [this message]
2018-01-12 11:00     ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2018-01-12  8:55 ` [Qemu-devel] [PATCH v5 4/9] block: Introduce buf register API Fam Zheng
2018-01-12  8:55 ` [Qemu-devel] [PATCH v5 5/9] block/nvme: Implement .bdrv_(un)register_buf Fam Zheng
2018-01-12  8:55 ` [Qemu-devel] [PATCH v5 6/9] qemu-img: Map bench buffer Fam Zheng
2018-01-12  8:55 ` [Qemu-devel] [PATCH v5 7/9] block: Move NVMe constants to a separate header Fam Zheng
2018-01-12  8:55 ` [Qemu-devel] [PATCH v5 8/9] docs: Add section for NVMe VFIO driver Fam Zheng
2018-01-12  9:45   ` Stefan Hajnoczi
2018-01-12  8:55 ` [Qemu-devel] [PATCH v5 9/9] qapi: Add NVMe driver options to the schema Fam Zheng
2018-01-12  9:46 ` [Qemu-devel] [PATCH v5 0/9] block: Add VFIO based driver for NVMe device Stefan Hajnoczi

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=20180112094429.GA7356@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=keith.busch@intel.com \
    --cc=krister@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).