Skip to content

Commit ff6357b

Browse files
James Morsesuryasaimadhu
authored andcommitted
x86/resctrl: Allow update_mba_bw() to update controls directly
update_mba_bw() calculates a new control value for the MBA resource based on the user provided mbps_val and the current measured bandwidth. Some control values need remapping by delay_bw_map(). It does this by calling wrmsrl() directly. This needs splitting up to be done by an architecture specific helper, so that the remainder can eventually be moved to /fs/. Add resctrl_arch_update_one() to apply one configuration value to the provided resource and domain. This avoids the staging and cross-calling that is only needed with changes made by user-space. delay_bw_map() moves to be part of the arch code, to maintain the 'percentage control' view of MBA resources in resctrl. 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 b58d4eb commit ff6357b

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ mba_wrmsr_amd(struct rdt_domain *d, struct msr_param *m, struct rdt_resource *r)
296296
* that can be written to QOS_MSRs.
297297
* There are currently no SKUs which support non linear delay values.
298298
*/
299-
u32 delay_bw_map(unsigned long bw, struct rdt_resource *r)
299+
static u32 delay_bw_map(unsigned long bw, struct rdt_resource *r)
300300
{
301301
if (r->membw.delay_linear)
302302
return MAX_MBA_BW - bw;

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,27 @@ static bool apply_config(struct rdt_hw_domain *hw_dom,
282282
return false;
283283
}
284284

285+
int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d,
286+
u32 closid, enum resctrl_conf_type t, u32 cfg_val)
287+
{
288+
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
289+
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d);
290+
u32 idx = get_config_index(closid, t);
291+
struct msr_param msr_param;
292+
293+
if (!cpumask_test_cpu(smp_processor_id(), &d->cpu_mask))
294+
return -EINVAL;
295+
296+
hw_dom->ctrl_val[idx] = cfg_val;
297+
298+
msr_param.res = r;
299+
msr_param.low = idx;
300+
msr_param.high = idx + 1;
301+
hw_res->msr_update(d, &msr_param, r);
302+
303+
return 0;
304+
}
305+
285306
int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
286307
{
287308
struct resctrl_staged_config *cfg;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ void mbm_setup_overflow_handler(struct rdt_domain *dom,
527527
void mbm_handle_overflow(struct work_struct *work);
528528
void __init intel_rdt_mbm_apply_quirk(void);
529529
bool is_mba_sc(struct rdt_resource *r);
530-
u32 delay_bw_map(unsigned long bw, struct rdt_resource *r);
531530
void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms);
532531
void cqm_handle_limbo(struct work_struct *work);
533532
bool has_busy_rmid(struct rdt_resource *r, struct rdt_domain *d);

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,8 @@ void mon_event_count(void *info)
420420
*/
421421
static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm)
422422
{
423-
u32 closid, rmid, cur_msr, cur_msr_val, new_msr_val;
423+
u32 closid, rmid, cur_msr_val, new_msr_val;
424424
struct mbm_state *pmbm_data, *cmbm_data;
425-
struct rdt_hw_resource *hw_r_mba;
426-
struct rdt_hw_domain *hw_dom_mba;
427425
u32 cur_bw, delta_bw, user_bw;
428426
struct rdt_resource *r_mba;
429427
struct rdt_domain *dom_mba;
@@ -433,8 +431,8 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm)
433431
if (!is_mbm_local_enabled())
434432
return;
435433

436-
hw_r_mba = &rdt_resources_all[RDT_RESOURCE_MBA];
437-
r_mba = &hw_r_mba->r_resctrl;
434+
r_mba = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl;
435+
438436
closid = rgrp->closid;
439437
rmid = rgrp->mon.rmid;
440438
pmbm_data = &dom_mbm->mbm_local[rmid];
@@ -444,7 +442,6 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm)
444442
pr_warn_once("Failure to get domain for MBA update\n");
445443
return;
446444
}
447-
hw_dom_mba = resctrl_to_arch_dom(dom_mba);
448445

449446
cur_bw = pmbm_data->prev_bw;
450447
user_bw = dom_mba->mbps_val[closid];
@@ -486,9 +483,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm)
486483
return;
487484
}
488485

489-
cur_msr = hw_r_mba->msr_base + closid;
490-
wrmsrl(cur_msr, delay_bw_map(new_msr_val, r_mba));
491-
hw_dom_mba->ctrl_val[closid] = new_msr_val;
486+
resctrl_arch_update_one(r_mba, dom_mba, closid, CDP_NONE, new_msr_val);
492487

493488
/*
494489
* Delta values are updated dynamically package wise for each

include/linux/resctrl.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ struct resctrl_schema {
197197
/* The number of closid supported by this resource regardless of CDP */
198198
u32 resctrl_arch_get_num_closid(struct rdt_resource *r);
199199
int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
200+
201+
/*
202+
* Update the ctrl_val and apply this config right now.
203+
* Must be called on one of the domain's CPUs.
204+
*/
205+
int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d,
206+
u32 closid, enum resctrl_conf_type t, u32 cfg_val);
207+
200208
u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d,
201209
u32 closid, enum resctrl_conf_type type);
202210
int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d);

0 commit comments

Comments
 (0)