From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757404AbcCRPHI (ORCPT ); Fri, 18 Mar 2016 11:07:08 -0400 Received: from casper.infradead.org ([85.118.1.10]:36197 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754237AbcCRPHB (ORCPT ); Fri, 18 Mar 2016 11:07:01 -0400 Message-Id: <20160318150538.551407299@infradead.org> User-Agent: quilt/0.61-1 Date: Fri, 18 Mar 2016 16:03:47 +0100 From: Peter Zijlstra To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, bp@alien8.de, aherrmann@suse.com, peterz@infradead.org, jencce.kernel@gmail.com Subject: [PATCH 2/3] x86/topology: Fix AMD core count References: <20160318150345.146716865@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=peterz-x86-fix-amd-siblings.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Borislav Petkov Cc: Thomas Gleixner Cc: Andreas Herrmann Reported-by: Xiong Zhou Fixes: 1f12e32f4cd5 ("x86/topology: Create logical package id") Signed-off-by: Peter Zijlstra (Intel) 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; c->compute_unit_id = ebx & 0xff; - cores_per_cu += ((ebx >> 8) & 3); } else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) { u64 value; @@ -331,8 +331,8 @@ static void amd_get_topology(struct cpui u32 cus_per_node; set_cpu_cap(c, X86_FEATURE_AMD_DCM); - cores_per_node = c->x86_max_cores / nodes_per_socket; - cus_per_node = cores_per_node / cores_per_cu; + cus_per_node = c->x86_max_cores / nodes_per_socket; + cores_per_node = cus_per_node * cores_per_cu; /* store NodeID, use llc_shared_map to store sibling info */ per_cpu(cpu_llc_id, cpu) = node_id;