Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1217204ybj; Tue, 5 May 2020 15:38:39 -0700 (PDT) X-Google-Smtp-Source: APiQypJkYUN3dBrS+f7A9Zp8zXqKLGXJBdo6bZitfvlJpZdjMM6U0W8UrzTfVNzWX/t/e/P51xfS X-Received: by 2002:a17:906:b896:: with SMTP id hb22mr4650960ejb.209.1588718319236; Tue, 05 May 2020 15:38:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588718319; cv=none; d=google.com; s=arc-20160816; b=FSbdqlFVxBn7IKbbCjEk9bP8ijk6bukElR0FOAHta7pFlss875IelV5ZSlvgoLQ+Q9 8Uk4bTuk9Sg9lodd7w7ZlXS3xj0jkUklv/G4NU0wpKv6eFIBhqcgA1arsXrUc+CWbOzs rrLB4JU+l1dTs5URnN1K8Xm9bG/HfukvQ4NCX4Q2o/GivoxDOV+uxRhSIC0jl7oQ8dC7 5TbBVDgZFFKj3R38QTeD/EkVDDBkzlE+JlS/pHkJT3cVqQBv3BMA7nzUm8Z4XZI0/qnv rTnRWyrvMFL+Fq6dwy+AGkkhHwhWZmJ0cdiSqHrOjo2hKUTJKY6ou9gY0Tgu+cqOw41U kIwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=5c5y79pfx81kVDdYI48ubJiMzSlDsx09brF6CeGIgMo=; b=deNCKOpRKdCdTbfKugkqruXb1xCUD/8HOdkro2H6wyCkYV8YDlO2Re6X6gN3YYofvd SJiEz1F+xo8x2zcboABtoZKkIwA8ddAbMbNut4p1cM/4qFq6TclYFLuiWDd7H28ic4Hc XxnjQrIYGw9i5OAFHaY+nLspJuNJrg78QPDt7Wd8pQDHtP3ziz1yiH9V0jUjyahYO13p pbYVfH1INBGGxW6i+wQ6SXfX9isVX5nxcz9NwQmPQ3UW7sOZ4b7ZzqBTQa5nAsQ5nWx/ C6LtJuSW1w6OK9XuJhgD81MzQm4CcDf3FYborVGViXpvwSbJVc1/vgjZnW7Gjb7pPtpi zK9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u21si41744ejz.518.2020.05.05.15.38.14; Tue, 05 May 2020 15:38:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729457AbgEEWgt (ORCPT + 99 others); Tue, 5 May 2020 18:36:49 -0400 Received: from mga09.intel.com ([134.134.136.24]:41848 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729370AbgEEWgq (ORCPT ); Tue, 5 May 2020 18:36:46 -0400 IronPort-SDR: y1V6kTZu4sJaYutNa/S+4+uc9ADz+9oQBT7zjIvm4tCqv8DW1QreQ3J4aMPHiYvKntXYvoTXZH jBxgcEAimEEQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2020 15:36:45 -0700 IronPort-SDR: LSbr1tLsgibNC4wHMtOQI2NZWQdAOeZLuIZswdtHO1Jz/UeOF7wbpfFOvugwMjdff64fxuoZ75 VRjnckI399nA== X-IronPort-AV: E=Sophos;i="5.73,357,1583222400"; d="scan'208";a="284410833" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2020 15:36:44 -0700 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, bp@alien8.de, tony.luck@intel.com Cc: kuo-lang.tseng@intel.com, mingo@redhat.com, babu.moger@amd.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre , Borislav Petkov Subject: [PATCH V2 2/7] x86/cpu: Move resctrl CPUID code to resctrl Date: Tue, 5 May 2020 15:36:13 -0700 Message-Id: <38433b99f9d16c8f4ee796f8cc42b871531fa203.1588715690.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function determining a platform's support and properties of cache occupancy and memory bandwidth monitoring (properties of X86_FEATURE_CQM_LLC) can be found among the common CPU code. After the feature's properties is populated in the per-CPU data the resctrl subsystem is the only consumer (via boot_cpu_data). Move the function that obtains the CPU information used by resctrl to the resctrl subsystem and rename it from init_cqm() to resctrl_cpu_detect(). The function continues to be called from the common CPU code. This move is done in preparation of the addition of some vendor specific code. No functional change. Suggested-by: Borislav Petkov Signed-off-by: Reinette Chatre --- arch/x86/include/asm/resctrl.h | 3 +++ arch/x86/kernel/cpu/common.c | 27 ++------------------------- arch/x86/kernel/cpu/resctrl/core.c | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 99b5728e441d..07603064df8f 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -84,9 +84,12 @@ static inline void resctrl_sched_in(void) __resctrl_sched_in(); } +void resctrl_cpu_detect(struct cpuinfo_x86 *c); + #else static inline void resctrl_sched_in(void) {} +static inline void resctrl_cpu_detect(struct cpuinfo_x86 *c) {} #endif /* CONFIG_X86_CPU_RESCTRL */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index bed0cb83fe24..a8f0f22ee5c1 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -56,6 +56,7 @@ #include #include #include +#include #include "cpu.h" @@ -854,30 +855,6 @@ static void init_speculation_control(struct cpuinfo_x86 *c) } } -static void init_cqm(struct cpuinfo_x86 *c) -{ - if (!cpu_has(c, X86_FEATURE_CQM_LLC)) { - c->x86_cache_max_rmid = -1; - c->x86_cache_occ_scale = -1; - return; - } - - /* will be overridden if occupancy monitoring exists */ - c->x86_cache_max_rmid = cpuid_ebx(0xf); - - if (cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC) || - cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL) || - cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL)) { - u32 eax, ebx, ecx, edx; - - /* QoS sub-leaf, EAX=0Fh, ECX=1 */ - cpuid_count(0xf, 1, &eax, &ebx, &ecx, &edx); - - c->x86_cache_max_rmid = ecx; - c->x86_cache_occ_scale = ebx; - } -} - void get_cpu_cap(struct cpuinfo_x86 *c) { u32 eax, ebx, ecx, edx; @@ -945,7 +922,7 @@ void get_cpu_cap(struct cpuinfo_x86 *c) init_scattered_cpuid_features(c); init_speculation_control(c); - init_cqm(c); + resctrl_cpu_detect(c); /* * Clear/Set all flags overridden by options, after probe. diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 6f38c88226af..861c6d1ba9ab 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -958,6 +958,30 @@ static __init void rdt_init_res_defs(void) static enum cpuhp_state rdt_online; +void resctrl_cpu_detect(struct cpuinfo_x86 *c) +{ + if (!cpu_has(c, X86_FEATURE_CQM_LLC)) { + c->x86_cache_max_rmid = -1; + c->x86_cache_occ_scale = -1; + return; + } + + /* will be overridden if occupancy monitoring exists */ + c->x86_cache_max_rmid = cpuid_ebx(0xf); + + if (cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC) || + cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL) || + cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL)) { + u32 eax, ebx, ecx, edx; + + /* QoS sub-leaf, EAX=0Fh, ECX=1 */ + cpuid_count(0xf, 1, &eax, &ebx, &ecx, &edx); + + c->x86_cache_max_rmid = ecx; + c->x86_cache_occ_scale = ebx; + } +} + static int __init resctrl_late_init(void) { struct rdt_resource *r; -- 2.21.0