Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755251AbbFCPuO (ORCPT ); Wed, 3 Jun 2015 11:50:14 -0400 Received: from mail-by2on0129.outbound.protection.outlook.com ([207.46.100.129]:34502 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754238AbbFCPuI (ORCPT ); Wed, 3 Jun 2015 11:50:08 -0400 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=amd.com; alien8.de; dkim=none (message not signed) header.d=none; X-WSS-ID: 0NPDLB9-07-IB5-02 X-M-MSG: Message-ID: <556F2222.9000701@amd.com> Date: Wed, 3 Jun 2015 10:49:54 -0500 From: Aravind Gopalakrishnan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Borislav Petkov CC: , , , , , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , Jacob Shin , Dave Hansen , Andy Lutomirski , "Paolo Bonzini" Subject: Re: [PATCH V2 7/9] x86, amd: Factor out number of nodes calculation References: <1433277362-10911-1-git-send-email-Aravind.Gopalakrishnan@amd.com> <1433277362-10911-8-git-send-email-Aravind.Gopalakrishnan@amd.com> <20150603085805.GE4403@pd.tnic> In-Reply-To: <20150603085805.GE4403@pd.tnic> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11OLC003;1:xsajmnkuBlY3E7GVYYUy8kXoyI7lrasRinQv1HMDdWK9hJT1UJ1o6uQcZXafoQ8fep9HwqbopY+7S5lW+QiwGAA6CsvEELdj3lJdN10NIKqDL/d6P72tujrTH+uJaPPqLfCA4Hw1fSVxUSxkSdZrKLfIvozKRcc5H81zNlnCywaLLaK73+lo/if1JlyKdXhVhA/F0Agwec2xbOuJNOlgt+RniQoCqHqvAhkTfB9Gopl3XARghg9TxnQNnG1qVjcYQqzAtf2BwsspxvzdCuwW4ds2pmXmIr+MItrr8FYkk58= X-Forefront-Antispam-Report: CIP:165.204.84.221;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(428002)(51704005)(377454003)(24454002)(199003)(189002)(479174004)(52604005)(68736005)(106466001)(46102003)(87936001)(50466002)(50986999)(97736004)(2950100001)(59896002)(47776003)(65956001)(86362001)(120886001)(87266999)(65806001)(64706001)(54356999)(4001540100001)(33656002)(64126003)(5001860100001)(101416001)(23676002)(110136002)(189998001)(77096005)(5001920100001)(5001830100001)(4001350100001)(83506001)(65816999)(62966003)(105586002)(77156002)(36756003)(92566002)(80316001)(76176999);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR02MB1107;H:atltwp01.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB1107;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB1185; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(520003)(3002001);SRVR:BLUPR02MB1107;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB1107; X-Forefront-PRVS: 05961EBAFC X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2015 15:49:59.3122 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96;Ip=[165.204.84.221];Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB1107 X-OriginatorOrg: amd.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3107 Lines: 106 On 6/3/2015 3:58 AM, Borislav Petkov wrote: > On Tue, Jun 02, 2015 at 03:36:00PM -0500, Aravind Gopalakrishnan wrote: > > >> +static void amd_set_num_nodes(void) >> +{ >> + if (cpu_has_topoext) { >> + u32 ecx; >> + >> + ecx = cpuid_ecx(0x8000001e); >> + nodes_per_processor = ((ecx >> 8) & 7) + 1; >> + } else if (static_cpu_has(X86_FEATURE_NODEID_MSR)) { >> + u64 value; >> + >> + rdmsrl(MSR_FAM10H_NODE_ID, value); >> + nodes_per_processor = ((value >> 3) & 7) + 1; >> + } >> +} >> + >> /* >> * Fixup core topology information for >> * (1) AMD multi-node processors >> * Assumption: Number of cores in each internal node is the same. >> * (2) AMD processors supporting compute units >> */ >> -#ifdef CONFIG_X86_HT >> static void amd_get_topology(struct cpuinfo_x86 *c) >> { >> - u32 nodes, cores_per_cu = 1; >> + u32 cores_per_cu = 1; >> u8 node_id; >> int cpu = smp_processor_id(); >> >> + amd_set_num_nodes(); > When I said, you like to complicate stuff, I wasn't joking. :-) > > See below for what I actually meant. Diff is ontop of the X86_HT removal > patch from today: *facepalm* Sorry about that. Thanks for fixing it. -Aravind. > --- > diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c > index 5bd3a99dc20b..bdca795743e8 100644 > --- a/arch/x86/kernel/cpu/amd.c > +++ b/arch/x86/kernel/cpu/amd.c > @@ -19,6 +19,8 @@ > > #include "cpu.h" > > +static u32 nodes_per_processor = 1; > + > static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p) > { > u32 gprs[8] = { 0 }; > @@ -291,7 +293,7 @@ static int nearby_node(int apicid) > #ifdef CONFIG_SMP > static void amd_get_topology(struct cpuinfo_x86 *c) > { > - u32 nodes, cores_per_cu = 1; > + u32 cores_per_cu = 1; > u8 node_id; > int cpu = smp_processor_id(); > > @@ -300,7 +302,7 @@ static void amd_get_topology(struct cpuinfo_x86 *c) > u32 eax, ebx, ecx, edx; > > cpuid(0x8000001e, &eax, &ebx, &ecx, &edx); > - nodes = ((ecx >> 8) & 7) + 1; > + nodes_per_processor = ((ecx >> 8) & 7) + 1; > node_id = ecx & 7; > > /* get compute unit information */ > @@ -311,18 +313,18 @@ static void amd_get_topology(struct cpuinfo_x86 *c) > u64 value; > > rdmsrl(MSR_FAM10H_NODE_ID, value); > - nodes = ((value >> 3) & 7) + 1; > + nodes_per_processor = ((value >> 3) & 7) + 1; > node_id = value & 7; > } else > return; > > /* fixup multi-node processor information */ > - if (nodes > 1) { > + if (nodes_per_processor > 1) { > u32 cores_per_node; > u32 cus_per_node; > > set_cpu_cap(c, X86_FEATURE_AMD_DCM); > - cores_per_node = c->x86_max_cores / nodes; > + cores_per_node = c->x86_max_cores / nodes_per_processor; > cus_per_node = cores_per_node / cores_per_cu; > > /* store NodeID, use llc_shared_map to store sibling info */ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/