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

Re: [PATCH 5/6] x86: use standard C types in struct cpuinfo_x86


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 16 Feb 2023 12:12:52 +0000
  • 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vK+IrBghED0m39s9V+gFp2OIx7T+4ggTO8MTQyYNMn8=; b=FBc2PvkwQHaXtpM+IirSq+OApujjktseZ6M0ol75Let8e0TlC1STJCm7ikEobxcpjZyVxRppMoZpnZLWYyS5PmAHzrw81QsKCOdQm+4vNrRatcN2bBaY7EDAB+T+1I98yyQeZuYI0GB50dXkjCyYg0DsZtxwOIXfv5gMgAhUKr04Nsyng1m05dLz6sXliQVFiWfNz0kB8aXsFY6Vz2VWptLErtTN5ldkN6eWbectGYxxo78teCONFI0HCuIgsWvLSdoAbChQGAaByeslBazl2X/CLkPU51AsVjV62/Wb/JZXTZyRXd/BUqFs3y1ZqiLW+JyvsjVkyl6YV2VOY6Z0IA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LuUfi296dqqMMhs3k/Bdi/4BZXhDRTWKKmNylRjsn1ruE5w1geMhX6QxSNoLy1jT7EuKZf/yiSCfwDictNcq/nn2DdiARwtxc0eOb1irRoh5H7Tao0euxA5u9jfndr8eUoXYvL/tcBFugdY1eOEolDBM9e+NnkzmLlM6s9aI5MOMcDJrwXricqyQKPRp3aHUUOwePlwgwJZGmWc954a9UhcgzvZ4a11oC3gRsp373InY2YjhN1c275abOsFbZZN5p2zHaCyAQZf23cizCrUhfOq9deMKLZUXknguv/EflrJuDxhycBeRtLg+nxDIbmCvI0KQABMbQel+y/uRsEuDgw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 16 Feb 2023 12:13:23 +0000
  • Ironport-data: A9a23:hnCBJ6xgDwyfSgc+vPZ6t+cVxyrEfRIJ4+MujC+fZmUNrF6WrkVRn DZKWj3XO/bbZmX9fdEjYIi+8hgG6sfTydIxSVBrqSAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw//F+UwHUMja4mtC5QRkPK4T5TcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KTBX2 M4aChtRUh+Oif2Sy7OjVOx3v9t2eaEHPKtH0p1h5RfwKK9/BLzmHeDN79Ie2yosjMdTG/qYf 9AedTdkcBXHZVtIJ0sTD5U92uyvgxETcRUB8A7T+fVxvjeVlVMuuFTuGIO9ltiibMNZhEuH4 EnB+Hz0GEoyP92D0zuVtHmrg4cjmAuqCd1LSePoqZaGhnWR3jctCU1MfGHrmtiwtxSUcsABF RULr39GQa8asRbDosPGdx+yrWOAvxUcc8FNCOB84waIooLE7gDcCmUaQzppbN09qNRwVTEsz kWOnd7iGXpoqrL9YW2Z3qeZq3W1Iyd9EIMZTSoNTA9A79y9pog210vLVow6T/HzicDpEzbtx TzMtDI5m7gYkc8M0eO84EzDhDWv4JPOS2bZ+znqY45s1SshDKbNWmBiwQGzASpoRGpBcmS8g Q==
  • Ironport-hdrordr: A9a23:dx6RuamYbLRs97zFyCLpKXAFslPpDfNpimdD5ihNYBxZY6Wkfq GV7YEmPHrP41gssR4b+exoR5PwPU80maQV3WBzB8bQYOCZghrLEGgK1+KLqQEIcBeOldK1u5 0QFpSXA7XLfCdHZa6R2mWF+71L+ra6GG/Dv4rj5kYodCUvT5xJqz5+DAPzKDwFeOGFb6BJaq Z1IqB81kqdkbF8VLXLOpB/ZZmmm/T70Kj+ZAIABVoO8RDmt0LQ1JfKVyKA2wsYUXdl3bcm/A H+4nHEz5Tmiei/1hjfk0ja65g+oqqH9vJzQPaUj9QTKHHLlAGlf+1aKtu/lQFwmvir9FEp1O Ptjn4bTrxOwkKURHixvRzunzPtyykj8FjrzVPwuwqZneXJAAgiDtZHh8ZnfgDC60wm1esMqp 524w==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 09/02/2023 10:42 am, Jan Beulich wrote:
