lkml.org 
[lkml]   [2021]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 17/20] x86/resctrl: Move get_corrected_mbm_count() into resctrl_arch_rmid_read()
Date
resctrl_arch_rmid_read() is intended as the function that an
architecture agnostic resctrl filesystem driver can use to
read a value in bytes from a counter. Currently the function returns
the mbm values in chunks directly from hardware. When reading a bandwidth
counter, get_corrected_mbm_count() must be used to correct the
value read.

get_corrected_mbm_count() is architecture specific, this work should be
done in resctrl_arch_rmid_read().

Move the function calls. This allows the resctrl filesystems's chunks
value to be removed in favour of the architecture private version.

Signed-off-by: James Morse <james.morse@arm.com>
---
arch/x86/kernel/cpu/resctrl/internal.h | 4 ++--
arch/x86/kernel/cpu/resctrl/monitor.c | 15 ++++++---------
2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 2d0a6bba4a01..65b472d6b146 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -279,14 +279,12 @@ 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_bw_chunks: Previous chunks value read when for bandwidth calculation
* @prev_bw: The most recent bandwidth in MBps
* @delta_bw: Difference between the current and previous bandwidth
* @delta_comp: Indicates whether to compute the delta_bw
*/
struct mbm_state {
- u64 chunks;
u64 prev_bw_chunks;
u32 prev_bw;
u32 delta_bw;
@@ -296,9 +294,11 @@ struct mbm_state {
/**
* struct arch_mbm_state - values used to compute resctrl_arch_rmid_read()s
* return value.
+ * @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 arch_mbm_state {
+ u64 chunks;
u64 prev_msr;
};

diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 39f7e74a4236..9321c758752a 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -201,7 +201,9 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d,

m = get_arch_mbm_state(hw_dom, rmid, eventid);
if (m) {
- *val = mbm_overflow_count(m->prev_msr, msr_val, hw_res->mbm_width);
+ m->chunks += mbm_overflow_count(m->prev_msr, msr_val,
+ hw_res->mbm_width);
+ *val = get_corrected_mbm_count(rmid, m->chunks);
m->prev_msr = msr_val;
} else {
*val = msr_val;
@@ -366,9 +368,7 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr)
return 0;
}

- m->chunks += tval;
-
- rr->val += get_corrected_mbm_count(rmid, m->chunks);
+ rr->val += tval;

return 0;
}
@@ -381,14 +381,11 @@ static void mbm_bw_count(u32 rmid, struct rmid_read *rr)
{
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(rr->r);
struct mbm_state *m = &rr->d->mbm_local[rmid];
- u64 tval = 0, cur_bw, bw_chunks;
+ u64 cur_bw, bw_chunks = 0;

- if (resctrl_arch_rmid_read(rr->r, rr->d, rmid, rr->evtid, &tval))
+ if (resctrl_arch_rmid_read(rr->r, rr->d, rmid, rr->evtid, &bw_chunks))
return;

- m->chunks += tval;
- bw_chunks = get_corrected_mbm_count(rmid, m->chunks);
-
cur_bw = (bw_chunks - m->prev_bw_chunks) * hw_res->mon_scale;
cur_bw >>= 20;

--
2.30.2
\
 
 \ /
  Last update: 2021-07-30 00:39    [W:0.193 / U:0.800 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site