[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v7 09/12] tools: add physinfo arch_capabilities handling for Arm


  • To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Thu, 25 May 2023 09:21:55 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H5VbXe48kVeShUYEX7XgaKDAkwnI9cCDdJgqbOfkCzg=; b=emQRl47qsSC1dHJzaEjd+Ttw1HHHiIxXy9TmGxC65laJZA2USGzOcYjp2CMJOK7PEPSHkkBVIH73B2sZDZztfHSWcgTSYhYUzKnnojukGVNVPFioS7R7s8h0BYPrj5m2vpYm5YIaOJ8r9wZwY3dGej9RvYXy03i8rynV7Gbyee7f1nkkyCwKIfG6s4WSh2PA+PEbIIpQY/Nvq1kqF/Mfa1zbBYUzPREyzSbQIB0FOnXRENuzCc0syI3v7FHwJ7f8xkz7QzSRWY3nekJpK5NGurk9C8sfl4M6Y96qA3dqCpzfTrqTvXOfWOk1mR/j3LFVa53Jgg/+JWvG10q6SFwXjw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CZ4ROIFq5n5sGyCqB9gfEnRrKnIpFtAZkY/p6GlWAg8DeewdiwE+Tu8ME7I4AeOEyv+Vu9xHh9Nd548AK5jziV3Qcfzer5FZR1o2+G9g+HK3tmA4+IAmBJ+i0YcG1d4rdMY7QDxNqqulWC3c7T20OONKlHg8PzKJQfymobjEXJX0jfysEpR2kQSoNV7DKHJUm3ZYR9R799HFukbVGs7qeIucgvuyEKM295bOQS68siJONCtoedDTaaTKVWceK3NZLfyaxG+/XCVctLg1uFhMerm0E7564ndZ9KDEvgb3d8pvFBHChsBZ2f5NDKhjrYJO5JuxW9OavMVbmtT5hZBVjg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Nick Rosbrook <rosbrookn@xxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Christian Lindig <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Christian Lindig <christian.lindig@xxxxxxxxx>
  • Delivery-date: Thu, 25 May 2023 09:22:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZjUpkSkVWSiVT2k+ILuaW20r/+q9qrj4AgAAKbYCAAAFlAA==
  • Thread-topic: [PATCH v7 09/12] tools: add physinfo arch_capabilities handling for Arm

