Skip to content

Commit 3643b7e

Browse files
committed
Merge branch 'x86-cache-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 cache resource updates from Thomas Gleixner: "This update provides updates to RDT: - A diagnostic framework for the Resource Director Technology (RDT) user interface (sysfs). The failure modes of the user interface are hard to diagnose from the error codes. An extra last command status file provides now sensible textual information about the failure so its simpler to use. - A few minor cleanups and updates in the RDT code" * 'x86-cache-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/intel_rdt: Fix a silent failure when writing zero value schemata x86/intel_rdt: Fix potential deadlock during resctrl mount x86/intel_rdt: Fix potential deadlock during resctrl unmount x86/intel_rdt: Initialize bitmask of shareable resource if CDP enabled x86/intel_rdt: Remove redundant assignment x86/intel_rdt/cqm: Make integer rmid_limbo_count static x86/intel_rdt: Add documentation for "info/last_cmd_status" x86/intel_rdt: Add diagnostics when making directories x86/intel_rdt: Add diagnostics when writing the cpus file x86/intel_rdt: Add diagnostics when writing the tasks file x86/intel_rdt: Add diagnostics when writing the schemata file x86/intel_rdt: Add framework for better RDT UI diagnostics
2 parents b18d628 + 2244645 commit 3643b7e

File tree

6 files changed

+170
-32
lines changed

6 files changed

+170
-32
lines changed

Documentation/x86/intel_rdt_ui.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ with the following files:
8787
bytes) at which a previously used LLC_occupancy
8888
counter can be considered for re-use.
8989

90+
Finally, in the top level of the "info" directory there is a file
91+
named "last_cmd_status". This is reset with every "command" issued
92+
via the file system (making new directories or writing to any of the
93+
control files). If the command was successful, it will read as "ok".
94+
If the command failed, it will provide more information that can be
95+
conveyed in the error returns from file operations. E.g.
96+
97+
# echo L3:0=f7 > schemata
98+
bash: echo: write error: Invalid argument
99+
# cat info/last_cmd_status
100+
mask f7 has non-consecutive 1-bits
90101

91102
Resource alloc and monitor groups
92103
---------------------------------

arch/x86/kernel/cpu/intel_rdt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ static void rdt_get_cdp_l3_config(int type)
267267
r->num_closid = r_l3->num_closid / 2;
268268
r->cache.cbm_len = r_l3->cache.cbm_len;
269269
r->default_ctrl = r_l3->default_ctrl;
270+
r->cache.shareable_bits = r_l3->cache.shareable_bits;
270271
r->data_width = (r->cache.cbm_len + 3) / 4;
271272
r->alloc_capable = true;
272273
/*

arch/x86/kernel/cpu/intel_rdt.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,15 @@ struct rdtgroup {
127127
#define RFTYPE_BASE BIT(1)
128128
#define RF_CTRLSHIFT 4
129129
#define RF_MONSHIFT 5
130+
#define RF_TOPSHIFT 6
130131
#define RFTYPE_CTRL BIT(RF_CTRLSHIFT)
131132
#define RFTYPE_MON BIT(RF_MONSHIFT)
133+
#define RFTYPE_TOP BIT(RF_TOPSHIFT)
132134
#define RFTYPE_RES_CACHE BIT(8)
133135
#define RFTYPE_RES_MB BIT(9)
134136
#define RF_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL)
135137
#define RF_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
138+
#define RF_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
136139
#define RF_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
137140

138141
/* List of all resource groups */
@@ -409,6 +412,10 @@ union cpuid_0x10_x_edx {
409412
unsigned int full;
410413
};
411414

415+
void rdt_last_cmd_clear(void);
416+
void rdt_last_cmd_puts(const char *s);
417+
void rdt_last_cmd_printf(const char *fmt, ...);
418+
412419
void rdt_ctrl_update(void *arg);
413420
struct rdtgroup *rdtgroup_kn_lock_live(struct kernfs_node *kn);
414421
void rdtgroup_kn_unlock(struct kernfs_node *kn);

arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,22 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
4242
/*
4343
* Only linear delay values is supported for current Intel SKUs.
4444
*/
45-
if (!r->membw.delay_linear)
45+
if (!r->membw.delay_linear) {
46+
rdt_last_cmd_puts("No support for non-linear MB domains\n");
4647
return false;
48+
}
4749

4850
ret = kstrtoul(buf, 10, &bw);
49-
if (ret)
51+
if (ret) {
52+
rdt_last_cmd_printf("Non-decimal digit in MB value %s\n", buf);
5053
return false;
54+
}
5155

52-
if (bw < r->membw.min_bw || bw > r->default_ctrl)
56+
if (bw < r->membw.min_bw || bw > r->default_ctrl) {
57+
rdt_last_cmd_printf("MB value %ld out of range [%d,%d]\n", bw,
58+
r->membw.min_bw, r->default_ctrl);
5359
return false;
60+
}
5461

