Linux Documentation
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Babu Moger <babu.moger@amd.com>, <tony.luck@intel.com>,
	<bp@alien8.de>, <ben.horgan@arm.com>
Cc: <corbet@lwn.net>, <skhan@linuxfoundation.org>,
	<rdunlap@infradead.org>, <x86@kernel.org>, <Dave.Martin@arm.com>,
	<james.morse@arm.com>, <tglx@kernel.org>, <mingo@redhat.com>,
	<dave.hansen@linux.intel.com>, <hpa@zytor.com>,
	<fenghuay@nvidia.com>, <kas@kernel.org>,
	<rick.p.edgecombe@intel.com>, <akpm@linux-foundation.org>,
	<rppt@kernel.org>, <dapeng1.mi@linux.intel.com>,
	<elver@google.com>, <enelsonmoore@gmail.com>,
	<jlayton@kernel.org>, <kuba@kernel.org>, <ebiggers@kernel.org>,
	<seanjc@google.com>, <ewanhai-oc@zhaoxin.com>,
	<binbin.wu@linux.intel.com>, <peterz@infradead.org>,
	<ashish.kalra@amd.com>, <superm1@kernel.org>,
	<chang.seok.bae@intel.com>, <prathyushi.nangia@amd.com>,
	<kim.phillips@amd.com>, <ackerleytng@google.com>,
	<elena.reshetova@intel.com>, <naveen@kernel.org>,
	<darwi@linutronix.de>, <linux-doc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-coco@lists.linux.dev>,
	<kvm@vger.kernel.org>, <eranian@google.com>,
	<peternewman@google.com>
Subject: Re: [PATCH v6 15/18] fs/resctrl: Reject mode changes for groups backing kernel mode
Date: Mon, 19 Oct 2026 15:01:25 -0700	[thread overview]
Message-ID: <e65c5f31-266a-4411-b7d4-873086451065@intel.com> (raw)
In-Reply-To: <592ae38c-3e73-4940-9720-d23f396f83a3@amd.com>

Hi Babu,

On 10/19/26 10:43 AM, Babu Moger wrote:
> On 10/15/26 10:49, Reinette Chatre wrote:
>> On 10/1/26 8:10 AM, Babu Moger wrote:
>>> Prevent mode changes for a resource group that backs the active kernel
>>> mode. Also prevent mode changes to the parent control group of a backing
>>> monitor group, and prevent a backing monitor group from being moved to a
>>> different parent. These restrictions ensure that the active kernel-mode
>>> association remains valid and consistent.
>>
>> "These restrictions ensure that the active kernel-mode association remains
>> valid and consistent." could this be more specific?
>>
>> This patch does two things:
>> - prevent user from switching the mode of the resource group backing the
>>    global per-CPU kernel mode. Why? The reason for this is never given and
>>    there is only a hint in the *code* of the *next* patch that requires the
>>    resource group to be shareable. The next changelog does not mention
>>    this requirement either.
>>    This is important to highlight since a resource group backing the global
>>    kernel mode would have all its resource allocations shared by kernel work
>>    done on behalf of *all* tasks. This makes it a clear requirement for this
>>    group to be shareable and for its mode to never change.
>>    This highlights that there is an ordering issue with the patches since this
>>    series establishes the requirement after it enforces the requirement.
> 
> This check is only exercised when userspace attempts to activate the kernel mode, which is introduced in the next patch.  I can merge this change in the next patch.

The next patch is already quite large. I would instead suggest that the
changelog of next patch includes why a resource group backing the global
kernel mode is required to be shareable. This patch can then follow after
that to ensure that the mode of a resource group backing kernel mode cannot
change.

> 
>> - prevent a monitor group backing global kernel mode from being moved to
>>    another control group. Why should this be prevented? Could the global
>>    kernel mode not just be reconfigured, just like when user space
>>    provides it a new group? This is a design decision that is never motivated.
> 
> [1] There is no specific reason for preventing it. I just did not
> consider it a use case. Also, changing the parent of a backing
> monitor group affects both groups because the kernel resource
> allocation is moved from one group to another.
> 
> If there is a valid use case for supporting this, we could allow it
> and update the kernel mode association accordingly. What do you
> think?

Up to you, but please make these design decisions explicit. Do not hide them
behind hand waving like "These restrictions ensure that the active kernel-mode
association remains valid and consistent.". If you choose to delay this support
until your customers ask for it then please change the message to something
that highlights this. For example, "Cannot move a group that backs kernel mode"
can be something like "Moving the MON group that backs global_enable_per_cpu kernel
mode is not supported."

>>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>>> ---
>>> v6: New patch to fix sashiko feedback.
>>>      https://sashiko.dev/#/patchset/cover.1787772750.git.babu.moger%40amd.com
>>> ---
>>>   fs/resctrl/internal.h |  2 ++
>>>   fs/resctrl/rdtgroup.c | 35 +++++++++++++++++++++++++++++++++++
>>>   2 files changed, 37 insertions(+)
>>>
>>> diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
>>> index 6b8d14c4bd83..84238e9e8e15 100644
>>> --- a/fs/resctrl/internal.h
>>> +++ b/fs/resctrl/internal.h
>>> @@ -462,6 +462,8 @@ ssize_t resctrl_mbm_assign_mode_write(struct kernfs_open_file *of, char *buf,
>>>   void resctrl_bmec_files_show(struct rdt_resource *r, struct kernfs_node *l3_mon_kn,
>>>                    bool show);
>>>   +bool rdtgroup_has_kmode_global(struct rdtgroup *rdtgrp);
>>
>> Does not look like this is needed, can this function just be static within fs/resctrl/rdtgroup.c?
> 
> 
> Yes. The only issue is the build dependency. Since the function is
> declared static, it needs a caller in the same patch. One option is
> to merge this change with the next patch, which is where the
> function is first used.

There is a caller in this patch, no?

 
>>
>>> +
>>>   int resctrl_num_mbm_cntrs_show(struct kernfs_open_file *of, struct seq_file *s, void *v);
>>>     int resctrl_available_mbm_cntrs_show(struct kernfs_open_file *of, struct seq_file *s,
>>> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
>>> index 98451b417fe3..dcf9f26540d6 100644
>>> --- a/fs/resctrl/rdtgroup.c
>>> +++ b/fs/resctrl/rdtgroup.c
>>> @@ -1738,6 +1738,27 @@ static bool rdtgroup_mode_test_exclusive(struct rdtgroup *rdtgrp)
>>>       return true;
>>>   }
>>>   +/* True when @rdtgrp or one of its monitor groups backs the kernel mode. */
>>> +bool rdtgroup_has_kmode_global(struct rdtgroup *rdtgrp)
>>> +{
>>> +    struct rdtgroup *child;
>>> +
>>> +    if (!resctrl_kmode.rdtgrp)
>>> +        return false;
>>> +
>>> +    if (resctrl_kmode.rdtgrp == rdtgrp)
>>> +        return true;
>>> +
>>> +    if (rdtgrp->type != RDTCTRL_GROUP)
>>> +        return false;
>>> +
>>> +    list_for_each_entry(child, &rdtgrp->mon.crdtgrp_list, mon.crdtgrp_list)
>>> +        if (child == resctrl_kmode.rdtgrp)
>>> +            return true;
>>> +
>>> +    return false;
>>> +}
>>> +
>>>   /*
>>>    * rdtgroup_mode_write - Modify the resource group's mode
>>>    */
>>> @@ -1778,6 +1799,12 @@ static ssize_t rdtgroup_mode_write(struct kernfs_open_file *of,
>>>           goto out;
>>>       }
>>>   +    if (rdtgroup_has_kmode_global(rdtgrp)) {

Above calls rdtgroup_has_kmode_global().

>>> +        rdt_last_cmd_puts("Cannot change mode for kernel-mode assigned group\n");
>>
>> The messages to user space also switch back and forth between kernel mode and kernel-mode.
> 
> Will change to  "kernel mode".
> 
>>
>>> +        ret = -EINVAL;
>>> +        goto out;
>>> +    }
>>> +
>>>       if (!strcmp(buf, "shareable")) {
>>>           if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
>>>               ret = rdtgroup_locksetup_exit(rdtgrp);
>>> @@ -4697,6 +4724,14 @@ static int rdtgroup_rename(struct kernfs_node *kn,
>>>           goto out;
>>>       }
>>>   +    /* Reject moving to different parent if group backs kernel-mode */
>>
>> Comment states the obvious. Could it instead state *why* this is rejected?
> 
> Same reason as in [1].

ok ... but could the comment be changed to reflect this design choice instead
of stating what is obvious just by looking at the code?

Reinette

  reply	other threads:[~2026-10-19 22:01 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 15:10 [PATCH v6 00/18] x86,fs/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
2026-10-01 15:10 ` [PATCH v6 01/18] x86/cpufeatures: Support Privilege Level Zero Association (PLZA) Babu Moger
2026-10-15 14:16   ` Reinette Chatre
2026-10-15 23:02     ` Babu Moger
2026-10-01 15:10 ` [PATCH v6 02/18] x86/resctrl: Add PLZA support to command-line options Babu Moger
2026-10-15 14:17   ` Reinette Chatre
2026-10-15 23:03     ` Babu Moger
2026-10-01 15:10 ` [PATCH v6 03/18] x86/resctrl: Add PLZA configuration definitions and data structures Babu Moger
2026-10-15 14:22   ` Reinette Chatre
2026-10-15 23:07     ` Babu Moger
2026-10-19 16:16       ` Reinette Chatre
2026-10-01 15:10 ` [PATCH v6 04/18] fs/resctrl: Introduce kernel mode enum Babu Moger
2026-10-15 14:44   ` Reinette Chatre
2026-10-15 23:09     ` Babu Moger
2026-10-19 16:17       ` Reinette Chatre
2026-10-01 15:10 ` [PATCH v6 05/18] x86,arm,fs/resctrl: Introduce architecture hook to program global kernel mode Babu Moger
2026-10-15 14:30   ` Reinette Chatre
2026-10-15 23:12     ` Moger, Babu
2026-10-01 15:10 ` [PATCH v6 06/18] fs/resctrl: Introduce kernel mode states for resctrl Babu Moger
2026-10-15 14:37   ` Reinette Chatre
2026-10-16 15:10     ` Moger, Babu
2026-10-19 16:18       ` Reinette Chatre
2026-10-01 15:10 ` [PATCH v6 07/18] fs/resctrl: Introduce resctrl_set_kmode_support() to register supported modes Babu Moger
2026-10-15 14:40   ` Reinette Chatre
2026-10-16 15:27     ` Moger, Babu
2026-10-19 16:19       ` Reinette Chatre
2026-10-01 15:10 ` [PATCH v6 08/18] x86/resctrl: Register RESCTRL_GLOBAL_ENABLE_PER_CPU when PLZA is available Babu Moger
2026-10-15 14:46   ` Reinette Chatre
2026-10-16 15:50     ` Moger, Babu
2026-10-01 15:10 ` [PATCH v6 09/18] fs/resctrl: Add interface to display kernel mode status Babu Moger
2026-10-15 15:16   ` Reinette Chatre
2026-10-16 19:10     ` Moger, Babu
2026-10-19 16:20       ` Reinette Chatre
2026-10-01 15:10 ` [PATCH v6 10/18] fs/resctrl: Add support for hidden resource group files Babu Moger
2026-10-15 15:27   ` Reinette Chatre
2026-10-16 20:53     ` Moger, Babu
2026-10-19 16:22       ` Reinette Chatre
2026-10-01 15:10 ` [PATCH v6 11/18] fs/resctrl: Introduce kmode_cpus/kmode_cpus_list per rdtgroup Babu Moger
2026-10-15 15:31   ` Reinette Chatre
2026-10-16 21:33     ` Moger, Babu
2026-10-19 16:34       ` Reinette Chatre
2026-10-01 15:10 ` [PATCH v6 12/18] fs/resctrl: Add CPU hotplug support for kernel mode associations Babu Moger
2026-10-15 15:33   ` Reinette Chatre
2026-10-16 22:21     ` Moger, Babu
2026-10-01 15:10 ` [PATCH v6 13/18] fs/resctrl: Deactivate kernel mode associations when a group is removed Babu Moger
2026-10-15 15:43   ` Reinette Chatre
2026-10-19 15:47     ` Babu Moger
2026-10-19 16:37       ` Reinette Chatre
2026-10-01 15:10 ` [PATCH v6 14/18] fs/resctrl: Control visibility of global per-CPU kernel mode group files Babu Moger
2026-10-15 15:46   ` Reinette Chatre
2026-10-19 16:31     ` Babu Moger
2026-10-19 22:00       ` Reinette Chatre
2026-10-01 15:10 ` [PATCH v6 15/18] fs/resctrl: Reject mode changes for groups backing kernel mode Babu Moger
2026-10-15 15:49   ` Reinette Chatre
2026-10-19 17:43     ` Babu Moger
2026-10-19 22:01       ` Reinette Chatre [this message]
2026-10-01 15:10 ` [PATCH v6 16/18] fs/resctrl: Add interface to modify kernel mode via info/kernel_mode Babu Moger
2026-10-15 16:07   ` Reinette Chatre
2026-10-20  0:21     ` Babu Moger
2026-10-01 15:10 ` [PATCH v6 17/18] fs/resctrl: Allow user space to write kmode_cpus/kmode_cpus_list Babu Moger
2026-10-01 15:10 ` [PATCH v6 18/18] fs/resctrl: Add kernel mode documentation and examples Babu Moger
2026-10-17  0:13 ` [PATCH v6 00/18] x86,fs/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Drew Fustini

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=e65c5f31-266a-4411-b7d4-873086451065@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=Dave.Martin@arm.com \
    --cc=ackerleytng@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=ashish.kalra@amd.com \
    --cc=babu.moger@amd.com \
    --cc=ben.horgan@arm.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@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=eranian@google.com \
    --cc=ewanhai-oc@zhaoxin.com \
    --cc=fenghuay@nvidia.com \
    --cc=hpa@zytor.com \
    --cc=james.morse@arm.com \
    --cc=jlayton@kernel.org \
    --cc=kas@kernel.org \
    --cc=kim.phillips@amd.com \
    --cc=kuba@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=naveen@kernel.org \
    --cc=peternewman@google.com \
    --cc=peterz@infradead.org \
    --cc=prathyushi.nangia@amd.com \
    --cc=rdunlap@infradead.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=rppt@kernel.org \
    --cc=seanjc@google.com \
    --cc=skhan@linuxfoundation.org \
    --cc=superm1@kernel.org \
    --cc=tglx@kernel.org \
    --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