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

Re: [PATCH 09/21] libs/guest: allow fetching a specific CPUID leaf from a cpu policy


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 1 Apr 2021 15:47:20 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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-SenderADCheck; bh=n+qothyvfianGc+oCmDzsXnEORNndPWHYlCGJwKnB6I=; b=bJY97WrTUlG37036KM4rirDx8ExYMLVJS1cEYpd4SAm8TAJ04xI4hQyozuJGUldhn+SGsvpRtaG+DaoD6W+MfAcQXR50HeRb8Wz5d6zEGL1eWWuNbjyoOGhUJcltvfbCunofT9l8rLutWNv3HvSGPAFEsL+9/3enW5Ozf1Z3/Z5bYmy4MWXGtCpwoRn0IdlTL7/495y/TlgdJsF2F3VrUb/F8zI0Mro4ojl9l1Aig2ijkmLvW/dTEPRF7xZlVR6DN3P7aVHktdLaRjANY8GKHbp8MZzAprohbNl/FiKtE1mfpwYUv7Emcl8TbJlK38ItbpED75dypYIhtwvgyf8Aeg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hpQIobgfWkvCqnFmU/olJ2NRUfSGJxdEOgcbcPbAcKmY6kjpp6JzmhDIR2A/xWCyahghu+gZwG0dkviqNVmEe493XOKeLTG3FTQUkuICposiCg4d37GMzcPpB0QStDrZadm2XsEMqgAL7L1n5aeKIAKPPdV2r1OtvmyV4wRP5zf3byAlIpeJtfXHVHGXMwMt/mrRxhbhdXmWeI2aa8EThTkz2ovEC8tBI5zatkMjbKmwcdO670S6B8q99EiS4Nz+tIprdhcS6r8xRxALOSWHz5FQ5/1gtvJ0CEp3TLl3ikXEVlGaVqEjqdnbBw9J96eEW0yIZQTlcNzRooqxkZUheA==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 01 Apr 2021 14:47:33 +0000
  • Ironport-hdrordr: A9a23:YFw1iq1a9f/Zr+2Dvr1TRwqjBbByeYIsi2QD101hICF9WMqeis yogbAnxQb54QxhOk0ItNicNMC7LU/02oVy5eAqU4uKeCnDlC+WIJp57Y3kqgeQeBHW0uJGz6 9vf+xfJbTLfD1HpP336gW5DNosqePvmMvD6Nv29Ht1SBEvVqcI1WdEIz2WD1FsQ01+DYc5fa DsgvZvnSaqengcc62AZ0UtYu6rnbL2vaOjXDpDLyRi0RKJgC+j9frEHwPw5GZ4bxp/hYoHtU D+1zf0/LmnrpiAu3nh/l6W0rATsOGk9sFOH4ilk9EPLCrhh0KTaINtV6bqhkFMnMifrGsP1P H35ys7M982wHbWdGO4rF/W1w7s3C1G0Q6Y9XaoxUbG5fbfeQh/Me59vOtiA2fkwntlgfVV6o 4O+2qFvZtaACjhsU3GlqH1fiAvq26dm1ZnquIIk3lDOLFuEoN5nMgj2GtuPNM+EDnh6IYhed Mecf3h2A==
  • Ironport-sdr: K5MO/ez6rLT1bri1vxUdscuqCOLn8iP0U2I/M5ELx5ImDbV59ijZD9lsRnAZy/MS2Z8KJiTsDY 5iBu/E37T7VY1CZxeJe5VgRA2cLklCsGffQ++vbUzpHuUQ/o3tpzV6aS4MCwd9cX27wQufvroE o5AfjmjYbT4kFsyEE/rmVjWTPEHysjuYQxnxcAUnlbTVTZ1bBpYKvtoq8jQVLxA3KHctJjdUku i6VMogeX9Ay6jtpz2MmgsqS2mdd0bAdNBhw4lzmEeda2D/LeQ+MNxRTY+AL+jfxi+9MZcdEgVI Grs=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 23/03/2021 09:58, Roger Pau Monne wrote:
> diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
> index 48351f1c4c6..a1e1bf10d5c 100644
> --- a/tools/libs/guest/xg_cpuid_x86.c
> +++ b/tools/libs/guest/xg_cpuid_x86.c
> @@ -883,3 +883,45 @@ int xc_cpu_policy_serialise(xc_interface *xch, const 
> xc_cpu_policy_t p,
>      errno = 0;
>      return 0;
>  }
> +
> +int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t policy,
> +                            uint32_t leaf, uint32_t subleaf,
> +                            xen_cpuid_leaf_t *out)
> +{
> +    unsigned int nr_leaves, nr_msrs, i;
> +    xen_cpuid_leaf_t *leaves;
> +    int rc = xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs);
> +
> +    if ( rc )
> +    {
> +        PERROR("Failed to obtain policy info size");
> +        return -1;
> +    }
> +
> +    leaves = calloc(nr_leaves, sizeof(*leaves));
> +    if ( !leaves )
> +    {
> +        PERROR("Failed to allocate resources");
> +        errno = ENOMEM;
> +        return -1;
> +    }
> +
> +    rc = xc_cpu_policy_serialise(xch, policy, leaves, &nr_leaves, NULL, 0);
> +    if ( rc )
> +        goto out;
> +
> +    for ( i = 0; i < nr_leaves; i++ )
> +        if ( leaves[i].leaf == leaf && leaves[i].subleaf == subleaf )
> +        {
> +            *out = leaves[i];
> +            goto out;
> +        }

Please adapt find_leaf(), probably by dropping xc_xend_cpuid and passing
in leaf/subleaf parameters.

Serialised leaves are sorted and there are plenty of them, so a log
search is better.

How frequent is this call going to be for the same policy?  With the
arrays embedded in a policy, they're still around, and serialise is an
expensive operation.

I wonder if it makes sense to try and keep both forms in sync, so we can
avoid redundant calls like this?

~Andrew




 


Rackspace

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