mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Babu Moger <babu.moger@amd.com>
To: Reinette Chatre <reinette.chatre@intel.com>,
	tony.luck@intel.com, Dave.Martin@arm.com, james.morse@arm.com,
	bp@alien8.de, ben.horgan@arm.com
Cc: corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org,
	tglx@kernel.org, mingo@redhat.com, dave.hansen@linux.intel.com,
	hpa@zytor.com, fenghuay@nvidia.com, akpm@linux-foundation.org,
	rppt@kernel.org, dapeng1.mi@linux.intel.com, elver@google.com,
	jlayton@kernel.org, enelsonmoore@gmail.com, kuba@kernel.org,
	ebiggers@kernel.org, seanjc@google.com, peterz@infradead.org,
	chao.gao@intel.com, jmattson@google.com, naveen@kernel.org,
	ricardo.neri-calderon@linux.intel.com, tiala@microsoft.com,
	chang.seok.bae@intel.com, prathyushi.nangia@amd.com,
	kim.phillips@amd.com, elena.reshetova@intel.com,
	darwi@linutronix.de, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH v5 09/16] fs/resctrl: Add interface to display supported and active kernel modes
Date: Thu, 17 Sep 2026 10:29:06 -0500	[thread overview]
Message-ID: <31a8026e-a1d3-4866-b32a-780b5127d7a1@amd.com> (raw)
In-Reply-To: <4d22e8ff-1050-4a88-af47-e78c96db1f6e@intel.com>

Hi Reinette,

On 9/16/26 00:32, Reinette Chatre wrote:
> Hi Babu,
> 
> On 8/26/26 12:32 PM, Babu Moger wrote:
>> ---
>>   Documentation/filesystems/resctrl.rst |  29 +++++++
>>   fs/resctrl/rdtgroup.c                 | 115 ++++++++++++++++++++++++++
>>   2 files changed, 144 insertions(+)
>>
>> diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesystems/resctrl.rst
>> index f3e941404967..c6e8cf828e18 100644
>> --- a/Documentation/filesystems/resctrl.rst
>> +++ b/Documentation/filesystems/resctrl.rst
>> @@ -528,6 +528,35 @@ conveyed in the error returns from file operations. E.g.
>>   	# cat info/last_cmd_status
>>   	mask f7 has non-consecutive 1-bits
>>   
>> +"kernel_mode":
>> +	In the top level of the "info" directory, "kernel_mode" reports
>> +	supported and active kernel modes available on the system.
>> +
>> +	Reading the file lists one mode per line. The active mode is wrapped in
>> +	square brackets. inherit_user is shown without options.
>> +	assign_global_enable_per_cpu is shown as::
>> +
>> +	  assign_global_enable_per_cpu:ctrl=<assign|inherit>;mon=<assign|inherit>;group=<ctrl>/<mon>/
>> +
>> +	- inherit_user: inherit allocation and monitoring from the user task.
> 
> To make this easier to read, instead of mixing the modes, could you please have text like:
> 	
> 	Possible kernel modes are:
> 	
> 	<description of inherit_user>
> 
> 	<description of assign_global_enable_per_cpu>
> 
> In addition to being easier to read something like above will also be easier to expand.

Sure. Will do.

> 
>> +	- assign_global_enable_per_cpu: kernel mode may use separate
>> +	  allocation and/or monitoring associations. ctrl= and mon= show
>> +	  whether each is assigned or inherited, and group= identifies the
> 
> Earlier is "ctrl=<assign|inherit>;mon=<assign|inherit>" and above is
> "ctrl= and mon= show whether each is assigned or inherited". This is rewrites
> the same thing in different ways without helping to explain what the parameters
> and their values mean.

Will add of the descriptions of "mon" and "ctrl" states.

> 
> 
>> +	  associated resource group using <CTRL_MON>/<MON>/ path syntax.
> 
> This text is difficult to parse. It switches between "assigned" and "associated"
> *in the same sentence* when referring to the same thing. Please use consistent terms
> and just be specific about what this actually by avoiding this vague language.

Ok. Will rephrase.

