Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4780336ooa; Tue, 14 Aug 2018 10:26:39 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwPZGfDmsvEnq4bbsfYIxHqzr0jl2esXUE+FgxeuqYsEOvvY25nQLDfzyaG+6YtrK9jMvVi X-Received: by 2002:a65:6104:: with SMTP id z4-v6mr22035046pgu.361.1534267599828; Tue, 14 Aug 2018 10:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534267599; cv=none; d=google.com; s=arc-20160816; b=Acu8Nv9sb3yLtRbWVTjVxls6dIJ+POQh27kYGf1gqQE262Vho4aEgRpWd+1cmLYNNX HWyaxCrPAWQQQOhHr7Cwtoc+N+al3ilH4tm2KEPas62Y81ysMs6/RFTQTbxiFwKMuH9G N+d/fcmztE3o2PnYE6kef2KHqW+LvUBP1ffYpVJP1QoVjTB0CffqL/hyV9OY4kslX9MG rLq47HMpBkcwxpqzisnJ6mQC3/kkmfQK5gN5MJqebbWs3UfbWX/UqjRipUC+lUMBBqMV 6lScOzSLJJ22vbVcu9Jaz/6pb2ORIiX4hIu+RgVnQ01AJWJIE65bGRJgtf03Mmnl2djc FSwg== 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=wR3sD4sqLBEtGPpSlqVUgnc5uvD6jN43abaiRw+TUUg=; b=tTFcA8DKX9df2kAfDP81Rb/ER1sQc9gsNIA/LG787CyzFHMWGAEU44jaBEYiFbyKgZ hq6k9lK7UGCqN52tIamDrtC1mUwXMUMKYubegKisR2dedGOSAjljAG4wA9k2HLYHcuXF eR4rqPMI0hxNj8QDO7SK/p2TPpQ/b31a6m9Eu5Sp/UH5oLwVJNDZjhcn9yIyFUa1bS1n oLMKTYjuFn51BpVxC7NtrcRnURnCHbS5aydRb/jESiQP44839idKqCoRVQPxN/OdN5Rn ZepXs5JP68hfuwlha2EXXcBdbiK+yhidXOc8PurlWNZMNM2oeAiT7t6NMOIGc9EYQfHF 5hTg== 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 o14-v6si16998531pll.185.2018.08.14.10.26.24; Tue, 14 Aug 2018 10:26:39 -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 S2388048AbeHNUNA (ORCPT + 99 others); Tue, 14 Aug 2018 16:13:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51478 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387747AbeHNUNA (ORCPT ); Tue, 14 Aug 2018 16:13:00 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A41C3CD8; Tue, 14 Aug 2018 17:24:53 +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 23/79] x86/cpu/topology: Provide detect_extended_topology_early() Date: Tue, 14 Aug 2018 19:16:42 +0200 Message-Id: <20180814171337.690977418@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_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: Greg Kroah-Hartman --- arch/x86/kernel/cpu/cpu.h | 1 + arch/x86/kernel/cpu/topology.c | 31 ++++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) --- a/arch/x86/kernel/cpu/cpu.h +++ b/arch/x86/kernel/cpu/cpu.h @@ -55,6 +55,7 @@ extern void init_intel_cacheinfo(struct extern void init_amd_cacheinfo(struct cpuinfo_x86 *c); extern void detect_num_cpu_cores(struct cpuinfo_x86 *c); +extern int detect_extended_topology_early(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); --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -22,17 +22,10 @@ #define BITS_SHIFT_NEXT_LEVEL(eax) ((eax) & 0x1f) #define LEVEL_MAX_SIBLINGS(ebx) ((ebx) & 0xffff) -/* - * Check for extended topology enumeration cpuid leaf 0xb and if it - * exists, use it for populating initial_apicid and cpu topology - * detection. - */ -int 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 -1; @@ -51,10 +44,30 @@ int detect_extended_topology(struct cpui * 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. + */ +int 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 -1; /* * 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);