arch/x86: AMD QoS support
v3 cover arch/x86: AMD QoS support
This series adds support for AMD64 architectural extensions for Platform Quality of Service. These extensions are intended to provide for the monitoring of the usage of certain system resources by one or more processors and for the separate allocation and enforcement of limits on the use of certain system resources by one or more processors.
The monitoring and enforcement are not necessarily applied across the entire system, but in general apply to a QOS domain which corresponds to some shared system resource. The set of resources which are monitored and the set for which the enforcement of limits is provided are implementation dependent. Platform QOS features are implemented on a logical processor basis. Therefore, multiple hardware threads of a single physical CPU core may have independent resource monitoring and enforcement configurations.
AMD's next generation of processors support following QoS sub-features.
- L3 Cache allocation enforcement
- L3 Cache occupancy monitoring
- L3 Code-Data Prioritization support
- Memory Bandwidth Enforcement(Allocation)
The public specification for this feature is available at
https://developer.amd.com/wp-content/resources/56375.pdf
Obviously, there are multiple ways we can go about these changes. We felt it is appropriate to rename and re-organize the code little bit before making the functional changes. The first few patches(1-6) renames and re-organizes the sources in preparation. Rest of the patches(7-11) adds support for AMD QoS features.
Please review and provide me feedback.
Changes from v2 -> v3:
a. Rebased the patches on top of below branch as suggested by Thomas Gleixner.
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/cache
b. Addressed comments from Reinette Chatre, Fenghua Yu and Borislav Petkov. c. Main changes are related to renaming the files and functions.
Renamed from intel_rdt to more generic resctrl(patches 1 to 3).
d. Config parameter changed from PLATFORM_QOS to more generic RESCTRL. e. Fixed minor indentation issues.
Changes from v1 -> v2:
https://lore.kernel.org/lkml/[email protected]/
a. Removed RFC from subject header. Based on the discussion so far,
plan is to go ahead with these patches and eventually re-structure the code to make arch and non-arch separate.
b. Addressed comments from Reinette Chatre and Fenghua Yu. c. Separated quirks and MBA from rdt init code. Kept the rest of the
code as is.
d. Added _intel suffixes all the Intel only code just like AMD code. e. Added one more patch to bring the macros into header file. f. Few minor text changes.
v1:
https://lore.kernel.org/lkml/[email protected]/
Babu Moger (10):
arch/x86: Start renaming the rdt files to more generic names arch/x86: Rename the RDT functions and definitions arch/x86: Re-arrange RDT init code
arch/x86: Bring all the macros to resctrl.h arch/x86: Introduce a new config parameter RESCTRL arch/x86: Use new config parameter RESCTRL for compilation arch/x86: Initialize the resource functions that are different arch/x86: Bring few more functions into the resource structure arch/x86: Introduce new config parameter AMD_QOS arch/x86: Introduce QOS feature for AMD
Sherry Hurwitz (1):
arch/x86: Add AMD feature bit X86_FEATURE_MBA in cpuid bits array
arch/x86/Kconfig | 19 ++
.../{intel_rdt_sched.h => resctrl_sched.h} | 28 +--
arch/x86/kernel/cpu/Makefile | 6 +-
.../x86/kernel/cpu/{intel_rdt.c => resctrl.c} | 169 +++++++++++++++---
.../x86/kernel/cpu/{intel_rdt.h => resctrl.h} | 41 +++--
...dt_ctrlmondata.c => resctrl_ctrlmondata.c} | 80 ++++++++-
...{intel_rdt_monitor.c => resctrl_monitor.c} | 30 ++--
...dt_pseudo_lock.c => resctrl_pseudo_lock.c} | 6 +-
...ck_event.h => resctrl_pseudo_lock_event.h} | 2 +-
...ntel_rdt_rdtgroup.c => resctrl_rdtgroup.c} | 14 +-
arch/x86/kernel/cpu/scattered.c | 7 +-
arch/x86/kernel/process_32.c | 4 +-
arch/x86/kernel/process_64.c | 4 +-
include/linux/sched.h | 2 +-
14 files changed, 320 insertions(+), 92 deletions(-)
rename arch/x86/include/asm/{intel_rdt_sched.h => resctrl_sched.h} (77%)
rename arch/x86/kernel/cpu/{intel_rdt.c => resctrl.c} (84%)
rename arch/x86/kernel/cpu/{intel_rdt.h => resctrl.h} (92%)
rename arch/x86/kernel/cpu/{intel_rdt_ctrlmondata.c => resctrl_ctrlmondata.c} (86%)
rename arch/x86/kernel/cpu/{intel_rdt_monitor.c => resctrl_monitor.c} (96%)
rename arch/x86/kernel/cpu/{intel_rdt_pseudo_lock.c => resctrl_pseudo_lock.c} (99%)
rename arch/x86/kernel/cpu/{intel_rdt_pseudo_lock_event.h => resctrl_pseudo_lock_event.h} (95%)
rename arch/x86/kernel/cpu/{intel_rdt_rdtgroup.c => resctrl_rdtgroup.c} (99%)Signature · 1 line
2.17.1
PATCH v3 1/11 arch/x86: Start renaming the rdt files to more generic names
New generation of AMD processors start supporting RDT(or QOS) features. With more than one vendors supporting these features, it seems more appropriate to rename these files.
Changed intel_rdt to resctrl where applicable.
---
arch/x86/include/asm/{intel_rdt_sched.h => resctrl_sched.h} | 0
arch/x86/kernel/cpu/Makefile | 6 +++---
arch/x86/kernel/cpu/{intel_rdt.c => resctrl.c} | 4 ++--
arch/x86/kernel/cpu/{intel_rdt.h => resctrl.h} | 6 +++---
.../cpu/{intel_rdt_ctrlmondata.c => resctrl_ctrlmondata.c} | 2 +-
.../kernel/cpu/{intel_rdt_monitor.c => resctrl_monitor.c} | 2 +-
.../cpu/{intel_rdt_pseudo_lock.c => resctrl_pseudo_lock.c} | 6 +++---
..._rdt_pseudo_lock_event.h => resctrl_pseudo_lock_event.h} | 2 +-
.../kernel/cpu/{intel_rdt_rdtgroup.c => resctrl_rdtgroup.c} | 4 ++--
arch/x86/kernel/process_32.c | 2 +-
arch/x86/kernel/process_64.c | 2 +-
11 files changed, 18 insertions(+), 18 deletions(-)
rename arch/x86/include/asm/{intel_rdt_sched.h => resctrl_sched.h} (100%)
rename arch/x86/kernel/cpu/{intel_rdt.c => resctrl.c} (99%)
rename arch/x86/kernel/cpu/{intel_rdt.h => resctrl.h} (99%)
rename arch/x86/kernel/cpu/{intel_rdt_ctrlmondata.c => resctrl_ctrlmondata.c} (99%)
rename arch/x86/kernel/cpu/{intel_rdt_monitor.c => resctrl_monitor.c} (99%)
rename arch/x86/kernel/cpu/{intel_rdt_pseudo_lock.c => resctrl_pseudo_lock.c} (99%)
rename arch/x86/kernel/cpu/{intel_rdt_pseudo_lock_event.h => resctrl_pseudo_lock_event.h} (95%)
rename arch/x86/kernel/cpu/{intel_rdt_rdtgroup.c => resctrl_rdtgroup.c} (99%)arch/x86/include/asm/resctrl_sched.h renamed from arch/x86/include/asm/intel_rdt_sched.h +0 -0
arch/x86/kernel/cpu/Makefile +3 -3
@@ -35,9 +35,9 @@ obj-$(CONFIG_CPU_SUP_CENTAUR) += centaur.o obj-$(CONFIG_CPU_SUP_TRANSMETA_32) += transmeta.o obj-$(CONFIG_CPU_SUP_UMC_32) += umc.o -obj-$(CONFIG_INTEL_RDT) += intel_rdt.o intel_rdt_rdtgroup.o intel_rdt_monitor.o -obj-$(CONFIG_INTEL_RDT) += intel_rdt_ctrlmondata.o intel_rdt_pseudo_lock.o -CFLAGS_intel_rdt_pseudo_lock.o = -I$(src) +obj-$(CONFIG_INTEL_RDT) += resctrl.o resctrl_rdtgroup.o resctrl_monitor.o +obj-$(CONFIG_INTEL_RDT) += resctrl_ctrlmondata.o resctrl_pseudo_lock.o +CFLAGS_resctrl_pseudo_lock.o = -I$(src) obj-$(CONFIG_X86_MCE) += mcheck/ obj-$(CONFIG_MTRR) += mtrr/
arch/x86/kernel/cpu/resctrl.c renamed from arch/x86/kernel/cpu/intel_rdt.c +2 -2
@@ -30,8 +30,8 @@#include <linux/cpuhotplug.h> #include <asm/intel-family.h> -#include <asm/intel_rdt_sched.h> -#include "intel_rdt.h" +#include <asm/resctrl_sched.h> +#include "resctrl.h" #define MBA_IS_LINEAR 0x4#define MBA_MAX_MBPS U32_MAX
arch/x86/kernel/cpu/resctrl.h renamed from arch/x86/kernel/cpu/intel_rdt.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_X86_INTEL_RDT_H -#define _ASM_X86_INTEL_RDT_H +#ifndef _ASM_X86_RESCTRL_H +#define _ASM_X86_RESCTRL_H#include <linux/sched.h> #include <linux/kernfs.h>
@@ -568,4 +568,4 @@ void cqm_handle_limbo(struct work_struct *work);bool has_busy_rmid (struct rdt_resource *r,struct rdt_domain *d);void __check_limbo (struct rdt_domain *d,bool force_free); -#endif /* _ASM_X86_INTEL_RDT_H */ +#endif /* _ASM_X86_RESCTRL_H */
arch/x86/kernel/cpu/resctrl_ctrlmondata.c renamed from arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c +1 -1
@@ -26,7 +26,7 @@#include <linux/kernfs.h> #include <linux/seq_file.h> #include <linux/slab.h> -#include "intel_rdt.h" +#include "resctrl.h" /* * Check whether MBA bandwidth percentage value is correct. The value is
arch/x86/kernel/cpu/resctrl_monitor.c renamed from arch/x86/kernel/cpu/intel_rdt_monitor.c +1 -1
@@ -26,7 +26,7 @@#include <linux/module.h> #include <linux/slab.h> #include <asm/cpu_device_id.h> -#include "intel_rdt.h" +#include "resctrl.h" #define MSR_IA32_QM_CTR 0x0c8e#define MSR_IA32_QM_EVTSEL 0x0c8d
arch/x86/kernel/cpu/resctrl_pseudo_lock.c renamed from arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c +3 -3
@@ -24,14 +24,14 @@#include <asm/cacheflush.h> #include <asm/intel-family.h> -#include <asm/intel_rdt_sched.h> +#include <asm/resctrl_sched.h> #include <asm/perf_event.h> #include "../../events/perf_event.h" /* For X86_CONFIG() */ -#include "intel_rdt.h" +#include "resctrl.h" #define CREATE_TRACE_POINTS -#include "intel_rdt_pseudo_lock_event.h" +#include "resctrl_pseudo_lock_event.h" /* * MSR_MISC_FEATURE_CONTROL register enables the modification of hardware
arch/x86/kernel/cpu/resctrl_pseudo_lock_event.h renamed from arch/x86/kernel/cpu/intel_rdt_pseudo_lock_event.h +1 -1
@@ -39,5 +39,5 @@ TRACE_EVENT(pseudo_lock_l3,#undef TRACE_INCLUDE_PATH#define TRACE_INCLUDE_PATH . -#define TRACE_INCLUDE_FILE intel_rdt_pseudo_lock_event +#define TRACE_INCLUDE_FILE resctrl_pseudo_lock_event#include <trace/define_trace.h>
arch/x86/kernel/cpu/resctrl_rdtgroup.c renamed from arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +2 -2
@@ -35,8 +35,8 @@#include <uapi/linux/magic.h> -#include <asm/intel_rdt_sched.h> -#include "intel_rdt.h" +#include <asm/resctrl_sched.h> +#include "resctrl.h" DEFINE_STATIC_KEY_FALSE (rdt_enable_key);DEFINE_STATIC_KEY_FALSE (rdt_mon_enable_key);
arch/x86/kernel/process_32.c +1 -1
@@ -56,7 +56,7 @@#include <asm/debugreg.h> #include <asm/switch_to.h> #include <asm/vm86.h> -#include <asm/intel_rdt_sched.h> +#include <asm/resctrl_sched.h> #include <asm/proto.h> void __show_regs (struct pt_regs *regs,enum show_regs_mode mode)
arch/x86/kernel/process_64.c +1 -1
@@ -52,7 +52,7 @@#include <asm/switch_to.h> #include <asm/xen/hypervisor.h> #include <asm/vdso.h> -#include <asm/intel_rdt_sched.h> +#include <asm/resctrl_sched.h> #include <asm/unistd.h> #ifdef CONFIG_IA32_EMULATION /* Not included via unistd.h */
Signature · 1 line
2.17.1
Re: [PATCH v3 01/11] arch/x86: Start renaming the rdt files to more generic names
Hi Babu,
Quoted 20 lines · Babu
New generation of AMD processors start supporting RDT(or QOS) features. With more than one vendors supporting these features, it seems more appropriate to rename these files.
Changed
intel_rdtto resctrl where applicable.Signed-off-by Babu Moger <[email protected]>--- arch/x86/include/asm/{intel_rdt_sched.h => resctrl_sched.h} | 0 arch/x86/kernel/cpu/Makefile | 6 +++--- arch/x86/kernel/cpu/{intel_rdt.c => resctrl.c} | 4 ++-- arch/x86/kernel/cpu/{intel_rdt.h => resctrl.h} | 6 +++--- .../cpu/{intel_rdt_ctrlmondata.c => resctrl_ctrlmondata.c} | 2 +- .../kernel/cpu/{intel_rdt_monitor.c => resctrl_monitor.c} | 2 +- .../cpu/{intel_rdt_pseudo_lock.c => resctrl_pseudo_lock.c} | 6 +++--- ..._rdt_pseudo_lock_event.h => resctrl_pseudo_lock_event.h} | 2 +- .../kernel/cpu/{intel_rdt_rdtgroup.c => resctrl_rdtgroup.c} | 4 ++-- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-)
Quoted 9 lines
rename arch/x86/include/asm/{intel_rdt_sched.h => resctrl_sched.h} (100%)
rename arch/x86/kernel/cpu/{intel_rdt.c => resctrl.c} (99%)
rename arch/x86/kernel/cpu/{intel_rdt.h => resctrl.h} (99%)
rename arch/x86/kernel/cpu/{intel_rdt_ctrlmondata.c => resctrl_ctrlmondata.c} (99%)
rename arch/x86/kernel/cpu/{intel_rdt_monitor.c => resctrl_monitor.c} (99%)
rename arch/x86/kernel/cpu/{intel_rdt_pseudo_lock.c => resctrl_pseudo_lock.c} (99%)
rename arch/x86/kernel/cpu/{intel_rdt_pseudo_lock_event.h => resctrl_pseudo_lock_event.h} (95%)
rename arch/x86/kernel/cpu/{intel_rdt_rdtgroup.c => resctrl_rdtgroup.c} (99%)I missed this earlier ... this change creates a need to change the MAINTAINERS file. There were some other things that a run of "checkpatch.pl --strict" picked up in the other patches that you could consider.
Reinette
Re: [PATCH v3 01/11] arch/x86: Start renaming the rdt files to more generic names
Hi Reinette,
Quoted 33 lines · Reinette Chatre
Hi Babu,
Quoted 20 lines · Babu
New generation of AMD processors start supporting RDT(or QOS) features. With more than one vendors supporting these features, it seems more appropriate to rename these files.
Changed
intel_rdtto resctrl where applicable.Signed-off-by Babu Moger <[email protected]>--- arch/x86/include/asm/{intel_rdt_sched.h => resctrl_sched.h} | 0 arch/x86/kernel/cpu/Makefile | 6 +++--- arch/x86/kernel/cpu/{intel_rdt.c => resctrl.c} | 4 ++-- arch/x86/kernel/cpu/{intel_rdt.h => resctrl.h} | 6 +++--- .../cpu/{intel_rdt_ctrlmondata.c => resctrl_ctrlmondata.c} | 2 +- .../kernel/cpu/{intel_rdt_monitor.c => resctrl_monitor.c} | 2 +- .../cpu/{intel_rdt_pseudo_lock.c => resctrl_pseudo_lock.c} | 6 +++--- ..._rdt_pseudo_lock_event.h => resctrl_pseudo_lock_event.h} | 2 +- .../kernel/cpu/{intel_rdt_rdtgroup.c => resctrl_rdtgroup.c} | 4 ++-- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-)Quoted 9 lines
rename arch/x86/include/asm/{intel_rdt_sched.h => resctrl_sched.h} (100%) rename arch/x86/kernel/cpu/{intel_rdt.c => resctrl.c} (99%) rename arch/x86/kernel/cpu/{intel_rdt.h => resctrl.h} (99%) rename arch/x86/kernel/cpu/{intel_rdt_ctrlmondata.c => resctrl_ctrlmondata.c} (99%) rename arch/x86/kernel/cpu/{intel_rdt_monitor.c => resctrl_monitor.c} (99%) rename arch/x86/kernel/cpu/{intel_rdt_pseudo_lock.c => resctrl_pseudo_lock.c} (99%) rename arch/x86/kernel/cpu/{intel_rdt_pseudo_lock_event.h => resctrl_pseudo_lock_event.h} (95%) rename arch/x86/kernel/cpu/{intel_rdt_rdtgroup.c => resctrl_rdtgroup.c} (99%)
Quoted 2 lines
I missed this earlier ... this change creates a need to change the
MAINTAINERSfile. There were some other things that a run of
Yes. I see that now. We need to update MAINTAINERS file. The file name Documentation/x86/intel_rdt_ui.txt needs rename. Also contents of the file needs some minor changes. Will take care of it in next revision.
Quoted 2 lines
"checkpatch.pl --strict" picked up in the other patches that you could consider.
Yes. With --strict I see some more warnings. Will try to fix most of it. Sorry, I did not run --strict before. There are couple of "line over 80 characters" warnings which are difficult to handle. I will skip those.
Quoted 3 lines
Reinette
PATCH v3 2/11 arch/x86: Rename the RDT functions and definitions
In reply to Moger, BabuAs AMD is starting to support RDT(or QOS) features, rename the RDT functions and definitions to more generic names.
Replace intel_rdt to resctrl where applicable.
--- arch/x86/include/asm/resctrl_sched.h | 24 ++++++++++++------------ arch/x86/kernel/cpu/resctrl.c | 26 +++++++++++++------------- arch/x86/kernel/cpu/resctrl.h | 2 +- arch/x86/kernel/cpu/resctrl_monitor.c | 11 ++++++----- arch/x86/kernel/cpu/resctrl_rdtgroup.c | 10 +++++----- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- 7 files changed, 39 insertions(+), 38 deletions(-)
arch/x86/include/asm/resctrl_sched.h +12 -12
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_X86_INTEL_RDT_SCHED_H -#define _ASM_X86_INTEL_RDT_SCHED_H +#ifndef _ASM_X86_RESCTRL_SCHED_H +#define _ASM_X86_RESCTRL_SCHED_H#ifdef CONFIG_INTEL_RDT
@@ -10,7 +10,7 @@#define IA32_PQR_ASSOC 0x0c8f/** -* struct intel_pqr_state - State cache for the PQR MSR +* struct resctrl_pqr_state - State cache for the PQR MSR * @cur_rmid: The cached Resource Monitoring ID * @cur_closid: The cached Class Of Service ID * @default_rmid: The user assigned Resource Monitoring ID
@@ -24,21 +24,21 @@* The cache also helps to avoid pointless updates if the value does * not change. */ -struct intel_pqr_state { +struct resctrl_pqr_state {u32 cur_rmid;u32 cur_closid;u32 default_rmid;u32 default_closid; }; -DECLARE_PER_CPU(struct intel_pqr_state, pqr_state); +DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state);DECLARE_STATIC_KEY_FALSE (rdt_enable_key);DECLARE_STATIC_KEY_FALSE (rdt_alloc_enable_key);DECLARE_STATIC_KEY_FALSE (rdt_mon_enable_key);/* -* __intel_rdt_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR +* __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR * * Following considerations are made so that this has minimal impact * on scheduler hot path:
@@ -51,9 +51,9 @@ DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);* simple as possible. * Must be called with preemption disabled. */ -static void __intel_rdt_sched_in (void ) +static void __resctrl_sched_in (void ) { -struct intel_pqr_state *state =this_cpu_ptr (&pqr_state); +struct resctrl_pqr_state *state =this_cpu_ptr (&pqr_state);u32 closid = state->default_closid;u32 rmid = state->default_rmid;
@@ -78,16 +78,16 @@ static void __intel_rdt_sched_in(void) } } -static inline void intel_rdt_sched_in (void ) +static inline void resctrl_sched_in (void ) {if (static_branch_likely (&rdt_enable_key)) -__intel_rdt_sched_in (); +__resctrl_sched_in (); }#else -static inline void intel_rdt_sched_in (void ) {} +static inline void resctrl_sched_in (void ) {}#endif /* CONFIG_INTEL_RDT */ -#endif /* _ASM_X86_INTEL_RDT_SCHED_H */ +#endif /* _ASM_X86_RESCTRL_SCHED_H */
arch/x86/kernel/cpu/resctrl.c +13 -13
@@ -40,12 +40,12 @@DEFINE_MUTEX (rdtgroup_mutex);/* -* The cached intel_pqr_state is strictly per CPU and can never be +* The cached resctrl_pqr_state is strictly per CPU and can never be * updated from a remote CPU. Functions which modify the state * are called with interrupts disabled and no preemption, which * is sufficient for the protection. */ -DEFINE_PER_CPU(struct intel_pqr_state, pqr_state); +DEFINE_PER_CPU(struct resctrl_pqr_state, pqr_state);/* * Used to store the max resource name width and max resource data width
@@ -632,7 +632,7 @@ static void domain_remove_cpu(int cpu, struct rdt_resource *r)static void clear_closid_rmid (int cpu) { -struct intel_pqr_state *state =this_cpu_ptr (&pqr_state); +struct resctrl_pqr_state *state =this_cpu_ptr (&pqr_state); state->default_closid =0 ; state->default_rmid =0 ;
@@ -641,7 +641,7 @@ static void clear_closid_rmid(int cpu)wrmsr (IA32_PQR_ASSOC ,0 ,0 ); } -static int intel_rdt_online_cpu (unsigned int cpu) +static int resctrl_online_cpu (unsigned int cpu) {struct rdt_resource *r;
@@ -667,7 +667,7 @@ static void clear_childcpus(struct rdtgroup *r, unsigned int cpu) } } -static int intel_rdt_offline_cpu (unsigned int cpu) +static int resctrl_offline_cpu (unsigned int cpu) {struct rdtgroup *rdtgrp;struct rdt_resource *r;
@@ -859,7 +859,7 @@ static __init bool get_rdt_resources(void)static enum cpuhp_state rdt_online; -static int __init intel_rdt_late_init (void ) +static int __init resctrl_late_init (void ) {struct rdt_resource *r;int state, ret;
@@ -870,8 +870,8 @@ static int __init intel_rdt_late_init(void)rdt_init_padding (); state =cpuhp_setup_state (CPUHP_AP_ONLINE_DYN , -"x86/rdt/cat:online:" , - intel_rdt_online_cpu, intel_rdt_offline_cpu); +"x86/resctrl/cat:online:" , + resctrl_online_cpu, resctrl_offline_cpu);if (state <0 )return state;
@@ -883,20 +883,20 @@ static int __init intel_rdt_late_init(void) rdt_online = state;for_each_alloc_capable_rdt_resource (r) -pr_info ("Intel RDT %s allocation detected\n" , r->name); +pr_info ("RESCTRL %s allocation detected\n" , r->name);for_each_mon_capable_rdt_resource (r) -pr_info ("Intel RDT %s monitoring detected\n" , r->name); +pr_info ("RESCTRL %s monitoring detected\n" , r->name);return 0 ; } -late_initcall (intel_rdt_late_init); +late_initcall (resctrl_late_init); -static void __exit intel_rdt_exit(void) +static void __exit resctrl_exit(void) {cpuhp_remove_state (rdt_online);rdtgroup_exit (); } -__exitcall (intel_rdt_exit); +__exitcall (resctrl_exit);
arch/x86/kernel/cpu/resctrl.h +1 -1
@@ -69,7 +69,7 @@ struct rmid_read {u64 val; }; -extern unsigned int intel_cqm_threshold; +extern unsigned int resctrl_cqm_threshold;extern bool rdt_alloc_capable;extern bool rdt_mon_capable;extern unsigned int rdt_mon_features;
arch/x86/kernel/cpu/resctrl_monitor.c +6 -5
@@ -73,7 +73,7 @@ unsigned int rdt_mon_features;* This is the threshold cache occupancy at which we will consider an * RMID available for re-allocation. */ -unsigned int intel_cqm_threshold; +unsigned int resctrl_cqm_threshold;static inline struct rmid_entry *__rmid_entry (u32 rmid) {
@@ -107,7 +107,7 @@ static bool rmid_dirty(struct rmid_entry *entry) {u64 val =__rmid_read (entry->rmid,QOS_L3_OCCUP_EVENT_ID ); -return val >= intel_cqm_threshold; +return val >= resctrl_cqm_threshold; }/*
@@ -187,7 +187,7 @@ static void add_rmid_to_limbo(struct rmid_entry *entry)list_for_each_entry (d, &r->domains, list) {if (cpumask_test_cpu (cpu, &d->cpu_mask)) { val =__rmid_read (entry->rmid,QOS_L3_OCCUP_EVENT_ID ); -if (val <= intel_cqm_threshold) +if (val <= resctrl_cqm_threshold)continue ; }
@@ -637,10 +637,11 @@ int rdt_get_mon_l3_config(struct rdt_resource *r)* * For a 35MB LLC and 56 RMIDs, this is ~1.8% of the LLC. */ - intel_cqm_threshold = boot_cpu_data.x86_cache_size *1024 / r->num_rmid; + resctrl_cqm_threshold = boot_cpu_data.x86_cache_size *1024 / + r->num_rmid;/* h/w works in units of "boot_cpu_data.x86_cache_occ_scale" */ - intel_cqm_threshold /= r->mon_scale; + resctrl_cqm_threshold /= r->mon_scale; ret =dom_data_init (r);if (ret)
arch/x86/kernel/cpu/resctrl_rdtgroup.c +5 -5
@@ -288,7 +288,7 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of, }/* -* This is safe against intel_rdt_sched_in() called from __switch_to() +* This is safe against resctrl_sched_in() called from __switch_to() * because __switch_to() is executed with interrupts disabled. A local call * from update_closid_rmid() is proteced against __switch_to() because * preemption is disabled.
@@ -307,7 +307,7 @@ static void update_cpu_closid_rmid(void *info)* executing task might have its own closid selected. Just reuse * the context switch code. */ -intel_rdt_sched_in (); +resctrl_sched_in (); }/*
@@ -532,7 +532,7 @@ static void move_myself(struct callback_head *head)preempt_disable ();/* update PQR_ASSOC MSR to make resource group go into effect */ -intel_rdt_sched_in (); +resctrl_sched_in ();preempt_enable ();kfree (callback);
@@ -916,7 +916,7 @@ static int max_threshold_occ_show(struct kernfs_open_file *of, {struct rdt_resource *r = of->kn->parent->priv; -seq_printf (seq,"%u\n" , intel_cqm_threshold * r->mon_scale); +seq_printf (seq,"%u\n" , resctrl_cqm_threshold * r->mon_scale);return 0 ; }
@@ -935,7 +935,7 @@ static ssize_t max_threshold_occ_write(struct kernfs_open_file *of,if (bytes > (boot_cpu_data.x86_cache_size *1024 ))return -EINVAL ; - intel_cqm_threshold = bytes / r->mon_scale; + resctrl_cqm_threshold = bytes / r->mon_scale;return nbytes; }
arch/x86/kernel/process_32.c +1 -1
@@ -302,7 +302,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)this_cpu_write (current_task, next_p);/* Load the Intel cache allocation PQR MSR. */ -intel_rdt_sched_in (); +resctrl_sched_in ();return prev_p; }
arch/x86/kernel/process_64.c +1 -1
@@ -536,7 +536,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) }/* Load the Intel cache allocation PQR MSR. */ -intel_rdt_sched_in (); +resctrl_sched_in ();return prev_p; }
Signature · 1 line
2.17.1
Re: [PATCH v3 02/11] arch/x86: Rename the RDT functions and definitions
Hi Babu,
arch/x86/kernel/cpu/resctrl.c static int __init intel_rdt_late_init(void) · line 890
Quoted 11 lines · Babu
arch/x86/kernel/cpu/resctrl.c +2
-2@@ -883,20 +883,20 @@ static int __init intel_rdt_late_init(void) rdt_online = state;for_each_alloc_capable_rdt_resource (r) -pr_info ("Intel RDT %s allocation detected\n" , r->name); +pr_info ("RESCTRL %s allocation detected\n" , r->name);for_each_mon_capable_rdt_resource (r) -pr_info ("Intel RDT %s monitoring detected\n" , r->name); +pr_info ("RESCTRL %s monitoring detected\n" , r->name);
I'm sorry - I know it was me who suggested the change to RESCTRL but I clearly did not consider the final result which is (for example):
resctrl: RESCTRL %s allocation detected
Perhaps we could just drop that RESCTRL text?
Reinette
Re: [PATCH v3 02/11] arch/x86: Rename the RDT functions and definitions
Quoted 18 lines · Reinette Chatre
Hi Babu,
arch/x86/kernel/cpu/resctrl.c static int __init intel_rdt_late_init(void) · line 890
Quoted 11 lines · Babu
arch/x86/kernel/cpu/resctrl.c +2
-2@@ -883,20 +883,20 @@ static int __init intel_rdt_late_init(void) rdt_online = state;for_each_alloc_capable_rdt_resource (r) -pr_info ("Intel RDT %s allocation detected\n" , r->name); +pr_info ("RESCTRL %s allocation detected\n" , r->name);for_each_mon_capable_rdt_resource (r) -pr_info ("Intel RDT %s monitoring detected\n" , r->name); +pr_info ("RESCTRL %s monitoring detected\n" , r->name);I'm sorry - I know it was me who suggested the change to RESCTRL but I clearly did not consider the final result which is (for example):
Quoted 3 lines
resctrl: RESCTRL %s allocation detected
Perhaps we could just drop that RESCTRL text?
Yes. We can drop it.
Quoted 3 lines
Reinette
PATCH v3 3/11 arch/x86: Re-arrange RDT init code
In reply to Moger, BabuSeparate the call sequence for rdt_quirks and MBA feature. This is in preparation to handle vendor differences in these call sequences.
--- arch/x86/kernel/cpu/resctrl.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/resctrl.c +23 -6
@@ -787,6 +787,16 @@ static bool __init rdt_cpu_has(int flag)return ret; } +static __init bool rdt_mba_config (void ) +{ +if (rdt_cpu_has (X86_FEATURE_MBA )) { +if (rdt_get_mem_config (&rdt_resources_all[RDT_RESOURCE_MBA ])) +return true; + } + +return false; +} +static __init bool get_rdt_alloc_resources (void ) {bool ret = false;
@@ -811,10 +821,9 @@ static __init bool get_rdt_alloc_resources(void) ret = true; } -if (rdt_cpu_has (X86_FEATURE_MBA )) { -if (rdt_get_mem_config (&rdt_resources_all[RDT_RESOURCE_MBA ])) - ret = true; - } +if (rdt_mba_config ()) + ret = true; +return ret; }
@@ -833,7 +842,7 @@ static __init bool get_rdt_mon_resources(void)return !rdt_get_mon_l3_config (&rdt_resources_all[RDT_RESOURCE_L3 ]); } -static __init void rdt_quirks (void ) +static __init void rdt_quirks_intel (void ) {switch (boot_cpu_data.x86_model) {case INTEL_FAM6_HASWELL_X :
@@ -848,9 +857,14 @@ static __init void rdt_quirks(void) } } +static __init void rdt_quirks (void ) +{ +if (boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL ) +rdt_quirks_intel (); +} +static __init bool get_rdt_resources (void ) { -rdt_quirks (); rdt_alloc_capable =get_rdt_alloc_resources (); rdt_mon_capable =get_rdt_mon_resources ();
@@ -864,6 +878,9 @@ static int __init resctrl_late_init(void)struct rdt_resource *r;int state, ret; +/* Run quirks first */ +rdt_quirks (); +if (!get_rdt_resources ())return -ENODEV ;
Signature · 1 line
2.17.1
PATCH v3 4/11 arch/x86: Bring all the macros to resctrl.h
In reply to Moger, BabuBring all the macros to resctrl.h and rename for consistency.
--- arch/x86/kernel/cpu/resctrl.c | 3 --- arch/x86/kernel/cpu/resctrl.h | 5 +++++ arch/x86/kernel/cpu/resctrl_monitor.c | 7 ++----- 3 files changed, 7 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/resctrl.c +0 -3
@@ -33,9 +33,6 @@#include <asm/resctrl_sched.h> #include "resctrl.h" -#define MBA_IS_LINEAR 0x4 -#define MBA_MAX_MBPS U32_MAX -/* Mutex to protect rdtgroup access. */ DEFINE_MUTEX (rdtgroup_mutex);
arch/x86/kernel/cpu/resctrl.h +5 -0
@@ -12,6 +12,9 @@#define IA32_L2_CBM_BASE 0xd10#define IA32_MBA_THRTL_BASE 0xd50 +#define IA32_QM_CTR 0x0c8e +#define IA32_QM_EVTSEL 0x0c8d +#define L3_QOS_CDP_ENABLE 0x01ULL#define L2_QOS_CDP_ENABLE 0x01ULL
@@ -29,6 +32,8 @@#define MBM_CNTR_WIDTH 24#define MBM_OVERFLOW_INTERVAL 1000#define MAX_MBA_BW 100u +#define MBA_IS_LINEAR 0x4 +#define MBA_MAX_MBPS U32_MAX#define RMID_VAL_ERROR BIT_ULL(63)#define RMID_VAL_UNAVAIL BIT_ULL(62)
arch/x86/kernel/cpu/resctrl_monitor.c +2 -5
@@ -28,9 +28,6 @@#include <asm/cpu_device_id.h> #include "resctrl.h" -#define MSR_IA32_QM_CTR 0x0c8e -#define MSR_IA32_QM_EVTSEL 0x0c8d -struct rmid_entry {u32 rmid;int busy;
@@ -97,8 +94,8 @@ static u64 __rmid_read(u32 rmid, u32 eventid)* IA32_QM_CTR.Error (bit 63) and IA32_QM_CTR.Unavailable (bit 62) * are error bits. */ -wrmsr (MSR_IA32_QM_EVTSEL , eventid, rmid); -rdmsrl (MSR_IA32_QM_CTR , val); +wrmsr (IA32_QM_EVTSEL , eventid, rmid); +rdmsrl (IA32_QM_CTR , val);return val; }
Signature · 1 line
2.17.1
PATCH v3 5/11 arch/x86: Introduce a new config parameter RESCTRL
In reply to Moger, BabuIntroduces a new config parameter RESCTRL.
This will be used as a common config parameter for both Intel and AMD. Each vendor will have their own config parameter to enable RDT feature. One for Intel(INTEL_RDT) and one for AMD(AMD_QOS). It can be enabled or disabled separately. The new parameter RESCTRL will be dependent on INTEL_RDT or AMD_QOS.
--- arch/x86/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/Kconfig +4 -0
@@ -458,6 +458,10 @@ config INTEL_RDT Say N if unsure. +config RESCTRL + def_bool y + depends on X86 && INTEL_RDT + if X86_32 config X86_BIGSMP bool "Support for big SMP systems with more than 8 CPUs"
Signature · 1 line
2.17.1
PATCH v3 6/11 arch/x86: Use new config parameter RESCTRL for compilation
In reply to Moger, BabuUse newly added config parameter RESCTRL to compile sources. This is common parameter across both Intel and AMD.
--- arch/x86/include/asm/resctrl_sched.h | 4 ++-- arch/x86/kernel/cpu/Makefile | 4 ++-- include/linux/sched.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
arch/x86/include/asm/resctrl_sched.h +2 -2
@@ -2,7 +2,7 @@#ifndef _ASM_X86_RESCTRL_SCHED_H#define _ASM_X86_RESCTRL_SCHED_H -#ifdef CONFIG_INTEL_RDT +#ifdef CONFIG_RESCTRL #include <linux/sched.h> #include <linux/jump_label.h>
@@ -88,6 +88,6 @@ static inline void resctrl_sched_in(void)static inline void resctrl_sched_in (void ) {} -#endif /* CONFIG_INTEL_RDT */ +#endif /* CONFIG_RESCTRL */ #endif /* _ASM_X86_RESCTRL_SCHED_H */
arch/x86/kernel/cpu/Makefile +2 -2
@@ -35,8 +35,8 @@ obj-$(CONFIG_CPU_SUP_CENTAUR) += centaur.o obj-$(CONFIG_CPU_SUP_TRANSMETA_32) += transmeta.o obj-$(CONFIG_CPU_SUP_UMC_32) += umc.o -obj-$(CONFIG_INTEL_RDT) += resctrl.o resctrl_rdtgroup.o resctrl_monitor.o -obj-$(CONFIG_INTEL_RDT) += resctrl_ctrlmondata.o resctrl_pseudo_lock.o +obj-$(CONFIG_RESCTRL) += resctrl.o resctrl_rdtgroup.o resctrl_monitor.o +obj-$(CONFIG_RESCTRL) += resctrl_ctrlmondata.o resctrl_pseudo_lock.o CFLAGS_resctrl_pseudo_lock.o = -I$(src) obj-$(CONFIG_X86_MCE) += mcheck/
include/linux/sched.h +1 -1
@@ -985,7 +985,7 @@ struct task_struct {/* cg_list protected by css_set_lock and tsk->alloc_lock: */ struct list_head cg_list;#endif -#ifdef CONFIG_INTEL_RDT +#ifdef CONFIG_RESCTRL u32 closid;u32 rmid;#endif
Signature · 1 line
2.17.1
PATCH v3 7/11 arch/x86: Initialize the resource functions that are different
In reply to Moger, BabuInitialize the resource functions that are different between the vendors. Some features are initialized differently between the vendors. Add _intel suffix to Intel specific functions.
For example, MBA feature varies significantly between Intel and AMD. Separate the initialization of these resource functions. That way we can easily add AMD's functions later.
--- arch/x86/kernel/cpu/resctrl.c | 34 +++++++++++++++++++---- arch/x86/kernel/cpu/resctrl.h | 8 ++++-- arch/x86/kernel/cpu/resctrl_ctrlmondata.c | 4 +-- 3 files changed, 37 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/resctrl.c +29 -5
@@ -57,7 +57,8 @@ int max_name_width, max_data_width;bool rdt_alloc_capable;static void -mba_wrmsr (struct rdt_domain *d,struct msr_param *m,struct rdt_resource *r); +mba_wrmsr_intel (struct rdt_domain *d,struct msr_param *m, +struct rdt_resource *r);static void cat_wrmsr (struct rdt_domain *d,struct msr_param *m,struct rdt_resource *r);
@@ -171,10 +172,7 @@ struct rdt_resource rdt_resources_all[] = { .rid = RDT_RESOURCE_MBA, .name = "MB", .domains = domain_init(RDT_RESOURCE_MBA), - .msr_base = IA32_MBA_THRTL_BASE, - .msr_update = mba_wrmsr, .cache_level = 3, - .parse_ctrlval = parse_bw, .format_str = "%d=%*u", .fflags = RFTYPE_RES_MB, },
@@ -356,7 +354,8 @@ u32 delay_bw_map(unsigned long bw, struct rdt_resource *r) }static void -mba_wrmsr (struct rdt_domain *d,struct msr_param *m,struct rdt_resource *r) +mba_wrmsr_intel (struct rdt_domain *d,struct msr_param *m, +struct rdt_resource *r) {unsigned int i;
@@ -868,6 +867,25 @@ static __init bool get_rdt_resources(void)return (rdt_mon_capable || rdt_alloc_capable); } +static __init void rdt_init_res_defs_intel (void ) +{ +struct rdt_resource *r; + +for_each_rdt_resource (r) { +if (r->rid ==RDT_RESOURCE_MBA ) { + r->msr_base =IA32_MBA_THRTL_BASE ; + r->msr_update = mba_wrmsr_intel; + r->parse_ctrlval = parse_bw_intel; + } + } +} + +static __init void rdt_init_res_defs (void ) +{ +if (boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL ) +rdt_init_res_defs_intel (); +} +static enum cpuhp_state rdt_online;static int __init resctrl_late_init (void )
@@ -875,6 +893,12 @@ static int __init resctrl_late_init(void)struct rdt_resource *r;int state, ret; +/* +* Initialize functions(or definitions) that are different +* between vendors here. +*/ +rdt_init_res_defs (); +/* Run quirks first */ rdt_quirks ();
arch/x86/kernel/cpu/resctrl.h +6 -2
@@ -444,8 +444,8 @@ struct rdt_resource {int parse_cbm (struct rdt_parse_data *data,struct rdt_resource *r,struct rdt_domain *d); -int parse_bw (struct rdt_parse_data *data,struct rdt_resource *r, -struct rdt_domain *d); +int parse_bw_intel (struct rdt_parse_data *data,struct rdt_resource *r, +struct rdt_domain *d);extern struct mutex rdtgroup_mutex;
@@ -468,6 +468,10 @@ enum { RDT_NUM_RESOURCES, }; +#define for_each_rdt_resource (r) \ + for (r = rdt_resources_all; r < rdt_resources_all + RDT_NUM_RESOURCES;\ + r++) +#define for_each_capable_rdt_resource (r) \ for (r = rdt_resources_all; r < rdt_resources_all + RDT_NUM_RESOURCES;\ r++) \
arch/x86/kernel/cpu/resctrl_ctrlmondata.c +2 -2
@@ -64,8 +64,8 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)return true; } -int parse_bw (struct rdt_parse_data *data,struct rdt_resource *r, -struct rdt_domain *d) +int parse_bw_intel (struct rdt_parse_data *data,struct rdt_resource *r, +struct rdt_domain *d) {unsigned long bw_val;
Signature · 1 line
2.17.1
PATCH v3 8/11 arch/x86: Bring few more functions into the resource structure
In reply to Moger, BabuBring all resource functions that are different between the vendors into resource structure and initialize them dynamically. Add _intel suffix to Intel specific functions.
Implement these functions separately for each vendors. update_mba_bw : Feedback loop bandwidth update functionality is not
needed for AMD.cbm_validate : Cache bitmask validate function. AMD allows
non-contiguous masks. So, use separate functions for Intel and AMD.
--- arch/x86/kernel/cpu/resctrl.c | 10 +++++++++- arch/x86/kernel/cpu/resctrl.h | 15 +++++++++++---- arch/x86/kernel/cpu/resctrl_ctrlmondata.c | 4 ++-- arch/x86/kernel/cpu/resctrl_monitor.c | 10 +++++++--- 4 files changed, 29 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/resctrl.c +9 -1
@@ -872,10 +872,18 @@ static __init void rdt_init_res_defs_intel(void)struct rdt_resource *r;for_each_rdt_resource (r) { -if (r->rid ==RDT_RESOURCE_MBA ) { +if ((r->rid ==RDT_RESOURCE_L3 ) || + (r->rid ==RDT_RESOURCE_L3DATA ) || + (r->rid ==RDT_RESOURCE_L3CODE ) || + (r->rid ==RDT_RESOURCE_L2 ) || + (r->rid ==RDT_RESOURCE_L2DATA ) || + (r->rid ==RDT_RESOURCE_L2CODE )) + r->cbm_validate = cbm_validate_intel; +else if (r->rid ==RDT_RESOURCE_MBA ) { r->msr_base =IA32_MBA_THRTL_BASE ; r->msr_update = mba_wrmsr_intel; r->parse_ctrlval = parse_bw_intel; + r->update_mba_bw = update_mba_bw_intel; } } }
arch/x86/kernel/cpu/resctrl.h +11 -4
@@ -410,10 +410,12 @@ struct rdt_parse_data {* @cache: Cache allocation related data * @format_str: Per resource format string to show domain value * @parse_ctrlval: Per resource function pointer to parse control values -* @evt_list: List of monitoring events -* @num_rmid: Number of RMIDs available -* @mon_scale: cqm counter * mon_scale = occupancy in bytes -* @fflags: flags to choose base and info files +* @update_mba_bw: Feedback loop for MBA software controller function +* @cbm_validate Cache bitmask validate function +* @evt_list: List of monitoring events +* @num_rmid: Number of RMIDs available +* @mon_scale: cqm counter * mon_scale = occupancy in bytes +* @fflags: flags to choose base and info files */ struct rdt_resource {int rid;
@@ -436,6 +438,9 @@ struct rdt_resource {int (*parse_ctrlval)(struct rdt_parse_data *data,struct rdt_resource *r,struct rdt_domain *d); +void (*update_mba_bw)(struct rdtgroup *rgrp, +struct rdt_domain *dom_mbm); +bool (*cbm_validate)(char *buf,u32 *data,struct rdt_resource *r);struct list_head evt_list;int num_rmid;unsigned int mon_scale;
@@ -576,5 +581,7 @@ void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms);void cqm_handle_limbo (struct work_struct *work);bool has_busy_rmid (struct rdt_resource *r,struct rdt_domain *d);void __check_limbo (struct rdt_domain *d,bool force_free); +void update_mba_bw_intel (struct rdtgroup *rgrp,struct rdt_domain *dom_mbm); +bool cbm_validate_intel (char *buf,u32 *data,struct rdt_resource *r);#endif /* _ASM_X86_RESCTRL_H */
arch/x86/kernel/cpu/resctrl_ctrlmondata.c +2 -2
@@ -88,7 +88,7 @@ int parse_bw_intel(struct rdt_parse_data *data, struct rdt_resource *r,* are allowed (e.g. FFFFH, 0FF0H, 003CH, etc.). * Additionally Haswell requires at least two bits set. */ -static bool cbm_validate (char *buf,u32 *data,struct rdt_resource *r) +bool cbm_validate_intel (char *buf,u32 *data,struct rdt_resource *r) {unsigned long first_bit, zero_bit, val;unsigned int cbm_len = r->cache.cbm_len;
@@ -148,7 +148,7 @@ int parse_cbm(struct rdt_parse_data *data, struct rdt_resource *r,return -EINVAL ; } -if (!cbm_validate (data->buf, &cbm_val, r)) +if (r->cbm_validate && !r->cbm_validate (data->buf, &cbm_val, r))return -EINVAL ; if ((rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
arch/x86/kernel/cpu/resctrl_monitor.c +7 -3
@@ -358,7 +358,7 @@ void mon_event_count(void *info)* throttle MSRs already have low percentage values. To avoid * unnecessarily restricting such rdtgroups, we also increase the bandwidth. */ -static void update_mba_bw (struct rdtgroup *rgrp,struct rdt_domain *dom_mbm) +void update_mba_bw_intel (struct rdtgroup *rgrp,struct rdt_domain *dom_mbm) {u32 closid, rmid, cur_msr, cur_msr_val, new_msr_val;struct mbm_state *pmbm_data, *cmbm_data;
@@ -517,6 +517,7 @@ void mbm_handle_overflow(struct work_struct *work)unsigned long delay =msecs_to_jiffies (MBM_OVERFLOW_INTERVAL );struct rdtgroup *prgrp, *crgrp;int cpu =smp_processor_id (); +struct rdt_resource *r_mba;struct list_head *head;struct rdt_domain *d;
@@ -536,8 +537,11 @@ void mbm_handle_overflow(struct work_struct *work)list_for_each_entry (crgrp, head, mon.crdtgrp_list)mbm_update (d, crgrp->mon.rmid); -if (is_mba_sc (NULL )) -update_mba_bw (prgrp, d); +if (is_mba_sc (NULL )) { + r_mba = &rdt_resources_all[RDT_RESOURCE_MBA ]; +if (r_mba->update_mba_bw) + r_mba->update_mba_bw (prgrp, d); + } }schedule_delayed_work_on (cpu, &d->mbm_over, delay);
Signature · 1 line
2.17.1
PATCH v3 9/11 arch/x86: Introduce new config parameter AMD_QOS
In reply to Moger, BabuIntroduces the new config parameter AMD_QOS. This parameter will be used to enable cache and memory bandwidth allocation and monitoring features on AMD processors. This will enable common config parameter RESCTRL if selected.
--- arch/x86/Kconfig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
arch/x86/Kconfig +16 -1
@@ -458,9 +458,24 @@ config INTEL_RDT Say N if unsure. +config AMD_QOS + bool "AMD Quality of Service support" + default n + depends on X86 && CPU_SUP_AMD + select KERNFS + help + Select to enable cache and memory bandwidth enforcement and monitoring + features of AMD processors. These features are intended to provide + support for the monitoring of the usage of certain system resources + by one or more processors and for the separate allocation and + enforcement of limits on the use of certain system resources by one or + more processors. + + Say N if unsure. + config RESCTRL def_bool y - depends on X86 && INTEL_RDT + depends on X86 && (INTEL_RDT || AMD_QOS) if X86_32 config X86_BIGSMP
Signature · 1 line
2.17.1
Re: [PATCH v3 09/11] arch/x86: Introduce new config parameter AMD_QOS
Quoted 15 lines · Babu
Introduces the new config parameter
AMD_QOS. This parameter will be used to enable cache and memory bandwidth allocation and monitoring features on AMD processors. This will enable common config parameter RESCTRL if selected.Signed-off-by Babu Moger <[email protected]>--- arch/x86/Kconfig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)arch/x86/Kconfig +0
-0
arch/x86/Kconfig config INTEL_RDT · line 464
Quoted 7 lines
arch/x86/Kconfig +4
-0@@ -458,9 +458,24 @@ config INTEL_RDT Say N if unsure. +config AMD_QOS + bool "AMD Quality of Service support" + default n + depends on X86 && CPU_SUP_AMD
Why the X86 dependency too? CPU_SUP_AMD is x86-specific and indirectly implies X86, I'd say.
Signature · 4 lines
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)Re: [PATCH v3 09/11] arch/x86: Introduce new config parameter AMD_QOS
Boris,
Quoted 19 lines · Borislav Petkov
Quoted 18 lines · Babu
Introduces the new config parameter
AMD_QOS. This parameter will be used to enable cache and memory bandwidth allocation and monitoring features on AMD processors. This will enable common config parameter RESCTRL if selected.Signed-off-by Babu Moger <[email protected]>--- arch/x86/Kconfig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)arch/x86/Kconfig +0
-0@@ -458,9 +458,24 @@ config INTEL_RDT Say N if unsure.
Quoted 7 lines
arch/x86/Kconfig config INTEL_RDT · line 464
Quoted 4 lines
arch/x86/Kconfig +4
-0+config AMD_QOS + bool "AMD Quality of Service support" + default n + depends on X86 && CPU_SUP_AMDWhy the X86 dependency too?
CPU_SUP_AMDis x86-specific and indirectly implies X86, I'd say.
That is correct. CPU_SUP_AMD implicitly means x86.
To be more specific, I will change it to
"depends on X86_64 && CPU_SUP_AMD" as this feature is for X86_64 only. Thanks
Re: [PATCH v3 09/11] arch/x86: Introduce new config parameter AMD_QOS
Quoted 3 lines · Babu
That is correct.
CPU_SUP_AMDimplicitly means x86.
To be more specific, I will change it to
"depends onX86_64&&CPU_SUP_AMD" as this feature is forX86_64only.
No, what I'm saying is, make it dependent *only* on CPU_SUP_AMD.
Signature · 4 lines
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)Re: [PATCH v3 09/11] arch/x86: Introduce new config parameter AMD_QOS
Quoted 6 lines · Borislav Petkov
Quoted 3 lines · Babu
That is correct.
CPU_SUP_AMDimplicitly means x86.
To be more specific, I will change it to
"depends onX86_64&&CPU_SUP_AMD" as this feature is forX86_64only.No, what I'm saying is, make it dependent *only* on
CPU_SUP_AMD.
Sure. Will do in next revision. Thanks
PATCH v3 10/11 arch/x86: Add AMD feature bit X86_FEATURE_MBA in cpuid bits array
In reply to Moger, BabuFrom: Sherry Hurwitz <[email protected]>
The feature bit X86_FEATURE_MBA is detected via CPUID leaf 0x80000008 EBX Bit 06. This bit indicates the support of AMD's MBA feature.
This feature is supported by both Intel and AMD. But they are detected different CPUID leaves.
--- arch/x86/kernel/cpu/scattered.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/scattered.c +6 -1
@@ -17,7 +17,11 @@ struct cpuid_bit {u32 sub_leaf; }; -/* Please keep the leaf sorted by cpuid_bit.level for faster search. */ +/* +* Please keep the leaf sorted by cpuid_bit.level for faster search. +* X86_FEATURE_MBA supported by both Intel and AMD. But the cpuid +* levels are different. Add a separate enty for each. +*/ static const struct cpuid_bit cpuid_bits[] = { {X86_FEATURE_APERFMPERF ,CPUID_ECX ,0 ,0x00000006 ,0 }, {X86_FEATURE_EPB ,CPUID_ECX ,3 ,0x00000006 ,0 },
@@ -29,6 +33,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_HW_PSTATE, CPUID_EDX, 7, 0x80000007, 0 }, { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, + { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SME, CPUID_EAX, 0, 0x8000001f, 0 }, { X86_FEATURE_SEV, CPUID_EAX, 1, 0x8000001f, 0 }, { 0, 0, 0, 0, 0 }
Signature · 1 line
2.17.1
PATCH v3 11/11 arch/x86: Introduce QOS feature for AMD
In reply to Moger, BabuEnables QOS feature on AMD.
Following QoS sub-features are supported in AMD if the underlying hardware supports it.
- L3 Cache allocation enforcement
- L3 Cache occupancy monitoring
- L3 Code-Data Prioritization support
- Memory Bandwidth Enforcement(Allocation)
The specification for this feature is available at
https://developer.amd.com/wp-content/resources/56375.pdf
There are differences in the way some of the features are implemented. Separate those functions and add those as vendor specific functions. The major difference is in MBA feature.
- AMD uses CPUID leaf 0x80000020 to initialize the MBA features.
- AMD uses direct bandwidth value instead of delay based on bandwidth values.
- MSR register base addresses are different for MBA.
- Also AMD allows non-contiguous L3 cache bit masks.
Adds following functions to take care of the differences. rdt_get_mem_config_amd : MBA initialization function parse_bw_amd : Bandwidth parsingmba_wrmsr_amd: Writes bandwidth value cbm_validate_amd : L3 cache bitmask validation
--- arch/x86/kernel/cpu/resctrl.c | 69 +++++++++++++++++++++- arch/x86/kernel/cpu/resctrl.h | 5 ++ arch/x86/kernel/cpu/resctrl_ctrlmondata.c | 70 +++++++++++++++++++++++ 3 files changed, 142 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/resctrl.c +67 -2
@@ -61,6 +61,9 @@ mba_wrmsr_intel(struct rdt_domain *d, struct msr_param *m, struct rdt_resource *r);static void cat_wrmsr (struct rdt_domain *d,struct msr_param *m,struct rdt_resource *r); +static void +mba_wrmsr_amd (struct rdt_domain *d,struct msr_param *m, +struct rdt_resource *r);#define domain_init (id) LIST_HEAD_INIT(rdt_resources_all[id].domains)
@@ -280,6 +283,31 @@ static bool rdt_get_mem_config(struct rdt_resource *r)return true; } +static bool rdt_get_mem_config_amd (struct rdt_resource *r) +{ +union cpuid_0x10_3_eax eax; +union cpuid_0x10_x_edx edx; +u32 ebx, ecx; + +cpuid_count (0x80000020 ,1 , &eax.full, &ebx, &ecx, &edx.full); + r->num_closid = edx.split.cos_max +1 ; + r->default_ctrl =MAX_MBA_BW_AMD ; + +/* AMD does not use delay. Set delay_linear to false by default */ + r->membw.delay_linear = false; + +/* FIX ME - May need to be read from MSR */ + r->membw.min_bw =0 ; + r->membw.bw_gran =1 ; +/* Max value is 2048, Data width should be 4 in decimal */ + r->data_width =4 ; + + r->alloc_capable = true; + r->alloc_enabled = true; + +return true; +} +static void rdt_get_cache_alloc_cfg (int idx,struct rdt_resource *r) {union cpuid_0x10_1_eax eax;
@@ -339,6 +367,16 @@ static int get_cache_id(int cpu, int level)return -1 ; } +static void +mba_wrmsr_amd (struct rdt_domain *d,struct msr_param *m,struct rdt_resource *r) +{ +unsigned int i; + +/* Write the bw values for mba. */ +for (i = m->low; i < m->high; i++) +wrmsrl (r->msr_base + i, d->ctrl_val[i]); +} +/* * Map the memory b/w percentage value to delay values * that can be written to QOS_MSRs.
@@ -786,8 +824,13 @@ static bool __init rdt_cpu_has(int flag)static __init bool rdt_mba_config (void ) {if (rdt_cpu_has (X86_FEATURE_MBA )) { -if (rdt_get_mem_config (&rdt_resources_all[RDT_RESOURCE_MBA ])) -return true; +if (boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL ) { +if (rdt_get_mem_config (&rdt_resources_all[RDT_RESOURCE_MBA ])) +return true; + }else if (boot_cpu_data.x86_vendor ==X86_VENDOR_AMD ) { +if (rdt_get_mem_config_amd (&rdt_resources_all[RDT_RESOURCE_MBA ])) +return true; + } }return false;
@@ -888,10 +931,32 @@ static __init void rdt_init_res_defs_intel(void) } } +static __init void rdt_init_res_defs_amd (void ) +{ +struct rdt_resource *r; + +for_each_rdt_resource (r) { +if ((r->rid ==RDT_RESOURCE_L3 ) || + (r->rid ==RDT_RESOURCE_L3DATA ) || + (r->rid ==RDT_RESOURCE_L3CODE ) || + (r->rid ==RDT_RESOURCE_L2 ) || + (r->rid ==RDT_RESOURCE_L2DATA ) || + (r->rid ==RDT_RESOURCE_L2CODE )) + r->cbm_validate = cbm_validate_amd; +else if (r->rid ==RDT_RESOURCE_MBA ) { + r->msr_base =IA32_MBA_BW_BASE ; + r->msr_update = mba_wrmsr_amd; + r->parse_ctrlval = parse_bw_amd; + } + } +} +static __init void rdt_init_res_defs (void ) {if (boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL )rdt_init_res_defs_intel (); +else if (boot_cpu_data.x86_vendor ==X86_VENDOR_AMD ) +rdt_init_res_defs_amd (); }static enum cpuhp_state rdt_online;
arch/x86/kernel/cpu/resctrl.h +5 -0
@@ -11,6 +11,7 @@#define IA32_L3_CBM_BASE 0xc90#define IA32_L2_CBM_BASE 0xd10#define IA32_MBA_THRTL_BASE 0xd50 +#define IA32_MBA_BW_BASE 0xc0000200#define IA32_QM_CTR 0x0c8e#define IA32_QM_EVTSEL 0x0c8d
@@ -34,6 +35,7 @@#define MAX_MBA_BW 100u#define MBA_IS_LINEAR 0x4#define MBA_MAX_MBPS U32_MAX +#define MAX_MBA_BW_AMD 0x800#define RMID_VAL_ERROR BIT_ULL(63)#define RMID_VAL_UNAVAIL BIT_ULL(62)
@@ -451,6 +453,8 @@ int parse_cbm(struct rdt_parse_data *data, struct rdt_resource *r, struct rdt_domain *d);int parse_bw_intel (struct rdt_parse_data *data,struct rdt_resource *r,struct rdt_domain *d); +int parse_bw_amd (struct rdt_parse_data *data,struct rdt_resource *r, +struct rdt_domain *d);extern struct mutex rdtgroup_mutex;
@@ -583,5 +587,6 @@ bool has_busy_rmid(struct rdt_resource *r, struct rdt_domain *d);void __check_limbo (struct rdt_domain *d,bool force_free);void update_mba_bw_intel (struct rdtgroup *rgrp,struct rdt_domain *dom_mbm);bool cbm_validate_intel (char *buf,u32 *data,struct rdt_resource *r); +bool cbm_validate_amd (char *buf,u32 *data,struct rdt_resource *r);#endif /* _ASM_X86_RESCTRL_H */
arch/x86/kernel/cpu/resctrl_ctrlmondata.c +70 -0
82 lines not on this page · raw message
Signature · 1 line
2.17.1