5562
*data = roundup(bw, (unsigned long)r->membw.bw_gran);
5663
return true;
@@ -60,8 +67,10 @@ int parse_bw(char *buf, struct rdt_resource *r, struct rdt_domain *d)
6067
{
6168
unsigned long data;
6269

63-
if (d->have_new_ctrl)
70+
if (d->have_new_ctrl) {
71+
rdt_last_cmd_printf("duplicate domain %d\n", d->id);
6472
return -EINVAL;
73+
}
6574

6675
if (!bw_validate(buf, &data, r))
6776
return -EINVAL;
@@ -84,20 +93,29 @@ static bool cbm_validate(char *buf, unsigned long *data, struct rdt_resource *r)
8493
int ret;
8594

8695
ret = kstrtoul(buf, 16, &val);
87-
if (ret)
96+
if (ret) {
97+
rdt_last_cmd_printf("non-hex character in mask %s\n", buf);
8898
return false;
99+
}
89100

90-
if (val == 0 || val > r->default_ctrl)
101+
if (val == 0 || val > r->default_ctrl) {
102+
rdt_last_cmd_puts("mask out of range\n");
91103
return false;
104+
}
92105

93106
first_bit = find_first_bit(&val, cbm_len);
94107
zero_bit = find_next_zero_bit(&val, cbm_len, first_bit);
95108

96-
if (find_next_bit(&val, cbm_len, zero_bit) < cbm_len)
109+
if (find_next_bit(&val, cbm_len, zero_bit) < cbm_len) {
110+
rdt_last_cmd_printf("mask %lx has non-consecutive 1-bits\n", val);
97111
return false;
112+
}
98113

99-
if ((zero_bit - first_bit) < r->cache.min_cbm_bits)
114+
if ((zero_bit - first_bit) < r->cache.min_cbm_bits) {
115+
rdt_last_cmd_printf("Need at least %d bits in mask\n",
116+
r->cache.min_cbm_bits);
100117
return false;
118+
}
101119

102120
*data = val;
103121
return true;
@@ -111,8 +129,10 @@ int parse_cbm(char *buf, struct rdt_resource *r, struct rdt_domain *d)
111129
{
112130
unsigned long data;
113131

114-
if (d->have_new_ctrl)
132+
if (d->have_new_ctrl) {
133+
rdt_last_cmd_printf("duplicate domain %d\n", d->id);
115134
return -EINVAL;
135+
}
116136

117137
if(!cbm_validate(buf, &data, r))
118138
return -EINVAL;
@@ -139,8 +159,10 @@ static int parse_line(char *line, struct rdt_resource *r)
139159
return 0;
140160
dom = strsep(&line, ";");
141161
id = strsep(&dom, "=");
142-
if (!dom || kstrtoul(id, 10, &dom_id))
162+
if (!dom || kstrtoul(id, 10, &dom_id)) {
163+
rdt_last_cmd_puts("Missing '=' or non-numeric domain\n");
143164
return -EINVAL;
165+
}
144166
dom = strim(dom);
145167
list_for_each_entry(d, &r->domains, list) {
146168
if (d->id == dom_id) {
@@ -196,6 +218,7 @@ static int rdtgroup_parse_resource(char *resname, char *tok, int closid)
196218
if (!strcmp(resname, r->name) && closid < r->num_closid)
197219
return parse_line(tok, r);
198220
}
221+
rdt_last_cmd_printf("unknown/unsupported resource name '%s'\n", resname);
199222
return -EINVAL;
200223
}
201224

@@ -218,6 +241,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
218241
rdtgroup_kn_unlock(of->kn);
219242
return -ENOENT;
220243
}
244+
rdt_last_cmd_clear();
221245

222246
closid = rdtgrp->closid;
223247

@@ -229,6 +253,12 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
229253
while ((tok = strsep(&buf, "\n")) != NULL) {
230254
resname = strim(strsep(&tok, ":"));
231255
if (!tok) {
256+
rdt_last_cmd_puts("Missing ':'\n");
257+
ret = -EINVAL;
258+
goto out;
259+
}
260+
if (tok[0] == '\0') {
261+
rdt_last_cmd_printf("Missing '%s' value\n", resname);
232262
ret = -EINVAL;
233263
goto out;
234264
}

arch/x86/kernel/cpu/intel_rdt_monitor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static LIST_HEAD(rmid_free_lru);
5151
* may have a occupancy value > intel_cqm_threshold. User can change
5252
* the threshold occupancy value.
5353
*/
54-
unsigned int rmid_limbo_count;
54+
static unsigned int rmid_limbo_count;
5555

5656
/**
5757
* @rmid_entry - The entry in the limbo and free lists.

0 commit comments

Comments
 (0)