Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3131083imm; Sun, 13 May 2018 05:01:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpcXkSot5JylvnSeyVM5G6AKblfBmE3UvaxUZSiNiVg89Bw7U2dgztAqK2pITLb8uqIOCAv X-Received: by 2002:a17:902:125:: with SMTP id 34-v6mr5902957plb.42.1526212914942; Sun, 13 May 2018 05:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526212914; cv=none; d=google.com; s=arc-20160816; b=IPIc/JppvfYWno2xyWoAtBi4IzybKGR9lyNYChcI+aqJ3542tHCqYnbExaB1d9222l evZdRcNHVZFdKtRvwYImLAH2jJpahsCMIIwL042U1qd7bSy4mXazDEu7r+nrv9uuVGqz d2l0LSZizKfgvTW/SD9g+CrM+sEylwYYQ9VNh+iq9GYq1Rdm8OymKKZrhCGEfp+6m/f3 hUbyvKikbZttTwdqV4zbaN7XcpoqpI2MZYviB1OJFOUrYGZur87BlYtwZexLy1UTgx6D r4GpWlXXWZfn/yukmzgY1RAKo1HB8KLfDZUEGfcus/AIqUDtNJCWryu+A33YL783gx+e Uycw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=QZGBmNUmYG7IriuZfTft84oGtV1FyIr/pHPuMSL1QS8=; b=1J03joJQYme4+yLAIjN9/SCNflIhR5IdwJfMyGCKpJNPryadvCoCgRJyc2dNwOWwZy O2TjKNYJcBJhfUqGBz2kCIqeuktLEch2/EGdjN+rkTwUB7Htq1uhdkQO614fFH2wEFZD C7wWeCIHht8UT1tkZl1OrF3NXMxctB3yXgDxZLPfHX9Bs9JpFiVvS+izQN/dydbY97Sc U52Xla5n9H4tFpangNHwv6b/8BB1iahu1fLAEpo7krNVkswkkI8+mARYURT3HwkZeYA1 e81dRg5fFFcfBTgniP1lnN4U0VACoGzaJ32AWgOHM0OZgeWexirqmzOmlO1u5jVanh0E ZxcQ== 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 b63-v6si1943665plb.566.2018.05.13.05.01.40; Sun, 13 May 2018 05:01:54 -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 S1751328AbeEMMB3 (ORCPT + 99 others); Sun, 13 May 2018 08:01:29 -0400 Received: from terminus.zytor.com ([198.137.202.136]:45113 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbeEMMB2 (ORCPT ); Sun, 13 May 2018 08:01:28 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w4DC1Ljl330167 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 13 May 2018 05:01:21 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w4DC1KMX330163; Sun, 13 May 2018 05:01:20 -0700 Date: Sun, 13 May 2018 05:01:20 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for David Wang Message-ID: Cc: davidwang@zhaoxin.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com Reply-To: davidwang@zhaoxin.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com In-Reply-To: <1525314766-18910-2-git-send-email-davidwang@zhaoxin.com> References: <1525314766-18910-2-git-send-email-davidwang@zhaoxin.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cpu] x86/CPU: Make intel_num_cpu_cores() generic Git-Commit-ID: 2cc61be60e37b1856a97ccbdcca3e86e593bf06a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 2cc61be60e37b1856a97ccbdcca3e86e593bf06a Gitweb: https://git.kernel.org/tip/2cc61be60e37b1856a97ccbdcca3e86e593bf06a Author: David Wang AuthorDate: Thu, 3 May 2018 10:32:44 +0800 Committer: Thomas Gleixner CommitDate: Sun, 13 May 2018 12:06:12 +0200 x86/CPU: Make intel_num_cpu_cores() generic intel_num_cpu_cores() is a static function in intel.c which can't be used by other files. Define another function called detect_num_cpu_cores() in common.c to replace this function so it can be reused. Signed-off-by: David Wang Signed-off-by: Thomas Gleixner Cc: lukelin@viacpu.com Cc: qiyuanwang@zhaoxin.com Cc: gregkh@linuxfoundation.org Cc: brucechang@via-alliance.com Cc: timguo@zhaoxin.com Cc: cooperyan@zhaoxin.com Cc: hpa@zytor.com Cc: benjaminpan@viatech.com Link: https://lkml.kernel.org/r/1525314766-18910-2-git-send-email-davidwang@zhaoxin.com --- arch/x86/kernel/cpu/common.c | 14 ++++++++++++++ arch/x86/kernel/cpu/cpu.h | 1 + arch/x86/kernel/cpu/intel.c | 20 +------------------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 37c7c8334a00..6993842e788c 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -584,6 +584,20 @@ static void get_model_name(struct cpuinfo_x86 *c) *(s + 1) = '\0'; } +int detect_num_cpu_cores(struct cpuinfo_x86 *c) +{ + unsigned int eax, ebx, ecx, edx; + + if (!IS_ENABLED(CONFIG_SMP) || c->cpuid_level < 4) + return 1; + + cpuid_count(4, 0, &eax, &ebx, &ecx, &edx); + if (eax & 0x1f) + return (eax >> 26) + 1; + else + return 1; +} + void cpu_detect_cache_sizes(struct cpuinfo_x86 *c) { unsigned int n, dummy, ebx, ecx, edx, l2size; diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h index c415f99e9599..efd6ef8ad14e 100644 --- a/arch/x86/kernel/cpu/cpu.h +++ b/arch/x86/kernel/cpu/cpu.h @@ -54,6 +54,7 @@ extern u32 get_scattered_cpuid_leaf(unsigned int level, extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); extern void init_amd_cacheinfo(struct cpuinfo_x86 *c); +extern int detect_num_cpu_cores(struct cpuinfo_x86 *c); extern int detect_extended_topology(struct cpuinfo_x86 *c); extern void detect_ht(struct cpuinfo_x86 *c); diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index b9693b80fc21..b54535be254a 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -453,24 +453,6 @@ static void srat_detect_node(struct cpuinfo_x86 *c) #endif } -/* - * find out the number of processor cores on the die - */ -static int intel_num_cpu_cores(struct cpuinfo_x86 *c) -{ - unsigned int eax, ebx, ecx, edx; - - if (!IS_ENABLED(CONFIG_SMP) || c->cpuid_level < 4) - return 1; - - /* Intel has a non-standard dependency on %ecx for this CPUID level. */ - cpuid_count(4, 0, &eax, &ebx, &ecx, &edx); - if (eax & 0x1f) - return (eax >> 26) + 1; - else - return 1; -} - static void detect_vmx_virtcap(struct cpuinfo_x86 *c) { /* Intel VMX MSR indicated features */ @@ -671,7 +653,7 @@ static void init_intel(struct cpuinfo_x86 *c) * let's use the legacy cpuid vector 0x1 and 0x4 for topology * detection. */ - c->x86_max_cores = intel_num_cpu_cores(c); + c->x86_max_cores = detect_num_cpu_cores(c); #ifdef CONFIG_X86_32 detect_ht(c); #endif