> 
>> +
>> +	Only supported modes are listed. On an inactive
>> +	assign_global_enable_per_cpu line, ctrl= and mon= show platform
>> +	capability defaults rather than the last active assignment, and
> 
> I find the text to be very vague. Above could be moved to section dedicated to
> the assign_global_enable_per_cpu mode and be made specific. For example,
> 
> 	When inactive, the parameter values displayed are the default values
> 	that will be used when no new value is provided during enabling/activation(*)
> 	
> 	(*) pick a term and stick with it

Ok. Sure.

> 
>> +	group=// is shown. When the mode is active, ctrl= and mon= report
>> +	the current assignment state and group= identifies the associated
>> +	resource group.
> 
> Last sentence just repeats the paragraph above, no?

Yes. Will rephrase this paragraph.

> 
> 
>> +
>> +	Example::
>> +
>> +	  # cat info/kernel_mode
>> +	  [inherit_user]
>> +	  assign_global_enable_per_cpu:ctrl=assign;mon=assign;group=//
>> +
>>   Resource alloc and monitor groups
>>   =================================
>>   
>> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
>> index 3bb0e3a203ac..992af586a194 100644
>> --- a/fs/resctrl/rdtgroup.c
>> +++ b/fs/resctrl/rdtgroup.c
>> @@ -1010,6 +1010,114 @@ static int rdt_last_cmd_status_show(struct kernfs_open_file *of,
>>   	return 0;
>>   }
>>   
>> +/* Sysfs lines for info/kernel_mode; indexed by enum resctrl_kernel_mode */
>> +static const char * const resctrl_mode_str[] = {
> 
> This is incredibly close to resctrl's existing rdtgroup_mode_str while being
> very high level. Could it be renamed to be more specific to this feature?
> For example, resctrl_kmode_str[]?

Sure.

> 
>> +	[RESCTRL_INHERIT_USER]	=			"inherit_user",
>> +	[RESCTRL_ASSIGN_GLOBAL_ENABLE_PER_CPU] =	"assign_global_enable_per_cpu"
> 
> As mentioned earlier I am starting to think that the "assign" in the name
> is not necessary and creates confusion with the "assign" values of its
> parameters.

Sure. Will remove "assign" from the name.

> 
>> +};
>> +
>> +static_assert(ARRAY_SIZE(resctrl_mode_str) == RESCTRL_NUM_KERNEL_MODES);
>> +
>> +static const char *resctrl_kmode_state_str(enum kmode_state state)
>> +{
>> +	return state == KMODE_ASSIGN ? "assign" : "inherit";
>> +}
>> +
>> +static void resctrl_kmode_group_path(struct rdtgroup *rdtgrp,
>> +				     const char **ctrl, const char **mon)
>> +{
>> +	*ctrl = "";
>> +	*mon = "";
>> +
>> +	if (!rdtgrp)
>> +		return;
>> +
>> +	if (rdtgrp->type == RDTMON_GROUP) {
>> +		*ctrl = rdt_kn_name(rdtgrp->mon.parent->kn);
>> +		*mon = rdt_kn_name(rdtgrp->kn);
>> +	} else {
>> +		*ctrl = rdt_kn_name(rdtgrp->kn);
>> +	}
>> +}
>> +
>> +/**
>> + * resctrl_kernel_mode_show() - Display supported and active kernel modes
>> + * @of: kernfs open file
>> + * @seq: output seq_file
>> + * @v: unused
>> + *
>> + * Lists one line per mode set in resctrl_kcfg.caps.kmode_sup. Brackets the
>> + * active mode. inherit_user is shown without any options.
>> + * assign_global_enable_per_cpu is shown as:
>> + *
>> + *   assign_global_enable_per_cpu:ctrl=<assign|inherit>;mon=<assign|inherit>;\
>> + *					group=<ctrl>/<mon>/
>> + *
>> + * When assign_global_enable_per_cpu is inactive, ctrl=assign and mon=assign
>> + * reflect resctrl_kcfg.caps.ctrl_en and resctrl_kcfg.caps.mon_en, and
>> + * group=//. When active, assign state comes from resctrl_kcfg.active.ctrl_mode
>> + * and resctrl_kcfg.active.mon_mode.
> 
> The code is much easier to read than above summary of it.

Let me rephrase it briefly.

> 
>> + *
>> + * Return: 0 on success, or -ENOENT on error.
>> + */
>> +static int resctrl_kernel_mode_show(struct kernfs_open_file *of,
>> +				    struct seq_file *seq, void *v)
>> +{
>> +	const char *ctrl_state, *mon_state;
>> +	enum resctrl_kernel_mode mode;
>> +	struct rdtgroup *rdtgrp;
>> +	const char *ctrl, *mon;
>> +	bool active;
>> +	int ret = 0;
>> +
>> +	if (!info_kn_lock(of->kn))
>> +		return -ENOENT;
>> +
>> +	for (mode = 0; mode < RESCTRL_NUM_KERNEL_MODES; mode++) {
>> +		if (!test_bit(mode, resctrl_kcfg.caps.kmode_sup))
>> +			continue;
>> +
>> +		active = (resctrl_kcfg.active.kmode_cur == mode);
>> +
>> +		if (mode == RESCTRL_INHERIT_USER) {
>> +			seq_printf(seq, active ? "[%s]\n" : "%s\n",
>> +				   resctrl_mode_str[mode]);
>> +			continue;
>> +		}
>> +
>> +		if (active) {
>> +			ctrl_state = resctrl_kmode_state_str(resctrl_kcfg.active.ctrl_mode);
>> +			mon_state = resctrl_kmode_state_str(resctrl_kcfg.active.mon_mode);
>> +			rdtgrp = resctrl_kcfg.active.k_rdtgrp;
>> +			if (WARN_ON(!rdtgrp)) {
> 
> Just pr_warn() is sufficient and avoids the discussion about panic_on_warn kernels.

ok.

> 
>> +				rdt_last_cmd_puts("Invalid kernel mode group\n");
>> +				ret = -ENOENT;
>> +				goto out_unlock;
>> +			}
>> +			resctrl_kmode_group_path(rdtgrp, &ctrl, &mon);
>> +		} else {
>> +			ctrl_state = resctrl_kcfg.caps.ctrl_en ? "assign" : "inherit";
> 
> This does not look right. As I understand ctrl_en represents whether the system supports
> allocation or not. So above means that if system supports allocation then the allocation
> state is "assign" while a system that does *not* support allocation inherits *allocation*
> association from user space?

When allocation is not supported, we should not print "ctrl". It should 
just print "<mode>:mon=assign;group=//"

Same way just print "<mode>ctrl=assign;group=//" when monitoring is not 
supported.

Will take care of it.
> 
>> +			mon_state = resctrl_kcfg.caps.mon_en ? "assign" : "inherit";
>> +			ctrl = "";
>> +			mon = "";
>> +		}
>> +
>> +		if (active) {
> 
> Why are there two separate "if (active)" blocks?

Will merge it.

> 
>> +			seq_printf(seq, "[%s:ctrl=%s;mon=%s;group=%s/%s/]\n",
> 
> This does not look right. The reason why this version moved to a single global mode
> with parameters is to be able to support systems that do not support allocation or
> monitoring. Having these separate parameters thus enables resctrl to only show the
> "ctrl=" parameter on a system that only supports allocation and only show the
> "mon=" parameter on a system that only supports monitoring. Above just keeps showing
> both whether system supports allocation/monitoring or not.

Yes. That is correct. It should only print states that are supported. 
Will change it.

thanks
Babu

  reply	other threads:[~2026-09-17 15:29 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 19:32 [PATCH v5 00/16] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
2026-08-26 19:32 ` [PATCH v5 01/16] x86/cpufeatures: Support Privilege Level Zero Association (PLZA) Babu Moger
2026-09-16  5:12   ` Reinette Chatre
2026-09-16 20:45     ` Babu Moger
2026-09-17 15:04       ` Reinette Chatre
2026-09-17 17:08         ` Babu Moger
2026-08-26 19:32 ` [PATCH v5 02/16] x86/resctrl: Add PLZA support to command-line options Babu Moger
2026-09-16  5:12   ` Reinette Chatre
2026-09-16 20:45     ` Babu Moger
2026-08-26 19:32 ` [PATCH v5 03/16] x86/resctrl: Add PLZA configuration definitions and data structures Babu Moger
2026-09-16  5:16   ` Reinette Chatre
2026-09-16 20:53     ` Babu Moger
2026-08-26 19:32 ` [PATCH v5 04/16] fs/resctrl: Introduce kernel mode policy enum Babu Moger
2026-09-16  5:14   ` Reinette Chatre
2026-09-16 20:53     ` Babu Moger
2026-08-26 19:32 ` [PATCH v5 05/16] x86,fs/resctrl: Introduce architecture hooks to program kernel mode Babu Moger
2026-09-16  5:26   ` Reinette Chatre
2026-09-16 20:57     ` Babu Moger
2026-08-26 19:32 ` [PATCH v5 06/16] fs/resctrl: Introduce kernel mode states for resctrl Babu Moger
2026-09-16  5:28   ` Reinette Chatre
2026-09-17 14:05     ` Babu Moger
2026-08-26 19:32 ` [PATCH v5 07/16] fs/resctrl: Introduce resctrl_set_kmode_support() to register supported modes Babu Moger
2026-09-16  5:29   ` Reinette Chatre
2026-09-17 14:20     ` Babu Moger
2026-08-26 19:32 ` [PATCH v5 08/16] x86/resctrl: Expose assign_global_enable_per_cpu when PLZA is available Babu Moger
2026-08-26 19:32 ` [PATCH v5 09/16] fs/resctrl: Add interface to display supported and active kernel modes Babu Moger
2026-09-16  5:32   ` Reinette Chatre
2026-09-17 15:29     ` Babu Moger [this message]
2026-08-26 19:32 ` [PATCH v5 10/16] fs/resctrl: Add support for hidden resource group files Babu Moger
2026-09-16  5:33   ` Reinette Chatre
2026-09-17 17:26     ` Babu Moger
2026-08-26 19:32 ` [PATCH v5 11/16] fs/resctrl: Introduce kmode_cpus/kmode_cpus_list per rdtgroup Babu Moger
2026-09-16  5:34   ` Reinette Chatre
2026-08-26 19:32 ` [PATCH v5 12/16] fs/resctrl: Program kernel mode assignments on CPU hotplug Babu Moger
2026-09-16  5:35   ` Reinette Chatre
2026-08-26 19:32 ` [PATCH v5 13/16] fs/resctrl: Deactivate the kernel mode association when a group is removed Babu Moger
2026-09-16  5:36   ` Reinette Chatre
2026-08-26 19:32 ` [PATCH v5 14/16] fs/resctrl: Add interface to modify kernel mode via info/kernel_mode Babu Moger
2026-09-16  5:50   ` Reinette Chatre
2026-08-26 19:32 ` [PATCH v5 15/16] fs/resctrl: Allow user space to write kmode_cpus/kmode_cpus_list Babu Moger
2026-08-26 19:32 ` [PATCH v5 16/16] fs/resctrl: Add documentation on kernel_mode with example Babu Moger
2026-09-01 21:14   ` Luck, Tony
2026-09-01 23:28     ` Moger, Babu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31a8026e-a1d3-4866-b32a-780b5127d7a1@amd.com \
    --to=babu.moger@amd.com \
    --cc=Dave.Martin@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=ben.horgan@arm.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=chao.gao@intel.com \
    --cc=corbet@lwn.net \
    --cc=dapeng1.mi@linux.intel.com \
    --cc=darwi@linutronix.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=ebiggers@kernel.org \
    --cc=elena.reshetova@intel.com \
    --cc=elver@google.com \
    --cc=enelsonmoore@gmail.com \
    --cc=fenghuay@nvidia.com \
    --cc=hpa@zytor.com \
    --cc=james.morse@arm.com \
    --cc=jlayton@kernel.org \
    --cc=jmattson@google.com \
    --cc=kim.phillips@amd.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=naveen@kernel.org \
    --cc=peterz@infradead.org \
    --cc=prathyushi.nangia@amd.com \
    --cc=rdunlap@infradead.org \
    --cc=reinette.chatre@intel.com \
    --cc=ricardo.neri-calderon@linux.intel.com \
    --cc=rppt@kernel.org \
    --cc=seanjc@google.com \
    --cc=skhan@linuxfoundation.org \
    --cc=tglx@kernel.org \
    --cc=tiala@microsoft.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®