From: tip-bot for Tony Luck <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, vikas.shivappa@linux.intel.com,
hpa@zytor.com, mingo@kernel.org, tony.luck@intel.com,
linux-kernel@vger.kernel.org
Subject: [tip:x86/cache] x86/intel_rdt/mbm: Basic counting of MBM events (total and local)
Date: Tue, 1 Aug 2017 13:56:20 -0700 [thread overview]
Message-ID: <tip-9f52425ba303d91c8370719e91d7e578bfdf309f@git.kernel.org> (raw)
In-Reply-To: <1501017287-28083-27-git-send-email-vikas.shivappa@linux.intel.com>
Commit-ID: 9f52425ba303d91c8370719e91d7e578bfdf309f
Gitweb: http://git.kernel.org/tip/9f52425ba303d91c8370719e91d7e578bfdf309f
Author: Tony Luck <tony.luck@intel.com>
AuthorDate: Tue, 25 Jul 2017 14:14:45 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 1 Aug 2017 22:41:28 +0200
x86/intel_rdt/mbm: Basic counting of MBM events (total and local)
Check CPUID bits for whether each of the MBM events is supported.
Allocate space for each RMID for each counter in each domain to save
previous MSR counter value and running total of data.
Create files in each of the monitor directories.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: ravi.v.shankar@intel.com
Cc: fenghua.yu@intel.com
Cc: peterz@infradead.org
Cc: eranian@google.com
Cc: vikas.shivappa@intel.com
Cc: ak@linux.intel.com
Cc: davidcc@google.com
Cc: reinette.chatre@intel.com
Link: http://lkml.kernel.org/r/1501017287-28083-27-git-send-email-vikas.shivappa@linux.intel.com
---
arch/x86/kernel/cpu/intel_rdt.c | 23 +++++++++++++++++++-
arch/x86/kernel/cpu/intel_rdt.h | 33 +++++++++++++++++++++++++++++
arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 1 +
arch/x86/kernel/cpu/intel_rdt_monitor.c | 31 ++++++++++++++++++++++++++-
4 files changed, 86 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
index f12bb91..4c17a70 100644
--- a/arch/x86/kernel/cpu/intel_rdt.c
+++ b/arch/x86/kernel/cpu/intel_rdt.c
@@ -420,6 +420,8 @@ static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_domain *d)
static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_domain *d)
{
+ size_t tsize;
+
if (is_llc_occupancy_enabled()) {
d->rmid_busy_llc = kcalloc(BITS_TO_LONGS(r->num_rmid),
sizeof(unsigned long),
@@ -427,6 +429,23 @@ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_domain *d)
if (!d->rmid_busy_llc)
return -ENOMEM;
}
+ if (is_mbm_total_enabled()) {
+ tsize = sizeof(*d->mbm_total);
+ d->mbm_total = kcalloc(r->num_rmid, tsize, GFP_KERNEL);
+ if (!d->mbm_total) {
+ kfree(d->rmid_busy_llc);
+ return -ENOMEM;
+ }
+ }
+ if (is_mbm_local_enabled()) {
+ tsize = sizeof(*d->mbm_local);
+ d->mbm_local = kcalloc(r->num_rmid, tsize, GFP_KERNEL);
+ if (!d->mbm_local) {
+ kfree(d->rmid_busy_llc);
+ kfree(d->mbm_total);
+ return -ENOMEM;
+ }
+ }
return 0;
}
@@ -466,6 +485,7 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r)
return;
d->id = id;
+ cpumask_set_cpu(cpu, &d->cpu_mask);
if (r->alloc_capable && domain_setup_ctrlval(r, d)) {
kfree(d);
@@ -477,7 +497,6 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r)
return;
}
- cpumask_set_cpu(cpu, &d->cpu_mask);
list_add_tail(&d->list, add_pos);
/*
@@ -509,6 +528,8 @@ static void domain_remove_cpu(int cpu, struct rdt_resource *r)
rmdir_mondata_subdir_allrdtgrp(r, d->id);
kfree(d->ctrl_val);
kfree(d->rmid_busy_llc);
+ kfree(d->mbm_total);
+ kfree(d->mbm_local);
list_del(&d->list);
kfree(d);
}
diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h
index 2660d15..2137d5e 100644
--- a/arch/x86/kernel/cpu/intel_rdt.h
+++ b/arch/x86/kernel/cpu/intel_rdt.h
@@ -19,6 +19,9 @@
#define QOS_L3_OCCUP_EVENT_ID 0x01
#define QOS_L3_MBM_TOTAL_EVENT_ID 0x02
#define QOS_L3_MBM_LOCAL_EVENT_ID 0x03
+
+#define MBM_CNTR_WIDTH 24
+
#define RMID_VAL_ERROR BIT_ULL(63)
#define RMID_VAL_UNAVAIL BIT_ULL(62)
@@ -50,6 +53,7 @@ union mon_data_bits {
struct rmid_read {
struct rdtgroup *rgrp;
+ struct rdt_domain *d;
int evtid;
u64 val;
};
@@ -160,12 +164,24 @@ 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
+ */
+struct mbm_state {
+ u64 chunks;
+ u64 prev_msr;
+};
+
+/**
* struct rdt_domain - group of cpus sharing an RDT resource
* @list: all instances of this resource
* @id: unique id for this instance
* @cpu_mask: which cpus share this resource
* @rmid_busy_llc:
* bitmap of which limbo RMIDs are above threshold
+ * @mbm_total: saved state for MBM total bandwidth
+ * @mbm_local: saved state for MBM local bandwidth
* @ctrl_val: array of cache or mem ctrl values (indexed by CLOSID)
* @new_ctrl: new ctrl value to be loaded
* @have_new_ctrl: did user provide new_ctrl for this domain
@@ -175,6 +191,8 @@ struct rdt_domain {
int id;
struct cpumask cpu_mask;
unsigned long *rmid_busy_llc;
+ struct mbm_state *mbm_total;
+ struct mbm_state *mbm_local;
u32 *ctrl_val;
u32 new_ctrl;
bool have_new_ctrl;
@@ -230,6 +248,21 @@ static inline bool is_llc_occupancy_enabled(void)
return (rdt_mon_features & (1 << QOS_L3_OCCUP_EVENT_ID));
}
+static inline bool is_mbm_total_enabled(void)
+{
+ return (rdt_mon_features & (1 << QOS_L3_MBM_TOTAL_EVENT_ID));
+}
+
+static inline bool is_mbm_local_enabled(void)
+{
+ return (rdt_mon_features & (1 << QOS_L3_MBM_LOCAL_EVENT_ID));
+}
+
+static inline bool is_mbm_enabled(void)
+{
+ return (is_mbm_total_enabled() || is_mbm_local_enabled());
+}
+
/**
* struct rdt_resource - attributes of an RDT resource
* @rid: The index of the resource
diff --git a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
index f44e77d..cf8e2c7 100644
--- a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
@@ -294,6 +294,7 @@ void mon_event_read(struct rmid_read *rr, struct rdt_domain *d,
*/
rr->rgrp = rdtgrp;
rr->evtid = evtid;
+ rr->d = d;
rr->val = 0;
smp_call_function_any(&d->cpu_mask, mon_event_count, rr, 1);
diff --git a/arch/x86/kernel/cpu/intel_rdt_monitor.c b/arch/x86/kernel/cpu/intel_rdt_monitor.c
index 6ae5cf5..ef0358b 100644
--- a/arch/x86/kernel/cpu/intel_rdt_monitor.c
+++ b/arch/x86/kernel/cpu/intel_rdt_monitor.c
@@ -296,7 +296,8 @@ void free_rmid(u32 rmid)
static int __mon_event_count(u32 rmid, struct rmid_read *rr)
{
- u64 tval;
+ u64 chunks, shift, tval;
+ struct mbm_state *m;
tval = __rmid_read(rmid, rr->evtid);
if (tval & (RMID_VAL_ERROR | RMID_VAL_UNAVAIL)) {
@@ -307,6 +308,12 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr)
case QOS_L3_OCCUP_EVENT_ID:
rr->val += tval;
return 0;
+ case QOS_L3_MBM_TOTAL_EVENT_ID:
+ m = &rr->d->mbm_total[rmid];
+ break;
+ case QOS_L3_MBM_LOCAL_EVENT_ID:
+ m = &rr->d->mbm_local[rmid];
+ break;
default:
/*
* Code would never reach here because
@@ -314,6 +321,14 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr)
*/
return -EINVAL;
}
+ shift = 64 - MBM_CNTR_WIDTH;
+ chunks = (tval << shift) - (m->prev_msr << shift);
+ chunks >>= shift;
+ m->chunks += chunks;
+ m->prev_msr = tval;
+
+ rr->val += m->chunks;
+ return 0;
}
/*
@@ -377,6 +392,16 @@ static struct mon_evt llc_occupancy_event = {
.evtid = QOS_L3_OCCUP_EVENT_ID,
};
+static struct mon_evt mbm_total_event = {
+ .name = "mbm_total_bytes",
+ .evtid = QOS_L3_MBM_TOTAL_EVENT_ID,
+};
+
+static struct mon_evt mbm_local_event = {
+ .name = "mbm_local_bytes",
+ .evtid = QOS_L3_MBM_LOCAL_EVENT_ID,
+};
+
/*
* Initialize the event list for the resource.
*
@@ -390,6 +415,10 @@ static void l3_mon_evt_init(struct rdt_resource *r)
if (is_llc_occupancy_enabled())
list_add_tail(&llc_occupancy_event.list, &r->evt_list);
+ if (is_mbm_total_enabled())
+ list_add_tail(&mbm_total_event.list, &r->evt_list);
+ if (is_mbm_local_enabled())
+ list_add_tail(&mbm_local_event.list, &r->evt_list);
}
int rdt_get_mon_l3_config(struct rdt_resource *r)
next prev parent reply other threads:[~2017-08-01 20:57 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-25 21:14 [PATCH 00/28 V2] Cqm3 patch series(along with MBM support) Vikas Shivappa
2017-07-25 21:14 ` [PATCH 01/28] x86/perf/cqm: Wipe out perf based cqm Vikas Shivappa
2017-08-01 20:46 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 02/28] x86/intel_rdt/cqm: Documentation for resctrl based RDT Monitoring Vikas Shivappa
2017-08-01 20:46 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 03/28] x86/intel_rdt: Introduce a common compile option for RDT Vikas Shivappa
2017-08-01 20:47 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 04/28] x86/intel_rdt: Change file names to accommodate RDT monitor code Vikas Shivappa
2017-08-01 20:47 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 05/28] x86/intel_rdt: Mark rdt_root and closid_alloc as static Vikas Shivappa
2017-08-01 20:48 ` [tip:x86/cache] " tip-bot for Reinette Chatre
2017-07-25 21:14 ` [PATCH 06/28] x86/intel_rdt: Cleanup namespace to support RDT monitoring Vikas Shivappa
2017-08-01 20:48 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 07/28] x86/intel_rdt: make rdt_resources_all more readable Vikas Shivappa
2017-08-01 20:48 ` [tip:x86/cache] x86/intel_rdt: Make " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 08/28] x86/intel_rdt/cqm: Add RDT monitoring initialization Vikas Shivappa
2017-08-01 20:49 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 09/28] x86/intel_rdt/cqm: Add RMID(Resource monitoring ID) management Vikas Shivappa
2017-08-01 20:14 ` Thomas Gleixner
2017-08-02 7:41 ` Shivappa Vikas
2017-08-01 20:49 ` [tip:x86/cache] x86/intel_rdt/cqm: Add RMID (Resource " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 10/28] x86/intel_rdt: Simplify info and base file lists Vikas Shivappa
2017-08-01 20:34 ` Thomas Gleixner
2017-08-01 20:50 ` [tip:x86/cache] " tip-bot for Tony luck
2017-07-25 21:14 ` [PATCH 11/28] x86/intel_rdt/cqm: Add info files for RDT monitoring Vikas Shivappa
2017-08-01 20:40 ` Thomas Gleixner
2017-08-01 20:50 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 12/28] x86/intel_rdt: Prepare for RDT monitoring mkdir support Vikas Shivappa
2017-08-01 20:50 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 13/28] x86/intel_rdt/cqm: Add mkdir support for RDT monitoring Vikas Shivappa
2017-08-01 20:51 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 14/28] x86/intel_rdt: Change closid type from int to u32 Vikas Shivappa
2017-08-01 20:51 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 15/28] x86/intel_rdt/cqm: Add tasks file support Vikas Shivappa
2017-08-01 20:52 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 16/28] x86/intel_rdt: Prepare to add RDT monitor cpus " Vikas Shivappa
2017-08-01 19:49 ` Thomas Gleixner
2017-08-01 21:35 ` Shivappa Vikas
2017-08-01 20:52 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 17/28] x86/intel_rdt/cqm: Add " Vikas Shivappa
2017-08-01 20:52 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 18/28] x86/intel_rdt: Prepare for RDT monitor data support Vikas Shivappa
2017-08-01 20:53 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 19/28] x86/intel_rdt/cqm: Add mon_data Vikas Shivappa
2017-08-01 20:53 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 20/28] x86/intel_rdt: Separate the ctrl bits from rmdir Vikas Shivappa
2017-08-01 20:54 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 21/28] x86/intel_rdt/cqm: Add rmdir support Vikas Shivappa
2017-08-01 20:54 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 22/28] x86/intel_rdt/cqm: Add mount,umount support Vikas Shivappa
2017-08-01 20:54 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 23/28] x86/intel_rdt: Introduce rdt_enable_key for scheduling Vikas Shivappa
2017-08-01 20:55 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 24/28] x86/intel_rdt/cqm: Add sched_in support Vikas Shivappa
2017-08-01 20:55 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 25/28] x86/intel_rdt/cqm: Add hotcpu support Vikas Shivappa
2017-08-01 20:55 ` [tip:x86/cache] x86/intel_rdt/cqm: Add CPU hotplug support tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 26/28] x86/intel_rdt/mbm: Basic counting of MBM events (total and local) Vikas Shivappa
2017-08-01 20:56 ` tip-bot for Tony Luck [this message]
2017-07-25 21:14 ` [PATCH 27/28] x86/intel_rdt/mbm: Add mbm counter initialization Vikas Shivappa
2017-08-01 20:56 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 21:14 ` [PATCH 28/28] x86/intel_rdt/mbm: Handle counter overflow Vikas Shivappa
2017-08-01 20:57 ` [tip:x86/cache] " tip-bot for Vikas Shivappa
2017-07-25 22:39 ` [PATCH] x86/intel_rdt: Show bitmask of shareable resource with other executing units Luck, Tony
2017-08-01 20:57 ` [tip:x86/cache] " tip-bot for Fenghua Yu
2017-07-25 22:42 ` [RFC PATCH] Add "-f" and "-F" flags to watch a "/sys? style file (single number) Luck, Tony
2017-08-01 20:51 ` [PATCH 00/28 V2] Cqm3 patch series(along with MBM support) Thomas Gleixner
2017-08-01 21:39 ` Shivappa Vikas
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=tip-9f52425ba303d91c8370719e91d7e578bfdf309f@git.kernel.org \
--to=tipbot@zytor.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=vikas.shivappa@linux.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
Powered by JetHome