Skip to contentSkip to conversation

x86/intel_rdt: Enable L2 CDP (Code and Data Prioritization)

PATCH In review Fenghua Yu 3 participants 15 messages Dec 20, 2017 – Jan 18, 2018

Subsystems (2)
lore
Share & tools
lore

Fenghua Yu

author
#0 lore raw

cover x86/intel_rdt: Enable L2 CDP (Code and Data Prioritization)

From: Fenghua Yu <[email protected]>

L2 CDP enables isolation and prioritization of code and data individually within the L2 cache. The feature is enumerated in CPUID.(EAX=0x10, ECX=2):ECX.CDP[bit 2] and enabled in bit 0 of MSR IA32_L2_QOS_CFG at address 0xc82.

As with L3 CDP, when L2 CDP is enabled, each CLOS is mapped 1:2 with mask MSRs, with one mask enabling programmatic control over data fill location and one mask control over data placement.

The feature is enabled in kernel along with other RDT features.

More detailed L2 CDP hardware information can be found in technical
article: https://software.intel.com/en-us/articles/intel-resource-director-technology-extensions-introducing-the-l2-code-and-data

The first patch fixes a documentation issue. The following five patches do the real work.

The patches are based on x86/cache branch in tip tree. The patch #3 cannot be applied to upstream now because of reformatting in arch/x86/include/asm /cpufeatures.h. But it's easy to rebase the patches to upstream.

