Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3080451ybt; Mon, 29 Jun 2020 14:49:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmxnnl3UDNQYJQ1zcmXT+HsVPjtXiXOxo9glt8kAacUvo8YNKVmGPbOVIGv8hM4XPAxE28 X-Received: by 2002:a17:906:fac1:: with SMTP id lu1mr10211265ejb.427.1593467397802; Mon, 29 Jun 2020 14:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593467397; cv=none; d=google.com; s=arc-20160816; b=UjlnKyXF5EG0hpX0Afgt5hJZayDEFMj9sS1UJ/BnjdUvMtZcjc1ZmU+v4mHCKVSzHW AGgK731qtnhpJVa1+eo45G3Y3h0c6p0PbHuv0sZn67N1sA2+buDdk4wdq/FgSGeLU67Z EuQShxeYzB/riEotbeRD9An/BWW2//NhejtR7tu6TNWVKbUPGYWdJQHpW3xRmaEctwva tbT+LoIfGhUuY9VsPgf323wTRVdXagIpfCsAut5E79hji/SvDOPcP6DZsrEgBoP12Lta nM+sbFbdoFs1fDcAhxR7bagRQNakSGJ8Z1sJaczdhE0PQNYxGkBsbPKBEUijYmP0F95i WtMw== 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 :dkim-signature; bh=O/YMrPNbkbDSapmFfCyr6NVhF0mwpVc65dbrcVUwSGI=; b=khx+gQqVb8i796eY9xi1bHev1pA4+WxJdR76LbDYSuAX6NbwyBm0aPL9H/b6YqFJlY QWY9/k5hT045sDDe/Gj1ouUSW9UlCv51YMW6zLpSssq/6NfPbn/cALBa6RQl0nHme22+ izy+Y3jhE5LOZgOhFLpOko/YuN4YYF8VtG9fWbMubRkRjmCFQFbgGiNq8Y7nboO2f277 xSBM0JcRBIX5jEXgBu2qHwrjV03fU5+NxhM37W97QpgY0loTxABGl/pYTq09e02wgI5a 0k6qWnXblKbyflBnufDvz98bJuaH7iflu6m4cux0etV3+n/Z3MYpFzMSOsLaIWfqarck CgeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WyrJM9uo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si510306ejb.510.2020.06.29.14.49.35; Mon, 29 Jun 2020 14:49:57 -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; dkim=pass header.i=@kernel.org header.s=default header.b=WyrJM9uo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404298AbgF2Vsb (ORCPT + 99 others); Mon, 29 Jun 2020 17:48:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:56764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbgF2Sfn (ORCPT ); Mon, 29 Jun 2020 14:35:43 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A5B6A246A7; Mon, 29 Jun 2020 15:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444000; bh=CShSKxwEsr2YDNf3cAE90Nyu4luZdDoF3ZS0WckTXJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WyrJM9uovylKDkjG7Gkz4nRXA2Az63YD2qtCSAVzkO+6MPGV5d54GRbs0Jk7qTSFH eB51k4qjHtCK7EP8KYwgWBqsIxF/trVamk6Q21CptamZ8V4c6kcxllUYwa4VKkjs03 nh60rDv5ZSoKBmm05mndC0KEexWmt4SIos1ojLX0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Reinette Chatre , Borislav Petkov , Sasha Levin Subject: [PATCH 5.7 105/265] x86/cpu: Move resctrl CPUID code to resctrl/ Date: Mon, 29 Jun 2020 11:15:38 -0400 Message-Id: <20200629151818.2493727-106-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629151818.2493727-1-sashal@kernel.org> References: <20200629151818.2493727-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.7.7-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.7.7-rc1 X-KernelTest-Deadline: 2020-07-01T15:14+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Reinette Chatre [ Upstream commit 0118ad82c2a64ebcf15d7565ed35361407efadfa ] 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 Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/38433b99f9d16c8f4ee796f8cc42b871531fa203.1588715690.git.reinette.chatre@intel.com Signed-off-by: Sasha Levin --- arch/x86/include/asm/resctrl_sched.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_sched.h b/arch/x86/include/asm/resctrl_sched.h index f6b7fe2833cc7..c8a27cbbdae29 100644 --- a/arch/x86/include/asm/resctrl_sched.h +++ b/arch/x86/include/asm/resctrl_sched.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 8293ee5149758..e2e4af685f9b4 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 d8cc5223b7ce8..49599733fa94d 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.25.1