From nobody Thu Apr 10 15:21:42 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=1741687998; cv=none; d=zohomail.com; s=zohoarc; b=RN82IyXeEWIlH81pWsU9xtFxsUCYrnWOeksrMjgoUlX0RzYxEBBuZ9fVPC9BfNVKwqt1aremESsQqLoiMiAE04YjD0aRW7ZPXdE57IV5QGL7KzZz1iVGe8757hr2Wfc9gR/IY2OXJzzwZk1vguXBjeESv+lY8JeKfJtEI0Lbx4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741687998; 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=naHVGJFa38LaQNICis0boZuo3re9eX6cS1hYuWgvw3DTM5l8lmzy6z437In2WyUd7a9HwOan37jfNJid/x0B63Hr8MMGEn82sGT1DtwUPl9AHbFMRgBCsL20Ee7RIoTZ2SAORRcqIsCtEk3qiD+oGw/IKI0fOO8xyAYmcX3UgBk= 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 1741687998414457.4881572404638; Tue, 11 Mar 2025 03:13:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1trwaw-0006Od-KE; Tue, 11 Mar 2025 06:12:18 -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 1trwav-0006Nl-0f for qemu-devel@nongnu.org; Tue, 11 Mar 2025 06:12:17 -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 1trwaq-0005dc-Ti for qemu-devel@nongnu.org; Tue, 11 Mar 2025 06:12:16 -0400 Received: from mx-prod-mc-08.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-8-H19LciYANsq9yMXh80e_2Q-1; Tue, 11 Mar 2025 06:12:06 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5B4AC1809CA5; Tue, 11 Mar 2025 10:12:05 +0000 (UTC) Received: from localhost (unknown [10.2.16.75]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 31E281800268; Tue, 11 Mar 2025 10:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741687929; 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=ZAnFlCVE+8KNtWgxSpGdbLYx6tpByhx7YN0baFxVtuRL+xbh8yDvTiIt53Z0E5Jq0Y8m7g mVU6joTHpgUE5PJxHvGCSJNH+VLI4dz1CVfNKM/+ppQFEFNqyOoErCnGsdPf0vmQGNGS0s PBqVZS+G2SABP0+59z6CRRoQozchX1o= X-MC-Unique: H19LciYANsq9yMXh80e_2Q-1 X-Mimecast-MFC-AGG-ID: H19LciYANsq9yMXh80e_2Q_1741687925 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Paolo Bonzini , David Hildenbrand , , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Kevin Wolf , Fam Zheng , "Michael S. Tsirkin" , Stefan Hajnoczi , Hanna Reitz , pkrempa@redhat.com, John Snow Subject: [PATCH v2 03/13] scsi: track per-SCSIRequest AioContext Date: Tue, 11 Mar 2025 18:11:35 +0800 Message-ID: <20250311101145.1037388-4-stefanha@redhat.com> In-Reply-To: <20250311101145.1037388-1-stefanha@redhat.com> References: <20250311101145.1037388-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1741688001247019100 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