lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9549e225-08d3-453f-8338-78f7f426d4f3@amd.com>
Date: Mon, 21 Jul 2025 15:21:20 -0500
From: "Moger, Babu" <babu.moger@....com>
To: Reinette Chatre <reinette.chatre@...el.com>, corbet@....net,
 tony.luck@...el.com, james.morse@....com, tglx@...utronix.de,
 mingo@...hat.com, bp@...en8.de, dave.hansen@...ux.intel.com
Cc: Dave.Martin@....com, x86@...nel.org, hpa@...or.com,
 akpm@...ux-foundation.org, paulmck@...nel.org, rostedt@...dmis.org,
 Neeraj.Upadhyay@....com, david@...hat.com, arnd@...db.de, fvdl@...gle.com,
 seanjc@...gle.com, jpoimboe@...nel.org, pawan.kumar.gupta@...ux.intel.com,
 xin@...or.com, manali.shukla@....com, tao1.su@...ux.intel.com,
 sohil.mehta@...el.com, kai.huang@...el.com, xiaoyao.li@...el.com,
 peterz@...radead.org, xin3.li@...el.com, kan.liang@...ux.intel.com,
 mario.limonciello@....com, thomas.lendacky@....com, perry.yuan@....com,
 gautham.shenoy@....com, chang.seok.bae@...el.com, linux-doc@...r.kernel.org,
 linux-kernel@...r.kernel.org, peternewman@...gle.com, eranian@...gle.com
Subject: Re: [PATCH v15 18/34] fs/resctrl: Add the functionality to unassign
 MBM events

Hi Reinette,

On 7/17/25 22:48, Reinette Chatre wrote:
> Hi Babu,
> 
> On 7/8/25 3:17 PM, Babu Moger wrote:
>> The "mbm_event" counter assignment mode offers "num_mbm_cntrs" number of
>> counters that can be 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>
>> ---
> 
> ...
> 
>> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
>> index bb074773420d..6c0410cf0195 100644
>> --- a/fs/resctrl/monitor.c
>> +++ b/fs/resctrl/monitor.c
>> @@ -1022,6 +1022,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(*d->cntr_cfg));
>> +}
>> +
>>  /*
>>   * rdtgroup_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.
>> @@ -1083,3 +1091,42 @@ int rdtgroup_assign_cntr_event(struct rdt_mon_domain *d, struct rdtgroup *rdtgrp
>>  
>>  	return ret;
>>  }
>> +
>> +/*
>> + * rdtgroup_free_config_cntr() - Unassign and reset the counter ID configuration
> 
> rdtgroup_free_config_cntr() -> rdtgroup_free_unassign_cntr() ?

Sure.

> 
>> + * for the event pointed to by @mevt within the domain @d and resctrl group @rdtgrp.
> 
> @mevt -> @evtid
> 

Sure.

>> + */
>> +static void rdtgroup_free_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,
>> +				      struct rdtgroup *rdtgrp, enum resctrl_event_id evtid)
>> +{
>> +	int cntr_id;
>> +
>> +	cntr_id = mbm_cntr_get(r, d, rdtgrp, evtid);
>> +
>> +	/* If there is no cntr_id assigned, nothing to do */
>> +	if (cntr_id < 0)
>> +		return;
>> +
>> +	resctrl_config_cntr(r, d, evtid, rdtgrp->mon.rmid, rdtgrp->closid,
>> +			    cntr_id, false);
>> +
>> +	mbm_cntr_free(d, cntr_id);
>> +}
>> +
>> +/*
>> + * rdtgroup_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 rdtgroup_unassign_cntr_event(struct rdt_mon_domain *d, struct rdtgroup *rdtgrp,
>> +				  struct mon_evt *mevt)
>> +{
>> +	struct rdt_resource *r = resctrl_arch_get_resource(mevt->rid);
>> +
>> +	if (!d) {
>> +		list_for_each_entry(d, &r->mon_domains, hdr.list)
>> +			rdtgroup_free_config_cntr(r, d, rdtgrp, mevt->evtid);
>> +	} else {
>> +		rdtgroup_free_config_cntr(r, d, rdtgrp, mevt->evtid);
>> +	}
>> +}
> 
> Reinette
> 

-- 
Thanks
Babu Moger

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