Skip to content

Commit 2ae20d6

Browse files
committed
Merge tag 'x86_cache_for_v6.19_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 resource control updates from Borislav Petkov: - Add support for AMD's Smart Data Cache Injection feature which allows for direct insertion of data from I/O devices into the L3 cache, thus bypassing DRAM and saving its bandwidth; the resctrl side of the feature allows the size of the L3 used for data injection to be controlled - Add Intel Clearwater Forest to the list of CPUs which support Sub-NUMA clustering - Other fixes and cleanups * tag 'x86_cache_for_v6.19_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: fs/resctrl: Update bit_usage to reflect io_alloc fs/resctrl: Introduce interface to modify io_alloc capacity bitmasks fs/resctrl: Modify struct rdt_parse_data to pass mode and CLOSID fs/resctrl: Introduce interface to display io_alloc CBMs fs/resctrl: Add user interface to enable/disable io_alloc feature fs/resctrl: Introduce interface to display "io_alloc" support x86,fs/resctrl: Implement "io_alloc" enable/disable handlers x86,fs/resctrl: Detect io_alloc feature x86/resctrl: Add SDCIAE feature in the command line options x86/cpufeatures: Add support for L3 Smart Data Cache Injection Allocation Enforcement fs/resctrl: Consider sparse masks when initializing new group's allocation x86/resctrl: Support Sub-NUMA Cluster (SNC) mode on Clearwater Forest
2 parents 2a47c26 + ac7de45 commit 2ae20d6

13 files changed

Lines changed: 580 additions & 47 deletions

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6207,7 +6207,7 @@
62076207
rdt= [HW,X86,RDT]
62086208
Turn on/off individual RDT features. List is:
62096209
cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp,
6210-
mba, smba, bmec, abmc.
6210+
mba, smba, bmec, abmc, sdciae.
62116211
E.g. to turn on cmt and turn off mba use:
62126212
rdt=cmt,!mba
62136213

Documentation/filesystems/resctrl.rst

Lines changed: 109 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ AMD refers to this feature as AMD Platform Quality of Service(AMD QoS).
1717
This feature is enabled by the CONFIG_X86_CPU_RESCTRL and the x86 /proc/cpuinfo
1818
flag bits:
1919

20-
=============================================== ================================
21-
RDT (Resource Director Technology) Allocation "rdt_a"
22-
CAT (Cache Allocation Technology) "cat_l3", "cat_l2"
23-
CDP (Code and Data Prioritization) "cdp_l3", "cdp_l2"
24-
CQM (Cache QoS Monitoring) "cqm_llc", "cqm_occup_llc"
25-
MBM (Memory Bandwidth Monitoring) "cqm_mbm_total", "cqm_mbm_local"
26-
MBA (Memory Bandwidth Allocation) "mba"
27-
SMBA (Slow Memory Bandwidth Allocation) ""
28-
BMEC (Bandwidth Monitoring Event Configuration) ""
29-
ABMC (Assignable Bandwidth Monitoring Counters) ""
30-
=============================================== ================================
20+
=============================================================== ================================
21+
RDT (Resource Director Technology) Allocation "rdt_a"
22+
CAT (Cache Allocation Technology) "cat_l3", "cat_l2"
23+
CDP (Code and Data Prioritization) "cdp_l3", "cdp_l2"
24+
CQM (Cache QoS Monitoring) "cqm_llc", "cqm_occup_llc"
25+
MBM (Memory Bandwidth Monitoring) "cqm_mbm_total", "cqm_mbm_local"
26+
MBA (Memory Bandwidth Allocation) "mba"
27+
SMBA (Slow Memory Bandwidth Allocation) ""
28+
BMEC (Bandwidth Monitoring Event Configuration) ""
29+
ABMC (Assignable Bandwidth Monitoring Counters) ""
30+
SDCIAE (Smart Data Cache Injection Allocation Enforcement) ""
31+
=============================================================== ================================
3132

3233
Historically, new features were made visible by default in /proc/cpuinfo. This
3334
resulted in the feature flags becoming hard to parse by humans. Adding a new
@@ -72,6 +73,11 @@ The 'info' directory contains information about the enabled
7273
resources. Each resource has its own subdirectory. The subdirectory
7374
names reflect the resource names.
7475

