From nobody Sat May 18 16:47:02 2024 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=1674071301; cv=none; d=zohomail.com; s=zohoarc; b=Kyu5scyJ2RQ7E7fvA2eRPRe3Q9rPBogYaOxyreoJvSqIPI0KctXSUQU6tS2RsOtf2VBRiSMF9Pb9g6zKjYe5N7yQZAD/vAhaAJ/jL1tjSm5KjLv6Ejj/eh72jYUL03u9CvKM8w/Aa7fCfXyw5kTsBXnqlvxtqu1ggpk3oVSqi30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674071301; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=k2aoHPelUbE36+eo9gQUruGzVlTIBas83/H+faoy6cM=; b=QHkEaEytBJxYLQ4WMwb7Cd794APAmYH1rq0bES9MAcfCpx+MIpqfsynadQREJVYHC3l9uwoYGlkjn+P/P4ywL797ap+njMnyYjOG8D8Q/Fr/W2Dh7m6g12a2edmcfNpHFBli/hcEjI41gDvBbhxgiHA2XUXMK3/UMIAtyGPJNLM= 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 1674071300691338.0536900396984; Wed, 18 Jan 2023 11:48:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIEPQ-0002cg-UE; Wed, 18 Jan 2023 14:47:44 -0500 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 1pIEPP-0002bs-2w for qemu-devel@nongnu.org; Wed, 18 Jan 2023 14:47:43 -0500 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 1pIEPN-0000nu-LL for qemu-devel@nongnu.org; Wed, 18 Jan 2023 14:47:42 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-32-ZB9Eg4pTPCaX3DDhzrN0cg-1; Wed, 18 Jan 2023 14:47:37 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C05E2101A52E; Wed, 18 Jan 2023 19:47:36 +0000 (UTC) Received: from localhost (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4243F40C6EC4; Wed, 18 Jan 2023 19:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674071260; 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=k2aoHPelUbE36+eo9gQUruGzVlTIBas83/H+faoy6cM=; b=BCwP7gF4WsrOP7mIIpw6P1H+fs/dvnY42tX3A/K6YuBp+BxbIAQ8WCLxwOay3j/ULGNhdn sumziDSfQIFBC8EajvCeCz0Tj0tlH9fUNXrNt2Gc7BMpqNlHcCSC51JAI2zNMnv5WcQl6s 0CmsHamDi/IZHh5FepI0pKTa57vZCBo= X-MC-Unique: ZB9Eg4pTPCaX3DDhzrN0cg-1 From: Stefan Hajnoczi To: Cc: Kevin Wolf , Eduardo Habkost , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Hanna Reitz , Markus Armbruster , Paolo Bonzini , Emanuele Giuseppe Esposito , qemu-block@nongnu.org, Eric Blake , Stefan Hajnoczi , "Michael S. Tsirkin" , Michal Privoznik Subject: [RFC 1/3] qdev-properties: alias all object class properties Date: Wed, 18 Jan 2023 14:47:30 -0500 Message-Id: <20230118194732.1258208-2-stefanha@redhat.com> In-Reply-To: <20230118194732.1258208-1-stefanha@redhat.com> References: <20230118194732.1258208-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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, 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: 1674071302030100001 Content-Type: text/plain; charset="utf-8" qdev_alias_all_properties() aliases a DeviceState's qdev properties onto an Object. This is used for VirtioPCIProxy types so that --device virtio-blk-pci has properties of its embedded --device virtio-blk-device object. Currently this function is implemented using qdev properties. Change the function to use QOM object class properties instead. This works because qdev properties create QOM object class properties, but it also catches any QOM object class-only properties that have no qdev properties. This change ensures that properties of devices are shown with --device foo,\? even if they are QOM object class properties. Signed-off-by: Stefan Hajnoczi --- hw/core/qdev-properties.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 357b8761b5..fbf3969d3c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -959,16 +959,18 @@ void device_class_set_props(DeviceClass *dc, Property= *props) void qdev_alias_all_properties(DeviceState *target, Object *source) { ObjectClass *class; - Property *prop; + ObjectPropertyIterator iter; + ObjectProperty *prop; =20 class =3D object_get_class(OBJECT(target)); - do { - DeviceClass *dc =3D DEVICE_CLASS(class); =20 - for (prop =3D dc->props_; prop && prop->name; prop++) { - object_property_add_alias(source, prop->name, - OBJECT(target), prop->name); + object_class_property_iter_init(&iter, class); + while ((prop =3D object_property_iter_next(&iter))) { + if (object_property_find(source, prop->name)) { + continue; /* skip duplicate properties */ } - class =3D object_class_get_parent(class); - } while (class !=3D object_class_by_name(TYPE_DEVICE)); + + object_property_add_alias(source, prop->name, + OBJECT(target), prop->name); + } } --=20 2.39.0 From nobody Sat May 18 16:47:02 2024 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=1674071301; cv=none; d=zohomail.com; s=zohoarc; b=hEBW7fYmr363otXYjTVv7gBoNWeZgNr7yeTRJnAvtGi86jWvr7fjuyR+Ola47a+2DjGIh8sVFqX8mWWRcKpApiIQr+ap9b2BvmtzpwPiSKuuhHXwsx8eqSzSvAskcr6hbiEgPbnnVLx8vkyjr7ZinB3cNAiWnR/jtjGvYS3hMik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674071301; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Jdbac7bWn14KYSrw8J1g3C+Lqe+SUOl94VtmVjU9v28=; b=CV0zxDONUb6AtMyxoCFfSjbFOc9qUvCW8cBnV+DhTXb+YT7iPxgJrguEjR7GmUE8GwjNHofVuyJ3DlqLLe45MUCGHJ4L/dtbJvoC1l+7N0gKFbbkGg/i1ziowBrnfc3rQwcUNOfXmKTzIDhIcCFb0b846JbJmdLXMYk6c08Ha/0= 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 1674071301188724.4455968688047; Wed, 18 Jan 2023 11:48:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIEPS-0002eE-NP; Wed, 18 Jan 2023 14:47:46 -0500 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 1pIEPR-0002cr-7i for qemu-devel@nongnu.org; Wed, 18 Jan 2023 14:47:45 -0500 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 1pIEPP-0000oN-Io for qemu-devel@nongnu.org; Wed, 18 Jan 2023 14:47:44 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-442-Id5nqg6sM7uOvlY9V7-B4A-1; Wed, 18 Jan 2023 14:47:39 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0365183B3C6; Wed, 18 Jan 2023 19:47:38 +0000 (UTC) Received: from localhost (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65BCB40C2064; Wed, 18 Jan 2023 19:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674071262; 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=Jdbac7bWn14KYSrw8J1g3C+Lqe+SUOl94VtmVjU9v28=; b=MzwmtCsMuiPnTaLL0TIZZqK9GaqDBHpeKgSvOux7p7PD5lck53WMuR6Bdvwe8uqcH8+3UL 4M7jaUOFilxE+gViz7m7fiASM+oyfziEEH5RWU3EKSA0vz9kNfKC4/+m23ntLvOkd+43Xw u5dQf8ffJIKPVC4uJiUQERcbDBwNT70= X-MC-Unique: Id5nqg6sM7uOvlY9V7-B4A-1 From: Stefan Hajnoczi To: Cc: Kevin Wolf , Eduardo Habkost , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Hanna Reitz , Markus Armbruster , Paolo Bonzini , Emanuele Giuseppe Esposito , qemu-block@nongnu.org, Eric Blake , Stefan Hajnoczi , "Michael S. Tsirkin" , Michal Privoznik Subject: [RFC 2/3] qdev: add IOThreadVirtQueueMappingList property type Date: Wed, 18 Jan 2023 14:47:31 -0500 Message-Id: <20230118194732.1258208-3-stefanha@redhat.com> In-Reply-To: <20230118194732.1258208-1-stefanha@redhat.com> References: <20230118194732.1258208-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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, 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: 1674071302043100003 Content-Type: text/plain; charset="utf-8" virtio-blk and virtio-scsi devices will need a way to specify the mapping between IOThreads and virtqueues. At the moment all virtqueues are assigned to a single IOThread or the main loop. This single thread can be a CPU bottleneck, so it is necessary to allow finer-grained assignment to spread the load. Introduce DEFINE_PROP_IOTHREAD_VQ_MAPPING_LIST() so devices can take a parameter that maps virtqueues to IOThreads. The command-line syntax for this new property is as follows: --device '{"driver":"foo","iothread-vq-mapping":[{"iothread":"iothread0",= "vqs":[0,1,2]},...]}' IOThreads are specified by name and virtqueues are specified by 0-based index. It will be common to simply assign virtqueues round-robin across a set of IOThreads. A convenient syntax that does not require specifying individual virtqueue indices is available: --device '{"driver":"foo","iothread-vq-mapping":[{"iothread":"iothread0"}= ,{"iothread":"iothread1"},...]}' Signed-off-by: Stefan Hajnoczi --- qapi/virtio.json | 30 ++++++++++++++++++ include/hw/qdev-properties-system.h | 4 +++ hw/core/qdev-properties-system.c | 47 +++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/qapi/virtio.json b/qapi/virtio.json index 019d2d1987..f8006bdf3e 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -952,3 +952,33 @@ 'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' }, 'returns': 'VirtioQueueElement', 'features': [ 'unstable' ] } + +## +# @IOThreadVirtQueueMapping: +# +# Describes the subset of virtqueues assigned to an IOThread. +# +# @iothread: the id of IOThread object +# @vqs: an optional array of virtqueue indices that will be handled by this +# IOThread. When absent, virtqueues are assigned round-robin across = all +# IOThreadVirtQueueMappings provided. Either all +# IOThreadVirtQueueMappings must have @vqs or none of them must have= it. +# +# Since: 8.0 +# +## + +{ 'struct': 'IOThreadVirtQueueMapping', + 'data': { 'iothread': 'str', '*vqs': ['uint16'] } } + +## +# @IOThreadVirtQueueMappings: +# +# IOThreadVirtQueueMapping list. This struct is not actually used but the +# IOThreadVirtQueueMappingList type it generates is! +# +# Since: 8.0 +## + +{ 'struct': 'IOThreadVirtQueueMappings', + 'data': { 'mappings': ['IOThreadVirtQueueMapping'] } } diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properti= es-system.h index 0ac327ae60..c526e502c8 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -22,6 +22,7 @@ extern const PropertyInfo qdev_prop_audiodev; extern const PropertyInfo qdev_prop_off_auto_pcibar; extern const PropertyInfo qdev_prop_pcie_link_speed; extern const PropertyInfo qdev_prop_pcie_link_width; +extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; =20 #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) @@ -73,5 +74,8 @@ extern const PropertyInfo qdev_prop_pcie_link_width; #define DEFINE_PROP_UUID_NODEFAULT(_name, _state, _field) \ DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID) =20 +#define DEFINE_PROP_IOTHREAD_VQ_MAPPING_LIST(_name, _state, _field) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list,= \ + IOThreadVirtQueueMappingList *) =20 #endif diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index 54a09fa9ac..9b41628d94 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -18,6 +18,7 @@ #include "qapi/qapi-types-block.h" #include "qapi/qapi-types-machine.h" #include "qapi/qapi-types-migration.h" +#include "qapi/qapi-visit-virtio.h" #include "qapi/qmp/qerror.h" #include "qemu/ctype.h" #include "qemu/cutils.h" @@ -1117,3 +1118,49 @@ const PropertyInfo qdev_prop_uuid =3D { .set =3D set_uuid, .set_default_value =3D set_default_uuid_auto, }; + +/* --- IOThreadVirtQueueMappingList --- */ + +static void get_iothread_vq_mapping_list(Object *obj, Visitor *v, + const char *name, void *opaque, Error **errp) +{ + IOThreadVirtQueueMappingList **prop_ptr =3D + object_field_prop_ptr(obj, opaque); + IOThreadVirtQueueMappingList *list =3D *prop_ptr; + + visit_type_IOThreadVirtQueueMappingList(v, name, &list, errp); +} + +static void set_iothread_vq_mapping_list(Object *obj, Visitor *v, + const char *name, void *opaque, Error **errp) +{ + IOThreadVirtQueueMappingList **prop_ptr =3D + object_field_prop_ptr(obj, opaque); + IOThreadVirtQueueMappingList *list; + + if (!visit_type_IOThreadVirtQueueMappingList(v, name, &list, errp)) { + return; + } + + qapi_free_IOThreadVirtQueueMappingList(*prop_ptr); + *prop_ptr =3D list; +} + +static void release_iothread_vq_mapping_list(Object *obj, + const char *name, void *opaque) +{ + IOThreadVirtQueueMappingList **prop_ptr =3D + object_field_prop_ptr(obj, opaque); + + qapi_free_IOThreadVirtQueueMappingList(*prop_ptr); + *prop_ptr =3D NULL; +} + +const PropertyInfo qdev_prop_iothread_vq_mapping_list =3D { + .name =3D "IOThreadVirtQueueMappingList", + .description =3D "IOThread virtqueue mapping list [{\"iothread\":\"\", " + "\"vqs\":[1,2,3,...]},...]", + .get =3D get_iothread_vq_mapping_list, + .set =3D set_iothread_vq_mapping_list, + .release =3D release_iothread_vq_mapping_list, +}; --=20 2.39.0 From nobody Sat May 18 16:47:02 2024 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=1674071304; cv=none; d=zohomail.com; s=zohoarc; b=NEJT3PGpQkzBowTi/ozEpZaHCP1lCG2cKHP7WL70nlT98/JKlLCoHJP4U/K0mIaXfgLB9dnhM/rgNTG5uvsm91RflJg8LQ6riDr2KPPzFgQk1MAFOpw6HsMcpHNfUipXO/rk6VNMN9cKUJLKbhyj2EsgCF0s+gc5J3vuAsPPpQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674071304; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K6bqAuqOMKjHHYbIvIDoBonaoMQyPqF/T5JIdhlQRQ0=; b=JFhhDoNt27b52HhS29UOFjg5KlbqXDiBjH69iZIVzKwNWoFNOXS7uEg5SIVW4d1Nj0cET8vAJJQoF9oF67MGM8yD0U1MojQXSZUB0OLjBAyS9CFMLikw5CL9YDjKboGGFSQRJV7lMjS04ccqR98u9tZW04GLxd5724LolZp1v0U= 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 1674071304497588.2136084546003; Wed, 18 Jan 2023 11:48:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIEPU-0002ep-FQ; Wed, 18 Jan 2023 14:47:48 -0500 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 1pIEPT-0002eG-3I for qemu-devel@nongnu.org; Wed, 18 Jan 2023 14:47:47 -0500 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 1pIEPR-0000ov-HY for qemu-devel@nongnu.org; Wed, 18 Jan 2023 14:47:46 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-240-lWTLAecRNOaYvz01pz48hQ-1; Wed, 18 Jan 2023 14:47:41 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71F5F1C0513C; Wed, 18 Jan 2023 19:47:41 +0000 (UTC) Received: from localhost (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA33A40C6EC4; Wed, 18 Jan 2023 19:47:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674071265; 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=K6bqAuqOMKjHHYbIvIDoBonaoMQyPqF/T5JIdhlQRQ0=; b=KOOGp4SAiY2E9ClMpJ6wXzkVPcvhKQzWl82qmocacDaItODY7rHzbcmlmsEePCALShwidC mIvPnMfGlbiPds2Q3w9JKlNpqj6L3elzjDLmNuxAaiR9EpSyMTggEnpSSb2w1JBX9Qc7ow biAR0bA0IuQ4vdkoh6AY2Ubr9nbhDWs= X-MC-Unique: lWTLAecRNOaYvz01pz48hQ-1 From: Stefan Hajnoczi To: Cc: Kevin Wolf , Eduardo Habkost , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Hanna Reitz , Markus Armbruster , Paolo Bonzini , Emanuele Giuseppe Esposito , qemu-block@nongnu.org, Eric Blake , Stefan Hajnoczi , "Michael S. Tsirkin" , Michal Privoznik Subject: [RFC 3/3] virtio-blk: add iothread-vq-mapping parameter Date: Wed, 18 Jan 2023 14:47:32 -0500 Message-Id: <20230118194732.1258208-4-stefanha@redhat.com> In-Reply-To: <20230118194732.1258208-1-stefanha@redhat.com> References: <20230118194732.1258208-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1674071305717100001 Content-Type: text/plain; charset="utf-8" Add the iothread-vq-mapping parameter to assign virtqueues to IOThreads. Note that this commit simply adds the VirtIOBlock->iothread_vq_mapping_list field but does not use it yet. The block layer doesn't support multi-queue yet, so we cannot safely process virtqueues from multiple IOThreads at this time. Signed-off-by: Stefan Hajnoczi --- include/hw/virtio/virtio-blk.h | 2 + hw/block/virtio-blk.c | 78 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index 7f589b4146..7324f4468f 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -21,6 +21,7 @@ #include "sysemu/block-backend.h" #include "sysemu/block-ram-registrar.h" #include "qom/object.h" +#include "qapi/qapi-types-virtio.h" =20 #define TYPE_VIRTIO_BLK "virtio-blk-device" OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBlock, VIRTIO_BLK) @@ -37,6 +38,7 @@ struct VirtIOBlkConf { BlockConf conf; IOThread *iothread; + IOThreadVirtQueueMappingList *iothread_vq_mapping_list; char *serial; uint32_t request_merging; uint16_t num_queues; diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index f717550fdc..ed53dc3686 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1098,6 +1098,68 @@ static int virtio_blk_load_device(VirtIODevice *vdev= , QEMUFile *f, return 0; } =20 +static bool +validate_iothread_vq_mapping_list(IOThreadVirtQueueMappingList *list, + uint16_t num_queues, Error **errp) +{ + g_autofree unsigned long *vqs =3D bitmap_new(num_queues); + g_autoptr(GHashTable) iothreads =3D + g_hash_table_new(g_str_hash, g_str_equal); + + for (IOThreadVirtQueueMappingList *node =3D list; node; node =3D node-= >next) { + const char *name =3D node->value->iothread; + uint16List *vq; + + if (!iothread_by_id(name)) { + error_setg(errp, "IOThread \"%s\" object does not exist", name= ); + return false; + } + + if (!g_hash_table_add(iothreads, (gpointer)name)) { + error_setg(errp, + "duplicate IOThread name \"%s\" in iothread-vq-mapping= ", + name); + return false; + } + + if (node !=3D list) { + if (!!node->value->vqs !=3D !!list->value->vqs) { + error_setg(errp, "either all items in iothread-vq-mapping " + "must have vqs or none of them must have = it"); + return false; + } + } + + for (vq =3D node->value->vqs; vq; vq =3D vq->next) { + if (vq->value >=3D num_queues) { + error_setg(errp, "vq index %u for IOThread \"%s\" must be " + "less than num_queues %u in iothread-vq-mapping", + vq->value, name, num_queues); + return false; + } + + if (test_and_set_bit(vq->value, vqs)) { + error_setg(errp, "cannot assign vq %u to IOThread \"%s\" " + "because it is already assigned", vq->value, name); + return false; + } + } + } + + if (list->value->vqs) { + for (uint16_t i =3D 0; i < num_queues; i++) { + if (!test_bit(i, vqs)) { + error_setg(errp, + "missing vq %u IOThread assignment in iothread-vq-= mapping", + i); + return false; + } + } + } + + return true; +} + static void virtio_resize_cb(void *opaque) { VirtIODevice *vdev =3D opaque; @@ -1191,6 +1253,19 @@ static void virtio_blk_device_realize(DeviceState *d= ev, Error **errp) return; } =20 + if (s->conf.iothread_vq_mapping_list) { + if (s->conf.iothread) { + error_setg(errp, "iothread and iothread-vq-mapping properties " + "cannot be set at the same time"); + return; + } + + if (!validate_iothread_vq_mapping_list(s->conf.iothread_vq_mapping= _list, + s->conf.num_queues, errp)) { + return; + } + } + s->config_size =3D virtio_get_config_size(&virtio_blk_cfg_size_params, s->host_features); virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size); @@ -1203,6 +1278,7 @@ static void virtio_blk_device_realize(DeviceState *de= v, Error **errp) virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output); } qemu_coroutine_inc_pool_size(conf->num_queues * conf->queue_size / 2); + /* TODO use iothread_vq_mapping_list */ virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err); if (err !=3D NULL) { error_propagate(errp, err); @@ -1284,6 +1360,8 @@ static Property virtio_blk_properties[] =3D { DEFINE_PROP_BOOL("seg-max-adjust", VirtIOBlock, conf.seg_max_adjust, t= rue), DEFINE_PROP_LINK("iothread", VirtIOBlock, conf.iothread, TYPE_IOTHREAD, IOThread *), + DEFINE_PROP_IOTHREAD_VQ_MAPPING_LIST("iothread-vq-mapping", VirtIOBloc= k, + conf.iothread_vq_mapping_list), DEFINE_PROP_BIT64("discard", VirtIOBlock, host_features, VIRTIO_BLK_F_DISCARD, true), DEFINE_PROP_BOOL("report-discard-granularity", VirtIOBlock, --=20 2.39.0