Skip to content

Commit 9ab021a

Browse files
committed
Merge tag 'x86_cache_for_6.7_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 resource control updates from Borislav Petkov: - Add support for non-contiguous capacity bitmasks being added to Intel's CAT implementation - Other improvements to resctrl code: better configuration, simplifications, debugging support, fixes * tag 'x86_cache_for_6.7_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/resctrl: Display RMID of resource group x86/resctrl: Add support for the files of MON groups only x86/resctrl: Display CLOSID for resource group x86/resctrl: Introduce "-o debug" mount option x86/resctrl: Move default group file creation to mount x86/resctrl: Unwind properly from rdt_enable_ctx() x86/resctrl: Rename rftype flags for consistency x86/resctrl: Simplify rftype flag definitions x86/resctrl: Add multiple tasks to the resctrl group at once Documentation/x86: Document resctrl's new sparse_masks x86/resctrl: Add sparse_masks file in info x86/resctrl: Enable non-contiguous CBMs in Intel CAT x86/resctrl: Rename arch_has_sparse_bitmaps x86/resctrl: Fix remaining kernel-doc warnings
2 parents f84a52e + 4cee14b commit 9ab021a

File tree

6 files changed

+276
-103
lines changed

6 files changed

+276
-103
lines changed

Documentation/arch/x86/resctrl.rst

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ about the feature from resctrl's info directory.
3535

3636
To use the feature mount the file system::
3737

38-
# mount -t resctrl resctrl [-o cdp[,cdpl2][,mba_MBps]] /sys/fs/resctrl
38+
# mount -t resctrl resctrl [-o cdp[,cdpl2][,mba_MBps][,debug]] /sys/fs/resctrl
3939

4040
mount options are:
4141

@@ -46,6 +46,9 @@ mount options are:
4646
"mba_MBps":
4747
Enable the MBA Software Controller(mba_sc) to specify MBA
4848
bandwidth in MBps
49+
"debug":
50+
Make debug files accessible. Available debug files are annotated with
51+
"Available only with debug option".
4952

5053
L2 and L3 CDP are controlled separately.
5154

@@ -124,6 +127,13 @@ related to allocation:
124127
"P":
125128
Corresponding region is pseudo-locked. No
126129
sharing allowed.
130+
"sparse_masks":
131+
Indicates if non-contiguous 1s value in CBM is supported.
132+
133+
"0":
134+
Only contiguous 1s value in CBM is supported.
135+
"1":
136+
Non-contiguous 1s value in CBM is supported.
127137

128138
Memory bandwidth(MB) subdirectory contains the following files
129139
with respect to allocation:
@@ -299,7 +309,14 @@ All groups contain the following files:
299309
"tasks":
300310
Reading this file shows the list of all tasks that belong to
301311
this group. Writing a task id to the file will add a task to the
302-
group. If the group is a CTRL_MON group the task is removed from
312+
group. Multiple tasks can be added by separating the task ids
313+
with commas. Tasks will be assigned sequentially. Multiple
314+
failures are not supported. A single failure encountered while
315+
attempting to assign a task will cause the operation to abort and
316+
already added tasks before the failure will remain in the group.
317+
Failures will be logged to /sys/fs/resctrl/info/last_cmd_status.
318+
319+
If the group is a CTRL_MON group the task is removed from
303320
whichever previous CTRL_MON group owned the task and also from
304321
any MON group that owned the task. If the group is a MON group,
305322
then the task must already belong to the CTRL_MON parent of this
@@ -342,6 +359,10 @@ When control is enabled all CTRL_MON groups will also contain:
342359
file. On successful pseudo-locked region creation the mode will
343360
automatically change to "pseudo-locked".
344361

362+
"ctrl_hw_id":
363+
Available only with debug option. The identifier used by hardware
364+
for the control group. On x86 this is the CLOSID.
365+
345366
When monitoring is enabled all MON groups will also contain:
346367

347368
"mon_data":
@@ -355,6 +376,10 @@ When monitoring is enabled all MON groups will also contain:
355376
the sum for all tasks in the CTRL_MON group and all tasks in
356377
MON groups. Please see example section for more details on usage.
357378