>> 
>> (...)
>> 
>>> diff --git a/tools/python/xen/lowlevel/xc/xc.c 
>>> b/tools/python/xen/lowlevel/xc/xc.c
>>> index 9728b34185ac..b3699fdac58e 100644
>>> --- a/tools/python/xen/lowlevel/xc/xc.c
>>> +++ b/tools/python/xen/lowlevel/xc/xc.c
>>> @@ -22,6 +22,7 @@
>>> #include <xen/hvm/hvm_info_table.h>
>>> #include <xen/hvm/params.h>
>>> 
>>> +#include <xen-tools/arm-arch-capabilities.h>
>>> #include <xen-tools/common-macros.h>
>>> 
>>> /* Needed for Python versions earlier than 2.3. */
>>> @@ -897,7 +898,7 @@ static PyObject *pyxc_physinfo(XcObject *self)
>>>    if ( p != virt_caps )
>>>      *(p-1) = '\0';
>>> 
>>> -    return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:l,s:i,s:s,s:s}",
>>> +    return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:l,s:i,s:s,s:s,s:I}",
>>>                            "nr_nodes",         pinfo.nr_nodes,
>>>                            "threads_per_core", pinfo.threads_per_core,
>>>                            "cores_per_socket", pinfo.cores_per_socket,
>>> @@ -907,7 +908,10 @@ static PyObject *pyxc_physinfo(XcObject *self)
>>>                            "scrub_memory",     
>>> pages_to_kib(pinfo.scrub_pages),
>>>                            "cpu_khz",          pinfo.cpu_khz,
>>>                            "hw_caps",          cpu_cap,
>>> -                            "virt_caps",        virt_caps);
>>> +                            "virt_caps",        virt_caps,
>>> +                            "arm_sve_vl",
>>> +                              
>>> arch_capabilities_arm_sve(pinfo.arch_capabilities)
>>> +                        );
>> 
>> This should be added only when building for ARM, similar as for other
>> bindings.
> 
> Hi Marek,
> 
> Thank you for taking the time to review this, are you ok if I make these 
> changes to the code?
> 
> diff --git a/tools/python/xen/lowlevel/xc/xc.c 
> b/tools/python/xen/lowlevel/xc/xc.c
> index b3699fdac58e..c7f690189770 100644
> --- a/tools/python/xen/lowlevel/xc/xc.c
> +++ b/tools/python/xen/lowlevel/xc/xc.c
> @@ -872,6 +872,8 @@ static PyObject *pyxc_physinfo(XcObject *self)
>     const char *virtcap_names[] = { "hvm", "pv" };
>     const unsigned virtcaps_bits[] = { XEN_SYSCTL_PHYSCAP_hvm,
>                                        XEN_SYSCTL_PHYSCAP_pv };
> +    PyObject *objret;
> +    int retcode;
> 
>     if ( xc_physinfo(self->xc_handle, &pinfo) != 0 )
>         return pyxc_error_to_exception(self->xc_handle);
> @@ -898,20 +900,31 @@ static PyObject *pyxc_physinfo(XcObject *self)
>     if ( p != virt_caps )
>       *(p-1) = '\0';
> 
> -    return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:l,s:i,s:s,s:s,s:I}",
> -                            "nr_nodes",         pinfo.nr_nodes,
> -                            "threads_per_core", pinfo.threads_per_core,
> -                            "cores_per_socket", pinfo.cores_per_socket,
> -                            "nr_cpus",          pinfo.nr_cpus,
> -                            "total_memory",     
> pages_to_kib(pinfo.total_pages),
> -                            "free_memory",      
> pages_to_kib(pinfo.free_pages),
> -                            "scrub_memory",     
> pages_to_kib(pinfo.scrub_pages),
> -                            "cpu_khz",          pinfo.cpu_khz,
> -                            "hw_caps",          cpu_cap,
> -                            "virt_caps",        virt_caps,
> -                            "arm_sve_vl",
> -                              
> arch_capabilities_arm_sve(pinfo.arch_capabilities)
> +    objret = Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:l,s:i,s:s,s:s}",
> +                           "nr_nodes",         pinfo.nr_nodes,
> +                           "threads_per_core", pinfo.threads_per_core,
> +                           "cores_per_socket", pinfo.cores_per_socket,
> +                           "nr_cpus",          pinfo.nr_cpus,
> +                           "total_memory",     
> pages_to_kib(pinfo.total_pages),
> +                           "free_memory",      
> pages_to_kib(pinfo.free_pages),
> +                           "scrub_memory",     
> pages_to_kib(pinfo.scrub_pages),
> +                           "cpu_khz",          pinfo.cpu_khz,
> +                           "hw_caps",          cpu_cap,
> +                           "virt_caps",        virt_caps
>                         );
> +
> +    #if defined(__aarch64__)
> +        if (objret) {
> +            retcode = PyDict_SetItemString(
> +                            objret, "arm_sve_vl",
> +                            
> arch_capabilities_arm_sve(pinfo.arch_capabilities)
> +                        );
> +            if ( retcode < 0 )
> +                return NULL;
> +        }
> +    #endif
> +
> +    return objret;
> }
> 
> static PyObject *pyxc_getcpuinfo(XcObject *self, PyObject *args, PyObject 
> *kwds)
> 
> 
> Please notice that now we can have a path that could return NULL, are you ok 
> for
> It or should I just ignore the return code for PyDict_SetItemString?
> 
> Also, do you want me to protect the include to 
> <xen-tools/arm-arch-capabilities.h>
> with ifdef?
> 

EDIT: I saw this doesn’t even compile, I will ask later when I will have 
something working,
I saw PyDict_SetItemString is used somewhere else so I will use that approach 
before
Proposing you a solution



>> 
>>> }
>>> 
>>> static PyObject *pyxc_getcpuinfo(XcObject *self, PyObject *args, PyObject 
>>> *kwds)
>> 
>> -- 
>> Best Regards,
>> Marek Marczykowski-Górecki
>> Invisible Things Lab



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.