mirror of
https://github.com/torvalds/linux.git
synced 2025-11-02 17:49:03 +02:00
fs/resctrl: Auto assign counters on mkdir and clean up on group removal
Resctrl provides a user-configurable option mbm_assign_on_mkdir that determines if a counter will automatically be assigned to an RMID, event pair when its associated monitor group is created via mkdir. Enable mbm_assign_on_mkdir by default to automatically assign counters to the two default events (MBM total and MBM local) of a new monitoring group created via mkdir. This maintains backward compatibility with original resctrl support for these two events. Unassign and free counters belonging to a monitoring group when the group is deleted. Monitor group creation does not fail if a counter cannot be assigned to one or both events. There may be limited counters and users have the flexibility to modify counter assignments at a later time. Log the error message "Failed to allocate counter for <event> in domain <id>" in /sys/fs/resctrl/info/last_cmd_status when a new monitoring group is created but counter assignment failed. Signed-off-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lore.kernel.org/cover.1757108044.git.babu.moger@amd.com
This commit is contained in:
parent
ac1df9bb0b
commit
ef712fe97e
2 changed files with 23 additions and 3 deletions
|
|
@ -1231,7 +1231,8 @@ void rdtgroup_unassign_cntrs(struct rdtgroup *rdtgrp)
|
|||
{
|
||||
struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
|
||||
|
||||
if (!r->mon_capable || !resctrl_arch_mbm_cntr_assign_enabled(r))
|
||||
if (!r->mon_capable || !resctrl_arch_mbm_cntr_assign_enabled(r) ||
|
||||
!r->mon.mbm_assign_on_mkdir)
|
||||
return;
|
||||
|
||||
if (resctrl_is_mon_event_enabled(QOS_L3_MBM_TOTAL_EVENT_ID))
|
||||
|
|
@ -1503,6 +1504,7 @@ int resctrl_mon_resource_init(void)
|
|||
(READS_TO_LOCAL_MEM |
|
||||
READS_TO_LOCAL_S_MEM |
|
||||
NON_TEMP_WRITE_TO_LOCAL_MEM);
|
||||
r->mon.mbm_assign_on_mkdir = true;
|
||||
resctrl_file_fflags_init("num_mbm_cntrs",
|
||||
RFTYPE_MON_INFO | RFTYPE_RES_CACHE);
|
||||
resctrl_file_fflags_init("available_mbm_cntrs",
|
||||
|
|
|
|||
|
|
@ -2713,6 +2713,8 @@ static int rdt_get_tree(struct fs_context *fc)
|
|||
if (ret < 0)
|
||||
goto out_info;
|
||||
|
||||
rdtgroup_assign_cntrs(&rdtgroup_default);
|
||||
|
||||
ret = mkdir_mondata_all(rdtgroup_default.kn,
|
||||
&rdtgroup_default, &kn_mondata);
|
||||
if (ret < 0)
|
||||
|
|
@ -2751,8 +2753,10 @@ static int rdt_get_tree(struct fs_context *fc)
|
|||
if (resctrl_arch_mon_capable())
|
||||
kernfs_remove(kn_mondata);
|
||||
out_mongrp:
|
||||
if (resctrl_arch_mon_capable())
|
||||
if (resctrl_arch_mon_capable()) {
|
||||
rdtgroup_unassign_cntrs(&rdtgroup_default);
|
||||
kernfs_remove(kn_mongrp);
|
||||
}
|
||||
out_info:
|
||||
kernfs_remove(kn_info);
|
||||
out_closid_exit:
|
||||
|
|
@ -2897,6 +2901,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp)
|
|||
|
||||
head = &rdtgrp->mon.crdtgrp_list;
|
||||
list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) {
|
||||
rdtgroup_unassign_cntrs(sentry);
|
||||
free_rmid(sentry->closid, sentry->mon.rmid);
|
||||
list_del(&sentry->mon.crdtgrp_list);
|
||||
|
||||
|
|
@ -2937,6 +2942,8 @@ static void rmdir_all_sub(void)
|
|||
cpumask_or(&rdtgroup_default.cpu_mask,
|
||||
&rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask);
|
||||
|
||||
rdtgroup_unassign_cntrs(rdtgrp);
|
||||
|
||||
free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);
|
||||
|
||||
kernfs_remove(rdtgrp->kn);
|
||||
|
|
@ -3021,6 +3028,7 @@ static void resctrl_fs_teardown(void)
|
|||
return;
|
||||
|
||||
rmdir_all_sub();
|
||||
rdtgroup_unassign_cntrs(&rdtgroup_default);
|
||||
mon_put_kn_priv();
|
||||
rdt_pseudo_lock_release();
|
||||
rdtgroup_default.mode = RDT_MODE_SHAREABLE;
|
||||
|
|
@ -3501,9 +3509,12 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgroup *rdtgrp)
|
|||
}
|
||||
rdtgrp->mon.rmid = ret;
|
||||
|
||||
rdtgroup_assign_cntrs(rdtgrp);
|
||||
|
||||
ret = mkdir_mondata_all(rdtgrp->kn, rdtgrp, &rdtgrp->mon.mon_data_kn);
|
||||
if (ret) {
|
||||
rdt_last_cmd_puts("kernfs subdir error\n");
|
||||
rdtgroup_unassign_cntrs(rdtgrp);
|
||||
free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -3513,8 +3524,10 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgroup *rdtgrp)
|
|||
|
||||
static void mkdir_rdt_prepare_rmid_free(struct rdtgroup *rgrp)
|
||||
{
|
||||
if (resctrl_arch_mon_capable())
|
||||
if (resctrl_arch_mon_capable()) {
|
||||
rdtgroup_unassign_cntrs(rgrp);
|
||||
free_rmid(rgrp->closid, rgrp->mon.rmid);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -3790,6 +3803,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)
|
|||
update_closid_rmid(tmpmask, NULL);
|
||||
|
||||
rdtgrp->flags = RDT_DELETED;
|
||||
|
||||
rdtgroup_unassign_cntrs(rdtgrp);
|
||||
|
||||
free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);
|
||||
|
||||
/*
|
||||
|
|
@ -3837,6 +3853,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)
|
|||
cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask);
|
||||
update_closid_rmid(tmpmask, NULL);
|
||||
|
||||
rdtgroup_unassign_cntrs(rdtgrp);
|
||||
|
||||
free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);
|
||||
closid_free(rdtgrp->closid);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue