Re: [PATCH v10 23/24] x86/resctrl: Introduce interface to list assignment states of all the groups

From: Luck, Tony
Date: Thu Dec 12 2024 - 17:57:18 EST


On Thu, Dec 12, 2024 at 02:15:26PM -0600, Babu Moger wrote:
> +static int rdtgroup_mbm_assign_control_show(struct kernfs_open_file *of,
> + struct seq_file *s, void *v)
> +{
> + struct rdt_resource *r = of->kn->parent->priv;
> + struct rdt_mon_domain *dom;
> + struct rdtgroup *rdtg;
> + char str[10];
> +
> + cpus_read_lock();
> + mutex_lock(&rdtgroup_mutex);
> + rdt_last_cmd_clear();
> +
> + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) {
> + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n");
> + mutex_unlock(&rdtgroup_mutex);
> + cpus_read_unlock();
> + return -EINVAL;
> + }
> +
> + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) {
> + struct rdtgroup *crg;
> +
> + seq_printf(s, "%s//", rdtg->kn->name);
> +
> + list_for_each_entry(dom, &r->mon_domains, hdr.list)
> + seq_printf(s, "%d=%s;", dom->hdr.id,
> + rdtgroup_mon_state_to_str(r, dom, rdtg, str));
> + seq_putc(s, '\n');

Other resctrl files with domain lists use ';' as a separator, not a
terminator. This code results in:

//0=tl;1=tl;

rather than

//0=tl;1=tl

> +
> + list_for_each_entry(crg, &rdtg->mon.crdtgrp_list,
> + mon.crdtgrp_list) {
> + seq_printf(s, "%s/%s/", rdtg->kn->name, crg->kn->name);
> +
> + list_for_each_entry(dom, &r->mon_domains, hdr.list)
> + seq_printf(s, "%d=%s;", dom->hdr.id,
> + rdtgroup_mon_state_to_str(r, dom, crg, str));
> + seq_putc(s, '\n');

Ditto.

> + }
> + }
> +
> + mutex_unlock(&rdtgroup_mutex);
> + cpus_read_unlock();
> + return 0;
> +}