[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <96297efd-0f65-4dde-9720-36dd9b689295@intel.com>
Date: Tue, 24 Jun 2025 20:38:35 -0700
From: Reinette Chatre <reinette.chatre@...el.com>
To: Babu Moger <babu.moger@....com>, <corbet@....net>, <tony.luck@...el.com>,
<Dave.Martin@....com>, <james.morse@....com>, <tglx@...utronix.de>,
<mingo@...hat.com>, <bp@...en8.de>, <dave.hansen@...ux.intel.com>
CC: <x86@...nel.org>, <hpa@...or.com>, <akpm@...ux-foundation.org>,
<rostedt@...dmis.org>, <paulmck@...nel.org>, <thuth@...hat.com>,
<ardb@...nel.org>, <gregkh@...uxfoundation.org>, <seanjc@...gle.com>,
<thomas.lendacky@....com>, <pawan.kumar.gupta@...ux.intel.com>,
<manali.shukla@....com>, <perry.yuan@....com>, <kai.huang@...el.com>,
<peterz@...radead.org>, <xiaoyao.li@...el.com>, <kan.liang@...ux.intel.com>,
<mario.limonciello@....com>, <xin3.li@...el.com>, <gautham.shenoy@....com>,
<xin@...or.com>, <chang.seok.bae@...el.com>, <fenghuay@...dia.com>,
<peternewman@...gle.com>, <maciej.wieczor-retman@...el.com>,
<eranian@...gle.com>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v14 19/32] fs/resctrl: Add the functionality to unassign
MBM events
Hi Babu,
On 6/13/25 2:05 PM, Babu Moger wrote:
> The "mbm_event" mode offers "num_mbm_cntrs" number of counters that can be
"The "mbm_event" mode" -> "The "mbm_event" counter assignment mode"?
> assigned to RMID, event pairs and monitor bandwidth usage as long as it is
> assigned. If all the counters are in use, the kernel logs the error message
> "Unable to allocate counter in domain" in
> /sys/fs/resctrl/info/last_cmd_status when a new assignment is requested.
>
> To make space for a new assignment, users must unassign an already
> assigned counter and retry the assignment again.
>
> Add the functionality to unassign and free the counters in the domain.
>
> Signed-off-by: Babu Moger <babu.moger@....com>
> ---
...
> ---
> fs/resctrl/internal.h | 2 ++
> fs/resctrl/monitor.c | 47 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+)
>
> diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
> index 0767a1c46f26..4496c359ac22 100644
> --- a/fs/resctrl/internal.h
> +++ b/fs/resctrl/internal.h
> @@ -388,6 +388,8 @@ int resctrl_find_cleanest_closid(void);
>
> int resctrl_assign_cntr_event(struct rdt_resource *r, struct rdt_mon_domain *d,
> struct rdtgroup *rdtgrp, struct mon_evt *mevt);
> +void resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_domain *d,
> + struct rdtgroup *rdtgrp, struct mon_evt *mevt);
>
> #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK
> int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp);
> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index 38800fe45931..f2636aea6545 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c
> @@ -1016,6 +1016,14 @@ static int mbm_cntr_alloc(struct rdt_resource *r, struct rdt_mon_domain *d,
> return -ENOSPC;
> }
>
> +/**
> + * mbm_cntr_free() - Clear the counter ID configuration details in the domain @d.
> + */
> +static void mbm_cntr_free(struct rdt_mon_domain *d, int cntr_id)
> +{
> + memset(&d->cntr_cfg[cntr_id], 0, sizeof(struct mbm_cntr_cfg));
sizeof(struct mbm_cntr_cfg) -> sizeof(*d->cntr_cfg[0])
> +}
> +
> /**
> * resctrl_alloc_config_cntr() - Allocate a counter ID and configure it for the
> * event pointed to by @mevt and the resctrl group @rdtgrp within the domain @d.
> @@ -1084,3 +1092,42 @@ int resctrl_assign_cntr_event(struct rdt_resource *r, struct rdt_mon_domain *d,
>
> return ret;
> }
> +
> +/**
> + * resctrl_free_config_cntr() - Unassign and reset the counter ID configuration
> + * for the event pointed to by @mevt within the domain @d and resctrl group @rdtgrp.
> + */
> +static void resctrl_free_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,
> + struct rdtgroup *rdtgrp, struct mon_evt *mevt)
> +{
> + int cntr_id;
> +
> + cntr_id = mbm_cntr_get(r, d, rdtgrp, mevt->evtid);
> +
> + /* If there is no cntr_id assigned, nothing to do */
> + if (cntr_id < 0)
> + return;
> +
> + resctrl_config_cntr(r, d, mevt->evtid, rdtgrp->mon.rmid, rdtgrp->closid,
> + cntr_id, false);
> +
> + mbm_cntr_free(d, cntr_id);
> +
> + return;
No need for this return.
> +}
> +
> +/**
> + * resctrl_unassign_cntr_event() - Unassign a hardware counter associated with
> + * the event structure @mevt from the domain @d and the group @rdtgrp. Unassign
> + * the counters from all the domains if @d is NULL else unassign from @d.
> + */
> +void resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_domain *d,
> + struct rdtgroup *rdtgrp, struct mon_evt *mevt)
> +{
> + if (!d) {
> + list_for_each_entry(d, &r->mon_domains, hdr.list)
> + resctrl_free_config_cntr(r, d, rdtgrp, mevt);
> + } else {
> + resctrl_free_config_cntr(r, d, rdtgrp, mevt);
> + }
> +}
Reinette
Powered by blists - more mailing lists