[14/15] x86/resctrl: Add interface unassign a ABMC counter
Commit Message
With the support of ABMC (Assignable Bandwidth Monitoring Counters)
feature, the user has the option to pin (or assign) or unpin (or unassign)
the RMID to hardware counter and monitor the bandwidth for the longer
duration.
Provide the interface to unpin (or unassign) the counter.
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
Documentation/arch/x86/resctrl.rst | 11 ++++++++
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 36 ++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
Comments
Hi Babu,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20231130]
[cannot apply to tip/x86/core linus/master v6.7-rc3 v6.7-rc2 v6.7-rc1 v6.7-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Babu-Moger/x86-resctrl-Remove-hard-coded-memory-bandwidth-limit/20231201-090621
base: next-20231130
patch link: https://lore.kernel.org/r/20231201005720.235639-15-babu.moger%40amd.com
patch subject: [PATCH 14/15] x86/resctrl: Add interface unassign a ABMC counter
config: i386-randconfig-013-20231202 (https://download.01.org/0day-ci/archive/20231206/202312060120.q62q2ha7-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060120.q62q2ha7-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312060120.q62q2ha7-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> arch/x86/kernel/cpu/resctrl/rdtgroup.c:195:6: warning: no previous prototype for 'abmc_counters_free' [-Wmissing-prototypes]
195 | void abmc_counters_free(int counterid)
| ^~~~~~~~~~~~~~~~~~
arch/x86/kernel/cpu/resctrl/rdtgroup.c:2675:5: warning: no previous prototype for 'resctrl_arch_set_abmc_enabled' [-Wmissing-prototypes]
2675 | int resctrl_arch_set_abmc_enabled(enum resctrl_res_level l, bool enable)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/abmc_counters_free +195 arch/x86/kernel/cpu/resctrl/rdtgroup.c
194
> 195 void abmc_counters_free(int counterid)
196 {
197 abmc_free_map |= 1 << counterid;
198 }
199
On 12/5/23 11:55, kernel test robot wrote:
> Hi Babu,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on next-20231130]
> [cannot apply to tip/x86/core linus/master v6.7-rc3 v6.7-rc2 v6.7-rc1 v6.7-rc4]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Babu-Moger/x86-resctrl-Remove-hard-coded-memory-bandwidth-limit/20231201-090621
> base: next-20231130
> patch link: https://lore.kernel.org/r/20231201005720.235639-15-babu.moger%40amd.com
> patch subject: [PATCH 14/15] x86/resctrl: Add interface unassign a ABMC counter
> config: i386-randconfig-013-20231202 (https://download.01.org/0day-ci/archive/20231206/202312060120.q62q2ha7-lkp@intel.com/config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060120.q62q2ha7-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202312060120.q62q2ha7-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
>>> arch/x86/kernel/cpu/resctrl/rdtgroup.c:195:6: warning: no previous prototype for 'abmc_counters_free' [-Wmissing-prototypes]
> 195 | void abmc_counters_free(int counterid)
Yes. Got it. This function requires a prototype in
arch/x86/kernel/cpu/resctrl/internal.h.
Will add it in the next revision after the other comments.
@@ -417,6 +417,17 @@ When monitoring is enabled all MON groups will also contain:
# echo total=assign > /sys/fs/resctrl/monitor_state
# echo total=assign;local=assign > /sys/fs/resctrl/monitor_state
+ The user needs to unpin (or unassign) counter to release it.
+ Example::
+
+ # echo total=unassign > /sys/fs/resctrl/monitor_state
+ # cat /sys/fs/resctrl/monitor_state
+ total=unassign;local=assign
+
+ # echo total=unassign;local=unassign > /sys/fs/resctrl/monitor_state
+ # cat /sys/fs/resctrl/monitor_state
+ total=unassign;local=unassign
+
"mon_hw_id":
Available only with debug option. The identifier used by hardware
for the monitor group. On x86 this is the RMID.
@@ -192,6 +192,11 @@ static int abmc_counters_alloc(void)
return counterid;
}
+void abmc_counters_free(int counterid)
+{
+ abmc_free_map |= 1 << counterid;
+}
+
/**
* rdtgroup_mode_by_closid - Return mode of resource group with closid
* @closid: closid if the resource group
@@ -1671,6 +1676,31 @@ static ssize_t rdtgroup_assign_abmc(struct rdtgroup *rdtgrp,
return 0;
}
+static ssize_t rdtgroup_unassign_abmc(struct rdtgroup *rdtgrp,
+ struct rdt_resource *r,
+ u32 evtid, int mon_state)
+{
+ struct rdt_domain *d;
+ int index;
+
+ index = mon_event_config_index_get(evtid);
+ if (index == INVALID_CONFIG_INDEX) {
+ pr_warn_once("Invalid event id %d\n", evtid);
+ return -EINVAL;
+ }
+
+ if (rdtgrp->mon.monitor_state & mon_state) {
+ list_for_each_entry(d, &r->domains, list)
+ rdtgroup_abmc_domain(d, rdtgrp, evtid, index, 0);
+
+ abmc_counters_free(rdtgrp->mon.abmc_ctr_id[index]);
+ }
+
+ rdtgrp->mon.monitor_state &= ~mon_state;
+
+ return 0;
+}
+
/**
* rdtgroup_monitor_state_write - Modify the resource group's assign
*
@@ -1716,6 +1746,12 @@ static ssize_t rdtgroup_monitor_state_write(struct kernfs_open_file *of,
rdt_last_cmd_puts("ABMC assign failed\n");
break;
}
+ } else if (!strcmp(abmc_str, "unassign")) {
+ ret = rdtgroup_unassign_abmc(rdtgrp, r, evtid, mon_state);
+ if (ret) {
+ rdt_last_cmd_puts("ABMC unassign failed\n");
+ break;
+ }
} else {
rdt_last_cmd_puts("Invalid ABMC event\n");
ret = -EINVAL;