Skip to content

Commit 38f72f5

Browse files
James Morsesuryasaimadhu
authored andcommitted
x86/resctrl: Move get_corrected_mbm_count() into resctrl_arch_rmid_read()
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 <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Jamie Iles <[email protected]> Reviewed-by: Shaopeng Tan <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Tested-by: Xin Hao <[email protected]> Tested-by: Shaopeng Tan <[email protected]> Tested-by: Cristian Marussi <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1d81d15 commit 38f72f5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,12 @@ struct rftype {
280280

281281
/**
282282
* struct mbm_state - status for each MBM counter in each domain
283-
* @chunks: Total data moved (multiply by rdt_group.mon_scale to get bytes)
284283
* @prev_bw_chunks: Previous chunks value read for bandwidth calculation
285284
* @prev_bw: The most recent bandwidth in MBps
286285
* @delta_bw: Difference between the current and previous bandwidth
287286
* @delta_comp: Indicates whether to compute the delta_bw
288287
*/
289288
struct mbm_state {
290-
u64 chunks;
291289
u64 prev_bw_chunks;
292290
u32 prev_bw;
293291
u32 delta_bw;
@@ -297,10 +295,12 @@ struct mbm_state {
297295
/**
298296
* struct arch_mbm_state - values used to compute resctrl_arch_rmid_read()s
299297
* return value.
298+
* @chunks: Total data moved (multiply by rdt_group.mon_scale to get bytes)
300299
* @prev_msr: Value of IA32_QM_CTR last time it was read for the RMID used to
301300
* find this struct.
302301
*/
303302
struct arch_mbm_state {
303+
u64 chunks;
304304
u64 prev_msr;
305305
};
306306

arch/x86/kernel/cpu/resctrl/monitor.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d,
204204

205205
am = get_arch_mbm_state(hw_dom, rmid, eventid);
206206
if (am) {
207-
*val = mbm_overflow_count(am->prev_msr, msr_val, hw_res->mbm_width);
207+
am->chunks += mbm_overflow_count(am->prev_msr, msr_val,
208+
hw_res->mbm_width);
209+
*val = get_corrected_mbm_count(rmid, am->chunks);
208210
am->prev_msr = msr_val;
209211
} else {
210212
*val = msr_val;
@@ -374,9 +376,7 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr)
374376
return 0;
375377
}
376378

377-
m->chunks += tval;
378-
379-
rr->val += get_corrected_mbm_count(rmid, m->chunks);
379+
rr->val += tval;
380380

381381
return 0;
382382
}

0 commit comments

Comments
 (0)