76+
Most of the files in the resource's subdirectory are read-only, and
77+
describe properties of the resource. Resources that support global
78+
configuration options also include writable files that can be used
79+
to modify those settings.
80+
7581
Each subdirectory contains the following files with respect to
7682
allocation:
7783

@@ -90,12 +96,19 @@ related to allocation:
9096
must be set when writing a mask.
9197

9298
"shareable_bits":
93-
Bitmask of shareable resource with other executing
94-
entities (e.g. I/O). User can use this when
95-
setting up exclusive cache partitions. Note that
96-
some platforms support devices that have their
97-
own settings for cache use which can over-ride
98-
these bits.
99+
Bitmask of shareable resource with other executing entities
100+
(e.g. I/O). Applies to all instances of this resource. User
101+
can use this when setting up exclusive cache partitions.
102+
Note that some platforms support devices that have their
103+
own settings for cache use which can over-ride these bits.
104+
105+
When "io_alloc" is enabled, a portion of each cache instance can
106+
be configured for shared use between hardware and software.
107+
"bit_usage" should be used to see which portions of each cache
108+
instance is configured for hardware use via "io_alloc" feature
109+
because every cache instance can have its "io_alloc" bitmask
110+
configured independently via "io_alloc_cbm".
111+
99112
"bit_usage":
100113
Annotated capacity bitmasks showing how all
101114
instances of the resource are used. The legend is:
@@ -109,16 +122,16 @@ related to allocation:
109122
"H":
110123
Corresponding region is used by hardware only
111124
but available for software use. If a resource
112-
has bits set in "shareable_bits" but not all
113-
of these bits appear in the resource groups'
114-
schematas then the bits appearing in
115-
"shareable_bits" but no resource group will
116-
be marked as "H".
125+
has bits set in "shareable_bits" or "io_alloc_cbm"
126+
but not all of these bits appear in the resource
127+
groups' schemata then the bits appearing in
128+
"shareable_bits" or "io_alloc_cbm" but no
129+
resource group will be marked as "H".
117130
"X":
118131
Corresponding region is available for sharing and
119-
used by hardware and software. These are the
120-
bits that appear in "shareable_bits" as
121-
well as a resource group's allocation.
132+
used by hardware and software. These are the bits
133+
that appear in "shareable_bits" or "io_alloc_cbm"
134+
as well as a resource group's allocation.
122135
"S":
123136
Corresponding region is used by software
124137
and available for sharing.
@@ -136,6 +149,77 @@ related to allocation:
136149
"1":
137150
Non-contiguous 1s value in CBM is supported.
138151

152+
"io_alloc":
153+
"io_alloc" enables system software to configure the portion of
154+
the cache allocated for I/O traffic. File may only exist if the
155+
system supports this feature on some of its cache resources.
156+
157+
"disabled":
158+
Resource supports "io_alloc" but the feature is disabled.
159+
Portions of cache used for allocation of I/O traffic cannot
160+
be configured.
161+
"enabled":
162+
Portions of cache used for allocation of I/O traffic
163+
can be configured using "io_alloc_cbm".
164+
"not supported":
165+
Support not available for this resource.
166+
167+
The feature can be modified by writing to the interface, for example:
168+
169+
To enable::
170+
171+
# echo 1 > /sys/fs/resctrl/info/L3/io_alloc
172+
173+
To disable::
174+
175+
# echo 0 > /sys/fs/resctrl/info/L3/io_alloc
176+
177+
The underlying implementation may reduce resources available to
178+
general (CPU) cache allocation. See architecture specific notes
179+
below. Depending on usage requirements the feature can be enabled
180+
or disabled.
181+
182+
On AMD systems, io_alloc feature is supported by the L3 Smart
183+
Data Cache Injection Allocation Enforcement (SDCIAE). The CLOSID for
184+
io_alloc is the highest CLOSID supported by the resource. When
185+
io_alloc is enabled, the highest CLOSID is dedicated to io_alloc and
186+
no longer available for general (CPU) cache allocation. When CDP is
187+
enabled, io_alloc routes I/O traffic using the highest CLOSID allocated
188+
for the instruction cache (CDP_CODE), making this CLOSID no longer
189+
available for general (CPU) cache allocation for both the CDP_CODE
190+
and CDP_DATA resources.
191+
192+
"io_alloc_cbm":
193+
Capacity bitmasks that describe the portions of cache instances to
194+
which I/O traffic from supported I/O devices are routed when "io_alloc"
195+
is enabled.
196+
197+
CBMs are displayed in the following format:
198+
199+
<cache_id0>=<cbm>;<cache_id1>=<cbm>;...
200+
201+
Example::
202+
203+
# cat /sys/fs/resctrl/info/L3/io_alloc_cbm
204+
0=ffff;1=ffff
205+
206+
CBMs can be configured by writing to the interface.
207+
208+
Example::
209+
210+
# echo 1=ff > /sys/fs/resctrl/info/L3/io_alloc_cbm
211+
# cat /sys/fs/resctrl/info/L3/io_alloc_cbm
212+
0=ffff;1=00ff
213+
214+
# echo "0=ff;1=f" > /sys/fs/resctrl/info/L3/io_alloc_cbm
215+
# cat /sys/fs/resctrl/info/L3/io_alloc_cbm
216+
0=00ff;1=000f
217+
218+
When CDP is enabled "io_alloc_cbm" associated with the CDP_DATA and CDP_CODE
219+
resources may reflect the same values. For example, values read from and
220+
written to /sys/fs/resctrl/info/L3DATA/io_alloc_cbm may be reflected by
221+
/sys/fs/resctrl/info/L3CODE/io_alloc_cbm and vice versa.
222+
139223
Memory bandwidth(MB) subdirectory contains the following files
140224
with respect to allocation:
141225

arch/x86/include/asm/cpufeatures.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@
500500
#define X86_FEATURE_ABMC (21*32+15) /* Assignable Bandwidth Monitoring Counters */
501501
#define X86_FEATURE_MSR_IMM (21*32+16) /* MSR immediate form instructions */
502502

503+
#define X86_FEATURE_SDCIAE (21*32+18) /* L3 Smart Data Cache Injection Allocation Enforcement */
504+
503505
/*
504506
* BUG word(s)
505507
*/

arch/x86/kernel/cpu/cpuid-deps.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static const struct cpuid_dep cpuid_deps[] = {
7272
{ X86_FEATURE_CQM_MBM_LOCAL, X86_FEATURE_CQM_LLC },
7373
{ X86_FEATURE_BMEC, X86_FEATURE_CQM_MBM_TOTAL },
7474
{ X86_FEATURE_BMEC, X86_FEATURE_CQM_MBM_LOCAL },
75+
{ X86_FEATURE_SDCIAE, X86_FEATURE_CAT_L3 },
7576
{ X86_FEATURE_AVX512_BF16, X86_FEATURE_AVX512VL },
7677
{ X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW },
7778
{ X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES },

arch/x86/kernel/cpu/resctrl/core.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ static void rdt_get_cdp_config(int level)
274274
rdt_resources_all[level].r_resctrl.cdp_capable = true;
275275
}
276276

