Re: [PATCH v17 25/33] fs/resctrl: Provide interface to update the event configurations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Reinette,

Thanks for the review of series.

On 9/2/25 21:41, Reinette Chatre wrote:
> Hi Babu,
> 
> On 8/14/25 7:25 PM, Babu Moger wrote:
> 
>> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
>> index 25fec9bf2d61..9201fedd2796 100644
>> --- a/fs/resctrl/monitor.c
>> +++ b/fs/resctrl/monitor.c
>> @@ -1029,6 +1029,125 @@ int event_filter_show(struct kernfs_open_file *of, struct seq_file *seq, void *v
>>  	return ret;
>>  }
>>  
>> +static int resctrl_parse_mem_transactions(char *tok, u32 *val)
>> +{
>> +	u32 temp_val = 0;
>> +	char *evt_str;
>> +	bool found;
>> +	int i;
>> +
>> +next_config:
>> +	if (!tok || tok[0] == '\0') {
>> +		*val = temp_val;
>> +		return 0;
>> +	}
> 
> Looks like resctrl_parse_mem_transactions() can return "success" with a parsed
> return value of "0" (*val = 0) ... (follow-up comment in event_filter_write()).

Yes. *val=0 is a valid value.

> 
>> +
>> +	/* Start processing the strings for each memory transaction type */
>> +	evt_str = strim(strsep(&tok, ","));
>> +	found = false;
>> +	for (i = 0; i < NUM_MBM_TRANSACTIONS; i++) {
>> +		if (!strcmp(mbm_transactions[i].name, evt_str)) {
>> +			temp_val |= mbm_transactions[i].val;
>> +			found = true;
>> +			break;
>> +		}
>> +	}
>> +
>> +	if (!found) {
>> +		rdt_last_cmd_printf("Invalid memory transaction type %s\n", evt_str);
>> +		return -EINVAL;
>> +	}
>> +
>> +	goto next_config;
>> +}
>> +
>> +/*
>> + * rdtgroup_update_cntr_event - Update the counter assignments for the event
>> + *				in a group.
>> + * @r:		Resource to which update needs to be done.
>> + * @rdtgrp:	Resctrl group.
>> + * @evtid:	MBM monitor event.
>> + */
>> +static void rdtgroup_update_cntr_event(struct rdt_resource *r, struct rdtgroup *rdtgrp,
>> +				       enum resctrl_event_id evtid)
>> +{
>> +	struct rdt_mon_domain *d;
>> +	struct mbm_state *m;
>> +	int cntr_id;
>> +
>> +	list_for_each_entry(d, &r->mon_domains, hdr.list) {
>> +		cntr_id = mbm_cntr_get(r, d, rdtgrp, evtid);
>> +		if (cntr_id >= 0) {
>> +			resctrl_arch_config_cntr(r, d, evtid, rdtgrp->mon.rmid,
>> +						 rdtgrp->closid, cntr_id, true);
>> +			m = get_mbm_state(d, rdtgrp->closid, rdtgrp->mon.rmid, evtid);
>> +			if (m)
>> +				memset(m, 0, sizeof(*m));
> 
> This looks like open code of rdtgroup_assign_cntr()?

Will call rdtgroup_assign_cntr() directly here.

> 
>> +		}
>> +	}
>> +}
>> +
> 
> ...
> 
>> +
>> +ssize_t event_filter_write(struct kernfs_open_file *of, char *buf, size_t nbytes,
>> +			   loff_t off)
>> +{
>> +	struct mon_evt *mevt = rdt_kn_parent_priv(of->kn);
>> +	struct rdt_resource *r;
>> +	u32 evt_cfg = 0;
>> +	int ret = 0;
>> +
>> +	/* Valid input requires a trailing newline */
>> +	if (nbytes == 0 || buf[nbytes - 1] != '\n')
>> +		return -EINVAL;
>> +
>> +	buf[nbytes - 1] = '\0';
>> +
>> +	cpus_read_lock();
>> +	mutex_lock(&rdtgroup_mutex);
>> +
>> +	rdt_last_cmd_clear();
>> +
>> +	r = resctrl_arch_get_resource(mevt->rid);
>> +	if (!resctrl_arch_mbm_cntr_assign_enabled(r)) {
>> +		rdt_last_cmd_puts("mbm_event counter assignment mode is not enabled\n");
>> +		ret = -EINVAL;
>> +		goto out_unlock;
>> +	}
>> +
>> +	ret = resctrl_parse_mem_transactions(buf, &evt_cfg);
>> +	if (!ret && mevt->evt_cfg != evt_cfg) {
> 
> ... is evt_cfg of 0 (a) a valid value (that will not cause hardware to fault) and
> (b) a reasonable value to allow? 
> 

The value evt_cfg = 0 is valid and permitted for both ABMC and BMEC. I
have confirmed here through verification and testing. In that case, the
event counter will not be monitoring anything.
-- 
Thanks
Babu Moger





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux