From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8C454CDB46B for ; Wed, 11 Oct 2023 17:18:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqcpv-0001pi-2A; Wed, 11 Oct 2023 13:17:31 -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 1qqcpt-0001ok-7T for qemu-devel@nongnu.org; Wed, 11 Oct 2023 13:17:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qqcpr-0006R2-H3 for qemu-devel@nongnu.org; Wed, 11 Oct 2023 13:17:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697044646; 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=GR1qn4ucznk0UrlzcreKFkECAHv7g19nzPf0ibZnwPI=; b=GouYcVHOpfUPRV8tSujDDyT5qElN5CM9sTJwfRoumqAoVz1Fcpz/CwjhWrOxTM8mUGu8JX /7HqbMDIMn09oOTdFWbjHIkNp0OhHK9FUjgeC8PCd3XHf7lYFqKBIh4xuiOfKyFcM+wTEE p63BNU2Jf3j+eAnbXmEbAzwt6xHPvQg= Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505-5PWXrWSuNKm_6G_h4frZDQ-1; Wed, 11 Oct 2023 13:17:15 -0400 X-MC-Unique: 5PWXrWSuNKm_6G_h4frZDQ-1 Received: by mail-io1-f69.google.com with SMTP id ca18e2360f4ac-79f9edb0086so8118739f.2 for ; Wed, 11 Oct 2023 10:17:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697044631; x=1697649431; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GR1qn4ucznk0UrlzcreKFkECAHv7g19nzPf0ibZnwPI=; b=vJWnrH3FFxo1DdEVj1xXoofLDUDY8ISawk1cKL7ATajdm/zuADNBY5z65CjBImwQ02 VwZZ79LLelF4jaUsn2db991vXE6R157exT5pUGH6gFMBokcSzirw3QBuTbdzfw1kEgb8 hrpucoteBKjwwu4V48Dn0ZDLjbE5AmXFZZf3tNmrlPQWma5wBN5eDpOI8gcuWwCSqxau ABuNc+GQsRcPBWyR/fsdmigC1mNG3SdTs6kk3EUetzelfgs88aRXnrnmqad+feTmY3sM 72HW7blCKhalrLILXfjnr1alwgup183mI/Pzzm8UdLkiAy/W5CS5f9luu62FwIdTMrmt kPOA== X-Gm-Message-State: AOJu0Ywgh8KUMvhT9mRhUWyiD8fiXJX8/nsTGXFfm9Arb1e5eb//TVFV mHUOnBoQ+L8h0LkJqnzUDjl5uvldgbbaYsHjzD/83FgYw6xttaqPv66MtvBby6P90LONJREEk3y pW3uJyYAY4XG4fjA= X-Received: by 2002:a6b:90b:0:b0:79f:e707:8813 with SMTP id t11-20020a6b090b000000b0079fe7078813mr23217267ioi.4.1697044630705; Wed, 11 Oct 2023 10:17:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfHH9s/Nzro3i4OXumCZ7GPpn8KRLVQSu6Xez0I2TGlkjj8njdjw9u6/TTYTrnISiFYACkig== X-Received: by 2002:a6b:90b:0:b0:79f:e707:8813 with SMTP id t11-20020a6b090b000000b0079fe7078813mr23217239ioi.4.1697044630443; Wed, 11 Oct 2023 10:17:10 -0700 (PDT) Received: from redhat.com ([38.15.60.12]) by smtp.gmail.com with ESMTPSA id gj12-20020a0566386a0c00b0043193e32c78sm3400795jab.152.2023.10.11.10.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 10:17:08 -0700 (PDT) Date: Mon, 9 Oct 2023 15:16:16 -0600 From: Alex Williamson To: Cc: , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v2 1/3] qom: new object to associate device to numa node Message-ID: <20231009151616.0119b03d.alex.williamson@redhat.com> In-Reply-To: <20231007201740.30335-2-ankita@nvidia.com> References: <20231007201740.30335-1-ankita@nvidia.com> <20231007201740.30335-2-ankita@nvidia.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=170.10.129.124; envelope-from=alex.williamson@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Sun, 8 Oct 2023 01:47:38 +0530 wrote: > From: Ankit Agrawal > > The CPU cache coherent device memory can be added as NUMA nodes > distinct from the system memory nodes. These nodes are associated > with the device and Qemu needs a way to maintain this link. > > Introduce a new acpi-generic-initiator object to allow host admin > provide the device and the corresponding NUMA node. Qemu maintain > this association and use this object to build the requisite GI > Affinity Structure. > > The admin provides the id of the device and the NUMA node id such > as in the following example. > -device vfio-pci-nohotplug,host=,bus=pcie.0,addr=04.0,rombar=0,id=dev0 \ > -object acpi-generic-initiator,id=gi0,device=dev0,node=2 \ > > Signed-off-by: Ankit Agrawal > --- > hw/acpi/acpi-generic-initiator.c | 74 ++++++++++++++++++++++++ > hw/acpi/meson.build | 1 + > include/hw/acpi/acpi-generic-initiator.h | 30 ++++++++++ > qapi/qom.json | 20 ++++++- > 4 files changed, 123 insertions(+), 2 deletions(-) > create mode 100644 hw/acpi/acpi-generic-initiator.c > create mode 100644 include/hw/acpi/acpi-generic-initiator.h > > diff --git a/hw/acpi/acpi-generic-initiator.c b/hw/acpi/acpi-generic-initiator.c > new file mode 100644 > index 0000000000..6406736090 > --- /dev/null > +++ b/hw/acpi/acpi-generic-initiator.c > @@ -0,0 +1,74 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved > + */ > + > +#include "qemu/osdep.h" > +#include "hw/qdev-properties.h" > +#include "qapi/error.h" > +#include "qapi/visitor.h" > +#include "qom/object_interfaces.h" > +#include "qom/object.h" > +#include "hw/qdev-core.h" > +#include "hw/vfio/vfio-common.h" > +#include "hw/vfio/pci.h" > +#include "hw/pci/pci_device.h" > +#include "sysemu/numa.h" > +#include "hw/acpi/acpi-generic-initiator.h" > + > +OBJECT_DEFINE_TYPE_WITH_INTERFACES(AcpiGenericInitiator, acpi_generic_initiator, > + ACPI_GENERIC_INITIATOR, OBJECT, > + { TYPE_USER_CREATABLE }, > + { NULL }) > + > +OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericInitiator, ACPI_GENERIC_INITIATOR) > + > +static void acpi_generic_initiator_init(Object *obj) > +{ > + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); > + gi->device = NULL; > + gi->node = MAX_NODES; > + gi->node_count = 1; > +} > + > +static void acpi_generic_initiator_finalize(Object *obj) > +{ > + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); > + > + g_free(gi->device); > +} > + > +static void acpi_generic_initiator_set_device(Object *obj, const char *value, > + Error **errp) > +{ > + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); > + > + gi->device = g_strdup(value); > +} > + > +static void acpi_generic_initiator_set_node(Object *obj, Visitor *v, > + const char *name, void *opaque, > + Error **errp) > +{ > + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); > + uint32_t value; > + > + if (!visit_type_uint32(v, name, &value, errp)) { > + return; > + } > + > + if (value >= MAX_NODES) { error_setg() here? Thanks, Alex > + return; > + } > + > + gi->node = value; > +} > + > +static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data) > +{ > + object_class_property_add_str(oc, ACPI_GENERIC_INITIATOR_DEVICE_PROP, NULL, > + acpi_generic_initiator_set_device); > + object_class_property_add(oc, ACPI_GENERIC_INITIATOR_NODE_PROP, "uint32", > + NULL, acpi_generic_initiator_set_node, NULL, > + NULL); > +} > diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build > index fc1b952379..22252836ed 100644 > --- a/hw/acpi/meson.build > +++ b/hw/acpi/meson.build > @@ -5,6 +5,7 @@ acpi_ss.add(files( > 'bios-linker-loader.c', > 'core.c', > 'utils.c', > + 'acpi-generic-initiator.c', > )) > acpi_ss.add(when: 'CONFIG_ACPI_CPU_HOTPLUG', if_true: files('cpu.c', 'cpu_hotplug.c')) > acpi_ss.add(when: 'CONFIG_ACPI_CPU_HOTPLUG', if_false: files('acpi-cpu-hotplug-stub.c')) > diff --git a/include/hw/acpi/acpi-generic-initiator.h b/include/hw/acpi/acpi-generic-initiator.h > new file mode 100644 > index 0000000000..e67e6e23b1 > --- /dev/null > +++ b/include/hw/acpi/acpi-generic-initiator.h > @@ -0,0 +1,30 @@ > +#ifndef ACPI_GENERIC_INITIATOR_H > +#define ACPI_GENERIC_INITIATOR_H > + > +#include "hw/mem/pc-dimm.h" > +#include "hw/acpi/bios-linker-loader.h" > +#include "qemu/uuid.h" > +#include "hw/acpi/aml-build.h" > +#include "qom/object.h" > +#include "qom/object_interfaces.h" > + > +#define TYPE_ACPI_GENERIC_INITIATOR "acpi-generic-initiator" > + > +#define ACPI_GENERIC_INITIATOR_DEVICE_PROP "device" > +#define ACPI_GENERIC_INITIATOR_NODE_PROP "node" > + > +typedef struct AcpiGenericInitiator { > + /* private */ > + Object parent; > + > + /* public */ > + char *device; > + uint32_t node; > + uint32_t node_count; > +} AcpiGenericInitiator; > + > +typedef struct AcpiGenericInitiatorClass { > + ObjectClass parent_class; > +} AcpiGenericInitiatorClass; > + > +#endif > diff --git a/qapi/qom.json b/qapi/qom.json > index fa3e88c8e6..86c87a161c 100644 > --- a/qapi/qom.json > +++ b/qapi/qom.json > @@ -779,6 +779,20 @@ > { 'struct': 'VfioUserServerProperties', > 'data': { 'socket': 'SocketAddress', 'device': 'str' } } > > +## > +# @AcpiGenericInitiatorProperties: > +# > +# Properties for acpi-generic-initiator objects. > +# > +# @device: the ID of the device to be associated with the node > +# > +# @node: the ID of the numa node > +# > +# Since: 8.0 > +## > +{ 'struct': 'AcpiGenericInitiatorProperties', > + 'data': { 'device': 'str', 'node': 'uint32' } } > + > ## > # @RngProperties: > # > @@ -947,7 +961,8 @@ > 'tls-creds-x509', > 'tls-cipher-suites', > { 'name': 'x-remote-object', 'features': [ 'unstable' ] }, > - { 'name': 'x-vfio-user-server', 'features': [ 'unstable' ] } > + { 'name': 'x-vfio-user-server', 'features': [ 'unstable' ] }, > + 'acpi-generic-initiator' > ] } > > ## > @@ -1014,7 +1029,8 @@ > 'tls-creds-x509': 'TlsCredsX509Properties', > 'tls-cipher-suites': 'TlsCredsProperties', > 'x-remote-object': 'RemoteObjectProperties', > - 'x-vfio-user-server': 'VfioUserServerProperties' > + 'x-vfio-user-server': 'VfioUserServerProperties', > + 'acpi-generic-initiator': 'AcpiGenericInitiatorProperties' > } } > > ##