From patchwork Wed Oct 6 16:49:27 2021 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: 1537286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dGInn6gU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HPgZz2LvXz9sR4 for ; Thu, 7 Oct 2021 03:56:27 +1100 (AEDT) Received: from localhost ([::1]:38572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYADQ-0003zd-E3 for incoming@patchwork.ozlabs.org; Wed, 06 Oct 2021 12:56:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYA6w-0003x2-DK for qemu-devel@nongnu.org; Wed, 06 Oct 2021 12:49:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYA6u-0007JM-SB for qemu-devel@nongnu.org; Wed, 06 Oct 2021 12:49:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633538980; 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=d0wXTRVmpQOHIPz9zqGtnv0qzZsKc85iVogQEdlDyD0=; b=dGInn6gUbzoblTcuLsF2syeJ1pKn0SDYPr3j57xw7cwMnXWzPY/n9U+3QD8KDhAHG8Hbuh 5JsvqJQxMELwbGXZDWcdvivcmvxSxvHyXIjvCaUk6tRaFp2zVrjX/Fi+JJzAOeJfz7BBEd IIVpcwH/oH5kDtDMqeVZxLlDMRMQuVw= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-WGtz2m8uMx6MVBpLle1ogA-1; Wed, 06 Oct 2021 12:49:39 -0400 X-MC-Unique: WGtz2m8uMx6MVBpLle1ogA-1 Received: by mail-wr1-f71.google.com with SMTP id d13-20020adfa34d000000b00160aa1cc5f1so2546614wrb.14 for ; Wed, 06 Oct 2021 09:49:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d0wXTRVmpQOHIPz9zqGtnv0qzZsKc85iVogQEdlDyD0=; b=XGFfK/CmdLu1JoJu++LrV/2mTbi/bYAxzWHbjnoONrOC13VRjQkA+hifPZgt9OVNep wfP5rLmHhQDO24TWUBIWhLKLr8hUdwls8Oy74IdxKwq5KgNYHIKeoTT7WEDpyWz1ZmbA 2lpv/HeCbZppFg/QRH3EMnbnGgDx32KqEuPdSbeDU2hkCQaUO+C79xEWZT6Op4aCsf3k hqQEIPX1OCFZzNTmvOr5g4WFavva7BhpaQWRO9oKSwrSiIGr43PkuGnGrHX697u4sX0+ YlAmg7eEa33Qi+JF44hxqkXjp2NS+SRLKw7qprD6oAwGCDQTJiCIfHaR1Z2x5NGoZdH2 6cWg== X-Gm-Message-State: AOAM531a7wDl8LULqPdL3c/pmRMSj0WIYC2IizjPI9LxOBUU8PuHhCbd 8YgLYZfqf+miS0XN09bi1EGivhfCa0oCi2oRz9W9ACXv0pgQyuICVzDel7lcPb1pb0Wtuoa7dSm 0axNuSAlCX/A2CaDODDxnZWGie856lxMTvdGBzbx+cLf2HOT3sqpQji6dnzu7Rddb X-Received: by 2002:a1c:f402:: with SMTP id z2mr11082191wma.53.1633538977737; Wed, 06 Oct 2021 09:49:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydeu1JlGJw2kKXfKAKwoIL9nQM05DbKetFZYl2QntNWdBATWFh+MyLoMXbF+gdHWtDcjzPMg== X-Received: by 2002:a1c:f402:: with SMTP id z2mr11082166wma.53.1633538977538; Wed, 06 Oct 2021 09:49:37 -0700 (PDT) Received: from x1w.redhat.com (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id x26sm2286144wmi.30.2021.10.06.09.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 09:49:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/5] block/nvme: Automatically free qemu_memalign() with QEMU_AUTO_VFREE Date: Wed, 6 Oct 2021 18:49:27 +0200 Message-Id: <20211006164931.172349-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211006164931.172349-1-philmd@redhat.com> References: <20211006164931.172349-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=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.05, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Hanna Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Since commit 4d324c0bf65 ("introduce QEMU_AUTO_VFREE") buffers allocated by qemu_memalign() can automatically freed when using the QEMU_AUTO_VFREE macro. Use it to simplify a bit. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 1cc7b62bb4b..fefcc04abe6 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -514,10 +514,10 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp) { BDRVNVMeState *s = bs->opaque; bool ret = false; - union { + QEMU_AUTO_VFREE union { NvmeIdCtrl ctrl; NvmeIdNs ns; - } *id; + } *id = NULL; NvmeLBAF *lbaf; uint16_t oncs; int r; @@ -595,7 +595,6 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp) s->blkshift = lbaf->ds; out: qemu_vfio_dma_unmap(s->vfio, id); - qemu_vfree(id); return ret; } @@ -1219,7 +1218,7 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes, { BDRVNVMeState *s = bs->opaque; int r; - uint8_t *buf = NULL; + QEMU_AUTO_VFREE uint8_t *buf = NULL; QEMUIOVector local_qiov; size_t len = QEMU_ALIGN_UP(bytes, qemu_real_host_page_size); assert(QEMU_IS_ALIGNED(offset, s->page_size)); @@ -1246,7 +1245,6 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes, if (!r && !is_write) { qemu_iovec_from_buf(qiov, 0, buf, bytes); } - qemu_vfree(buf); return r; } @@ -1365,7 +1363,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, BDRVNVMeState *s = bs->opaque; NVMeQueuePair *ioq = s->queues[INDEX_IO(0)]; NVMeRequest *req; - NvmeDsmRange *buf; + QEMU_AUTO_VFREE NvmeDsmRange *buf = NULL; QEMUIOVector local_qiov; int ret; @@ -1440,7 +1438,6 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, trace_nvme_dsm_done(s, offset, bytes, ret); out: qemu_iovec_destroy(&local_qiov); - qemu_vfree(buf); return ret; } From patchwork Wed Oct 6 16:49:28 2021 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: 1537281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EGGtptHM; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HPgTD3zWnz9sS8 for ; Thu, 7 Oct 2021 03:51:27 +1100 (AEDT) Received: from localhost ([::1]:55706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYA8Z-0004xr-Ji for incoming@patchwork.ozlabs.org; Wed, 06 Oct 2021 12:51:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYA73-00041D-K9 for qemu-devel@nongnu.org; Wed, 06 Oct 2021 12:49:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31911) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYA70-0007OE-TE for qemu-devel@nongnu.org; Wed, 06 Oct 2021 12:49:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633538984; 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=uyPtVC6HvIWx2rYECRqbct1GQVLi/CnHV8MyElho2m0=; b=EGGtptHMWR5bhnkmRq4nc0U8ajF4PeznpwZbaxxQCXA3DQBQ9u9IhFM+KDNRpgqVWhCYnU /G2hWRS00tYzePxDIGT8ngTj93SAVdyGEBf96O7zTXc7jqh/kyqZDFXgVo+I+WJD59XsGS rHtdq92RfSOvchgJxGx+JKbX0E8x3hM= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-594-XRokz5fLPkaNiPtsRuuhVg-1; Wed, 06 Oct 2021 12:49:43 -0400 X-MC-Unique: XRokz5fLPkaNiPtsRuuhVg-1 Received: by mail-wr1-f72.google.com with SMTP id l9-20020adfc789000000b00160111fd4e8so2558720wrg.17 for ; Wed, 06 Oct 2021 09:49:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uyPtVC6HvIWx2rYECRqbct1GQVLi/CnHV8MyElho2m0=; b=ogv+avT5g/pHVsm5ULVAow2d1FyofRsJ+cXnu1zKykJA875L6FGRq0WQpVUu8k+z+k cxa4V5RQrvEqhVQSQvbBlGZlTKrrAyHlrIsCCiefvZJ79HOPvuJVL4gBxe/7HMQpODpN 6Rcg8J8A5hQDHllLqrAcjUpYRX2DPrhHNoAC8kbb9TPl/C16EWtwLN8zBfifmcHWmecc B9rQUJ4R0z86PAs9eiYmc4zEQsCC0wolRmTH0mlm9T/RQGAyMIUvpyovFr5vemI9V9iR zEQDVbhcF0TDJOXrj7CCXOwBq7GoRdjHevpnYQECxcysSTEcjhMnrXO2n6w+ioh+MKtp 2QwA== X-Gm-Message-State: AOAM531iD8FAzTKKNNlGvlPj6zUAxFlUPAfrm6em9bSZ30YFytq9jN2O kNqqizl2UfDDLOrfCLrKIpwnFy81WBUT/HOC3tu5LQZ/lzBaYL2VAL4rHdoo2VP7bkadKLVOU50 TQxWtX5aIGAlKTEsGAlj538aMcLsXdZV/kyNshY/uXud/lx7ZB916W7259CED6ebv X-Received: by 2002:a7b:c314:: with SMTP id k20mr11104730wmj.50.1633538982172; Wed, 06 Oct 2021 09:49:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQsYH0xOdrDeZY6YPbibs3veeOy7/Xb5lWWrxX+u9T5Y8Dqs5Uf2WytMSPIYbHg1lGNOGlxg== X-Received: by 2002:a7b:c314:: with SMTP id k20mr11104708wmj.50.1633538982005; Wed, 06 Oct 2021 09:49:42 -0700 (PDT) Received: from x1w.redhat.com (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id p3sm5905016wmp.43.2021.10.06.09.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 09:49:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/5] block/nvme: Display CQ/SQ pointer in nvme_free_queue_pair() Date: Wed, 6 Oct 2021 18:49:28 +0200 Message-Id: <20211006164931.172349-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211006164931.172349-1-philmd@redhat.com> References: <20211006164931.172349-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.05, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Hanna Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" For debugging purpose it is helpful to know the CQ/SQ pointers. We already have a trace event in nvme_free_queue_pair(), extend it to report these pointer addresses. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 2 +- block/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index fefcc04abe6..0c94799a541 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -185,7 +185,7 @@ static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, static void nvme_free_queue_pair(NVMeQueuePair *q) { - trace_nvme_free_queue_pair(q->index, q); + trace_nvme_free_queue_pair(q->index, q, &q->cq, &q->sq); if (q->completion_bh) { qemu_bh_delete(q->completion_bh); } diff --git a/block/trace-events b/block/trace-events index f2d0a9b62a7..491e765c611 100644 --- a/block/trace-events +++ b/block/trace-events @@ -157,7 +157,7 @@ nvme_dsm_done(void *s, int64_t offset, int64_t bytes, int ret) "s %p offset 0x%" nvme_dma_map_flush(void *s) "s %p" nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u" nvme_create_queue_pair(unsigned q_index, void *q, size_t size, void *aio_context, int fd) "index %u q %p size %zu aioctx %p fd %d" -nvme_free_queue_pair(unsigned q_index, void *q) "index %u q %p" +nvme_free_queue_pair(unsigned q_index, void *q, void *cq, void *sq) "index %u q %p cq %p sq %p" nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d" nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"PRIx64 nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d] %p pages %d" From patchwork Wed Oct 6 16:49:29 2021 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: 1537283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Bi4ABnmG; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HPgYQ6pYkz9sR4 for ; Thu, 7 Oct 2021 03:55:06 +1100 (AEDT) Received: from localhost ([::1]:36002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYAC8-0002Jm-MA for incoming@patchwork.ozlabs.org; Wed, 06 Oct 2021 12:55:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYA75-00041Y-AZ for qemu-devel@nongnu.org; Wed, 06 Oct 2021 12:49:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27189) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYA73-0007Sb-PA for qemu-devel@nongnu.org; Wed, 06 Oct 2021 12:49:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633538989; 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=k+ZAZbWmuK9qI+HMawgY0ECoHoMJ3zL59+qK7eacaOw=; b=Bi4ABnmGRFofKRfDdQObMTve/PGjaiEMyd0rBbWVRamgshGCM8jxTirJ31s8Tw49XGjOVN 5vx4dw/VtPi1ndU8laiwOmMGkTQS3FMhG/UaH+6RZCdD9S0oFNKsG4KsVgGKWoI5V203js hdoZks405I/SX+pUtnh5I7B01lu8JJA= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-458-QievpNW1NrWL99p3dC3uGQ-1; Wed, 06 Oct 2021 12:49:48 -0400 X-MC-Unique: QievpNW1NrWL99p3dC3uGQ-1 Received: by mail-wr1-f71.google.com with SMTP id r21-20020adfa155000000b001608162e16dso2541134wrr.15 for ; Wed, 06 Oct 2021 09:49:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k+ZAZbWmuK9qI+HMawgY0ECoHoMJ3zL59+qK7eacaOw=; b=RbuNwdh+xUmqonjIWYfDHFd4YSxfzTh0y9KTHM+Xn5P4RtJRU0JN02OxkhjJUto9MQ sy4L3iJztfzzngsr08x73Wnj7tAzjluiHDvZyR7s18QzpC2nCWeP9V6XJDKgZIhaBpVo /II6Z4IGijVw514aF/UgtRPnhvNGUVOPYmzGIdTFwtlFuXrg3LDlUyXZPm3B4N+rE6p6 lcWuif+0reFvCW1Wj1VcrGIPZBLpZF8G8qhPyIvmqBWIXAbXT40K5IpGHyw+WZ2LUSGS ORC1inArIdwfd/iOu5LG5liSn09QInSs/9a/ORro+qtf0m+5H8E3vjXeo3p7v4JHADxw LbRQ== X-Gm-Message-State: AOAM531CbxEC+iPC5gTX+ncSTLFR41anzoaHNkiLgwbPmHtIqLeKb+hB cxFrongmiahq7lhFHqFIXyTBdct/hoZVYpbxwVAbGjoD0RSF6vJeU9JrqrJPQoeygEGkjN1JLru kIBROoQbHmdPgKatN7y3EFFJcD2iEuKreN/BFYIT+hSPR77OeGY+Tb+7HrcnONiUe X-Received: by 2002:adf:b353:: with SMTP id k19mr30254337wrd.325.1633538986717; Wed, 06 Oct 2021 09:49:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzutprFgfB/UY53Z6w3HOQ7RCmMEs6QikmtESWYnrbW09dujC14zqUXYhEDaS34vi7r1rD9HA== X-Received: by 2002:adf:b353:: with SMTP id k19mr30254305wrd.325.1633538986440; Wed, 06 Oct 2021 09:49:46 -0700 (PDT) Received: from x1w.redhat.com (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id r2sm6275534wmq.28.2021.10.06.09.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 09:49:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/5] block/nvme: Extract nvme_free_queue() from nvme_free_queue_pair() Date: Wed, 6 Oct 2021 18:49:29 +0200 Message-Id: <20211006164931.172349-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211006164931.172349-1-philmd@redhat.com> References: <20211006164931.172349-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.05, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Hanna Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Instead of duplicating code, extract the common helper to free a single queue. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 0c94799a541..e4f336d79c2 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -183,15 +183,20 @@ static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, return r == 0; } +static void nvme_free_queue(NVMeQueue *q) +{ + qemu_vfree(q->queue); +} + static void nvme_free_queue_pair(NVMeQueuePair *q) { trace_nvme_free_queue_pair(q->index, q, &q->cq, &q->sq); if (q->completion_bh) { qemu_bh_delete(q->completion_bh); } + nvme_free_queue(&q->sq); + nvme_free_queue(&q->cq); qemu_vfree(q->prp_list_pages); - qemu_vfree(q->sq.queue); - qemu_vfree(q->cq.queue); qemu_mutex_destroy(&q->lock); g_free(q); } From patchwork Wed Oct 6 16:49:30 2021 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: 1537291 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RzOu/xhj; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HPgdc6N1hz9sR4 for ; Thu, 7 Oct 2021 03:58:44 +1100 (AEDT) Received: from localhost ([::1]:44640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYAFe-00086b-Ko for incoming@patchwork.ozlabs.org; Wed, 06 Oct 2021 12:58:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYA7B-0004Ew-JO for qemu-devel@nongnu.org; Wed, 06 Oct 2021 12:49:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51353) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYA79-0007Wd-4v for qemu-devel@nongnu.org; Wed, 06 Oct 2021 12:49:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633538994; 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=nAMHwyEPSOT7TJ8wVCCF5DgrBGt0mBuF7+qovAFjDW4=; b=RzOu/xhjgVXm+DgS3xjfcobaRUhQGf3qzEZcdwRteCAuTDQ3qkVm4AFJmhWyunysl/PIJo 2yTh4kvB3SpGwltxk9vPrw4gOHvTVnalcQq3Q/1z6VSdcoEGoH7vXar4JE/+OFFqXI/b3B JJdqE8P0Ivs/7xkfPb5/FfkPP3jg0Eg= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-GwEvMTplP66E42r_-GQgNQ-1; Wed, 06 Oct 2021 12:49:52 -0400 X-MC-Unique: GwEvMTplP66E42r_-GQgNQ-1 Received: by mail-wr1-f69.google.com with SMTP id d13-20020adf9b8d000000b00160a94c235aso2557906wrc.2 for ; Wed, 06 Oct 2021 09:49:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nAMHwyEPSOT7TJ8wVCCF5DgrBGt0mBuF7+qovAFjDW4=; b=NSGRLHPfS016+8s5tCLlGBzRMHGayDFY7FhvGQPWUvfczAIGbAO3ioi8qg7km51nW0 f/B5DpbTG4PT/FDp/m3vS7mBNmVoNSfSwQbVhEF7JPH3+sC5r4e6VPDMH89F5Jmz9Xqp jE8EUu8ZPZtT9G3zsWFjeo4JE3U5s1HEva2Ci/XmDwpno52PsS9FX2yrd1cRDgL3QR2O efBxy0WrmuuX679bjrWsyyWNFu+B2xMHp2b0DrwBgiigi0L/wknGgwkAW87lFYTsqaFk 8ImY6yo9oVQp2D9iXY/AaoZxW8g2O0bc862I6IUDBU8UT2mY9F6Ob5GWCxe5nw+p94wK IjbQ== X-Gm-Message-State: AOAM533ECayUHEz+EQ35Q4C3zXrjR6M1hN5XPUig5KXtj8aQjgya1KRb 1Ynm9EMHIvalT1zgUpbMK/73mnYBVv8OYxkKZs3fj6Ock0cO3XC26O0B3cKu5LNcHhSfY/H5EuU Ts3H66rGe6B5EHJDmTW4O3zPH1DoyWsS/byrK8uxuzFfcFu8FzIPZ4uq36LHHt4hu X-Received: by 2002:a05:6000:15c4:: with SMTP id y4mr29709451wry.177.1633538991164; Wed, 06 Oct 2021 09:49:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx088Od+UzGJjUsyPDFDGtFyPV4u0VVM3HCBTBkz5LB87TvNgTYW80kboCbqGF8FMgT3NMulw== X-Received: by 2002:a05:6000:15c4:: with SMTP id y4mr29709408wry.177.1633538990835; Wed, 06 Oct 2021 09:49:50 -0700 (PDT) Received: from x1w.redhat.com (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id 61sm21482602wrl.94.2021.10.06.09.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 09:49:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/5] block/nvme: Pass BDRVNVMeState* handle to nvme_free_queue_pair() Date: Wed, 6 Oct 2021 18:49:30 +0200 Message-Id: <20211006164931.172349-5-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211006164931.172349-1-philmd@redhat.com> References: <20211006164931.172349-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=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.05, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Hanna Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In the next commit we want to access BDRVNVMeState from nvme_free_queue_pair() callee. Pass it along first. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index e4f336d79c2..6e476f54b9f 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -183,19 +183,19 @@ static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, return r == 0; } -static void nvme_free_queue(NVMeQueue *q) +static void nvme_free_queue(BDRVNVMeState *s, NVMeQueue *q) { qemu_vfree(q->queue); } -static void nvme_free_queue_pair(NVMeQueuePair *q) +static void nvme_free_queue_pair(BDRVNVMeState *s, NVMeQueuePair *q) { trace_nvme_free_queue_pair(q->index, q, &q->cq, &q->sq); if (q->completion_bh) { qemu_bh_delete(q->completion_bh); } - nvme_free_queue(&q->sq); - nvme_free_queue(&q->cq); + nvme_free_queue(s, &q->sq); + nvme_free_queue(s, &q->cq); qemu_vfree(q->prp_list_pages); qemu_mutex_destroy(&q->lock); g_free(q); @@ -270,7 +270,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, return q; fail: - nvme_free_queue_pair(q); + nvme_free_queue_pair(s, q); return NULL; } @@ -693,7 +693,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) s->queue_count++; return true; out_error: - nvme_free_queue_pair(q); + nvme_free_queue_pair(s, q); return false; } @@ -918,7 +918,7 @@ static void nvme_close(BlockDriverState *bs) BDRVNVMeState *s = bs->opaque; for (unsigned i = 0; i < s->queue_count; ++i) { - nvme_free_queue_pair(s->queues[i]); + nvme_free_queue_pair(s, s->queues[i]); } g_free(s->queues); aio_set_event_notifier(bdrv_get_aio_context(bs), From patchwork Wed Oct 6 16:49:31 2021 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: 1537294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RBuZldxp; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HPghh2nwPz9sR4 for ; Thu, 7 Oct 2021 04:01:24 +1100 (AEDT) Received: from localhost ([::1]:52024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYAIE-0004ZV-5t for incoming@patchwork.ozlabs.org; Wed, 06 Oct 2021 13:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYA7F-0004RO-Fk for qemu-devel@nongnu.org; Wed, 06 Oct 2021 12:50:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23468) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYA7C-0007ab-Ph for qemu-devel@nongnu.org; Wed, 06 Oct 2021 12:50:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633538998; 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=d3SY8kt+0eUr16xiO6WRv5UUaNaOH2E74e2h2BTlxRY=; b=RBuZldxpt2+H8VjqJj4puyGxU/7Es5yOPD4FU4N4GKJc//omfMXbpSMoN9JNhbbZAy5EKf 93d3/cviQK/G5JBPUc1VGSilgnNf1zbHJo1CLKC5egJkJkK5dG8msqWdveLySDGPXCQQ7Y khG4DQzTYg3394gsYVIYzq8OMq/TdT8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-375-aaKbAiqeM4mRfsOKcDCgeg-1; Wed, 06 Oct 2021 12:49:57 -0400 X-MC-Unique: aaKbAiqeM4mRfsOKcDCgeg-1 Received: by mail-wr1-f69.google.com with SMTP id d13-20020adfa34d000000b00160aa1cc5f1so2547211wrb.14 for ; Wed, 06 Oct 2021 09:49:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d3SY8kt+0eUr16xiO6WRv5UUaNaOH2E74e2h2BTlxRY=; b=o87He0HME8O9T07Bku/qmXECDkGv38ZqdXEFs99+bSNsJl/u2/I/JEV9jvE+jkD220 gjaER/Vk4PD63WgrDwPfUn2dBpznSsUcrtWWB7ujmFALeYRFAEzdoFIebE6lZT7+hKRC yZEK48OKuGzSXtXLbIf69w2cXjLuAKWBcnACSbH83v+Pm9fOxSK5eIMLtgDQhEqbaSNb SYEHCGHKYXt3uVJNy1kPQBUKlfxEP01ryy3LX9zUBA1i5CTVjvL0dz8a0smq0OcR/nsb Tfwk4pgL82yuPRFdIneCz4OMwovEeA2xX6PfHuSOKAeAcZh5/6Zc9KbVScrosZGwB2Bu Rtag== X-Gm-Message-State: AOAM530t+RRHrsRmxxGepVuuApyzGJ9zddFqqiJhgArwQCsrwVQXmQLQ 071ZTxP2dkxSNKp5CuDjjp1fekNb4ADeQcaiOpwfw0IRDsfHTmePcIr6XhSM6gH4Z+ea1ziMVRR KIDUju+yVR6NnVXjZQDirzksm14KzW6H9i08nQ61zftE+2mOl0ROn3dIFMaVK+6ce X-Received: by 2002:a1c:158:: with SMTP id 85mr10873941wmb.187.1633538995662; Wed, 06 Oct 2021 09:49:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYXrWDPsnysXoTslg9CNi8EtDOIX+tHxKAHzrlnJ6h+EnzldDiVm9QAyPTkus4yIScFH6FPg== X-Received: by 2002:a1c:158:: with SMTP id 85mr10873911wmb.187.1633538995379; Wed, 06 Oct 2021 09:49:55 -0700 (PDT) Received: from x1w.redhat.com (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id k22sm21875271wrd.59.2021.10.06.09.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 09:49:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 5/5] block/nvme: Fix memory leak from nvme_init_queue() Date: Wed, 6 Oct 2021 18:49:31 +0200 Message-Id: <20211006164931.172349-6-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211006164931.172349-1-philmd@redhat.com> References: <20211006164931.172349-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=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.05, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Hanna Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" nvme_create_queue_pair() allocates resources with qemu_vfio_dma_map(), but we never release them. Do it in nvme_free_queue() which is called from nvme_free_queue_pair(). Reported by valgrind: ==252858== 520,192 bytes in 1 blocks are still reachable in loss record 8,293 of 8,302 ==252858== at 0x4846803: memalign (vg_replace_malloc.c:1265) ==252858== by 0x484691F: posix_memalign (vg_replace_malloc.c:1429) ==252858== by 0xB8AFE4: qemu_try_memalign (oslib-posix.c:210) ==252858== by 0xA9E315: nvme_create_queue_pair (nvme.c:229) ==252858== by 0xAA0125: nvme_init (nvme.c:799) ==252858== by 0xAA081C: nvme_file_open (nvme.c:953) ==252858== by 0xA23DDD: bdrv_open_driver (block.c:1550) ==252858== by 0xA24806: bdrv_open_common (block.c:1827) ==252858== by 0xA2889B: bdrv_open_inherit (block.c:3747) ==252858== by 0xA28DE4: bdrv_open (block.c:3840) ==252858== by 0x9E0F8E: bds_tree_init (blockdev.c:675) ==252858== by 0x9E7C74: qmp_blockdev_add (blockdev.c:3551) Fixes: bdd6a90a9e5 ("block: Add VFIO based NVMe driver") Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/nvme.c b/block/nvme.c index 6e476f54b9f..903c8ffa060 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -185,6 +185,7 @@ static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, static void nvme_free_queue(BDRVNVMeState *s, NVMeQueue *q) { + qemu_vfio_dma_unmap(s->vfio, q->queue); qemu_vfree(q->queue); }