From patchwork Thu Jun 23 21:18:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1647373 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" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=PPV5nQys; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=qKb1pqSP; 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 4LTYQx1xxWz9s09 for ; Fri, 24 Jun 2022 07:33:44 +1000 (AEST) Received: from localhost ([::1]:52352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4USM-0002JZ-2Q for incoming@patchwork.ozlabs.org; Thu, 23 Jun 2022 17:33:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDx-0006Gr-4A; Thu, 23 Jun 2022 17:18:49 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:48911) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UDv-00046I-Fq; Thu, 23 Jun 2022 17:18:48 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 7E697320091E; Thu, 23 Jun 2022 17:18:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 23 Jun 2022 17:18:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656019125; x= 1656105525; bh=urkDKj28QOaJNNz3LSM48EgyVlP0l7gXJ1kwu/bRW4s=; b=P PV5nQysTSSh9AEW7bw0BGLMuknaO4mhjJRW4aH+D6DZ+uydLBBLOKzQTqOC6K95U Zkzqpj3hUQEpzFGGGYSLigOP0HvRSB8RYPFqNF23/wSsnS6zijxw2+x4fWIWTirI 2p9od6jY8RGkYA+5Yai5ORFfqUJrwPD15XEIc320ZUb5xWEwUxlgnwFhqVeGpsBm tDRhu5toYO7uKxoaA7G2EUNQ6DoPXwVd1BAkoAkaa3GoP9VdmvNrerZ2Ir/PQfRm KM1fSQq5RvB+ffugxBptyIP6Gv3ipp9A4vYDcXye26GCF2SEt5O3RUHaKJuMV/rC gkgIIwxvuTtir7577eT1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656019125; x=1656105525; bh=urkDKj28QOaJN Nz3LSM48EgyVlP0l7gXJ1kwu/bRW4s=; b=qKb1pqSPOMsD4GopT1rZBgAe71cDW CXr/xf6wLgk2z3RwVMw3+alccLCjUG5kkCwDNB6bw1eNYDChYV0eKS80aEMf+Ru9 WjSEe9Fn6Zu3TCnwFvRBcdVCMwNUu+28y910qFfLqByGXTlHZ/0chV01HBm+Teh1 NvvN79paScPfDbWwE2SbiRw7Z8GQvPm/XulzC9e5+LGOBG7vACSnD/7D1adYG90o Gp7JZAN1+fEKZB9l0hSYD1kQDUBnBwzNeFT2OeBDWq1TJYWsUurQHL4+Lg456sv8 Hgy1p/hiph599xguPd0+UsmrZ5mfvX6RRMXCsSYVkuPazFO82EEPhguFg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedu jedugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jun 2022 17:18:43 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Keith Busch , Klaus Jensen , Klaus Jensen Subject: [PATCH 08/12] hw/nvme: rework flush bh scheduling Date: Thu, 23 Jun 2022 23:18:17 +0200 Message-Id: <20220623211821.50534-9-its@irrelevant.dk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623211821.50534-1-its@irrelevant.dk> References: <20220623211821.50534-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Remove an initial bh scheduling and move the completion invocation into a separate bh. Also, make sure that iocb->aiocb is NULL'ed when cancelling. Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index cea90cf65ce8..1acf88d9e8c7 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -3168,6 +3168,19 @@ static const AIOCBInfo nvme_flush_aiocb_info = { .get_aio_context = nvme_get_aio_context, }; +static void nvme_flush_bh(void *opaque) +{ + NvmeFlushAIOCB *iocb = opaque; + + iocb->common.cb(iocb->common.opaque, iocb->ret); + + qemu_bh_delete(iocb->bh); + iocb->bh = NULL; + qemu_aio_unref(iocb); +} + +static void nvme_do_flush(NvmeFlushAIOCB *iocb); + static void nvme_flush_ns_cb(void *opaque, int ret) { NvmeFlushAIOCB *iocb = opaque; @@ -3189,13 +3202,11 @@ static void nvme_flush_ns_cb(void *opaque, int ret) } out: - iocb->aiocb = NULL; - qemu_bh_schedule(iocb->bh); + nvme_do_flush(iocb); } -static void nvme_flush_bh(void *opaque) +static void nvme_do_flush(NvmeFlushAIOCB *iocb) { - NvmeFlushAIOCB *iocb = opaque; NvmeRequest *req = iocb->req; NvmeCtrl *n = nvme_ctrl(req); int i; @@ -3222,14 +3233,9 @@ static void nvme_flush_bh(void *opaque) return; done: - qemu_bh_delete(iocb->bh); - iocb->bh = NULL; - - iocb->common.cb(iocb->common.opaque, iocb->ret); - - qemu_aio_unref(iocb); - - return; + if (iocb->bh) { + qemu_bh_schedule(iocb->bh); + } } static uint16_t nvme_flush(NvmeCtrl *n, NvmeRequest *req) @@ -3263,7 +3269,7 @@ static uint16_t nvme_flush(NvmeCtrl *n, NvmeRequest *req) } req->aiocb = &iocb->common; - qemu_bh_schedule(iocb->bh); + nvme_do_flush(iocb); return NVME_NO_COMPLETE;