Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4799398ooa; Tue, 14 Aug 2018 10:42:52 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwcl7uduKJM1vSYV+pbxMKo1vgWnXtydl4AWrlhnlvZ9kMn/a67kKSXUxOWNCHm+RczwRze X-Received: by 2002:a63:7b4d:: with SMTP id k13-v6mr21899155pgn.64.1534268572503; Tue, 14 Aug 2018 10:42:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268572; cv=none; d=google.com; s=arc-20160816; b=HRQ8lAIzc+7RpzLkgpSZsXhQSRCc8sTsniMn5OPfc/4Pm9yIH/EkfNgZPRCrQLiDY0 NDZJYganucz48SWi5WcUFskJTm/R+2gSK/IV36LPGq+gOWhX06abihWblOJSPVrVIJuj 9J7ojwnPc5WaWF/7GU/hkbBkF7KK5bd3KgKOkgaYmbTMaSaxctHDmKXsWhowXuhDupnM UdAXWLeaK6oi+OBmiHvW1c9TS0ZyALgLv+X8hl84BeewVeZg/XeJk1bbauCsvjUsc1zd b7bOeI7RyjWZs7C0UI0Q+Aajm8Q0avhjQWcpwyDYw2h0LnaSV5rf9GNkaYEczam7FMYd sG3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=EMIT5qx5d7ffUZ+LtRMXAAoFz0zFH5p8aSTx6JQHp9w=; b=tBlTf1gZyDT62lskG4O5LwWz1iOJiGAMxtlR0PADy+EggHQVnVcB0tCp97rgSmUX3Z KjxUtxCFrp1cCZkpxWNP8iupjk6QLoqXAS6hc6T3tIMgYpN3Te2Fc8xVaJdNSg3XHWM2 mJx1gaR+M6L9TU0Ne1NJ30mc7wLCeYv7o2G8aW4GICq1yz50ZvOWNI9cnaIzNLPSrWry nbRss4Sf227/ov2WeSg99UpMJC5dB+aW40WMpp8kkxW3zAosk3C8AZ8KkJgwXLSUfakY 7Pxe6ElcpRlvM3zAEk3dQiyMJU0sV9DX2kh6wCZS+8PsnY55TotTs9SmJcTYpsnmRjv+ 3Y4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t62-v6si20494590pgd.485.2018.08.14.10.42.37; Tue, 14 Aug 2018 10:42:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389542AbeHNU3o (ORCPT + 99 others); Tue, 14 Aug 2018 16:29:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59018 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730587AbeHNU3n (ORCPT ); Tue, 14 Aug 2018 16:29:43 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0EBC7D20; Tue, 14 Aug 2018 17:41:31 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Konrad Rzeszutek Wilk , Ingo Molnar , David Woodhouse Subject: [PATCH 4.9 045/107] x86/cpu/topology: Provide detect_extended_topology_early() Date: Tue, 14 Aug 2018 19:17:08 +0200 Message-Id: <20180814171523.808733626@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171520.883143803@linuxfoundation.org> References: <20180814171520.883143803@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner commit 95f3d39ccf7aaea79d1ffdac1c887c2e100ec1b6 upstream To support force disabling of SMT it's required to know the number of thread siblings early. detect_extended_topology() cannot be called before the APIC driver is selected, so split out the part which initializes smp_num_siblings. Signed-off-by: Thomas Gleixner Reviewed-by: Konrad Rzeszutek Wilk Acked-by: Ingo Molnar Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/cpu.h | 1 + arch/x86/kernel/cpu/topology.c | 30 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) --- a/arch/x86/kernel/cpu/cpu.h +++ b/arch/x86/kernel/cpu/cpu.h @@ -46,6 +46,7 @@ extern const struct cpu_dev *const __x86 extern void get_cpu_cap(struct cpuinfo_x86 *c); extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c); +extern int detect_extended_topology_early(struct cpuinfo_x86 *c); extern int detect_ht_early(struct cpuinfo_x86 *c); extern void x86_spec_ctrl_setup_ap(void); --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -26,15 +26,13 @@ * exists, use it for populating initial_apicid and cpu topology * detection. */ -void detect_extended_topology(struct cpuinfo_x86 *c) +int detect_extended_topology_early(struct cpuinfo_x86 *c) { #ifdef CONFIG_SMP - unsigned int eax, ebx, ecx, edx, sub_index; - unsigned int ht_mask_width, core_plus_mask_width; - unsigned int core_select_mask, core_level_siblings; + unsigned int eax, ebx, ecx, edx; if (c->cpuid_level < 0xb) - return; + return -1; cpuid_count(0xb, SMT_LEVEL, &eax, &ebx, &ecx, &edx); @@ -42,7 +40,7 @@ void detect_extended_topology(struct cpu * check if the cpuid leaf 0xb is actually implemented. */ if (ebx == 0 || (LEAFB_SUBTYPE(ecx) != SMT_TYPE)) - return; + return -1; set_cpu_cap(c, X86_FEATURE_XTOPOLOGY); @@ -50,10 +48,30 @@ void detect_extended_topology(struct cpu * initial apic id, which also represents 32-bit extended x2apic id. */ c->initial_apicid = edx; + smp_num_siblings = LEVEL_MAX_SIBLINGS(ebx); +#endif + return 0; +} + +/* + * Check for extended topology enumeration cpuid leaf 0xb and if it + * exists, use it for populating initial_apicid and cpu topology + * detection. + */ +void detect_extended_topology(struct cpuinfo_x86 *c) +{ +#ifdef CONFIG_SMP + unsigned int eax, ebx, ecx, edx, sub_index; + unsigned int ht_mask_width, core_plus_mask_width; + unsigned int core_select_mask, core_level_siblings; + + if (detect_extended_topology_early(c) < 0) + return; /* * Populate HT related information from sub-leaf level 0. */ + cpuid_count(0xb, SMT_LEVEL, &eax, &ebx, &ecx, &edx); core_level_siblings = smp_num_siblings = LEVEL_MAX_SIBLINGS(ebx); core_plus_mask_width = ht_mask_width = BITS_SHIFT_NEXT_LEVEL(eax);