From nobody Fri Apr 4 03:42:04 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1741702457; cv=none; d=zohomail.com; s=zohoarc; b=QP8g4HNgH9HdOUJbaZezb1GcTlOk0xwf98h23uUthdDzc2BDn9pwVIyK9v/uvR+8pJSrnhnMCnGPMsLMpHuCOIDK3OtYQ+wlR/lYuNjGFm/7QGzmJeMrZcpfUxK+p8124IPynoajIJEyvL6SdCzShJMUm7PO1FrVwxZJ3D1KMYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741702457; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=owj2HZv9sPJ7eC1JcJnAuK8sPXLAi7OHMr4StlZBrM4=; b=X0gkuylJTVUNZYbqIBb2qM3ED/uFWOmQG2SmO0lbW2byGsYH3LhPvM07DWO2uu6SWBdSylS3qWBSSPWE/yQBEuQqMv03LQX05kiiM2/LWBmijJuecOqqzIeuHL0juu3YynOu1bAlULFTR4dFJXrzq7wQu+kiywlSNyTtp860VMw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741702457679961.8169739981068; Tue, 11 Mar 2025 07:14:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1trzNj-0006GA-5V; Tue, 11 Mar 2025 09:10:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1trzL8-00036j-VS for qemu-devel@nongnu.org; Tue, 11 Mar 2025 09:08:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1trzL7-0001Zi-8v for qemu-devel@nongnu.org; Tue, 11 Mar 2025 09:08:10 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-428-Ez4THJVqMLe7WvlV6uCgrA-1; Tue, 11 Mar 2025 09:08:04 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B6803180025E; Tue, 11 Mar 2025 13:08:01 +0000 (UTC) Received: from localhost (unknown [10.2.16.91]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A1D141956094; Tue, 11 Mar 2025 13:07:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741698488; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=owj2HZv9sPJ7eC1JcJnAuK8sPXLAi7OHMr4StlZBrM4=; b=Tn7fqryI2BOEimon3AD3J9ekVHUXxpFQu/6NfbOvazftxYlXMRzaYY/3QO2IPosL3oW8Cc bz+/pxWE6hRK8V7LzHD0aKtC3I7pe88o3MyPRu3M6P0CPYiWkVu+CVgBdaN6X9EoElR4iA CpgRe5Y1cGMZK81cnGfEeSa90JnaiYU= X-MC-Unique: Ez4THJVqMLe7WvlV6uCgrA-1 X-Mimecast-MFC-AGG-ID: Ez4THJVqMLe7WvlV6uCgrA_1741698483 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Kevin Wolf , pkrempa@redhat.com, Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , David Hildenbrand , "Michael S. Tsirkin" , Hanna Reitz , Peter Xu , Fam Zheng , John Snow Subject: [PATCH v3 03/14] scsi: track per-SCSIRequest AioContext Date: Tue, 11 Mar 2025 21:07:30 +0800 Message-ID: <20250311130741.1047903-4-stefanha@redhat.com> In-Reply-To: <20250311130741.1047903-1-stefanha@redhat.com> References: <20250311130741.1047903-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1741702460138019000 Content-Type: text/plain; charset="utf-8" Until now, a SCSIDevice's I/O requests have run in a single AioContext. In order to support multiple IOThreads it will be necessary to move to the concept of a per-SCSIRequest AioContext. Signed-off-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- include/hw/scsi/scsi.h | 1 + hw/scsi/scsi-bus.c | 1 + hw/scsi/scsi-disk.c | 17 ++++++----------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index c3d5e17e38..ffc48203f9 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -24,6 +24,7 @@ struct SCSIRequest { SCSIBus *bus; SCSIDevice *dev; const SCSIReqOps *ops; + AioContext *ctx; uint32_t refcount; uint32_t tag; uint32_t lun; diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 7d4546800f..846bbbf0ec 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -868,6 +868,7 @@ invalid_opcode: } } =20 + req->ctx =3D qemu_get_current_aio_context(); req->cmd =3D cmd; req->residual =3D req->cmd.xfer; =20 diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index f049a20275..7cf8c31b98 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -328,9 +328,8 @@ static void scsi_aio_complete(void *opaque, int ret) SCSIDiskReq *r =3D (SCSIDiskReq *)opaque; SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, r->req.dev); =20 - /* The request must only run in the BlockBackend's AioContext */ - assert(blk_get_aio_context(s->qdev.conf.blk) =3D=3D - qemu_get_current_aio_context()); + /* The request must run in its AioContext */ + assert(r->req.ctx =3D=3D qemu_get_current_aio_context()); =20 assert(r->req.aiocb !=3D NULL); r->req.aiocb =3D NULL; @@ -430,12 +429,10 @@ static void scsi_dma_complete(void *opaque, int ret) =20 static void scsi_read_complete_noio(SCSIDiskReq *r, int ret) { - SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint32_t n; =20 - /* The request must only run in the BlockBackend's AioContext */ - assert(blk_get_aio_context(s->qdev.conf.blk) =3D=3D - qemu_get_current_aio_context()); + /* The request must run in its AioContext */ + assert(r->req.ctx =3D=3D qemu_get_current_aio_context()); =20 assert(r->req.aiocb =3D=3D NULL); if (scsi_disk_req_check_error(r, ret, ret > 0)) { @@ -562,12 +559,10 @@ static void scsi_read_data(SCSIRequest *req) =20 static void scsi_write_complete_noio(SCSIDiskReq *r, int ret) { - SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint32_t n; =20 - /* The request must only run in the BlockBackend's AioContext */ - assert(blk_get_aio_context(s->qdev.conf.blk) =3D=3D - qemu_get_current_aio_context()); + /* The request must run in its AioContext */ + assert(r->req.ctx =3D=3D qemu_get_current_aio_context()); =20 assert (r->req.aiocb =3D=3D NULL); if (scsi_disk_req_check_error(r, ret, ret > 0)) { --=20 2.48.1