All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Woods <brian.woods@amd.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Brian Woods <brian.woods@amd.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [PATCH 4/8] x86/AMD: distinguish compute units from hyper-threads
Date: Wed, 11 Jul 2018 13:11:35 -0500	[thread overview]
Message-ID: <20180711181134.GA7455@amd.com> (raw)
In-Reply-To: <5B45F30E02000078001D3139@prv1-mh.provo.novell.com>

On Wed, Jul 11, 2018 at 06:07:42AM -0600, Jan Beulich wrote:
> Fam17 replaces CUs by HTs, which we should reflect accordingly, even if
> the difference is not very big. The most relevant change (requiring some
> code restructuring) is that the topoext feature no longer means there is
> a valid CU ID.
> 
> Take the opportunity and convert wrongly plain int variables in
> set_cpu_sibling_map() to unsigned int.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> --- a/xen/arch/x86/cpu/amd.c
> +++ b/xen/arch/x86/cpu/amd.c
> @@ -504,17 +504,23 @@ static void amd_get_topology(struct cpui
>                  u32 eax, ebx, ecx, edx;
>  
>                  cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
> -                c->compute_unit_id = ebx & 0xFF;
>                  c->x86_num_siblings = ((ebx >> 8) & 0x3) + 1;
> +
> +		if (c->x86 < 0x17)
> +	                c->compute_unit_id = ebx & 0xFF;
> +		else {
> +	                c->cpu_core_id = ebx & 0xFF;
> +			c->x86_max_cores /= c->x86_num_siblings;
> +		}
>          }
>          
>          if (opt_cpu_info)
>                  printk("CPU %d(%d) -> Processor %d, %s %d\n",
>                         cpu, c->x86_max_cores, c->phys_proc_id,
> -                       cpu_has(c, X86_FEATURE_TOPOEXT) ? "Compute Unit" : 
> -                                                         "Core",
> -                       cpu_has(c, X86_FEATURE_TOPOEXT) ? c->compute_unit_id :
> -                                                         c->cpu_core_id);
> +                       c->compute_unit_id != INVALID_CUID ? "Compute Unit"
> +                                                          : "Core",
> +                       c->compute_unit_id != INVALID_CUID ? c->compute_unit_id
> +                                                          : c->cpu_core_id);
>  }
>  
>  static void early_init_amd(struct cpuinfo_x86 *c)
> --- a/xen/arch/x86/smpboot.c
> +++ b/xen/arch/x86/smpboot.c
> @@ -236,33 +236,41 @@ static void link_thread_siblings(int cpu
>      cpumask_set_cpu(cpu2, per_cpu(cpu_core_mask, cpu1));
>  }
>  
> -static void set_cpu_sibling_map(int cpu)
> +static void set_cpu_sibling_map(unsigned int cpu)
>  {
> -    int i;
> +    unsigned int i;
>      struct cpuinfo_x86 *c = cpu_data;
>  
>      cpumask_set_cpu(cpu, &cpu_sibling_setup_map);
>  
>      cpumask_set_cpu(cpu, socket_cpumask[cpu_to_socket(cpu)]);
> +    cpumask_set_cpu(cpu, per_cpu(cpu_core_mask, cpu));
> +    cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu));
>  
>      if ( c[cpu].x86_num_siblings > 1 )
>      {
>          for_each_cpu ( i, &cpu_sibling_setup_map )
>          {
> -            if ( cpu_has(c, X86_FEATURE_TOPOEXT) ) {
> -                if ( (c[cpu].phys_proc_id == c[i].phys_proc_id) &&
> -                     (c[cpu].compute_unit_id == c[i].compute_unit_id) )
> +            if ( cpu == i || c[cpu].phys_proc_id != c[i].phys_proc_id )
> +                continue;
> +            if ( c[cpu].compute_unit_id != INVALID_CUID &&
> +                 c[i].compute_unit_id != INVALID_CUID )
> +            {
> +                if ( c[cpu].compute_unit_id == c[i].compute_unit_id )
>                      link_thread_siblings(cpu, i);
> -            } else if ( (c[cpu].phys_proc_id == c[i].phys_proc_id) &&
> -                        (c[cpu].cpu_core_id == c[i].cpu_core_id) ) {
> -                link_thread_siblings(cpu, i);
>              }
> +            else if ( c[cpu].cpu_core_id != XEN_INVALID_CORE_ID &&
> +                      c[i].cpu_core_id != XEN_INVALID_CORE_ID )
> +            {
> +                if ( c[cpu].cpu_core_id == c[i].cpu_core_id )
> +                    link_thread_siblings(cpu, i);
> +            }
> +            else
> +                printk(XENLOG_WARNING
> +                       "CPU%u: unclear relationship with CPU%u\n",
> +                       cpu, i);
>          }
>      }
> -    else
> -    {
> -        cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu));
> -    }
>  
>      if ( c[cpu].x86_max_cores == 1 )
>      {
> 
> 
> 
> 

Side note: if cpu_core_id isn't the logical cpu, it might be worth
updating the comments in processor.h

Reviewed-by: Brian Woods <brian.woods@amd.com>

-- 
Brian Woods

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-07-11 18:11 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-11 11:55 [PATCH 0/8] x86: (allow to) suppress use of hyper-threading Jan Beulich
2018-07-11 12:04 ` [PATCH 1/8] cpupools: fix state when downing a CPU failed Jan Beulich
2018-07-11 12:06 ` [PATCH 2/8] x86: distinguish CPU offlining from CPU removal Jan Beulich
2018-07-12 10:53   ` Wei Liu
2018-07-12 11:48     ` Jan Beulich
2018-07-13  8:39       ` Wei Liu
2018-07-12 12:42   ` Andrew Cooper
2018-07-11 12:06 ` [PATCH 3/8] allow cpu_down() to be called earlier Jan Beulich
2018-07-12 10:55   ` Wei Liu
2018-07-12 12:44   ` Andrew Cooper
2018-07-11 12:07 ` [PATCH 4/8] x86/AMD: distinguish compute units from hyper-threads Jan Beulich
2018-07-11 18:11   ` Brian Woods [this message]
2018-07-12 13:02   ` Andrew Cooper
2018-07-12 14:22     ` Jan Beulich
2018-07-11 12:09 ` [PATCH 5/8] x86: bring up all CPUs even if not all are supposed to be used Jan Beulich
2018-07-12 15:38   ` Andrew Cooper
2018-07-13  8:11     ` Jan Beulich
2018-07-11 12:10 ` [PATCH 6/8] x86: (command line option to) avoid use of secondary hyper-threads Jan Beulich
2018-07-12 15:45   ` Andrew Cooper
2018-07-13  8:13     ` Jan Beulich
2018-07-16 12:37       ` Andrew Cooper
2018-07-16 12:53         ` Jan Beulich
2018-07-16 13:01           ` Andrew Cooper
2018-07-11 12:11 ` [PATCH 7/8] x86/shim: fully ignore "nosmp" and "maxcpus=" Jan Beulich
2018-07-11 12:23   ` Andrew Cooper
2018-07-11 15:18   ` Roger Pau Monné
2018-07-11 16:02   ` Wei Liu
2018-07-11 12:12 ` [PATCH 8/8] cpumask: tidy {,z}alloc_cpumask_var() Jan Beulich
2018-07-11 12:20   ` Andrew Cooper
2018-07-12 15:13   ` Wei Liu
     [not found] ` <5B45F26A02000078001D312F@suse.com>
2018-07-13  9:02   ` [PATCH 1/8] cpupools: fix state when downing a CPU failed Juergen Gross
2018-07-16  9:17     ` Jan Beulich
     [not found]     ` <5B4C629002000078001D4346@suse.com>
2018-07-16 11:47       ` Juergen Gross
2018-07-16 12:19         ` Jan Beulich
     [not found]         ` <5B4C8D3702000078001D45EA@suse.com>
2018-07-16 12:47           ` Juergen Gross
2018-07-16 13:01             ` Jan Beulich
     [not found]             ` <5B4C973D02000078001D4693@suse.com>
2018-07-16 14:21               ` Juergen Gross
2018-07-16 14:26                 ` Jan Beulich
     [not found]                 ` <5B4CAB1202000078001D47BC@suse.com>
2018-07-16 14:53                   ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180711181134.GA7455@amd.com \
    --to=brian.woods@amd.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.