Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4800347ooa; Tue, 14 Aug 2018 10:43:41 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxFehTSwyDU4KIYK5xaqlBOyxMqGN2pnvM1VltY6PaYqyrd4eu4f5HmgxKx93osGZdxZ4om X-Received: by 2002:a17:902:bd44:: with SMTP id b4-v6mr4823192plx.144.1534268621200; Tue, 14 Aug 2018 10:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268621; cv=none; d=google.com; s=arc-20160816; b=sOGaft5ZF90SC/qWm0+iwvo/VCFBdoMc7AFBdWF4ujgptcv5HSGHBsR9KPFWTSy1Zh svUt4KUpRnY9uta9uroAHrwNdJ3Xx2TlRM2UnNwKN4+7EDG4Zf4o7/sfA+bjTVuWoSc6 NLrTf/tkKh2Qa+V0GLa+Ja0YVoEucs+/A69EVhrOxeD621+zU0pNQM938nMC3x2AzDQX yJh22YnxuX1Kw08DRwGfIcEwQsSDxUIDFUYc8FWVhvm/Rbs8IiBZU+ig1Xi4a09ywJm/ PNNYmLm9N9XV7YnLn9gkmsEhiqtZ6zJal0MYb/fnR6BWCmtIh0HGicxnoc7mLIk31JUe gShA== 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=Vs2XKAIWSN30CRX9r4Dsyk/HtzquepLs1OVeF1rNIZE=; b=h8BZ8o/GtkHNEz+/bcUjj0ZVrsV9vRo5djxaAoObjM9juhgyVa73tSwAzFEUse/Go2 9m1PAPzWwOou5FCnmq539PgPH3+EjzyJp7I6GPltXvfzmqYm+AGT7K38d9m3njnZ87m9 JZj+DFljyhQpStc9mOA3C44xLsEJlPy/3qiLMJSgzp/2boeNbUBcLbAoxb1TMbx5Vgtm 0ZIoBoSZ06fLnj6LVrATAgWlUOKI48zdk8WuRGrcFfqg+xf3aJ6F3FNXPsPlno5XYO/S 5o71cL0qAVcf0nE3jfrfC/wDwtOQUvgh3BHPIzjRj+/r04fNK/xxoMCsLfHe7FGX4IXN Yp4w== 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 c3-v6si17118121plr.108.2018.08.14.10.43.26; Tue, 14 Aug 2018 10:43:41 -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 S2389983AbeHNU3b (ORCPT + 99 others); Tue, 14 Aug 2018 16:29:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59008 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730587AbeHNU3a (ORCPT ); Tue, 14 Aug 2018 16:29:30 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2F712D4A; Tue, 14 Aug 2018 17:41:20 +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 044/107] x86/cpu/common: Provide detect_ht_early() Date: Tue, 14 Aug 2018 19:17:07 +0200 Message-Id: <20180814171523.687891710@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 545401f4448a807b963ff17b575e0a393e68b523 upstream To support force disabling of SMT it's required to know the number of thread siblings early. detect_ht() 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/common.c | 24 ++++++++++++++---------- arch/x86/kernel/cpu/cpu.h | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -606,32 +606,36 @@ static void cpu_detect_tlb(struct cpuinf tlb_lld_4m[ENTRIES], tlb_lld_1g[ENTRIES]); } -void detect_ht(struct cpuinfo_x86 *c) +int detect_ht_early(struct cpuinfo_x86 *c) { #ifdef CONFIG_SMP u32 eax, ebx, ecx, edx; - int index_msb, core_bits; if (!cpu_has(c, X86_FEATURE_HT)) - return; + return -1; if (cpu_has(c, X86_FEATURE_CMP_LEGACY)) - return; + return -1; if (cpu_has(c, X86_FEATURE_XTOPOLOGY)) - return; + return -1; cpuid(1, &eax, &ebx, &ecx, &edx); smp_num_siblings = (ebx & 0xff0000) >> 16; + if (smp_num_siblings == 1) + pr_info_once("CPU0: Hyper-Threading is disabled\n"); +#endif + return 0; +} - if (!smp_num_siblings) - smp_num_siblings = 1; +void detect_ht(struct cpuinfo_x86 *c) +{ +#ifdef CONFIG_SMP + int index_msb, core_bits; - if (smp_num_siblings == 1) { - pr_info_once("CPU0: Hyper-Threading is disabled\n"); + if (detect_ht_early(c) < 0) return; - } index_msb = get_count_order(smp_num_siblings); c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, index_msb); --- 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_ht_early(struct cpuinfo_x86 *c); extern void x86_spec_ctrl_setup_ap(void);