mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fenghua Yu <fenghua.yu@intel.com>
To: "Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>, "H Peter Anvin" <hpa@zytor.com>,
	"Tony Luck" <tony.luck@intel.com>
Cc: "Chatre, Reinette" <reinette.chatre@intel.com>,
	"Xiaochen Shen" <xiaochen.shen@intel.com>,
	"Chen Yu" <yu.c.chen@intel.com>,
	"linux-kernel" <linux-kernel@vger.kernel.org>,
	"x86" <x86@kernel.org>, "Fenghua Yu" <fenghua.yu@intel.com>
Subject: [PATCH 2/9] x86/intel_rdt: Fix size reporting of MBA resource
Date: Fri, 14 Sep 2018 13:32:02 -0700	[thread overview]
Message-ID: <1536957129-70380-3-git-send-email-fenghua.yu@intel.com> (raw)
In-Reply-To: <1536957129-70380-1-git-send-email-fenghua.yu@intel.com>

From: Reinette Chatre <reinette.chatre@intel.com>

Chen Yu reported a divide-by-zero error when accessing the 'size'
resctrl file when a MBA resource is enabled.

[  151.193447] divide error: 0000 [#1] SMP PTI
[  151.197743] CPU: 93 PID: 1929 Comm: cat Not tainted 4.19.0-rc2-debug-rdt+ #25
[  151.205070] Hardware name: Dell Inc. PowerEdge R640/0CRT1G, BIOS 1.3.7 02/08/2018
[  151.212783] RIP: 0010:rdtgroup_cbm_to_size+0x7e/0xa0
[  151.237172] RSP: 0018:ffffb3454f90bd88 EFLAGS: 00010246
[  151.242538] RAX: 00000000023c0000 RBX: 0000000000000000 RCX: 0000000000000003
[  151.249878] RDX: 0000000000000000 RSI: 0000000000000004 RDI: 0000000000000003
[  151.257213] RBP: ffff96ff0089e000 R08: 0000000000000000 R09: 0000000000aaaaaa
[  151.264544] R10: ffffb3454f90bd8c R11: 00000000ffffffff R12: ffffffffb5028910
[  151.271887] R13: ffffffffb5028910 R14: 0000000000000064 R15: ffff96ff0089e000
[  151.279217] FS:  00007f95a623a500(0000) GS:ffff97170f9c0000(0000) knlGS:0000000000000000
[  151.287532] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  151.293432] CR2: 00007f95a6217000 CR3: 00000023f696c003 CR4: 00000000007606e0
[  151.300766] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  151.308094] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  151.315426] PKRU: 55555554
[  151.318212] Call Trace:
[  151.320732]  rdtgroup_size_show+0x11a/0x1d0
[  151.325039]  seq_read+0xd8/0x3b0
[  151.328363]  __vfs_read+0x36/0x170
[  151.331857]  vfs_read+0x89/0x130
[  151.335179]  ksys_read+0x52/0xc0
[  151.338500]  do_syscall_64+0x5b/0x180
[  151.342261]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

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: d9b48c86eb38 ("x86/intel_rdt: Display resource groups' allocations in bytes")
Link: https://lkml.kernel.org/r/20180904174614.26682-1-yu.c.chen@intel.com
Reported-by: Chen Yu <yu.c.chen@intel.com>
Tested-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>
---
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index b799c00bef09..32e8bbdf2400 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -1155,8 +1155,8 @@ static int rdtgroup_size_show(struct kernfs_open_file *of,
 	struct rdt_resource *r;
 	struct rdt_domain *d;
 	unsigned int size;
-	bool sep = false;
-	u32 cbm;
+	bool sep;
+	u32 ctrl;
 
 	rdtgrp = rdtgroup_kn_lock_live(of->kn);
 	if (!rdtgrp) {
@@ -1174,6 +1174,7 @@ static int rdtgroup_size_show(struct kernfs_open_file *of,
 	}
 
 	for_each_alloc_enabled_rdt_resource(r) {
+		sep = false;
 		seq_printf(s, "%*s:", max_name_width, r->name);
 		list_for_each_entry(d, &r->domains, list) {
 			if (sep)
@@ -1181,8 +1182,13 @@ static int rdtgroup_size_show(struct kernfs_open_file *of,
 			if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
 				size = 0;
 			} else {
-				cbm = d->ctrl_val[rdtgrp->closid];
-				size = rdtgroup_cbm_to_size(r, d, cbm);
+				ctrl = (!is_mba_sc(r) ?
+						d->ctrl_val[rdtgrp->closid] :
+						d->mbps_val[rdtgrp->closid]);
+				if (r->rid == RDT_RESOURCE_MBA)
+					size = ctrl;
+				else
+					size = rdtgroup_cbm_to_size(r, d, ctrl);
 			}
 			seq_printf(s, "%d=%u", d->id, size);
 			sep = true;
-- 
2.19.0


  parent reply	other threads:[~2018-09-14 20:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14 20:32 [PATCH 0/9] x86/intel_rdt: MBA integration fixes Fenghua Yu
2018-09-14 20:32 ` [PATCH 1/9] x86/intel_rdt: Fix MBA parsing callback Fenghua Yu
2018-09-15 10:13   ` Thomas Gleixner
2018-09-15 22:27     ` Fenghua Yu
2018-09-14 20:32 ` Fenghua Yu [this message]
2018-09-14 20:32 ` [PATCH 3/9] x86/intel_rdt: Global closid helper to support future fixes Fenghua Yu
2018-09-14 20:32 ` [PATCH 4/9] x86/intel_rdt: Fix invalid mode warning when Fenghua Yu
2018-09-15  4:36   ` Reinette Chatre
2018-09-15  4:47     ` Reinette Chatre
2018-09-15 10:22   ` Thomas Gleixner
2018-09-14 20:32 ` [PATCH 5/9] x86/intel_rdt: Fix unchecked MSR access Fenghua Yu
2018-09-14 20:32 ` [PATCH 6/9] x86/intel_rdt: Do not allow pseudo-locking of MBA resource Fenghua Yu
2018-09-14 20:32 ` [PATCH 7/9] x86/intel_rdt: Fix incorrect loop end condition Fenghua Yu
2018-09-14 20:32 ` [PATCH 8/9] x86/intel_rdt: Fix exclusive mode handling of MBA resource Fenghua Yu
2018-09-14 20:32 ` [PATCH 9/9] x86/intel_rdt: Fix incorrect loop end condition Fenghua Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1536957129-70380-3-git-send-email-fenghua.yu@intel.com \
    --to=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=reinette.chatre@intel.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=xiaochen.shen@intel.com \
    --cc=yu.c.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®