From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 12 Jun 2018 20:22:25 -0000 Received: from aserp2130.oracle.com ([141.146.126.79]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fSpo7-0003wM-N8 for speck@linutronix.de; Tue, 12 Jun 2018 22:22:25 +0200 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5CKGNrv119603 for ; Tue, 12 Jun 2018 20:22:17 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2jg4dm3wrt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 12 Jun 2018 20:22:16 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5CKMFFG029008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 12 Jun 2018 20:22:15 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5CKMFkN025936 for ; Tue, 12 Jun 2018 20:22:15 GMT Date: Tue, 12 Jun 2018 16:22:14 -0400 From: Konrad Rzeszutek Wilk Subject: [MODERATED] Re: [patch V2 08/12] x86/cpu/common: Provide detect_ht_early() Message-ID: <20180612202214.GH25607@char.us.oracle.com> References: <20180606192714.754943543@linutronix.de> <20180606192807.593002375@linutronix.de> MIME-Version: 1.0 In-Reply-To: <20180606192807.593002375@linutronix.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Wed, Jun 06, 2018 at 09:27:22PM +0200, speck for Thomas Gleixner wrote: > Subject: [patch V2 08/12] x86/cpu/common: Provide detect_ht_early() > 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 Thank you! > --- > arch/x86/kernel/cpu/common.c | 25 ++++++++++++++----------- > arch/x86/kernel/cpu/cpu.h | 1 + > 2 files changed, 15 insertions(+), 11 deletions(-) > > --- a/arch/x86/kernel/cpu/common.c > +++ b/arch/x86/kernel/cpu/common.c > @@ -658,33 +658,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; > - static bool printed; > > 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); >