Re: [PATCH v6 19/22] x86/resctrl: Introduce the interface to switch between monitor modes

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

 



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.

+	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




[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