Re: [PATCH][v4] x86/resctrl: Add task resctrl information display

From: Alexey Dobriyan
Date: Sun Nov 24 2019 - 08:25:47 EST


On Fri, Nov 22, 2019 at 05:58:33PM +0800, Chen Yu wrote:
> Monitoring tools that want to find out which resctrl control
> and monitor groups a task belongs to must currently read
> the "tasks" file in every group until they locate the process
> ID.
>
> Add an additional file /proc/{pid}/resctrl to provide this
> information.

> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c

> + seq_printf(s, "/%s", rdtg->kn->name);
> + list_for_each_entry(crg, &rdtg->mon.crdtgrp_list,
> + mon.crdtgrp_list) {
> + if (tsk->rmid != crg->mon.rmid)
> + continue;
> + seq_printf(s, "%smon_groups/%s",
> + rdtg == &rdtgroup_default ? "" : "/",
> + crg->kn->name);
> + break;
> + }
> + seq_puts(s, "\n");

This should be seq_putc().


> --- /dev/null
> +++ b/include/linux/resctrl.h
> @@ -0,0 +1,16 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _RESCTRL_H
> +#define _RESCTRL_H
> +
> +#ifdef CONFIG_PROC_CPU_RESCTRL
> +
> +#include <linux/proc_fs.h>

Forward declaring stuff should be more than enough.

> +int proc_resctrl_show(struct seq_file *m,
> + struct pid_namespace *ns,
> + struct pid *pid,
> + struct task_struct *tsk);
> +
> +#endif
> +
> +#endif /* _RESCTRL_H */