379+
"mon_hw_id":
380+
Available only with debug option. The identifier used by hardware
381+
for the monitor group. On x86 this is the RMID.
382+
358383
Resource allocation rules
359384
-------------------------
360385

@@ -445,12 +470,13 @@ For cache resources we describe the portion of the cache that is available
445470
for allocation using a bitmask. The maximum value of the mask is defined
446471
by each cpu model (and may be different for different cache levels). It
447472
is found using CPUID, but is also provided in the "info" directory of
448-
the resctrl file system in "info/{resource}/cbm_mask". Intel hardware
473+
the resctrl file system in "info/{resource}/cbm_mask". Some Intel hardware
449474
requires that these masks have all the '1' bits in a contiguous block. So
450475
0x3, 0x6 and 0xC are legal 4-bit masks with two bits set, but 0x5, 0x9
451-
and 0xA are not. On a system with a 20-bit mask each bit represents 5%
452-
of the capacity of the cache. You could partition the cache into four
453-
equal parts with masks: 0x1f, 0x3e0, 0x7c00, 0xf8000.
476+
and 0xA are not. Check /sys/fs/resctrl/info/{resource}/sparse_masks
477+
if non-contiguous 1s value is supported. On a system with a 20-bit mask
478+
each bit represents 5% of the capacity of the cache. You could partition
479+
the cache into four equal parts with masks: 0x1f, 0x3e0, 0x7c00, 0xf8000.
454480

455481
Memory bandwidth Allocation and monitoring
456482
==========================================

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ static inline void cache_alloc_hsw_probe(void)
152152
r->cache.cbm_len = 20;
153153
r->cache.shareable_bits = 0xc0000;
154154
r->cache.min_cbm_bits = 2;
155+
r->cache.arch_has_sparse_bitmasks = false;
155156
r->alloc_capable = true;
156157

157158
rdt_alloc_capable = true;
@@ -267,15 +268,18 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r)
267268
{
268269
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
269270
union cpuid_0x10_1_eax eax;
271+
union cpuid_0x10_x_ecx ecx;
270272
union cpuid_0x10_x_edx edx;
271-
u32 ebx, ecx;
273+
u32 ebx;
272274

273-
cpuid_count(0x00000010, idx, &eax.full, &ebx, &ecx, &edx.full);
275+
cpuid_count(0x00000010, idx, &eax.full, &ebx, &ecx.full, &edx.full);
274276
hw_res->num_closid = edx.split.cos_max + 1;
275277
r->cache.cbm_len = eax.split.cbm_len + 1;
276278
r->default_ctrl = BIT_MASK(eax.split.cbm_len + 1) - 1;
277279
r->cache.shareable_bits = ebx & r->default_ctrl;
278280
r->data_width = (r->cache.cbm_len + 3) / 4;
281+
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
282+
r->cache.arch_has_sparse_bitmasks = ecx.split.noncont;
279283
r->alloc_capable = true;
280284
}
281285

@@ -872,7 +876,6 @@ static __init void rdt_init_res_defs_intel(void)
872876

873877
if (r->rid == RDT_RESOURCE_L3 ||
874878
r->rid == RDT_RESOURCE_L2) {
875-
r->cache.arch_has_sparse_bitmaps = false;
876879
r->cache.arch_has_per_cpu_cfg = false;
877880
r->cache.min_cbm_bits = 1;
878881
} else if (r->rid == RDT_RESOURCE_MBA) {
@@ -892,7 +895,7 @@ static __init void rdt_init_res_defs_amd(void)
892895

893896
if (r->rid == RDT_RESOURCE_L3 ||
894897
r->rid == RDT_RESOURCE_L2) {
895-
r->cache.arch_has_sparse_bitmaps = true;
898+
r->cache.arch_has_sparse_bitmasks = true;
896899
r->cache.arch_has_per_cpu_cfg = true;
897900
r->cache.min_cbm_bits = 0;
898901
} else if (r->rid == RDT_RESOURCE_MBA) {

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,
8787

8888
/*
8989
* Check whether a cache bit mask is valid.
90-
* For Intel the SDM says:
91-
* Please note that all (and only) contiguous '1' combinations
92-
* are allowed (e.g. FFFFH, 0FF0H, 003CH, etc.).
93-
* Additionally Haswell requires at least two bits set.
90+
* On Intel CPUs, non-contiguous 1s value support is indicated by CPUID:
91+
* - CPUID.0x10.1:ECX[3]: L3 non-contiguous 1s value supported if 1
92+
* - CPUID.0x10.2:ECX[3]: L2 non-contiguous 1s value supported if 1
93+
*
94+
* Haswell does not support a non-contiguous 1s value and additionally
95+
* requires at least two bits set.
9496
* AMD allows non-contiguous bitmasks.
9597
*/
9698
static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
@@ -113,8 +115,8 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
113115
first_bit = find_first_bit(&val, cbm_len);
114116
zero_bit = find_next_zero_bit(&val, cbm_len, first_bit);
115117

116-
/* Are non-contiguous bitmaps allowed? */
117-
if (!r->cache.arch_has_sparse_bitmaps &&
118+
/* Are non-contiguous bitmasks allowed? */
119+
if (!r->cache.arch_has_sparse_bitmasks &&
118120
(find_next_bit(&val, cbm_len, zero_bit) < cbm_len)) {
119121
rdt_last_cmd_printf("The mask %lx has non-consecutive 1-bits\n", val);
120122
return false;

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct rdt_fs_context {
5959
bool enable_cdpl2;
6060
bool enable_cdpl3;
6161
bool enable_mba_mbps;
62+
bool enable_debug;
6263
};
6364

6465
static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
@@ -243,18 +244,17 @@ struct rdtgroup {
243244
*/
244245
#define RFTYPE_INFO BIT(0)
245246
#define RFTYPE_BASE BIT(1)
246-
#define RF_CTRLSHIFT 4
247-
#define RF_MONSHIFT 5
248-
#define RF_TOPSHIFT 6
249-
#define RFTYPE_CTRL BIT(RF_CTRLSHIFT)
250-
#define RFTYPE_MON BIT(RF_MONSHIFT)
251-
#define RFTYPE_TOP BIT(RF_TOPSHIFT)
247+
#define RFTYPE_CTRL BIT(4)
248+
#define RFTYPE_MON BIT(5)
249+
#define RFTYPE_TOP BIT(6)
252250
#define RFTYPE_RES_CACHE BIT(8)
253251
#define RFTYPE_RES_MB BIT(9)
254-
#define RF_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL)
255-
#define RF_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
256-
#define RF_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
257-
#define RF_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
252+
#define RFTYPE_DEBUG BIT(10)
253+
#define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL)
254+
#define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
255+
#define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
256+
#define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
257+
#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON)
258258

259259
/* List of all resource groups */
260260
extern struct list_head rdt_all_groups;
@@ -270,7 +270,7 @@ void __exit rdtgroup_exit(void);
270270
* @mode: Access mode
271271
* @kf_ops: File operations
272272
* @flags: File specific RFTYPE_FLAGS_* flags
273-
* @fflags: File specific RF_* or RFTYPE_* flags
273+
* @fflags: File specific RFTYPE_* flags
274274
* @seq_show: Show content of the file
275275
* @write: Write to the file
276276
*/
@@ -492,6 +492,15 @@ union cpuid_0x10_3_eax {
492492
unsigned int full;
493493
};
494494

495+
/* CPUID.(EAX=10H, ECX=ResID).ECX */
496+
union cpuid_0x10_x_ecx {
497+
struct {
498+
unsigned int reserved:3;
499+
unsigned int noncont:1;
500+
} split;
501+
unsigned int full;
502+
};
503+
495504
/* CPUID.(EAX=10H, ECX=ResID).EDX */
496505
union cpuid_0x10_x_edx {
497506
struct {

0 commit comments

Comments
 (0)