> Consolidate this to use exclusively standard types, and change oprofile
> code (apparently trying to mirror those types) at the same time. Where
> sensible actually drop local variables.
>
> No functional change intended.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> Much like x86_capability[] already doesn't use a fixed width type, most
> if not all of the other fields touched here probably also shouldn't. I
> wasn't sure though whether switching might be controversial for some of
> them ...

x86_capability isn't an inherently 32bit structure.  It's a bitmap, and
all of Xen's bitmap operations take unsigned int *.

Most other things in this structure don't need to have specific widths
IMO, but there is huge quantity of junk here.

> --- a/xen/arch/x86/include/asm/processor.h
> +++ b/xen/arch/x86/include/asm/processor.h
> @@ -119,24 +119,24 @@ struct x86_cpu_id {
>  };
>  
>  struct cpuinfo_x86 {
> -    __u8 x86;            /* CPU family */
> -    __u8 x86_vendor;     /* CPU vendor */
> -    __u8 x86_model;
> -    __u8 x86_mask;
> +    uint8_t x86;            /* CPU family */
> +    uint8_t x86_vendor;     /* CPU vendor */
> +    uint8_t x86_model;
> +    uint8_t x86_mask;

These specific names always irritated me.  They should be vendor,
family, model, stepping and probably in that order.  The x86 prefix is
entirely redundant.

>      int  cpuid_level;    /* Maximum supported CPUID level, -1=no CPUID */

There's no such thing a "no CPUID" cpu for Xen any more.

> -    __u32 extended_cpuid_level; /* Maximum supported CPUID extended level */
> +    uint32_t extended_cpuid_level; /* Maximum supported CPUID extended level 
> */

This does need to be this wide, but I really regret the name being this
wide...

>      unsigned int x86_capability[NCAPINTS];
>      char x86_vendor_id[16];
>      char x86_model_id[64];

These arrays should be 12 and 48 respectively, but the vendor id is
redundant with the vendor field.

Furthermore, we do some non-trivial string rearranging of the string,
and (seeing as you rejected my patch to print it on boot) only ever gets
used to hand to dom0 in a machine check.

>      int  x86_cache_size; /* in KB - valid for CPUS which support this call  
> */
>      int  x86_cache_alignment;    /* In bytes */

The only interesting thing I can see about this field is that the
Netburst quirk is wrong.  double-pumped IO was a firmware setting
because it was a tradeoff and different workloads favoured different
settings.

> -    __u32 x86_max_cores; /* cpuid returned max cores value */
> -    __u32 booted_cores;  /* number of cores as seen by OS */
> -    __u32 x86_num_siblings; /* cpuid logical cpus per chip value */
> -    __u32 apicid;
> -    __u32 phys_proc_id;    /* package ID of each logical CPU */
> -    __u32 cpu_core_id;     /* core ID of each logical CPU*/
> -    __u32 compute_unit_id; /* AMD compute unit ID of each logical CPU */
> +    uint32_t x86_max_cores;   /* cpuid returned max cores value */
> +    uint32_t booted_cores;    /* number of cores as seen by OS */
> +    uint32_t x86_num_siblings; /* cpuid logical cpus per chip value */
> +    uint32_t apicid;
> +    uint32_t phys_proc_id;    /* package ID of each logical CPU */
> +    uint32_t cpu_core_id;     /* core ID of each logical CPU */
> +    uint32_t compute_unit_id; /* AMD compute unit ID of each logical CPU */

There's lots of redundancy here, and half of these fields can be derived
directly from the 32bit APIC ID.

For the purpose of the type cleanup, Acked-by: Andrew Cooper
<andrew.cooper3@xxxxxxxxxx>.

~Andrew



 


Rackspace

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