Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1361129

Re: [PATCH 2/3] x86/topology: Fix AMD core count

From Borislav Petkov <bp@alien8.de>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] x86/topology: Fix AMD core count
Date 2016-03-19 17:00 +0100
Message-ID <rersd-1NK-3@gated-at.bofh.it> (permalink)
References <re4ci-8fa-9@gated-at.bofh.it> <re4ci-8fa-19@gated-at.bofh.it> <relmO-6i1-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Mar 19, 2016 at 10:24:59AM +0100, Thomas Gleixner wrote:
> On Fri, 18 Mar 2016, Peter Zijlstra wrote:
> > It turns out AMD gets x86_max_cores wrong when there are compute
> > units.
> > 
> > The issue is that Linux assumes:
> > 
> > 	nr_logical_cpus = nr_cores * nr_siblings
> > 
> > But AMD reports its CU unit as 2 cores, but then sets num_smp_siblings
> > to 2 as well.
> > 
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: Borislav Petkov <bp@alien8.de>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Andreas Herrmann <aherrmann@suse.com>
> > Reported-by: Xiong Zhou <jencce.kernel@gmail.com>
> > Fixes: 1f12e32f4cd5 ("x86/topology: Create logical package id")
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > Link: http://lkml.kernel.org/r/20160317095220.GO6344@twins.programming.kicks-ass.net
> > ---
> >  arch/x86/kernel/cpu/amd.c |    8 ++++----
> >  arch/x86/kernel/smpboot.c |   11 ++++++-----
> >  2 files changed, 10 insertions(+), 9 deletions(-)
> > 
> > --- a/arch/x86/kernel/cpu/amd.c
> > +++ b/arch/x86/kernel/cpu/amd.c
> > @@ -313,9 +313,9 @@ static void amd_get_topology(struct cpui
> >  		node_id = ecx & 7;
> >  
> >  		/* get compute unit information */
> > -		smp_num_siblings = ((ebx >> 8) & 3) + 1;
> > +		cores_per_cu = smp_num_siblings = ((ebx >> 8) & 3) + 1;
> > +		c->x86_max_cores /= smp_num_siblings;
> 
> Unfortunately that will break stuff in event/amd/core.c, ras/mce_amd_inj.c
> which rely on the AMD interpretation of c->x86_max_cores.

What is the events/amd/core.c check even mean? We alloc an amd_nb per
core but not per thread?

The mce_amd_inj.c thing we could fix probably like this:

---
diff --git a/arch/x86/ras/mce_amd_inj.c b/arch/x86/ras/mce_amd_inj.c
index 55d38cfa46c2..b5a917d943c8 100644
--- a/arch/x86/ras/mce_amd_inj.c
+++ b/arch/x86/ras/mce_amd_inj.c
@@ -203,12 +203,7 @@ static void trigger_thr_int(void *info)
 
 static u32 get_nbc_for_node(int node_id)
 {
-	struct cpuinfo_x86 *c = &boot_cpu_data;
-	u32 cores_per_node;
-
-	cores_per_node = c->x86_max_cores / amd_get_nodes_per_socket();
-
-	return cores_per_node * node_id;
+	return boot_cpu_data.x86_max_cores * node_id;
 }
 
 static void toggle_nb_mca_mst_cpu(u16 nid)
---

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/3] x86/topology: Fix AMD core count Peter Zijlstra <peterz@infradead.org> - 2016-03-18 16:10 +0100
  Re: [PATCH 2/3] x86/topology: Fix AMD core count Borislav Petkov <bp@alien8.de> - 2016-03-18 17:50 +0100
    Re: [PATCH 2/3] x86/topology: Fix AMD core count Borislav Petkov <bp@alien8.de> - 2016-03-21 09:30 +0100
    Re: [PATCH 2/3] x86/topology: Fix AMD core count Borislav Petkov <bp@alien8.de> - 2016-03-21 09:30 +0100
      Re: [PATCH 2/3] x86/topology: Fix AMD core count Borislav Petkov <bp@alien8.de> - 2016-03-21 11:30 +0100
    Re: [PATCH 2/3] x86/topology: Fix AMD core count Peter Zijlstra <peterz@infradead.org> - 2016-03-21 09:30 +0100
      Re: [PATCH 2/3] x86/topology: Fix AMD core count Borislav Petkov <bp@alien8.de> - 2016-03-21 15:00 +0100
        Re: [PATCH 2/3] x86/topology: Fix AMD core count Borislav Petkov <bp@alien8.de> - 2016-03-22 12:30 +0100
    Re: [PATCH 2/3] x86/topology: Fix AMD core count Thomas Gleixner <tglx@linutronix.de> - 2016-03-21 10:00 +0100
  Re: [PATCH 2/3] x86/topology: Fix AMD core count Thomas Gleixner <tglx@linutronix.de> - 2016-03-19 10:30 +0100
    Re: [PATCH 2/3] x86/topology: Fix AMD core count Borislav Petkov <bp@alien8.de> - 2016-03-19 17:00 +0100
    Re: [PATCH 2/3] x86/topology: Fix AMD core count Peter Zijlstra <peterz@infradead.org> - 2016-03-20 11:50 +0100
      Re: [PATCH 2/3] x86/topology: Fix AMD core count Borislav Petkov <bp@alien8.de> - 2016-03-20 12:10 +0100
        Re: [PATCH 2/3] x86/topology: Fix AMD core count Peter Zijlstra <peterz@infradead.org> - 2016-03-20 13:40 +0100
          Re: [PATCH 2/3] x86/topology: Fix AMD core count Peter Zijlstra <peterz@infradead.org> - 2016-03-20 13:50 +0100
            Re: [PATCH 2/3] x86/topology: Fix AMD core count Borislav Petkov <bp@alien8.de> - 2016-03-20 14:10 +0100
              Re: [PATCH 2/3] x86/topology: Fix AMD core count Peter Zijlstra <peterz@infradead.org> - 2016-03-20 18:20 +0100
                Re: [PATCH 2/3] x86/topology: Fix AMD core count Borislav Petkov <bp@alien8.de> - 2016-03-20 19:50 +0100
            [tip:x86/urgent] perf/x86/amd: Cleanup Fam10h NB event constraints tip-bot for Peter Zijlstra <tipbot@zytor.com> - 2016-03-29 11:00 +0200

csiph-web