From patchwork Tue Jun 30 19:13:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00D9DC433E0 for ; Tue, 30 Jun 2020 19:15:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 326BD206A1 for ; Tue, 30 Jun 2020 19:15:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MUqWCk1f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 326BD206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqLin-0007px-NJ for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 15:15:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqLhL-000627-7N for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:13:39 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:51970 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jqLhG-0005W9-Bq for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:13:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593544413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sSpxL68KI0zjY+P0ZTv/agflMQHnncdM/JAB05rWw4M=; b=MUqWCk1fAyLdZ4ENaxkf+eA6qC71is5wdgHnB8QYlZB5gxj9r0EEglts62rZzXw6EWVvkw L37PObXtcrZN/E+rHkNp0V/ZszzX7h6l+anppx9eME3NTY/3HYNLkDWfxHpG1MrWZ9UF1s gU4E/bLKPy+1PxSzuDqwAtMAnB6mt50= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-313-05q7PtuFPqapqQmFngKUMg-1; Tue, 30 Jun 2020 15:13:32 -0400 X-MC-Unique: 05q7PtuFPqapqQmFngKUMg-1 Received: by mail-wm1-f69.google.com with SMTP id v24so21394945wmh.3 for ; Tue, 30 Jun 2020 12:13:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sSpxL68KI0zjY+P0ZTv/agflMQHnncdM/JAB05rWw4M=; b=I4A7GyUboRGiJqRTK3XVrqLDNMaO32KJiByLmcROvHpK/ZtW8Vvyh/YpcNOmGgd8H9 86qAG/rBnVrEHnrPiGlv6UGF34tffdBbbhmUrtHd9KUQqSGhL7ed420r5r8AZ4nyNrUu bXM/7VtANPcYv/0g3ig25RxpLXNln0QtwUFtpAebEdQ/PpLO8draOqw253jASDIy3n5Y e0aZgd/WPb7skQmRHIEgTJtvMngCqu9DaYBacruA0Se7b1clRnacRZQKFf09F7zFwINq oWBDA/2S9nDpna7YXuoUDuzDopSKRzYi4L7YYkI6/uKo0uQqwZQwSXTrSGL7216nOrcG HoTg== X-Gm-Message-State: AOAM532pg1dUxhmIu1+ppBZW3Ett0BWtl4mI9mrQbI9TSN5yBIRWt4JY xzxn1UVaIZ3VfbCUe33p1+mqFA43f7vcTAlIqHvN7NBZ3doiejpF68qU2npAa2XtMPXjMNFO+Q5 DXumdegVqTI1GESU= X-Received: by 2002:a1c:2602:: with SMTP id m2mr23955274wmm.50.1593544410828; Tue, 30 Jun 2020 12:13:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLyipKg//WKrV8o5D+oPIV/Utzm3hTol8MMrTlA3AQVAJTLZ+Tx5dgMEDayArhX8VC+GGiLw== X-Received: by 2002:a1c:2602:: with SMTP id m2mr23955260wmm.50.1593544410661; Tue, 30 Jun 2020 12:13:30 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id c6sm4670385wma.15.2020.06.30.12.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 12:13:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Stefan Hajnoczi , qemu-devel@nongnu.org Subject: [PATCH v2 02/12] block/nvme: Avoid further processing if trace event not enabled Date: Tue, 30 Jun 2020 21:13:08 +0200 Message-Id: <20200630191318.30021-3-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630191318.30021-1-philmd@redhat.com> References: <20200630191318.30021-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/30 02:00:02 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Avoid further processing if TRACE_NVME_SUBMIT_COMMAND_RAW is not enabled. This is an untested intend of performance optimization. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index 2f5e3c2adf..8c30a5fee2 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -441,6 +441,9 @@ static void nvme_trace_command(const NvmeCmd *cmd) { int i; + if (!trace_event_get_state_backends(TRACE_NVME_SUBMIT_COMMAND_RAW)) { + return; + } for (i = 0; i < 8; ++i) { uint8_t *cmdp = (uint8_t *)cmd + i * 8; trace_nvme_submit_command_raw(cmdp[0], cmdp[1], cmdp[2], cmdp[3], From patchwork Tue Jun 30 19:13:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9262CC433E0 for ; Tue, 30 Jun 2020 19:16:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55054206A1 for ; Tue, 30 Jun 2020 19:16:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YR4YaC1a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55054206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqLjw-0001ge-FP for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 15:16:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqLhO-00068n-0x for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:13:42 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51489 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jqLhM-0005We-IQ for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:13:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593544419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KdE6JsIw8dAhfeVIz93JjPSKDmry/14DEkZ0JE7PkKI=; b=YR4YaC1aE5u9Bf8s2zFxIQRmhcZ2yLhuXhqA75u4bDRedToyGafGASEFS9XkvCKb7Iwlff 5rSJ7aOZWU55nU/UoeYvdgFrdJCBPvjm9oYi6R4kK/jzKCyIalT7qZOuDnKlmQ4XH5kntJ IZ9e4+dY9cy4OImfKqnSIPls4bCW8Xc= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-dLk15A7RNcKnXnv2Qh9C4A-1; Tue, 30 Jun 2020 15:13:37 -0400 X-MC-Unique: dLk15A7RNcKnXnv2Qh9C4A-1 Received: by mail-wm1-f69.google.com with SMTP id f68so9848695wmf.1 for ; Tue, 30 Jun 2020 12:13:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KdE6JsIw8dAhfeVIz93JjPSKDmry/14DEkZ0JE7PkKI=; b=QSixNxp//kXSZugMz02iyBhMS/NJmZnMi/2Cj18o57yKJsywkxUd247Smoae9N7xYu GELcYdY1qjFBzqNT7chuGe8u3sWPwwlg2HumUBsIuZqQDcYhoUg06yck/5EW7a9vrxRn b17Idmp87DQcFXOfkittFbPzO9+PQ6LFqst33NNYlWMwUw4iGjbgB6dbLUKhNSm/a2sY EYf6iPu4dd2RM3OFuNsQxvCHFy7stQ1XTTyZPyxgrYzc7uEQK9rBVB8q0d75JNM7d6xk IxZZSL+h8Icql9EJcNLZnUVN9fb2w/EpOxfAdiTcEPr4Zj3PBV1P4ess3TFCqp6VySnB BA0w== X-Gm-Message-State: AOAM530LwmQPaYegNahmEXwRKIf8eppZWtzQ0gG7ARiwbv7C4lvSTQib MKgJ52Z/ZhUqX9+AYGy/cV43TTwqHxzLEjDzHoxQWLrfDTN2HJk6teosSWIr7A5DK+gh8plwd1z c1VST7ckzl50oYjI= X-Received: by 2002:adf:8168:: with SMTP id 95mr23392316wrm.104.1593544415496; Tue, 30 Jun 2020 12:13:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhGtkqbtq5kDafv1A2Eo+oeXUyQvOonJJ/uL4Ooy6GdcKDkFti91dhNzt9/l6aG6NaBC3gEQ== X-Received: by 2002:adf:8168:: with SMTP id 95mr23392299wrm.104.1593544415295; Tue, 30 Jun 2020 12:13:35 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id p29sm4524114wmi.43.2020.06.30.12.13.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 12:13:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Stefan Hajnoczi , qemu-devel@nongnu.org Subject: [PATCH v2 03/12] block/nvme: Let nvme_create_queue_pair() fail gracefully Date: Tue, 30 Jun 2020 21:13:09 +0200 Message-Id: <20200630191318.30021-4-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630191318.30021-1-philmd@redhat.com> References: <20200630191318.30021-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/30 03:55:26 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" As nvme_create_queue_pair() is allowed to fail, replace the alloc() calls by try_alloc() to avoid aborting QEMU. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 8c30a5fee2..e1893b4e79 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -213,14 +213,22 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, int i, r; BDRVNVMeState *s = bs->opaque; Error *local_err = NULL; - NVMeQueuePair *q = g_new0(NVMeQueuePair, 1); + NVMeQueuePair *q; uint64_t prp_list_iova; + q = g_try_new0(NVMeQueuePair, 1); + if (!q) { + return NULL; + } + q->prp_list_pages = qemu_try_blockalign0(bs, + s->page_size * NVME_QUEUE_SIZE); + if (!q->prp_list_pages) { + goto fail; + } qemu_mutex_init(&q->lock); q->s = s; q->index = idx; qemu_co_queue_init(&q->free_req_queue); - q->prp_list_pages = qemu_blockalign0(bs, s->page_size * NVME_NUM_REQS); q->completion_bh = aio_bh_new(bdrv_get_aio_context(bs), nvme_process_completion_bh, q); r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, From patchwork Tue Jun 30 19:13:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F222C433DF for ; Tue, 30 Jun 2020 19:19:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 62795206A1 for ; Tue, 30 Jun 2020 19:19:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZsYMNyV/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62795206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqLmX-0005ZB-51 for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 15:19:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqLhu-0006vM-B6 for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:14:14 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:29211 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jqLhp-0005ZT-Ci for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:14:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593544448; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tuXzLILJ7FT7I+1GOee4KI1h3HYM5KlaYdYlB+vyW7M=; b=ZsYMNyV/J8YqlxKW9oVXhdM6Day2Q3YidvMmM249D9ClbccU0CioPLTrgDeSGHh0VZRdfF rT+q9iWOg0e/g5aA12zXmcT+14MUZ0+22HbCEBaPe5qChykQFL8LdD+rlt5z4LllzS0BR9 QUfJdWqjXrkvtub8wynajwuZ5m3N0jc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-88-6f-JqpFcPjC8ZCriJSM0yQ-1; Tue, 30 Jun 2020 15:14:06 -0400 X-MC-Unique: 6f-JqpFcPjC8ZCriJSM0yQ-1 Received: by mail-wm1-f72.google.com with SMTP id g6so15598977wmk.4 for ; Tue, 30 Jun 2020 12:14:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tuXzLILJ7FT7I+1GOee4KI1h3HYM5KlaYdYlB+vyW7M=; b=H4/OtJn7dwmPYbhbuD/JoatVqGTEkRKiTkjzN4QyV9b6jb5PU9hde3RuK1WT0wWS47 f50W9cA0mBvsLAk/XUxKlVObkiNzbvQ2AZN1WXIsqZy8344xsVRn+0oAYH3dthYNg9p4 rbC4z51DS37na3hmt8npjXSxUeUrrbMXPW8cOiVcvi0A45W80YTlqZ34/AzLSY2Gnd7Y p47OPzHpaJZB3hZhE0Tht9wnbqPZ8vkzwiV02E4/OOG+AJkWjVY/BM2GkIMoHjHBfPt8 hkrGg0mPtp2R3/rITJzx2vkkl6cDcg7UGTH/waggUoKT6bjLNsT52IiwkJcHs8nSDeZ4 9gOA== X-Gm-Message-State: AOAM532ADahivjYf5YAwxHyMzJ9jiNn/aGNLhDknUciQruJV9H7zahTd Gy+EucNCAO4ueLEFA35CFB/TXnjgng0BwyAfMHJaYBW8pQuekptWpQyPVq8Qw5b9Pnq01kcqi9V gdhC2ScqbKcRMPdg= X-Received: by 2002:a5d:664e:: with SMTP id f14mr23197623wrw.6.1593544444112; Tue, 30 Jun 2020 12:14:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuuJsDa+yK4/Rkce9dWMBX06w+o1lBpOcWhfDJnvRKOmk/YZqeeGkAtA0VFdnrGuxaxZBo9w== X-Received: by 2002:a5d:664e:: with SMTP id f14mr23197598wrw.6.1593544443854; Tue, 30 Jun 2020 12:14:03 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id s10sm4633017wme.31.2020.06.30.12.14.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 12:14:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Stefan Hajnoczi , qemu-devel@nongnu.org Subject: [PATCH v2 09/12] block/nvme: Simplify nvme_init_queue() arguments Date: Tue, 30 Jun 2020 21:13:15 +0200 Message-Id: <20200630191318.30021-10-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630191318.30021-1-philmd@redhat.com> References: <20200630191318.30021-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/30 01:11:03 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_init_queue() doesn't require BlockDriverState anymore. Replace it by BDRVNVMeState to simplify. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 8b4d957a8e..c28c08b3e3 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -165,10 +165,9 @@ static QemuOptsList runtime_opts = { }, }; -static void nvme_init_queue(BlockDriverState *bs, NVMeQueue *q, +static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, int nentries, int entry_bytes, Error **errp) { - BDRVNVMeState *s = bs->opaque; size_t bytes; int r; @@ -251,14 +250,14 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, req->prp_list_iova = prp_list_iova + i * s->page_size; } - nvme_init_queue(bs, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err); + nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; } q->sq.doorbell = &s->regs->doorbells[idx * 2 * s->doorbell_scale]; - nvme_init_queue(bs, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err); + nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; From patchwork Tue Jun 30 19:13:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9029EC433DF for ; Tue, 30 Jun 2020 19:17:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 541C0206A1 for ; Tue, 30 Jun 2020 19:17:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NixcHs8m" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 541C0206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqLks-0003EZ-PW for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 15:17:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqLhz-0006ym-Jt for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:14:19 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56495 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jqLhs-0005Zx-Lu for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:14:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593544451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KOpQpvHqMfX4FPMLDJD68SQU34AdCnwRx9P5g+DPasA=; b=NixcHs8m+u3HEC6pHi72fbeqXzjBN/kY+eTB/CQeJAxD+wSyZY3q5AB1JHfH/m1Vd3aijY ySnHs328YqECBw80AlJAPBEieduvqMDE11FvYivpmincjXVkZ+DJytN6LVVCIK6+z++/6T nwDfPZymQFV1+iGdNWn0/Mkg5XbDUjU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-gdVpSrkmOuyyUIkEBQtHoA-1; Tue, 30 Jun 2020 15:14:09 -0400 X-MC-Unique: gdVpSrkmOuyyUIkEBQtHoA-1 Received: by mail-wr1-f70.google.com with SMTP id o25so19038196wro.16 for ; Tue, 30 Jun 2020 12:14:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KOpQpvHqMfX4FPMLDJD68SQU34AdCnwRx9P5g+DPasA=; b=ByMwIxX1C+qPrYtswDK24mMwDBCis1UGYdMqtEab0WmVhpWctie+mTQ1mKwmSZvtEC RgHCqma92vSrQw3jOoipZDJVCaoA0UORKtjhTDGjKvgRo68X6YNqLadmK6CyF3CPquVM +gXqcKJhVqme0GMRKE8njFBp6/BavWCvMDRnk99cFrhK0yPDoSHJrqnHKUlRs9LbYoSe +HvV1L0R+gi2kLGVg+JOCe/cTkWhaDs1ToZsLT3vF+R4OAPVEmJQBY9/c4eWRRoGXw/x KrMFXBc/iHr2aUB008BvEUbu4YsfeHTIfjw1tHc1ewqRjorFoqRlzTVNI+s+8RFClYSx HiBQ== X-Gm-Message-State: AOAM530GABbHNpn05H0lDn6yU4JGh69Pic57idoOuuk9SpEUeH7SsNyG 68vUWGZS0suqKPKc2obqjsB7lH5fZPvfhQBgzRNWKPkXdRGp6gJkQPFiOJFxMUwhPn21M2ccKcF /Mg34rDvm6LrTtao= X-Received: by 2002:adf:e38b:: with SMTP id e11mr22761568wrm.65.1593544448681; Tue, 30 Jun 2020 12:14:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1EZVpTdd6iXbH3PSnKeVnsDO0FFxLn8ufo5u4r8UFQHUawa91336cWUspmUwMIrMWX837DQ== X-Received: by 2002:adf:e38b:: with SMTP id e11mr22761556wrm.65.1593544448497; Tue, 30 Jun 2020 12:14:08 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id i19sm4911419wrb.56.2020.06.30.12.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 12:14:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Stefan Hajnoczi , qemu-devel@nongnu.org Subject: [PATCH v2 10/12] block/nvme: Replace BDRV_POLL_WHILE by AIO_WAIT_WHILE Date: Tue, 30 Jun 2020 21:13:16 +0200 Message-Id: <20200630191318.30021-11-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630191318.30021-1-philmd@redhat.com> References: <20200630191318.30021-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/30 03:55:26 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" BDRV_POLL_WHILE() is defined as: #define BDRV_POLL_WHILE(bs, cond) ({ \ BlockDriverState *bs_ = (bs); \ AIO_WAIT_WHILE(bdrv_get_aio_context(bs_), \ cond); }) As we will remove the BlockDriverState use in the next commit, start by using the exploded version of BDRV_POLL_WHILE(). Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index c28c08b3e3..010286e8ad 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -493,6 +493,7 @@ static void nvme_cmd_sync_cb(void *opaque, int ret) static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, NvmeCmd *cmd) { + AioContext *aio_context = bdrv_get_aio_context(bs); NVMeRequest *req; int ret = -EINPROGRESS; req = nvme_get_free_req(q); @@ -501,7 +502,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, } nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret); - BDRV_POLL_WHILE(bs, ret == -EINPROGRESS); + AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS); return ret; } From patchwork Tue Jun 30 19:13:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 278999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CAD0C433DF for ; Tue, 30 Jun 2020 19:23:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D418C206C0 for ; Tue, 30 Jun 2020 19:23:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XbDaR9FZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D418C206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqLqX-0003Ju-In for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 15:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqLi0-00072Q-VQ for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:14:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51213 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jqLhz-0005aj-8C for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:14:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593544456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2lvVHFOutT4xNyLe5+eXbBjp3teTx1IVF01y815xjeo=; b=XbDaR9FZ0wzuzZ3DQ7G7ZF+XFICF+5K5tf4cQ1Cal9ZR5Vb8b2Y46NdUq+AiCBDQN3JSqr tp/KhoM3/4HaZzGkc27ngduk/HuAiLDw6pgyJ1fdMJd5qptaT+iJFMHDF/SONqmw3+YIsA 14thS5RokKyAxtDb+Qs8JLyxB41lTzA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-339-2WH3npdbOAGMT_5ruAF77Q-1; Tue, 30 Jun 2020 15:14:14 -0400 X-MC-Unique: 2WH3npdbOAGMT_5ruAF77Q-1 Received: by mail-wm1-f71.google.com with SMTP id a21so21154546wmd.0 for ; Tue, 30 Jun 2020 12:14:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2lvVHFOutT4xNyLe5+eXbBjp3teTx1IVF01y815xjeo=; b=r5CSkxGfStpnRekocxcSafgC9GEqASsieGjx6ITG4nr0nNjzLL9DChRBmnWx0Ly52j Ckb6XrD01tNtDqqWww7sq3QO6e80WA9kEG0CdMG21gZ7HohugHNLbjAkifA0Y1/mLxth RHxNopocV/gvC7J0IVNzze3rsG17A4TsKVkeU1XzZ0xCha2E1JN6KkoYoPU8DDx63Brw fbuA5vDwQ2Umg9ZsOwEHZcg/Vgr2QptiFs7kL53Vlh0jRufsnpDVRw7zyrBwFayju0+z vLcNFfw9RGHAtg+3EXFKBIF1rgXg3EngA2JtKPxW9uPaiEzH0hh3OgcZFYDuTYTTW3xD ds5g== X-Gm-Message-State: AOAM533pFrbDdaYIzYq0ZhFhdKzL1yqfK640KO0nfPSWzyybJ6Bgz0z1 q+Kyhit79OlxORMtXAOrk7fJk1jFFQlYGg1/YbPxWfr2yNlADuT8rZrMUPQUicxHMEvwnewwdbx 6l4bjt+w84FDshZ4= X-Received: by 2002:a7b:c775:: with SMTP id x21mr7981681wmk.34.1593544453477; Tue, 30 Jun 2020 12:14:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGZM7NxTJSQKKuMFFlvtMBFSlO59hmL8uK6jk8OfYAQMXly4R54KczyTR9KdpmWogkyRkb3w== X-Received: by 2002:a7b:c775:: with SMTP id x21mr7981658wmk.34.1593544453216; Tue, 30 Jun 2020 12:14:13 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id f14sm5135901wro.90.2020.06.30.12.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 12:14:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Stefan Hajnoczi , qemu-devel@nongnu.org Subject: [PATCH v2 11/12] block/nvme: Simplify nvme_create_queue_pair() arguments Date: Tue, 30 Jun 2020 21:13:17 +0200 Message-Id: <20200630191318.30021-12-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630191318.30021-1-philmd@redhat.com> References: <20200630191318.30021-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/30 00:34:33 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_create_queue_pair() doesn't require BlockDriverState anymore. Replace it by BDRVNVMeState and AioContext to simplify. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 010286e8ad..90b2e00e8d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -208,12 +208,12 @@ static void nvme_free_req_queue_cb(void *opaque) qemu_mutex_unlock(&q->lock); } -static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, +static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, + AioContext *aio_context, int idx, int size, Error **errp) { int i, r; - BDRVNVMeState *s = bs->opaque; Error *local_err = NULL; NVMeQueuePair *q; uint64_t prp_list_iova; @@ -232,8 +232,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, q->s = s; q->index = idx; qemu_co_queue_init(&q->free_req_queue); - q->completion_bh = aio_bh_new(bdrv_get_aio_context(bs), - nvme_process_completion_bh, q); + q->completion_bh = aio_bh_new(aio_context, nvme_process_completion_bh, q); r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, s->page_size * NVME_NUM_REQS, false, &prp_list_iova); @@ -637,7 +636,8 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) NvmeCmd cmd; int queue_size = NVME_QUEUE_SIZE; - q = nvme_create_queue_pair(bs, n, queue_size, errp); + q = nvme_create_queue_pair(s, bdrv_get_aio_context(bs), + n, queue_size, errp); if (!q) { return false; } @@ -682,6 +682,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, Error **errp) { BDRVNVMeState *s = bs->opaque; + AioContext *aio_context = bdrv_get_aio_context(bs); int ret; uint64_t cap; uint64_t timeout_ms; @@ -742,7 +743,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, /* Set up admin queue. */ s->queues = g_new(NVMeQueuePair *, 1); - s->queues[QUEUE_INDEX_ADMIN] = nvme_create_queue_pair(bs, 0, + s->queues[QUEUE_INDEX_ADMIN] = nvme_create_queue_pair(s, aio_context, 0, NVME_QUEUE_SIZE, errp); if (!s->queues[QUEUE_INDEX_ADMIN]) { From patchwork Tue Jun 30 19:13:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279000 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B2F4C433E0 for ; Tue, 30 Jun 2020 19:21:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 248CE206C0 for ; Tue, 30 Jun 2020 19:21:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Og6/WfJU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 248CE206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqLpC-0001O0-DW for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 15:21:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqLi5-0007FO-UO for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:14:25 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:34823 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jqLi3-0005bh-C4 for qemu-devel@nongnu.org; Tue, 30 Jun 2020 15:14:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593544462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zAFtHKEAEKWoAOfXmSXZPp5z9h7DCo+BkNURFMtuFac=; b=Og6/WfJUzBQFQrirxH6c16Wx/1IC8WIWHs6oeXxSsQtyIGhEOeQho7ktOjr5ZoxrUJ3SPn S/Qpcvy+579YwYUcYcCbhyH3PW3y5D+ZPMlYvWxPHMdwbDcltwxso1DeOnCIsln8CjcwAc y5wrZNRxXKZjoD2UWCd9hjhqAMJZeQI= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-54-R1nmEce5NDSjSZL7075G_A-1; Tue, 30 Jun 2020 15:14:20 -0400 X-MC-Unique: R1nmEce5NDSjSZL7075G_A-1 Received: by mail-wm1-f70.google.com with SMTP id v6so19114730wmg.1 for ; Tue, 30 Jun 2020 12:14:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zAFtHKEAEKWoAOfXmSXZPp5z9h7DCo+BkNURFMtuFac=; b=sdkx4mSrc0sqmIG0+qt3T8aTrgX77QxkSgSQdy0gimNlCemvGJKEC9zOuZLMSqS5zY raYgzbIkCbROYRcs0HRyLB4xHHQBzSxhBTfvIbcZgyLvW4+fFH5cCDuxo8uJnwDQe+MQ aW0bcXre2iJBZKBOKm+3h49XS5rOxnL6h6LHQllhHdnkmQEKAaVfDbCz4fd2wAUEd4A7 m47bgt4JJ4yfwRIJFmdJHG3lU2XDa0Os2iR5VjysjFsHq1tfOrXchvyP13bXgSFJQoxT D+QMs8ayBGVDmtJL/6r+o1L/NZSKHn+aYHSpkDclUWjcNisAJ880DodLTaRFrObcve/w qsrw== X-Gm-Message-State: AOAM530mF6cPVQH2U0BRlbw+FEDHmhkwqCzmMdJhMWErPKil24BJZjBg rkpVAwOJVMdMt8afP28GyJJUTBiNMmz6QYYDDQFMp8mPNR2Jrb6tPg0Ej3Bx8hMirAdbhWNyVei UhX7K/U4s2VtVM04= X-Received: by 2002:a7b:c099:: with SMTP id r25mr24195355wmh.159.1593544459154; Tue, 30 Jun 2020 12:14:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS+GVZcXdBdr03+WUdIODlRoiYh+OrDBOfQ3oZdX5CH4N1AC5cjse7JHuOB0xcP1Uld5yNLA== X-Received: by 2002:a7b:c099:: with SMTP id r25mr24195270wmh.159.1593544457866; Tue, 30 Jun 2020 12:14:17 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id v20sm4225841wmh.26.2020.06.30.12.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 12:14:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Stefan Hajnoczi , qemu-devel@nongnu.org Subject: [PATCH v2 12/12] block/nvme: Use per-queue AIO context Date: Tue, 30 Jun 2020 21:13:18 +0200 Message-Id: <20200630191318.30021-13-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630191318.30021-1-philmd@redhat.com> References: <20200630191318.30021-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/30 03:55:26 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" To be able to use multiple queues on the same hardware, we need to have each queue able to receive IRQ notifications in the correct AIO context. The AIO context and the notification handler have to be proper to each queue, not to the block driver. Move aio_context and irq_notifier from BDRVNVMeState to NVMeQueuePair. Signed-off-by: Philippe Mathieu-Daudé --- Since v1: Moved irq_notifier to NVMeQueuePair --- block/nvme.c | 71 +++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 90b2e00e8d..e7b9ecec41 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -60,6 +60,8 @@ typedef struct { typedef struct { QemuMutex lock; + AioContext *aio_context; + EventNotifier irq_notifier; /* Read from I/O code path, initialized under BQL */ BDRVNVMeState *s; @@ -107,7 +109,6 @@ QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) != 0x1000); #define QUEUE_INDEX_IO(n) (1 + n) struct BDRVNVMeState { - AioContext *aio_context; QEMUVFIOState *vfio; NVMeRegs *regs; /* The submission/completion queue pairs. @@ -120,7 +121,6 @@ struct BDRVNVMeState { /* How many uint32_t elements does each doorbell entry take. */ size_t doorbell_scale; bool write_cache_supported; - EventNotifier irq_notifier; uint64_t nsze; /* Namespace size reported by identify command */ int nsid; /* The namespace id to read/write data. */ @@ -227,11 +227,17 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, if (!q->prp_list_pages) { goto fail; } + r = event_notifier_init(&q->irq_notifier, 0); + if (r) { + error_setg(errp, "Failed to init event notifier"); + goto fail; + } memset(q->prp_list_pages, 0, s->page_size * NVME_QUEUE_SIZE); qemu_mutex_init(&q->lock); q->s = s; q->index = idx; qemu_co_queue_init(&q->free_req_queue); + q->aio_context = aio_context; q->completion_bh = aio_bh_new(aio_context, nvme_process_completion_bh, q); r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, s->page_size * NVME_NUM_REQS, @@ -325,7 +331,7 @@ static void nvme_put_free_req_locked(NVMeQueuePair *q, NVMeRequest *req) static void nvme_wake_free_req_locked(NVMeQueuePair *q) { if (!qemu_co_queue_empty(&q->free_req_queue)) { - replay_bh_schedule_oneshot_event(q->s->aio_context, + replay_bh_schedule_oneshot_event(q->aio_context, nvme_free_req_queue_cb, q); } } @@ -492,7 +498,6 @@ static void nvme_cmd_sync_cb(void *opaque, int ret) static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, NvmeCmd *cmd) { - AioContext *aio_context = bdrv_get_aio_context(bs); NVMeRequest *req; int ret = -EINPROGRESS; req = nvme_get_free_req(q); @@ -501,7 +506,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, } nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret); - AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS); + AIO_WAIT_WHILE(q->aio_context, ret == -EINPROGRESS); return ret; } @@ -621,14 +626,16 @@ static bool nvme_poll_queues(BDRVNVMeState *s) static void nvme_handle_event(EventNotifier *n) { - BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier); + NVMeQueuePair *q = container_of(n, NVMeQueuePair, irq_notifier); + BDRVNVMeState *s = q->s; trace_nvme_handle_event(s); event_notifier_test_and_clear(n); nvme_poll_queues(s); } -static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) +static bool nvme_add_io_queue(BlockDriverState *bs, + AioContext *aio_context, Error **errp) { BDRVNVMeState *s = bs->opaque; int n = s->nr_queues; @@ -636,8 +643,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) NvmeCmd cmd; int queue_size = NVME_QUEUE_SIZE; - q = nvme_create_queue_pair(s, bdrv_get_aio_context(bs), - n, queue_size, errp); + q = nvme_create_queue_pair(s, aio_context, n, queue_size, errp); if (!q) { return false; } @@ -672,7 +678,8 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) static bool nvme_poll_cb(void *opaque) { EventNotifier *e = opaque; - BDRVNVMeState *s = container_of(e, BDRVNVMeState, irq_notifier); + NVMeQueuePair *q = container_of(e, NVMeQueuePair, irq_notifier); + BDRVNVMeState *s = q->s; trace_nvme_poll_cb(s); return nvme_poll_queues(s); @@ -693,12 +700,6 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, qemu_co_queue_init(&s->dma_flush_queue); s->device = g_strdup(device); s->nsid = namespace; - s->aio_context = bdrv_get_aio_context(bs); - ret = event_notifier_init(&s->irq_notifier, 0); - if (ret) { - error_setg(errp, "Failed to init event notifier"); - return ret; - } s->vfio = qemu_vfio_open_pci(device, errp); if (!s->vfio) { @@ -773,12 +774,14 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, } } - ret = qemu_vfio_pci_init_irq(s->vfio, &s->irq_notifier, + ret = qemu_vfio_pci_init_irq(s->vfio, + &s->queues[QUEUE_INDEX_ADMIN]->irq_notifier, VFIO_PCI_MSIX_IRQ_INDEX, errp); if (ret) { goto out; } - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, + aio_set_event_notifier(aio_context, + &s->queues[QUEUE_INDEX_ADMIN]->irq_notifier, false, nvme_handle_event, nvme_poll_cb); nvme_identify(bs, namespace, &local_err); @@ -789,7 +792,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, } /* Set up command queues. */ - if (!nvme_add_io_queue(bs, errp)) { + if (!nvme_add_io_queue(bs, aio_context, errp)) { ret = -EIO; } out: @@ -858,12 +861,14 @@ static void nvme_close(BlockDriverState *bs) BDRVNVMeState *s = bs->opaque; for (i = 0; i < s->nr_queues; ++i) { - nvme_free_queue_pair(s->queues[i]); + NVMeQueuePair *q = s->queues[i]; + + aio_set_event_notifier(q->aio_context, + &q->irq_notifier, false, NULL, NULL); + event_notifier_cleanup(&q->irq_notifier); + nvme_free_queue_pair(q); } g_free(s->queues); - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, - false, NULL, NULL); - event_notifier_cleanup(&s->irq_notifier); qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE); qemu_vfio_close(s->vfio); @@ -1075,7 +1080,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriverState *bs, .cdw12 = cpu_to_le32(cdw12), }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1184,7 +1189,7 @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs) .nsid = cpu_to_le32(s->nsid), }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1225,7 +1230,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1275,7 +1280,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1368,10 +1373,10 @@ static void nvme_detach_aio_context(BlockDriverState *bs) qemu_bh_delete(q->completion_bh); q->completion_bh = NULL; - } - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, - false, NULL, NULL); + aio_set_event_notifier(bdrv_get_aio_context(bs), &q->irq_notifier, + false, NULL, NULL); + } } static void nvme_attach_aio_context(BlockDriverState *bs, @@ -1379,13 +1384,11 @@ static void nvme_attach_aio_context(BlockDriverState *bs, { BDRVNVMeState *s = bs->opaque; - s->aio_context = new_context; - aio_set_event_notifier(new_context, &s->irq_notifier, - false, nvme_handle_event, nvme_poll_cb); - for (int i = 0; i < s->nr_queues; i++) { NVMeQueuePair *q = s->queues[i]; + aio_set_event_notifier(new_context, &q->irq_notifier, + false, nvme_handle_event, nvme_poll_cb); q->completion_bh = aio_bh_new(new_context, nvme_process_completion_bh, q); }