Skip to content

Commit f968dc1

Browse files
rchatreKAGA-KOKO
authored andcommitted
x86/intel_rdt: Fix size reporting of MBA resource
Chen Yu reported a divide-by-zero error when accessing the 'size' resctrl file when a MBA resource is enabled. divide error: 0000 [#1] SMP PTI CPU: 93 PID: 1929 Comm: cat Not tainted 4.19.0-rc2-debug-rdt+ torvalds#25 RIP: 0010:rdtgroup_cbm_to_size+0x7e/0xa0 Call Trace: rdtgroup_size_show+0x11a/0x1d0 seq_read+0xd8/0x3b0 Quoting Chen Yu's report: This is because for MB resource, the r->cache.cbm_len is zero, thus calculating size in rdtgroup_cbm_to_size() will trigger the exception. Fix this issue in the 'size' file by getting correct memory bandwidth value which is in MBps when MBA software controller is enabled or in percentage when MBA software controller is disabled. Fixes: d9b48c8 ("x86/intel_rdt: Display resource groups' allocations in bytes") Reported-by: Chen Yu <yu.c.chen@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Chen Yu <yu.c.chen@intel.com> Cc: "H Peter Anvin" <hpa@zytor.com> Cc: "Tony Luck" <tony.luck@intel.com> Cc: "Xiaochen Shen" <xiaochen.shen@intel.com> Link: https://lkml.kernel.org/r/20180904174614.26682-1-yu.c.chen@intel.com Link: https://lkml.kernel.org/r/1537048707-76280-3-git-send-email-fenghua.yu@intel.com
1 parent 753694a commit f968dc1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

arch/x86/kernel/cpu/intel_rdt_rdtgroup.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,8 +1155,8 @@ static int rdtgroup_size_show(struct kernfs_open_file *of,
11551155
struct rdt_resource *r;
11561156
struct rdt_domain *d;
11571157
unsigned int size;
1158-
bool sep = false;
1159-
u32 cbm;
1158+
bool sep;
1159+
u32 ctrl;
11601160

11611161
rdtgrp = rdtgroup_kn_lock_live(of->kn);
11621162
if (!rdtgrp) {
@@ -1174,15 +1174,21 @@ static int rdtgroup_size_show(struct kernfs_open_file *of,
11741174
}
11751175

11761176
for_each_alloc_enabled_rdt_resource(r) {
1177+
sep = false;
11771178
seq_printf(s, "%*s:", max_name_width, r->name);
11781179
list_for_each_entry(d, &r->domains, list) {
11791180
if (sep)
11801181
seq_putc(s, ';');
11811182
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
11821183
size = 0;
11831184
} else {
1184-
cbm = d->ctrl_val[rdtgrp->closid];
1185-
size = rdtgroup_cbm_to_size(r, d, cbm);
1185+
ctrl = (!is_mba_sc(r) ?
1186+
d->ctrl_val[rdtgrp->closid] :
1187+
d->mbps_val[rdtgrp->closid]);
1188+
if (r->rid == RDT_RESOURCE_MBA)
1189+
size = ctrl;
1190+
else
1191+
size = rdtgroup_cbm_to_size(r, d, ctrl);
11861192
}
11871193
seq_printf(s, "%d=%u", d->id, size);
11881194
sep = true;

0 commit comments

Comments
 (0)