Re: [PATCH v6 19/22] x86/resctrl: Introduce the interface to switch between monitor modes
From: Moger, Babu
Date: Wed Aug 21 2024 - 14:08:58 EST
Hi Reinette,
On 8/16/24 16:42, Reinette Chatre wrote:
> Hi Babu,
>
> On 8/6/24 3:00 PM, Babu Moger wrote:
>> +static ssize_t rdtgroup_mbm_mode_write(struct kernfs_open_file *of,
>> + char *buf, size_t nbytes,
>> + loff_t off)
>> +{
>> + int mbm_cntr_assign = resctrl_arch_get_abmc_enabled();
>
> This needs to be protected by the mutex.
Agree.. Will do.
>
>> + struct rdt_resource *r = of->kn->parent->priv;
>> + 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();
>> +
>> + if (!strcmp(buf, "legacy")) {
>> + if (mbm_cntr_assign)
>> + resctrl_arch_mbm_cntr_assign_disable();
>> + } else if (!strcmp(buf, "mbm_cntr_assign")) {
>> + if (!mbm_cntr_assign) {
>> + rdtgroup_mbm_cntr_reset(r);
>> + ret = resctrl_arch_mbm_cntr_assign_enable();
>> + }
>> + } else {
>> + ret = -EINVAL;
>> + }
>> +
>> + mutex_unlock(&rdtgroup_mutex);
>> + cpus_read_unlock();
>> +
>> + return ret ?: nbytes;
>> +}
>> +
>
> Reinette
>
--
Thanks
Babu Moger