Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4780876ooa; Tue, 14 Aug 2018 10:27:08 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwOP1J/tRQyLCWF5FRp/mjextojwJzTqWO4dyTr2JQOBUk2FU1U5KA4/et8q3wycOOGWfhI X-Received: by 2002:a63:cb04:: with SMTP id p4-v6mr21409800pgg.197.1534267628896; Tue, 14 Aug 2018 10:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534267628; cv=none; d=google.com; s=arc-20160816; b=k4BY8yIZhcS8xz/CWS3zyBQeyCo/c86vCE7YH6WjWqYbuKxW8UoFl4F0egWhSA1kYU DTMXPoTr0zDl3M4yolWVOQycOmBq7KMeDLSvPsCE4bqWLr1k/Cmj53Wr+Kxyx+ksqUDG c/sE5lJKYOGLVYcsNMsQ4T7SZoSNdU/Gn6HQPbE0/AeYrDE/c45NRM6RML+6sG6/vVf0 XPAdMaunlt4hW2ywITpgs/zko184qh4IZuWjB4aSqCWuM0RB0vRGdNd24wITPKjSpuC7 6y/scq7F2DcTgQIQN7FowYEskG2gWfD+m9bR5koo2okag3Qtut4gzip6/0rUrH+bWDVe PXPg== 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=lpEq/Z1gmUBoEeHP+aKZ050mqaHjJ1NuiQemvLljlsk=; b=QFPHJ1MhYIc8K/CWrAiFQtR+Pq1Bg33jlNMToBWSsn55Sy15aELljwQvludDlokML1 9YU6Eug+UUbgz99RNatuu2Bo1hAu834oBKMWMnZqM4JnZ30JTtG1VBu2fuLilIshybp8 QwpWT7NEqZloCnkPBYstTsUnuibvTVWV2+peWNAXx6dgbyLvl0ZF6qQeuwkWI6fpeTZg d4L08htBDyG4LRQ+PCcBXMWQwELsYy5CE1yliZ7Fi2VGIKsqNIu0Q94x99/PmZVyETKn DmYr2u3QOcLrfc8Wm3LZCGnh4hDKHUlymO7nuNOTHeia6M8HunZm12Jn9utgiz2woXfb /CkA== 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 h34-v6si16787652pld.355.2018.08.14.10.26.53; Tue, 14 Aug 2018 10:27:08 -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 S2388033AbeHNUM5 (ORCPT + 99 others); Tue, 14 Aug 2018 16:12:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51468 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387747AbeHNUM4 (ORCPT ); Tue, 14 Aug 2018 16:12:56 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8E715D1D; Tue, 14 Aug 2018 17:24:50 +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 Subject: [PATCH 4.18 22/79] x86/cpu/common: Provide detect_ht_early() Date: Tue, 14 Aug 2018 19:16:41 +0200 Message-Id: <20180814171337.650642136@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171336.799314117@linuxfoundation.org> References: <20180814171336.799314117@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner 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: 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 @@ -661,32 +661,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 @@ -56,6 +56,7 @@ extern void init_amd_cacheinfo(struct cp extern void detect_num_cpu_cores(struct cpuinfo_x86 *c); extern int detect_extended_topology(struct cpuinfo_x86 *c); +extern int detect_ht_early(struct cpuinfo_x86 *c); extern void detect_ht(struct cpuinfo_x86 *c); unsigned int aperfmperf_get_khz(int cpu);