From: Vikas Shivappa <vikas.shivappa@linux.intel.com>
To: vikas.shivappa@intel.com, tony.luck@intel.com,
ravi.v.shankar@intel.com, fenghua.yu@intel.com,
sai.praneeth.prakhya@intel.com, x86@kernel.org,
tglx@linutronix.de, hpa@zytor.com
Cc: linux-kernel@vger.kernel.org, ak@linux.intel.com,
vikas.shivappa@linux.intel.com
Subject: [PATCH 5/6] x86/intel_rdt/mba_sc: Add counting for MBA software controller
Date: Thu, 29 Mar 2018 15:26:15 -0700 [thread overview]
Message-ID: <1522362376-3505-6-git-send-email-vikas.shivappa@linux.intel.com> (raw)
In-Reply-To: <1522362376-3505-1-git-send-email-vikas.shivappa@linux.intel.com>
Currently we store the per package "total bytes" for each rdtgroup for
Memory bandwidth management which exposed via
"/sys/fs/resctrl/<rdtgrpx>/mon_data/mon_L3_00/mbm_local_bytes".
The above user interface remains while we also add support to measure
the per package b/w in Megabytes and the delta b/w when the b/w MSR
values change. We do this by taking the time stamp every time a the
counter is read and then keeping a history of b/w. This will be used to
support internal queries for the bandwidth in Megabytes.
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
---
arch/x86/kernel/cpu/intel_rdt.c | 1 -
arch/x86/kernel/cpu/intel_rdt.h | 24 ++++++++++++++++++++--
arch/x86/kernel/cpu/intel_rdt_monitor.c | 36 +++++++++++++++++++++++++++------
3 files changed, 52 insertions(+), 9 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
index 8a12d26..78beb64 100644
--- a/arch/x86/kernel/cpu/intel_rdt.c
+++ b/arch/x86/kernel/cpu/intel_rdt.c
@@ -33,7 +33,6 @@
#include <asm/intel_rdt_sched.h>
#include "intel_rdt.h"
-#define MAX_MBA_BW 100u
#define MBA_IS_LINEAR 0x4
#define MBA_BW_MAX_MB U32_MAX
diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h
index 68c7da0..b74619d 100644
--- a/arch/x86/kernel/cpu/intel_rdt.h
+++ b/arch/x86/kernel/cpu/intel_rdt.h
@@ -28,6 +28,18 @@
#define MBM_CNTR_WIDTH 24
#define MBM_OVERFLOW_INTERVAL 1000
+#define MAX_MBA_BW 100u
+
+/*
+ * This measures a tolerable delta value in MegaBytes between
+ * the expected bandwidth and the actual bandwidth.
+ * This is done so that we dont keep flipping the control
+ * bandwidth to more than and less than the expected bandwidth.
+ *
+ * However note that this is only initial threshold value and
+ * it is adjusted dynamically package wise for each rdtgrp
+ */
+#define MBA_BW_MB_THRSHL 1024
#define RMID_VAL_ERROR BIT_ULL(63)
#define RMID_VAL_UNAVAIL BIT_ULL(62)
@@ -180,10 +192,18 @@ struct rftype {
* struct mbm_state - status for each MBM counter in each domain
* @chunks: Total data moved (multiply by rdt_group.mon_scale to get bytes)
* @prev_msr Value of IA32_QM_CTR for this RMID last time we read it
+ * @prev_read_time:The last time counter was read
+ * @prev_bw: The most recent bandwidth in Megabytes
+ * @delta_bw: Difference between the current b/w and previous b/w
+ * @threshl_calib: Indicates when to calculate the delta_bw
*/
struct mbm_state {
- u64 chunks;
- u64 prev_msr;
+ u64 chunks;
+ u64 prev_msr;
+ unsigned long prev_read_time;
+ u64 prev_bw;
+ u64 delta_bw;
+ bool thrshl_calib;
};
/**
diff --git a/arch/x86/kernel/cpu/intel_rdt_monitor.c b/arch/x86/kernel/cpu/intel_rdt_monitor.c
index 681450e..509f338 100644
--- a/arch/x86/kernel/cpu/intel_rdt_monitor.c
+++ b/arch/x86/kernel/cpu/intel_rdt_monitor.c
@@ -225,9 +225,11 @@ void free_rmid(u32 rmid)
list_add_tail(&entry->list, &rmid_free_lru);
}
-static int __mon_event_count(u32 rmid, struct rmid_read *rr)
+static int __mon_event_count(u32 rmid, struct rmid_read *rr, struct mbm_state **md)
{
- u64 chunks, shift, tval;
+ struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3];
+ u64 chunks, shift, tval, cur_bw = 0;
+ unsigned long delta_time, now;
struct mbm_state *m;
tval = __rmid_read(rmid, rr->evtid);
@@ -256,6 +258,9 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr)
if (rr->first) {
m->prev_msr = tval;
m->chunks = 0;
+ m->prev_read_time = jiffies;
+ m->prev_bw = 0;
+ m->delta_bw = MBA_BW_MB_THRSHL;
return 0;
}
@@ -266,6 +271,24 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr)
m->prev_msr = tval;
rr->val += m->chunks;
+
+ if(!md)
+ goto out;
+
+ now = jiffies;
+ delta_time = jiffies_to_usecs(now - m->prev_read_time);
+ if (delta_time)
+ cur_bw = (chunks * r->mon_scale) / delta_time;
+
+ if (m->thrshl_calib)
+ m->delta_bw = abs(cur_bw - m->prev_bw);
+ m->thrshl_calib = false;
+ m->prev_bw = cur_bw;
+ m->prev_read_time = now;
+
+ *md = m;
+out:
+
return 0;
}
@@ -281,7 +304,7 @@ void mon_event_count(void *info)
rdtgrp = rr->rgrp;
- if (__mon_event_count(rdtgrp->mon.rmid, rr))
+ if (__mon_event_count(rdtgrp->mon.rmid, rr, NULL))
return;
/*
@@ -291,7 +314,7 @@ void mon_event_count(void *info)
if (rdtgrp->type == RDTCTRL_GROUP) {
list_for_each_entry(entry, head, mon.crdtgrp_list) {
- if (__mon_event_count(entry->mon.rmid, rr))
+ if (__mon_event_count(entry->mon.rmid, rr, NULL))
return;
}
}
@@ -299,6 +322,7 @@ void mon_event_count(void *info)
static void mbm_update(struct rdt_domain *d, int rmid)
{
+
struct rmid_read rr;
rr.first = false;
@@ -310,11 +334,11 @@ static void mbm_update(struct rdt_domain *d, int rmid)
*/
if (is_mbm_total_enabled()) {
rr.evtid = QOS_L3_MBM_TOTAL_EVENT_ID;
- __mon_event_count(rmid, &rr);
+ __mon_event_count(rmid, &rr, NULL);
}
if (is_mbm_local_enabled()) {
rr.evtid = QOS_L3_MBM_LOCAL_EVENT_ID;
- __mon_event_count(rmid, &rr);
+ __mon_event_count(rmid, &rr, NULL);
}
}
--
1.9.1
next prev parent reply other threads:[~2018-03-29 22:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-29 22:26 [PATCH RFC 0/6] Memory b/w allocation software controller Vikas Shivappa
2018-03-29 22:26 ` [PATCH 1/6] x86/intel_rdt/mba_sc: Add documentation for MBA " Vikas Shivappa
2018-04-03 9:46 ` Thomas Gleixner
2018-04-03 14:29 ` Thomas Gleixner
2018-04-03 18:49 ` Shivappa Vikas
2018-04-04 9:30 ` Thomas Gleixner
2018-04-03 18:45 ` Shivappa Vikas
2018-04-04 9:11 ` Thomas Gleixner
2018-04-04 18:56 ` Shivappa Vikas
2018-03-29 22:26 ` [PATCH 2/6] x86/intel_rdt/mba_sc: Add support to enable/disable via mount option Vikas Shivappa
2018-03-30 9:32 ` Thomas Gleixner
2018-03-30 17:19 ` Shivappa Vikas
2018-03-29 22:26 ` [PATCH 3/6] x86/intel_rdt/mba_sc: Add initialization support Vikas Shivappa
2018-04-03 9:52 ` Thomas Gleixner
2018-04-03 18:51 ` Shivappa Vikas
2018-03-29 22:26 ` [PATCH 4/6] x86/intel_rdt/mba_sc: Add schemata support Vikas Shivappa
2018-03-29 22:26 ` Vikas Shivappa [this message]
2018-03-29 22:26 ` [PATCH 6/6] x86/intel_rdt/mba_sc: Add support to dynamically update the memory b/w Vikas Shivappa
2018-03-30 21:21 ` kbuild test robot
2018-03-31 1:37 ` kbuild test robot
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=1522362376-3505-6-git-send-email-vikas.shivappa@linux.intel.com \
--to=vikas.shivappa@linux.intel.com \
--cc=ak@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ravi.v.shankar@intel.com \
--cc=sai.praneeth.prakhya@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=vikas.shivappa@intel.com \
--cc=x86@kernel.org \
/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