277+
static void rdt_set_io_alloc_capable(struct rdt_resource *r)
278+
{
279+
r->cache.io_alloc_capable = true;
280+
}
281+
277282
static void rdt_get_cdp_l3_config(void)
278283
{
279284
rdt_get_cdp_config(RDT_RESOURCE_L3);
@@ -719,6 +724,7 @@ enum {
719724
RDT_FLAG_SMBA,
720725
RDT_FLAG_BMEC,
721726
RDT_FLAG_ABMC,
727+
RDT_FLAG_SDCIAE,
722728
};
723729

724730
#define RDT_OPT(idx, n, f) \
@@ -745,6 +751,7 @@ static struct rdt_options rdt_options[] __ro_after_init = {
745751
RDT_OPT(RDT_FLAG_SMBA, "smba", X86_FEATURE_SMBA),
746752
RDT_OPT(RDT_FLAG_BMEC, "bmec", X86_FEATURE_BMEC),
747753
RDT_OPT(RDT_FLAG_ABMC, "abmc", X86_FEATURE_ABMC),
754+
RDT_OPT(RDT_FLAG_SDCIAE, "sdciae", X86_FEATURE_SDCIAE),
748755
};
749756
#define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options)
750757

@@ -853,6 +860,8 @@ static __init bool get_rdt_alloc_resources(void)
853860
rdt_get_cache_alloc_cfg(1, r);
854861
if (rdt_cpu_has(X86_FEATURE_CDP_L3))
855862
rdt_get_cdp_l3_config();
863+
if (rdt_cpu_has(X86_FEATURE_SDCIAE))
864+
rdt_set_io_alloc_capable(r);
856865
ret = true;
857866
}
858867
if (rdt_cpu_has(X86_FEATURE_CAT_L2)) {

arch/x86/kernel/cpu/resctrl/ctrlmondata.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,43 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
9191

9292
return hw_dom->ctrl_val[idx];
9393
}
94+
95+
bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r)
96+
{
97+
return resctrl_to_arch_res(r)->sdciae_enabled;
98+
}
99+
100+
static void resctrl_sdciae_set_one_amd(void *arg)
101+
{
102+
bool *enable = arg;
103+
104+
if (*enable)
105+
msr_set_bit(MSR_IA32_L3_QOS_EXT_CFG, SDCIAE_ENABLE_BIT);
106+
else
107+
msr_clear_bit(MSR_IA32_L3_QOS_EXT_CFG, SDCIAE_ENABLE_BIT);
108+
}
109+
110+
static void _resctrl_sdciae_enable(struct rdt_resource *r, bool enable)
111+
{
112+
struct rdt_ctrl_domain *d;
113+
114+
/* Walking r->ctrl_domains, ensure it can't race with cpuhp */
115+
lockdep_assert_cpus_held();
116+
117+
/* Update MSR_IA32_L3_QOS_EXT_CFG MSR on all the CPUs in all domains */
118+
list_for_each_entry(d, &r->ctrl_domains, hdr.list)
119+
on_each_cpu_mask(&d->hdr.cpu_mask, resctrl_sdciae_set_one_amd, &enable, 1);
120+
}
121+
122+
int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable)
123+
{
124+
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
125+
126+
if (hw_res->r_resctrl.cache.io_alloc_capable &&
127+
hw_res->sdciae_enabled != enable) {
128+
_resctrl_sdciae_enable(r, enable);
129+
hw_res->sdciae_enabled = enable;
130+
}
131+
132+
return 0;
133+
}

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ struct arch_mbm_state {
4646
#define ABMC_EXTENDED_EVT_ID BIT(31)
4747
#define ABMC_EVT_ID BIT(0)
4848

49+
/* Setting bit 1 in MSR_IA32_L3_QOS_EXT_CFG enables the SDCIAE feature. */
50+
#define SDCIAE_ENABLE_BIT 1
51+
4952
/**
5053
* struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs that share
5154
* a resource for a control function
@@ -112,6 +115,7 @@ struct msr_param {
112115
* @mbm_width: Monitor width, to detect and correct for overflow.
113116
* @cdp_enabled: CDP state of this resource
114117
* @mbm_cntr_assign_enabled: ABMC feature is enabled
118+
* @sdciae_enabled: SDCIAE feature (backing "io_alloc") is enabled.
115119
*
116120
* Members of this structure are either private to the architecture
117121
* e.g. mbm_width, or accessed via helpers that provide abstraction. e.g.
@@ -126,6 +130,7 @@ struct rdt_hw_resource {
126130
unsigned int mbm_width;
127131
bool cdp_enabled;
128132
bool mbm_cntr_assign_enabled;
133+
bool sdciae_enabled;
129134
};
130135

131136
static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r)

arch/x86/kernel/cpu/resctrl/monitor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ static const struct x86_cpu_id snc_cpu_ids[] __initconst = {
361361
X86_MATCH_VFM(INTEL_EMERALDRAPIDS_X, 0),
362362
X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, 0),
363363
X86_MATCH_VFM(INTEL_ATOM_CRESTMONT_X, 0),
364+
X86_MATCH_VFM(INTEL_ATOM_DARKMONT_X, 0),
364365
{}
365366
};
366367

arch/x86/kernel/cpu/scattered.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static const struct cpuid_bit cpuid_bits[] = {
5353
{ X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 },
5454
{ X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 },
5555
{ X86_FEATURE_ABMC, CPUID_EBX, 5, 0x80000020, 0 },
56+
{ X86_FEATURE_SDCIAE, CPUID_EBX, 6, 0x80000020, 0 },
5657
{ X86_FEATURE_TSA_SQ_NO, CPUID_ECX, 1, 0x80000021, 0 },
5758
{ X86_FEATURE_TSA_L1_NO, CPUID_ECX, 2, 0x80000021, 0 },
5859
{ X86_FEATURE_AMD_WORKLOAD_CLASS, CPUID_EAX, 22, 0x80000021, 0 },

0 commit comments

Comments
 (0)