Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1317147/?format=api
{ "id": 1317147, "url": "http://patchwork.ozlabs.org/api/patches/1317147/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20200625184838.28172-16-philmd@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20200625184838.28172-16-philmd@redhat.com>", "list_archive_url": null, "date": "2020-06-25T18:48:36", "name": "[RFC,15/17] block/nvme: Use per-queue AIO context", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "1210fb25f9e7f77525439fb5d6ef056a9e710165", "submitter": { "id": 74995, "url": "http://patchwork.ozlabs.org/api/people/74995/?format=api", "name": "Philippe Mathieu-Daudé", "email": "philmd@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20200625184838.28172-16-philmd@redhat.com/mbox/", "series": [ { "id": 185846, "url": "http://patchwork.ozlabs.org/api/series/185846/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=185846", "date": "2020-06-25T18:48:21", "name": "block/nvme: Various cleanups required to use multiple queues", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/185846/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1317147/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1317147/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=<UNKNOWN>)", "ozlabs.org;\n dmarc=fail (p=none dis=none) header.from=redhat.com", "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=CtDJeMgV;\n\tdkim-atps=neutral" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 49t8WL5JLsz9sQt\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 26 Jun 2020 05:01:34 +1000 (AEST)", "from localhost ([::1]:56310 helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1joX7s-0002P2-A6\n\tfor incoming@patchwork.ozlabs.org; Thu, 25 Jun 2020 15:01:32 -0400", "from eggs.gnu.org ([2001:470:142:3::10]:40552)\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <philmd@redhat.com>) id 1joWwj-00011y-MX\n for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:50:01 -0400", "from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59827\n helo=us-smtp-1.mimecast.com)\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256)\n (Exim 4.90_1) (envelope-from <philmd@redhat.com>) id 1joWwh-0001I9-LM\n for qemu-devel@nongnu.org; Thu, 25 Jun 2020 14:50:01 -0400", "from mail-wr1-f69.google.com (mail-wr1-f69.google.com\n [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-482-bTJjE_jrOf-9zmri1r_1XQ-1; Thu, 25 Jun 2020 14:49:52 -0400", "by mail-wr1-f69.google.com with SMTP id y16so7685440wrr.20\n for <qemu-devel@nongnu.org>; Thu, 25 Jun 2020 11:49:52 -0700 (PDT)", "from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net.\n [83.51.162.1])\n by smtp.gmail.com with ESMTPSA id c2sm33371926wrv.47.2020.06.25.11.49.49\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 25 Jun 2020 11:49:50 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1593110998;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=J6KNnPouNo074HwjJp3LZ774db1owVLbnaAdPIC0ay4=;\n b=CtDJeMgVSW8Sej7hPhaxqCW20Aq1cCJ2DJDovjBBbQCi4/uAIVrcLoCXZpyeauemoPDjgL\n qExCCHRgj3q1ce1ntld6o0Wfwtr5+NnTYE5MLds+w9aZNltNkz5geHflWUvI6B3EgbABst\n MGic8Crc0e3QfIIJdj9C2WRsGrFjAk4=", "X-MC-Unique": "bTJjE_jrOf-9zmri1r_1XQ-1", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20161025;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references:mime-version:content-transfer-encoding;\n bh=J6KNnPouNo074HwjJp3LZ774db1owVLbnaAdPIC0ay4=;\n b=IvdQ66F3xfERsLjXW22J1z7cnyOgSMqlznXStnoA6DW8oLFE36bjw+inXm7IdtLX3p\n fUUq5P8axeQB1jyA/RE9TcFMMB4rgMir09R01424Tnp/aylXSd5r4dVcJkSZ1M75Pj+P\n BQJ7dN/Jv3kabJwntxvdGny5/ZmD2EJO2RByC9zGxIm4/+FE3oCskY8ltem87iKXzBeD\n 8M08liLqBHvvyweBCLEwSqmwOZMNIxyX3xBaWMTYOcPawBtYbZhrC5iFdRMxvaxB6e/u\n NCQ064vbg0vrp8CmKQFeCGUFC4XEzGDLrZXbnBQTGi6mTTA/taKPpj7llPq5yZlKabHs\n Jb/A==", "X-Gm-Message-State": "AOAM531i1FFjRhLCVaNgvr6dPLv01BoctP63myYEA/7DfanKDW+m3HBh\n m+lIKA5jgu++h9EcyupXTIkmMq2eaZECJ67DtEdq1UVHPiOZ6/wb0anJvvCHXjXcarZL9TNP1MZ\n SOgASsoXn7WDC9Yw=", "X-Received": [ "by 2002:a05:600c:2045:: with SMTP id\n p5mr5352532wmg.91.1593110991002;\n Thu, 25 Jun 2020 11:49:51 -0700 (PDT)", "by 2002:a05:600c:2045:: with SMTP id\n p5mr5352516wmg.91.1593110990770;\n Thu, 25 Jun 2020 11:49:50 -0700 (PDT)" ], "X-Google-Smtp-Source": "\n ABdhPJz/2Wk8W3TCFa0pSd5Pg0O29Xw/XHbyw8/JZaS9NHCmqmadJh7UszD8vJp+rwy4knFS8xOAqQ==", "From": "=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@redhat.com>", "To": "qemu-devel@nongnu.org,\n\tStefan Hajnoczi <stefanha@redhat.com>", "Subject": "[RFC PATCH 15/17] block/nvme: Use per-queue AIO context", "Date": "Thu, 25 Jun 2020 20:48:36 +0200", "Message-Id": "<20200625184838.28172-16-philmd@redhat.com>", "X-Mailer": "git-send-email 2.21.3", "In-Reply-To": "<20200625184838.28172-1-philmd@redhat.com>", "References": "<20200625184838.28172-1-philmd@redhat.com>", "MIME-Version": "1.0", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Type": "text/plain; charset=UTF-8;\n\ttext/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com;\n helo=us-smtp-1.mimecast.com", "X-detected-operating-system": "by eggs.gnu.org: First seen = 2020/06/25 00:45:15", "X-ACL-Warn": "Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]", "X-Spam_score_int": "-30", "X-Spam_score": "-3.1", "X-Spam_bar": "---", "X-Spam_report": "(-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,\n SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.23", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,\n qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>,\n Maxim Levitsky <mlevitsk@redhat.com>,\n =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@redhat.com>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "To be able to use multiple queues on the same hardware,\nwe need to have each queue able to receive IRQ notifications\nin the correct AIO context.\nThe context has to be proper to each queue, not to the block\ndriver. Move aio_context from BDRVNVMeState to NVMeQueuePair.\n\nSigned-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>\n---\nRFC because I'm not familiar with AIO context\n\n block/nvme.c | 35 ++++++++++++++++++-----------------\n 1 file changed, 18 insertions(+), 17 deletions(-)", "diff": "diff --git a/block/nvme.c b/block/nvme.c\nindex ac933cafd0..0f7cc568ef 100644\n--- a/block/nvme.c\n+++ b/block/nvme.c\n@@ -51,6 +51,7 @@ typedef struct {\n } NVMeRequest;\n \n typedef struct {\n+ AioContext *aio_context;\n CoQueue free_req_queue;\n QemuMutex lock;\n \n@@ -93,7 +94,6 @@ QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) != 0x1000);\n #define QUEUE_INDEX_IO(n) (1 + n)\n \n typedef struct {\n- AioContext *aio_context;\n QEMUVFIOState *vfio;\n NVMeRegs *regs;\n /* The submission/completion queue pairs.\n@@ -190,6 +190,7 @@ static void nvme_free_req_queue_cb(void *opaque)\n }\n \n static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,\n+ AioContext *aio_context,\n int idx, int size,\n Error **errp)\n {\n@@ -207,6 +208,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,\n if (!q->prp_list_pages) {\n goto fail;\n }\n+ q->aio_context = aio_context;\n memset(q->prp_list_pages, 0, s->page_size * NVME_QUEUE_SIZE);\n qemu_mutex_init(&q->lock);\n q->index = idx;\n@@ -365,7 +367,7 @@ static bool nvme_process_completion(BDRVNVMeState *s, NVMeQueuePair *q)\n smp_mb_release();\n *q->cq.doorbell = cpu_to_le32(q->cq.head);\n if (!qemu_co_queue_empty(&q->free_req_queue)) {\n- replay_bh_schedule_oneshot_event(s->aio_context,\n+ replay_bh_schedule_oneshot_event(q->aio_context,\n nvme_free_req_queue_cb, q);\n }\n }\n@@ -419,7 +421,6 @@ static void nvme_cmd_sync_cb(void *opaque, int ret)\n static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q,\n NvmeCmd *cmd)\n {\n- AioContext *aio_context = bdrv_get_aio_context(bs);\n NVMeRequest *req;\n BDRVNVMeState *s = bs->opaque;\n int ret = -EINPROGRESS;\n@@ -429,7 +430,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q,\n }\n nvme_submit_command(s, q, req, cmd, nvme_cmd_sync_cb, &ret);\n \n- AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS);\n+ AIO_WAIT_WHILE(q->aio_context, ret == -EINPROGRESS);\n return ret;\n }\n \n@@ -547,7 +548,8 @@ static void nvme_handle_event(EventNotifier *n)\n nvme_poll_queues(s);\n }\n \n-static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)\n+static bool nvme_add_io_queue(BlockDriverState *bs,\n+ AioContext *aio_context, Error **errp)\n {\n BDRVNVMeState *s = bs->opaque;\n int n = s->nr_queues;\n@@ -555,7 +557,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)\n NvmeCmd cmd;\n int queue_size = NVME_QUEUE_SIZE;\n \n- q = nvme_create_queue_pair(s, n, queue_size, errp);\n+ q = nvme_create_queue_pair(s, aio_context, n, queue_size, errp);\n if (!q) {\n return false;\n }\n@@ -600,6 +602,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,\n Error **errp)\n {\n BDRVNVMeState *s = bs->opaque;\n+ AioContext *aio_context = bdrv_get_aio_context(bs);\n int ret;\n uint64_t cap;\n uint64_t timeout_ms;\n@@ -610,7 +613,6 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,\n qemu_co_queue_init(&s->dma_flush_queue);\n s->device = g_strdup(device);\n s->nsid = namespace;\n- s->aio_context = bdrv_get_aio_context(bs);\n ret = event_notifier_init(&s->irq_notifier, 0);\n if (ret) {\n error_setg(errp, \"Failed to init event notifier\");\n@@ -660,7 +662,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,\n \n /* Set up admin queue. */\n s->queues = g_new(NVMeQueuePair *, 1);\n- s->queues[QUEUE_INDEX_ADMIN] = nvme_create_queue_pair(s, 0,\n+ s->queues[QUEUE_INDEX_ADMIN] = nvme_create_queue_pair(s, aio_context, 0,\n NVME_QUEUE_SIZE,\n errp);\n if (!s->queues[QUEUE_INDEX_ADMIN]) {\n@@ -695,7 +697,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,\n if (ret) {\n goto out;\n }\n- aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,\n+ aio_set_event_notifier(aio_context, &s->irq_notifier,\n false, nvme_handle_event, nvme_poll_cb);\n \n nvme_identify(bs, namespace, &local_err);\n@@ -706,7 +708,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,\n }\n \n /* Set up command queues. */\n- if (!nvme_add_io_queue(bs, errp)) {\n+ if (!nvme_add_io_queue(bs, aio_context, errp)) {\n ret = -EIO;\n }\n out:\n@@ -775,11 +777,11 @@ static void nvme_close(BlockDriverState *bs)\n BDRVNVMeState *s = bs->opaque;\n \n for (i = 0; i < s->nr_queues; ++i) {\n+ aio_set_event_notifier(s->queues[i]->aio_context,\n+ &s->irq_notifier, false, NULL, NULL);\n nvme_free_queue_pair(s->queues[i]);\n }\n g_free(s->queues);\n- aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,\n- false, NULL, NULL);\n event_notifier_cleanup(&s->irq_notifier);\n qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE);\n qemu_vfio_close(s->vfio);\n@@ -992,7 +994,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriverState *bs,\n .cdw12 = cpu_to_le32(cdw12),\n };\n NVMeCoData data = {\n- .ctx = bdrv_get_aio_context(bs),\n+ .ctx = ioq->aio_context,\n .ret = -EINPROGRESS,\n };\n \n@@ -1101,7 +1103,7 @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs)\n .nsid = cpu_to_le32(s->nsid),\n };\n NVMeCoData data = {\n- .ctx = bdrv_get_aio_context(bs),\n+ .ctx = ioq->aio_context,\n .ret = -EINPROGRESS,\n };\n \n@@ -1142,7 +1144,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs,\n };\n \n NVMeCoData data = {\n- .ctx = bdrv_get_aio_context(bs),\n+ .ctx = ioq->aio_context,\n .ret = -EINPROGRESS,\n };\n \n@@ -1192,7 +1194,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs,\n };\n \n NVMeCoData data = {\n- .ctx = bdrv_get_aio_context(bs),\n+ .ctx = ioq->aio_context,\n .ret = -EINPROGRESS,\n };\n \n@@ -1289,7 +1291,6 @@ static void nvme_attach_aio_context(BlockDriverState *bs,\n {\n BDRVNVMeState *s = bs->opaque;\n \n- s->aio_context = new_context;\n aio_set_event_notifier(new_context, &s->irq_notifier,\n false, nvme_handle_event, nvme_poll_cb);\n }\n", "prefixes": [ "RFC", "15/17" ] }