Fenghua Yu (6):
x86/intel_rdt: Classify /proc/cpuinfo flag bits and add missing bits
in documentation
x86/intel_rdt: Add L2 Code and Data Prioritization (CDP) support in
documentation
x86/intel_rdt: Enumerate L2 Code and Data Prioritization (CDP) feature x86/intel_rdt: Add two new resources for L2 Code and Data
Prioritization (CDP)
x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG x86/intel_rdt: Turn on/off L2 CDP in kernel parameter

 Documentation/admin-guide/kernel-parameters.txt |   3 +-
 Documentation/x86/intel_rdt_ui.txt              |  14 ++-
 arch/x86/include/asm/cpufeatures.h              |   1 +
 arch/x86/kernel/cpu/intel_rdt.c                 |  68 ++++++++++++--
 arch/x86/kernel/cpu/intel_rdt.h                 |   5 +
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c        | 117 ++++++++++++++++++------
 arch/x86/kernel/cpu/scattered.c                 |   1 +
 7 files changed, 170 insertions(+), 39 deletions(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/6 x86/intel_rdt: Classify /proc/cpuinfo flag bits and add missing bits in documentation

From: Fenghua Yu <[email protected]>

With more flag bits in /proc/cpuinfo for RDT, it's better to classify the bits for readability.

Some previously missing bits are added as well.

---
 Documentation/x86/intel_rdt_ui.txt | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Documentation/x86/intel_rdt_ui.txt +7 -1
index 6851854..1ad77b1 100644
@@ -7,7 +7,13 @@ Tony Luck <[email protected]>
 Vikas Shivappa <[email protected]>
 
 This feature is enabled by the CONFIG_INTEL_RDT Kconfig and the
-X86 /proc/cpuinfo flag bits "rdt", "cqm", "cat_l3" and "cdp_l3".
+X86 /proc/cpuinfo flag bits:
+RDT (Resource Director Technology) Allocation - "rdt_a"
+CAT (Cache Allocation Technology) - "cat_l3", "cat_l2"
+CDP (Code and Data Prioritization ) - "cdp_l3"
+CQM (Cache QoS Monitoring) - "cqm_llc", "cqm_occup_llc"
+MBM (Memory Bandwidth Monitoring) - "cqm_mbm_total", "cqm_mbm_local"
+MBA (Memory Bandwidth Allocation) - "mba"
 
 To use the feature mount the file system:
 
Signature · 1 line
1.8.3.1
#2 lore raw

[tip:x86/cache] x86/intel_rdt: Update documentation

x86/intel_rdt: Update documentation
Commit-ID:  0ff8e080b18d1d2dbe5c866d5f31c27ab806a785
Gitweb:     https://git.kernel.org/tip/0ff8e080b18d1d2dbe5c866d5f31c27ab806a785
Author:     Fenghua Yu <[email protected]>
AuthorDate: Wed, 20 Dec 2017 14:57:19 -0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 18 Jan 2018 09:33:30 +0100

x86/intel_rdt: Update documentation

With more flag bits in /proc/cpuinfo for RDT, it's better to classify the bits for readability.

Some previously missing bits are added as well.

---
 Documentation/x86/intel_rdt_ui.txt | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Documentation/x86/intel_rdt_ui.txt +7 -1
index 6851854..1ad77b1 100644
@@ -7,7 +7,13 @@ Tony Luck <[email protected]>
 Vikas Shivappa <[email protected]>
 
 This feature is enabled by the CONFIG_INTEL_RDT Kconfig and the
-X86 /proc/cpuinfo flag bits "rdt", "cqm", "cat_l3" and "cdp_l3".
+X86 /proc/cpuinfo flag bits:
+RDT (Resource Director Technology) Allocation - "rdt_a"
+CAT (Cache Allocation Technology) - "cat_l3", "cat_l2"
+CDP (Code and Data Prioritization ) - "cdp_l3"
+CQM (Cache QoS Monitoring) - "cqm_llc", "cqm_occup_llc"
+MBM (Memory Bandwidth Monitoring) - "cqm_mbm_total", "cqm_mbm_local"
+MBA (Memory Bandwidth Allocation) - "mba"
 
 To use the feature mount the file system:
 
author
#3 lore raw

PATCH 2/6 x86/intel_rdt: Add L2 Code and Data Prioritization (CDP) support in documentation

In reply to Fenghua Yu

From: Fenghua Yu <[email protected]>

A new mount parameter "cdpl2" is added to enable L2 CDP in documentation. The legacy mount parameter "cdp" is still used to enable L3 CDP.

L2 and L3 CDP can be enabled separately.

---
 Documentation/x86/intel_rdt_ui.txt | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Documentation/x86/intel_rdt_ui.txt +6 -2
index 1ad77b1..86bc5b2 100644
@@ -10,18 +10,22 @@ This feature is enabled by the CONFIG_INTEL_RDT Kconfig and the
 X86 /proc/cpuinfo flag bits:
 RDT (Resource Director Technology) Allocation - "rdt_a"
 CAT (Cache Allocation Technology) - "cat_l3", "cat_l2"
-CDP (Code and Data Prioritization ) - "cdp_l3"
+CDP (Code and Data Prioritization ) - "cdp_l3", "cdp_l2"
 CQM (Cache QoS Monitoring) - "cqm_llc", "cqm_occup_llc"
 MBM (Memory Bandwidth Monitoring) - "cqm_mbm_total", "cqm_mbm_local"
 MBA (Memory Bandwidth Allocation) - "mba"
 
 To use the feature mount the file system:
 
- # mount -t resctrl resctrl [-o cdp] /sys/fs/resctrl
+ # mount -t resctrl resctrl [-o cdp[,cdpl2]] /sys/fs/resctrl
 
 mount options are:
 
 "cdp": Enable code/data prioritization in L3 cache allocations.
+"cdpl2": Enable code/data prioritization in L2 cache allocations.
+
+Please note: We keep the "cdp" option for enabling L3 CDP to maintain
+legacy interface. L2 and L3 CDP can be enabled separately.
 
 RDT features are orthogonal. A particular system may support only
 monitoring, only control, or both monitoring and control.
Signature · 1 line
1.8.3.1
#4 lore raw

[tip:x86/cache] x86/intel_rdt: Add L2CDP support in documentation

x86/intel_rdt: Add L2CDP support in documentation
Commit-ID:  aa55d5a4bd919f26fce519c470d11a58541c6aa7
Gitweb:     https://git.kernel.org/tip/aa55d5a4bd919f26fce519c470d11a58541c6aa7
Author:     Fenghua Yu <[email protected]>
AuthorDate: Wed, 20 Dec 2017 14:57:20 -0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 18 Jan 2018 09:33:30 +0100

x86/intel_rdt: Add L2CDP support in documentation

L2 and L3 Code and Data Prioritization (CDP) can be enabled separately. The existing mount parameter "cdp" is only for enabling L3 CDP and will be kept for backwards compability.

Add a new mount parameter 'cdpl2' for L2 CDP.

[ tglx: Made changelog readable ]

---
 Documentation/x86/intel_rdt_ui.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Documentation/x86/intel_rdt_ui.txt +5 -2
index 1ad77b1..756fd76 100644
@@ -10,18 +10,21 @@ This feature is enabled by the CONFIG_INTEL_RDT Kconfig and the
 X86 /proc/cpuinfo flag bits:
 RDT (Resource Director Technology) Allocation - "rdt_a"
 CAT (Cache Allocation Technology) - "cat_l3", "cat_l2"
-CDP (Code and Data Prioritization ) - "cdp_l3"
+CDP (Code and Data Prioritization ) - "cdp_l3", "cdp_l2"
 CQM (Cache QoS Monitoring) - "cqm_llc", "cqm_occup_llc"
 MBM (Memory Bandwidth Monitoring) - "cqm_mbm_total", "cqm_mbm_local"
 MBA (Memory Bandwidth Allocation) - "mba"
 
 To use the feature mount the file system:
 
- # mount -t resctrl resctrl [-o cdp] /sys/fs/resctrl
+ # mount -t resctrl resctrl [-o cdp[,cdpl2]] /sys/fs/resctrl
 
 mount options are:
 
 "cdp": Enable code/data prioritization in L3 cache allocations.
+"cdpl2": Enable code/data prioritization in L2 cache allocations.
+
+L2 and L3 CDP are controlled seperately.
 
 RDT features are orthogonal. A particular system may support only
 monitoring, only control, or both monitoring and control.
author
#5 lore raw

PATCH 3/6 x86/intel_rdt: Enumerate L2 Code and Data Prioritization (CDP) feature

In reply to Fenghua Yu

From: Fenghua Yu <[email protected]>

L2 Code and Data Prioritization (CDP) is enumerated in CPUID(EAX=0x10, ECX=0x2):ECX.bit2

---
 arch/x86/include/asm/cpufeatures.h | 1 +
 arch/x86/kernel/cpu/scattered.c    | 1 +
 2 files changed, 2 insertions(+)
arch/x86/include/asm/cpufeatures.h +1 -0
index 2519c6c..f05b114 100644
@@ -193,6 +193,7 @@
 #define X86_FEATURE_CAT_L3	( 7*32+ 4) /* Cache Allocation Technology L3 */
 #define X86_FEATURE_CAT_L2	( 7*32+ 5) /* Cache Allocation Technology L2 */
 #define X86_FEATURE_CDP_L3	( 7*32+ 6) /* Code and Data Prioritization L3 */
+#define X86_FEATURE_CDP_L2	( 7*32+ 7) /* Code and Data Prioritization L2 */
 
 #define X86_FEATURE_HW_PSTATE	( 7*32+ 8) /* AMD HW-PState */
 #define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
arch/x86/kernel/cpu/scattered.c +1 -0
index 05459ad..da43128 100644
@@ -27,6 +27,7 @@ struct cpuid_bit {
 	{ X86_FEATURE_CAT_L3,		CPUID_EBX,  1, 0x00000010, 0 },
 	{ X86_FEATURE_CAT_L2,		CPUID_EBX,  2, 0x00000010, 0 },
 	{ X86_FEATURE_CDP_L3,		CPUID_ECX,  2, 0x00000010, 1 },
+	{ X86_FEATURE_CDP_L2,		CPUID_ECX,  2, 0x00000010, 2 },
 	{ X86_FEATURE_MBA,		CPUID_EBX,  3, 0x00000010, 0 },
 	{ X86_FEATURE_HW_PSTATE,	CPUID_EDX,  7, 0x80000007, 0 },
 	{ X86_FEATURE_CPB,		CPUID_EDX,  9, 0x80000007, 0 },
Signature · 1 line
1.8.3.1
#6 lore raw

[tip:x86/cache] x86/intel_rdt: Enumerate L2 Code and Data Prioritization (CDP) feature

x86/intel_rdt: Enumerate L2 Code and Data Prioritization (CDP) feature
Commit-ID:  a511e7935378ef1f321456a90beae2a2632d3d83
Gitweb:     https://git.kernel.org/tip/a511e7935378ef1f321456a90beae2a2632d3d83
Author:     Fenghua Yu <[email protected]>
AuthorDate: Wed, 20 Dec 2017 14:57:21 -0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 18 Jan 2018 09:33:30 +0100

x86/intel_rdt: Enumerate L2 Code and Data Prioritization (CDP) feature

L2 Code and Data Prioritization (CDP) is enumerated in CPUID(EAX=0x10, ECX=0x2):ECX.bit2

---
 arch/x86/include/asm/cpufeatures.h | 1 +
 arch/x86/kernel/cpu/scattered.c    | 1 +
 2 files changed, 2 insertions(+)
arch/x86/include/asm/cpufeatures.h +1 -0
index 25b9375..67bbfaa 100644
@@ -206,6 +206,7 @@
 #define X86_FEATURE_RETPOLINE		( 7*32+12) /* Generic Retpoline mitigation for Spectre variant 2 */
 #define X86_FEATURE_RETPOLINE_AMD	( 7*32+13) /* AMD Retpoline mitigation for Spectre variant 2 */
 #define X86_FEATURE_INTEL_PPIN		( 7*32+14) /* Intel Processor Inventory Number */
+#define X86_FEATURE_CDP_L2		( 7*32+15) /* Code and Data Prioritization L2 */
 #define X86_FEATURE_AVX512_4VNNIW	( 7*32+16) /* AVX-512 Neural Network Instructions */
 #define X86_FEATURE_AVX512_4FMAPS	( 7*32+17) /* AVX-512 Multiply Accumulation Single precision */
 
arch/x86/kernel/cpu/scattered.c +1 -0
index d0e6976..df4d8f7 100644
@@ -26,6 +26,7 @@ static const struct cpuid_bit cpuid_bits[] = {
 	{ X86_FEATURE_CAT_L3,		CPUID_EBX,  1, 0x00000010, 0 },
 	{ X86_FEATURE_CAT_L2,		CPUID_EBX,  2, 0x00000010, 0 },
 	{ X86_FEATURE_CDP_L3,		CPUID_ECX,  2, 0x00000010, 1 },
+	{ X86_FEATURE_CDP_L2,		CPUID_ECX,  2, 0x00000010, 2 },
 	{ X86_FEATURE_MBA,		CPUID_EBX,  3, 0x00000010, 0 },
 	{ X86_FEATURE_HW_PSTATE,	CPUID_EDX,  7, 0x80000007, 0 },
 	{ X86_FEATURE_CPB,		CPUID_EDX,  9, 0x80000007, 0 },
author
#7 lore raw

PATCH 4/6 x86/intel_rdt: Add two new resources for L2 Code and Data Prioritization (CDP)

In reply to Fenghua Yu

From: Fenghua Yu <[email protected]>

L2 data and L2 code are added as new resources in rdt_resources_all[] and data in the resources are configured.

When L2 CDP is enabled, the schemata will have the two resources in this format:
L2DATA:l2id0=xxxx;l2id1=xxxx;.... L2CODE:l2id0=xxxx;l2id1=xxxx;....

---
 arch/x86/kernel/cpu/intel_rdt.c | 66 ++++++++++++++++++++++++++++++++++-------
 arch/x86/kernel/cpu/intel_rdt.h |  2 ++
 2 files changed, 58 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/intel_rdt.c +56 -10
index 88dcf84..a739a32 100644
@@ -135,6 +135,40 @@ struct rdt_resource rdt_resources_all[] = {
 		.format_str		= "%d=%0*x",
 		.fflags			= RFTYPE_RES_CACHE,
 	},
+	[RDT_RESOURCE_L2DATA] =
+	{
+		.rid			= RDT_RESOURCE_L2DATA,
+		.name			= "L2DATA",
+		.domains		= domain_init(RDT_RESOURCE_L2DATA),
+		.msr_base		= IA32_L2_CBM_BASE,
+		.msr_update		= cat_wrmsr,
+		.cache_level		= 2,
+		.cache = {
+			.min_cbm_bits	= 1,
+			.cbm_idx_mult	= 2,
+			.cbm_idx_offset	= 0,
+		},
+		.parse_ctrlval		= parse_cbm,
+		.format_str		= "%d=%0*x",
+		.fflags			= RFTYPE_RES_CACHE,
+	},
+	[RDT_RESOURCE_L2CODE] =
+	{
+		.rid			= RDT_RESOURCE_L2CODE,
+		.name			= "L2CODE",
+		.domains		= domain_init(RDT_RESOURCE_L2CODE),
+		.msr_base		= IA32_L2_CBM_BASE,
+		.msr_update		= cat_wrmsr,
+		.cache_level		= 2,
+		.cache = {
+			.min_cbm_bits	= 1,
+			.cbm_idx_mult	= 2,
+			.cbm_idx_offset	= 1,
+		},
+		.parse_ctrlval		= parse_cbm,
+		.format_str		= "%d=%0*x",
+		.fflags			= RFTYPE_RES_CACHE,
+	},
 	[RDT_RESOURCE_MBA] =
 	{
 		.rid			= RDT_RESOURCE_MBA,
@@ -259,15 +293,15 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r)
 	r->alloc_enabled = true;
 }
 
-static void rdt_get_cdp_l3_config(int type)
+static void rdt_get_cdp_config(int level, int type)
 {
-	struct rdt_resource *r_l3 = &rdt_resources_all[RDT_RESOURCE_L3];
+	struct rdt_resource *r_l = &rdt_resources_all[level];
 	struct rdt_resource *r = &rdt_resources_all[type];
 
-	r->num_closid = r_l3->num_closid / 2;
-	r->cache.cbm_len = r_l3->cache.cbm_len;
-	r->default_ctrl = r_l3->default_ctrl;
-	r->cache.shareable_bits = r_l3->cache.shareable_bits;
+	r->num_closid = r_l->num_closid / 2;
+	r->cache.cbm_len = r_l->cache.cbm_len;
+	r->default_ctrl = r_l->default_ctrl;
+	r->cache.shareable_bits = r_l->cache.shareable_bits;
 	r->data_width = (r->cache.cbm_len + 3) / 4;
 	r->alloc_capable = true;
 	/*
@@ -277,6 +311,18 @@ static void rdt_get_cdp_l3_config(int type)
 	r->alloc_enabled = false;
 }
 
+static void rdt_get_cdp_l3_config(void)
+{
+	rdt_get_cdp_config(RDT_RESOURCE_L3, RDT_RESOURCE_L3DATA);
+	rdt_get_cdp_config(RDT_RESOURCE_L3, RDT_RESOURCE_L3CODE);
+}
+
+static void rdt_get_cdp_l2_config(void)
+{
+	rdt_get_cdp_config(RDT_RESOURCE_L2, RDT_RESOURCE_L2DATA);
+	rdt_get_cdp_config(RDT_RESOURCE_L2, RDT_RESOURCE_L2CODE);
+}
+
 static int get_cache_id(int cpu, int level)
 {
 	struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu);
@@ -729,15 +775,15 @@ static __init bool get_rdt_alloc_resources(void)
 
 	if (rdt_cpu_has(X86_FEATURE_CAT_L3)) {
 		rdt_get_cache_alloc_cfg(1, &rdt_resources_all[RDT_RESOURCE_L3]);
-		if (rdt_cpu_has(X86_FEATURE_CDP_L3)) {
-			rdt_get_cdp_l3_config(RDT_RESOURCE_L3DATA);
-			rdt_get_cdp_l3_config(RDT_RESOURCE_L3CODE);
-		}
+		if (rdt_cpu_has(X86_FEATURE_CDP_L3))
+			rdt_get_cdp_l3_config();
 		ret = true;
 	}
 	if (rdt_cpu_has(X86_FEATURE_CAT_L2)) {
 		/* CPUID 0x10.2 fields are same format at 0x10.1 */
 		rdt_get_cache_alloc_cfg(2, &rdt_resources_all[RDT_RESOURCE_L2]);
+		if (rdt_cpu_has(X86_FEATURE_CDP_L2))
+			rdt_get_cdp_l2_config();
 		ret = true;
 	}
 
arch/x86/kernel/cpu/intel_rdt.h +2 -0
index 9d3148d..cea9f4b 100644
@@ -356,6 +356,8 @@ enum {
 	RDT_RESOURCE_L3DATA,
 	RDT_RESOURCE_L3CODE,
 	RDT_RESOURCE_L2,
+	RDT_RESOURCE_L2DATA,
+	RDT_RESOURCE_L2CODE,
 	RDT_RESOURCE_MBA,
 
 	/* Must be the last */
Signature · 1 line
1.8.3.1
reviewer
#8 lore raw

Re: [PATCH 4/6] x86/intel_rdt: Add two new resources for L2 Code and Data Prioritization (CDP)

Quoted 9 lines · Fenghua Yu

From: Fenghua Yu <[email protected]>

L2 data and L2 code are added as new resources in rdt_resources_all[] and data in the resources are configured.

When L2 CDP is enabled, the schemata will have the two resources in this format:
L2DATA:l2id0=xxxx;l2id1=xxxx;.... L2CODE:l2id0=xxxx;l2id1=xxxx;....

Hi,

What do the xxxx represent?

Thanks.

Quoted 5 lines
---
 arch/x86/kernel/cpu/intel_rdt.c | 66 ++++++++++++++++++++++++++++++++++-------
 arch/x86/kernel/cpu/intel_rdt.h |  2 ++
 2 files changed, 58 insertions(+), 10 deletions(-)
Signature · 1 line
~Randy
#9 lore raw

RE: [PATCH 4/6] x86/intel_rdt: Add two new resources for L2 Code and Data Prioritization (CDP)

Quoted 8 lines
Quoted 4 lines

When L2 CDP is enabled, the schemata will have the two resources in this format:
L2DATA:l2id0=xxxx;l2id1=xxxx;.... L2CODE:l2id0=xxxx;l2id1=xxxx;....

Hi,

What do the xxxx represent?

The xxxx represents CBM (Cache Bit Mask) values in the schemata, similar to all others (L2 CAT/L3 CAT/L3 CDP).

Thanks.

-Fenghua

#10 lore raw

[tip:x86/cache] x86/intel_rdt: Add two new resources for L2 Code and Data Prioritization (CDP)

In reply to Fenghua Yu
x86/intel_rdt: Add two new resources for L2 Code and Data Prioritization (CDP)
Commit-ID:  def10853930a82456ab862a3a8292a3a16c386e7
Gitweb:     https://git.kernel.org/tip/def10853930a82456ab862a3a8292a3a16c386e7
Author:     Fenghua Yu <[email protected]>
AuthorDate: Wed, 20 Dec 2017 14:57:22 -0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 18 Jan 2018 09:33:31 +0100

x86/intel_rdt: Add two new resources for L2 Code and Data Prioritization (CDP)

L2 data and L2 code are added as new resources in rdt_resources_all[] and data in the resources are configured.

When L2 CDP is enabled, the schemata will have the two resources in this format:
L2DATA:l2id0=xxxx;l2id1=xxxx;.... L2CODE:l2id0=xxxx;l2id1=xxxx;....

xxxx represent CBM (Cache Bit Mask) values in the schemata, similar to all others (L2 CAT/L3 CAT/L3 CDP).

---
 arch/x86/kernel/cpu/intel_rdt.c | 66 ++++++++++++++++++++++++++++++++++-------
 arch/x86/kernel/cpu/intel_rdt.h |  2 ++
 2 files changed, 58 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/intel_rdt.c +56 -10
index 9944237..5202da0 100644
@@ -135,6 +135,40 @@ struct rdt_resource rdt_resources_all[] = {
 		.format_str		= "%d=%0*x",
 		.fflags			= RFTYPE_RES_CACHE,
 	},
+	[RDT_RESOURCE_L2DATA] =
+	{
+		.rid			= RDT_RESOURCE_L2DATA,
+		.name			= "L2DATA",
+		.domains		= domain_init(RDT_RESOURCE_L2DATA),
+		.msr_base		= IA32_L2_CBM_BASE,
+		.msr_update		= cat_wrmsr,
+		.cache_level		= 2,
+		.cache = {
+			.min_cbm_bits	= 1,
+			.cbm_idx_mult	= 2,
+			.cbm_idx_offset	= 0,
+		},
+		.parse_ctrlval		= parse_cbm,
+		.format_str		= "%d=%0*x",
+		.fflags			= RFTYPE_RES_CACHE,
+	},
+	[RDT_RESOURCE_L2CODE] =
+	{
+		.rid			= RDT_RESOURCE_L2CODE,
+		.name			= "L2CODE",
+		.domains		= domain_init(RDT_RESOURCE_L2CODE),
+		.msr_base		= IA32_L2_CBM_BASE,
+		.msr_update		= cat_wrmsr,
+		.cache_level		= 2,
+		.cache = {
+			.min_cbm_bits	= 1,
+			.cbm_idx_mult	= 2,
+			.cbm_idx_offset	= 1,
+		},
+		.parse_ctrlval		= parse_cbm,
+		.format_str		= "%d=%0*x",
+		.fflags			= RFTYPE_RES_CACHE,
+	},
 	[RDT_RESOURCE_MBA] =
 	{
 		.rid			= RDT_RESOURCE_MBA,
@@ -259,15 +293,15 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r)
 	r->alloc_enabled = true;
 }
 
-static void rdt_get_cdp_l3_config(int type)
+static void rdt_get_cdp_config(int level, int type)
 {
-	struct rdt_resource *r_l3 = &rdt_resources_all[RDT_RESOURCE_L3];
+	struct rdt_resource *r_l = &rdt_resources_all[level];
 	struct rdt_resource *r = &rdt_resources_all[type];
 
-	r->num_closid = r_l3->num_closid / 2;
-	r->cache.cbm_len = r_l3->cache.cbm_len;
-	r->default_ctrl = r_l3->default_ctrl;
-	r->cache.shareable_bits = r_l3->cache.shareable_bits;
+	r->num_closid = r_l->num_closid / 2;
+	r->cache.cbm_len = r_l->cache.cbm_len;
+	r->default_ctrl = r_l->default_ctrl;
+	r->cache.shareable_bits = r_l->cache.shareable_bits;
 	r->data_width = (r->cache.cbm_len + 3) / 4;
 	r->alloc_capable = true;
 	/*
@@ -277,6 +311,18 @@ static void rdt_get_cdp_l3_config(int type)
 	r->alloc_enabled = false;
 }
 
+static void rdt_get_cdp_l3_config(void)
+{
+	rdt_get_cdp_config(RDT_RESOURCE_L3, RDT_RESOURCE_L3DATA);
+	rdt_get_cdp_config(RDT_RESOURCE_L3, RDT_RESOURCE_L3CODE);
+}
+
+static void rdt_get_cdp_l2_config(void)
+{
+	rdt_get_cdp_config(RDT_RESOURCE_L2, RDT_RESOURCE_L2DATA);
+	rdt_get_cdp_config(RDT_RESOURCE_L2, RDT_RESOURCE_L2CODE);
+}
+
 static int get_cache_id(int cpu, int level)
 {
 	struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu);
@@ -729,15 +775,15 @@ static __init bool get_rdt_alloc_resources(void)
 
 	if (rdt_cpu_has(X86_FEATURE_CAT_L3)) {
 		rdt_get_cache_alloc_cfg(1, &rdt_resources_all[RDT_RESOURCE_L3]);
-		if (rdt_cpu_has(X86_FEATURE_CDP_L3)) {
-			rdt_get_cdp_l3_config(RDT_RESOURCE_L3DATA);
-			rdt_get_cdp_l3_config(RDT_RESOURCE_L3CODE);
-		}
+		if (rdt_cpu_has(X86_FEATURE_CDP_L3))
+			rdt_get_cdp_l3_config();
 		ret = true;
 	}
 	if (rdt_cpu_has(X86_FEATURE_CAT_L2)) {
 		/* CPUID 0x10.2 fields are same format at 0x10.1 */
 		rdt_get_cache_alloc_cfg(2, &rdt_resources_all[RDT_RESOURCE_L2]);
+		if (rdt_cpu_has(X86_FEATURE_CDP_L2))
+			rdt_get_cdp_l2_config();
 		ret = true;
 	}
 
arch/x86/kernel/cpu/intel_rdt.h +2 -0
index 3397244..19ffc5a 100644
@@ -357,6 +357,8 @@ enum {
 	RDT_RESOURCE_L3DATA,
 	RDT_RESOURCE_L3CODE,
 	RDT_RESOURCE_L2,
+	RDT_RESOURCE_L2DATA,
+	RDT_RESOURCE_L2CODE,
 	RDT_RESOURCE_MBA,
 
 	/* Must be the last */
author
#11 lore raw

PATCH 5/6 x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG

In reply to Fenghua Yu

From: Fenghua Yu <[email protected]>

Bit 0 in MSR IA32_L2_QOS_CFG (0xc82) is L2 CDP enable bit. By default, the bit is zero, i.e. L2 CAT is enabled, and L2 CDP is disabled. When the resctrl mount parameter "cdpl2" is given, the bit is set as 1 and L2 CDP is enabled.

In L2 CDP mode, the L2 CAT mask MSRs are re-mapped into interleaved pair of mask MSRs for code (in odd number of CLOSID) and data (in even number of CLOSID).

---
 arch/x86/kernel/cpu/intel_rdt.h          |   3 +
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 117 ++++++++++++++++++++++++-------
 2 files changed, 94 insertions(+), 26 deletions(-)
arch/x86/kernel/cpu/intel_rdt.h +3 -0
index cea9f4b..1c5d2a3 100644
@@ -6,12 +6,15 @@
 #include <linux/jump_label.h>
 
 #define IA32_L3_QOS_CFG		0xc81
+#define IA32_L2_QOS_CFG		0xc82
 #define IA32_L3_CBM_BASE	0xc90
 #define IA32_L2_CBM_BASE	0xd10
 #define IA32_MBA_THRTL_BASE	0xd50
 
 #define L3_QOS_CDP_ENABLE	0x01ULL
 
+#define L2_QOS_CDP_ENABLE	0x01ULL
+
 /*
  * Event IDs are used to program IA32_QM_EVTSEL before reading event
  * counter from IA32_QM_CTR
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +91 -26

187 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#12 lore raw

[tip:x86/cache] x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG

x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG
Commit-ID:  99adde9b370de8e07ef76630c6f60dbf586cdf0e
Gitweb:     https://git.kernel.org/tip/99adde9b370de8e07ef76630c6f60dbf586cdf0e
Author:     Fenghua Yu <[email protected]>
AuthorDate: Wed, 20 Dec 2017 14:57:23 -0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 18 Jan 2018 09:33:31 +0100

x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG

Bit 0 in MSR IA32_L2_QOS_CFG (0xc82) is L2 CDP enable bit. By default, the bit is zero, i.e. L2 CAT is enabled, and L2 CDP is disabled. When the resctrl mount parameter "cdpl2" is given, the bit is set to 1 and L2 CDP is enabled.

In L2 CDP mode, the L2 CAT mask MSRs are re-mapped into interleaved pairs of mask MSRs for code (referenced by an odd CLOSID) and data (referenced by an even CLOSID).

---
 arch/x86/kernel/cpu/intel_rdt.h          |   3 +
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 117 ++++++++++++++++++++++++-------
 2 files changed, 94 insertions(+), 26 deletions(-)
arch/x86/kernel/cpu/intel_rdt.h +3 -0
index 19ffc5a..3fd7a70 100644
@@ -7,12 +7,15 @@
 #include <linux/jump_label.h>
 
 #define IA32_L3_QOS_CFG		0xc81
+#define IA32_L2_QOS_CFG		0xc82
 #define IA32_L3_CBM_BASE	0xc90
 #define IA32_L2_CBM_BASE	0xd10
 #define IA32_MBA_THRTL_BASE	0xd50
 
 #define L3_QOS_CDP_ENABLE	0x01ULL
 
+#define L2_QOS_CDP_ENABLE	0x01ULL
+
 /*
  * Event IDs are used to program IA32_QM_EVTSEL before reading event
  * counter from IA32_QM_CTR
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +91 -26

187 lines not on this page · raw message

author
#13 lore raw

PATCH 6/6 x86/intel_rdt: Turn on/off L2 CDP in kernel parameter

In reply to Fenghua Yu

From: Fenghua Yu <[email protected]>

L2 CDP can be turned on or off by kernel parameter "rdt=". If "rdt=l2cdp", L2 CDP is turned on.
If "rdt=!l2cdp", L2 CDP is turned off.

---
 Documentation/admin-guide/kernel-parameters.txt | 3 ++-
 arch/x86/kernel/cpu/intel_rdt.c                 | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +2 -1
index 0549662..077eebc 100644
@@ -3623,7 +3623,8 @@
 
 	rdt=		[HW,X86,RDT]
 			Turn on/off individual RDT features. List is:
-			cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, mba.
+			cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp,
+			mba.
 			E.g. to turn on cmt and turn off mba use:
 				rdt=cmt,!mba
 
arch/x86/kernel/cpu/intel_rdt.c +2 -0
index a739a32..25cfb17 100644
@@ -691,6 +691,7 @@ enum {
 	RDT_FLAG_L3_CAT,
 	RDT_FLAG_L3_CDP,
 	RDT_FLAG_L2_CAT,
+	RDT_FLAG_L2_CDP,
 	RDT_FLAG_MBA,
 };
 
@@ -713,6 +714,7 @@ struct rdt_options {
 	RDT_OPT(RDT_FLAG_L3_CAT,    "l3cat",	X86_FEATURE_CAT_L3),
 	RDT_OPT(RDT_FLAG_L3_CDP,    "l3cdp",	X86_FEATURE_CDP_L3),
 	RDT_OPT(RDT_FLAG_L2_CAT,    "l2cat",	X86_FEATURE_CAT_L2),
+	RDT_OPT(RDT_FLAG_L2_CDP,    "l2cdp",	X86_FEATURE_CDP_L2),
 	RDT_OPT(RDT_FLAG_MBA,	    "mba",	X86_FEATURE_MBA),
 };
 #define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options)
Signature · 1 line
1.8.3.1
#14 lore raw

[tip:x86/cache] x86/intel_rdt: Add command line parameter to control L2_CDP

x86/intel_rdt: Add command line parameter to control L2_CDP
Commit-ID:  31516de306c0c9235156cdc7acb976ea21f1f646
Gitweb:     https://git.kernel.org/tip/31516de306c0c9235156cdc7acb976ea21f1f646
Author:     Fenghua Yu <[email protected]>
AuthorDate: Wed, 20 Dec 2017 14:57:24 -0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 18 Jan 2018 09:33:32 +0100

x86/intel_rdt: Add command line parameter to control L2_CDP

L2 CDP can be controlled by kernel parameter "rdt=". If "rdt=l2cdp", L2 CDP is turned on.
If "rdt=!l2cdp", L2 CDP is turned off.

---
 Documentation/admin-guide/kernel-parameters.txt | 3 ++-
 arch/x86/kernel/cpu/intel_rdt.c                 | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +2 -1
index 46b26bf..fde058c 100644
@@ -3682,7 +3682,8 @@
 
 	rdt=		[HW,X86,RDT]
 			Turn on/off individual RDT features. List is:
-			cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, mba.
+			cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp,
+			mba.
 			E.g. to turn on cmt and turn off mba use:
 				rdt=cmt,!mba
 
arch/x86/kernel/cpu/intel_rdt.c +2 -0
index 5202da0..410629f 100644
@@ -691,6 +691,7 @@ enum {
 	RDT_FLAG_L3_CAT,
 	RDT_FLAG_L3_CDP,
 	RDT_FLAG_L2_CAT,
+	RDT_FLAG_L2_CDP,
 	RDT_FLAG_MBA,
 };
 
@@ -713,6 +714,7 @@ static struct rdt_options rdt_options[]  __initdata = {
 	RDT_OPT(RDT_FLAG_L3_CAT,    "l3cat",	X86_FEATURE_CAT_L3),
 	RDT_OPT(RDT_FLAG_L3_CDP,    "l3cdp",	X86_FEATURE_CDP_L3),
 	RDT_OPT(RDT_FLAG_L2_CAT,    "l2cat",	X86_FEATURE_CAT_L2),
+	RDT_OPT(RDT_FLAG_L2_CDP,    "l2cdp",	X86_FEATURE_CDP_L2),
 	RDT_OPT(RDT_FLAG_MBA,	    "mba",	X86_FEATURE_MBA),
 };
 #define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options)