Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752832AbdHAU5y (ORCPT ); Tue, 1 Aug 2017 16:57:54 -0400 Received: from terminus.zytor.com ([65.50.211.136]:60181 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752004AbdHAU5v (ORCPT ); Tue, 1 Aug 2017 16:57:51 -0400 Date: Tue, 1 Aug 2017 13:56:44 -0700 From: tip-bot for Vikas Shivappa Message-ID: Cc: mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, vikas.shivappa@linux.intel.com Reply-To: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, vikas.shivappa@linux.intel.com In-Reply-To: <1501017287-28083-28-git-send-email-vikas.shivappa@linux.intel.com> References: <1501017287-28083-28-git-send-email-vikas.shivappa@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt/mbm: Add mbm counter initialization Git-Commit-ID: a4de1dfdd726537e2a78b55759fc646d9b0a0be8 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4920 Lines: 142 Commit-ID: a4de1dfdd726537e2a78b55759fc646d9b0a0be8 Gitweb: http://git.kernel.org/tip/a4de1dfdd726537e2a78b55759fc646d9b0a0be8 Author: Vikas Shivappa AuthorDate: Tue, 25 Jul 2017 14:14:46 -0700 Committer: Thomas Gleixner CommitDate: Tue, 1 Aug 2017 22:41:29 +0200 x86/intel_rdt/mbm: Add mbm counter initialization MBM counters are monotonically increasing counts representing the total memory bytes at a particular time. In order to calculate total_bytes for an rdtgroup, we store the value of the counter when we create an rdtgroup or when a new domain comes online. When the total_bytes(all memory controller bytes) or local_bytes(local memory controller bytes) file in "mon_data" is read it shows the total bytes for that rdtgroup since its creation. User can snapshot this at different time intervals to obtain bytes/second. Signed-off-by: Vikas Shivappa Signed-off-by: Thomas Gleixner Cc: ravi.v.shankar@intel.com Cc: tony.luck@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-28-git-send-email-vikas.shivappa@linux.intel.com --- arch/x86/kernel/cpu/intel_rdt.h | 9 +++++++++ arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 5 +++-- arch/x86/kernel/cpu/intel_rdt_monitor.c | 7 +++++++ arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 4 ++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h index 2137d5e..f160403 100644 --- a/arch/x86/kernel/cpu/intel_rdt.h +++ b/arch/x86/kernel/cpu/intel_rdt.h @@ -55,6 +55,7 @@ struct rmid_read { struct rdtgroup *rgrp; struct rdt_domain *d; int evtid; + bool first; u64 val; }; @@ -263,6 +264,12 @@ static inline bool is_mbm_enabled(void) return (is_mbm_total_enabled() || is_mbm_local_enabled()); } +static inline bool is_mbm_event(int e) +{ + return (e >= QOS_L3_MBM_TOTAL_EVENT_ID && + e <= QOS_L3_MBM_LOCAL_EVENT_ID); +} + /** * struct rdt_resource - attributes of an RDT resource * @rid: The index of the resource @@ -402,5 +409,7 @@ void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, unsigned int dom_id); void mkdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, struct rdt_domain *d); +void mon_event_read(struct rmid_read *rr, struct rdt_domain *d, + struct rdtgroup *rdtgrp, int evtid, int first); #endif /* _ASM_X86_INTEL_RDT_H */ diff --git a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c index cf8e2c7..f6ea94f 100644 --- a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c +++ b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c @@ -287,7 +287,7 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of, } void mon_event_read(struct rmid_read *rr, struct rdt_domain *d, - struct rdtgroup *rdtgrp, int evtid) + struct rdtgroup *rdtgrp, int evtid, int first) { /* * setup the parameters to send to the IPI to read the data. @@ -296,6 +296,7 @@ void mon_event_read(struct rmid_read *rr, struct rdt_domain *d, rr->evtid = evtid; rr->d = d; rr->val = 0; + rr->first = first; smp_call_function_any(&d->cpu_mask, mon_event_count, rr, 1); } @@ -325,7 +326,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) goto out; } - mon_event_read(&rr, d, rdtgrp, evtid); + mon_event_read(&rr, d, rdtgrp, evtid, false); if (rr.val & RMID_VAL_ERROR) seq_puts(m, "Error\n"); diff --git a/arch/x86/kernel/cpu/intel_rdt_monitor.c b/arch/x86/kernel/cpu/intel_rdt_monitor.c index ef0358b..383a023 100644 --- a/arch/x86/kernel/cpu/intel_rdt_monitor.c +++ b/arch/x86/kernel/cpu/intel_rdt_monitor.c @@ -321,6 +321,13 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr) */ return -EINVAL; } + + if (rr->first) { + m->prev_msr = tval; + m->chunks = 0; + return 0; + } + shift = 64 - MBM_CNTR_WIDTH; chunks = (tval << shift) - (m->prev_msr << shift); chunks >>= shift; diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index ea37b97..05088e3 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -1351,6 +1351,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, union mon_data_bits priv; struct kernfs_node *kn; struct mon_evt *mevt; + struct rmid_read rr; char name[32]; int ret; @@ -1381,6 +1382,9 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, ret = mon_addfile(kn, mevt->name, priv.priv); if (ret) goto out_destroy; + + if (is_mbm_event(mevt->evtid)) + mon_event_read(&rr, d, prgrp, mevt->evtid, true); } kernfs_activate(kn); return 0;