mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Babu Moger <babu.moger@amd.com>
To: Qinyun Tan <qinyuntan@linux.alibaba.com>, "Moger, Babu" <bmoger@amd.com>
Cc: "Luck, Tony" <tony.luck@intel.com>,
	Reinette Chatre <reinette.chatre@intel.com>,
	corbet@lwn.net, Dave.Martin@arm.com, james.morse@arm.com,
	tglx@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com,
	x86@kernel.org, feng.tang@linux.alibaba.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 04/12] x86,fs/resctrl: Program PLZA through kmode arch hooks
Date: Mon, 8 Jun 2026 13:17:49 -0500	[thread overview]
Message-ID: <1d7c79bf-1e40-4db7-8f66-45f234b6d87e@amd.com> (raw)
In-Reply-To: <20260605100642.1103628-1-qinyuntan@linux.alibaba.com>

Hi Qinyun,

Thanks for reviewing the patches.

On 6/5/26 05:06, Qinyun Tan wrote:
> On Wed, May 20, 2026 at 06:09:27PM -0500, Moger, Babu wrote:
>> On 5/20/2026 5:16 PM, Luck, Tony wrote:
>>> So maybe I'm just confused by the name
>>> "global_assign_ctrl_inherit_mon_per_cpu"
>>>
>>> That sounds like "Use the CLOSID from PLZA, but keep the RMID from
>>> legacy PQR_ASSOC.
>>
>>> To make that happen, I thing the PLZA MSR should have rmid_en = 0.
>>> But the only code I see that sets this always sets rmid_en=1.
>>
>> Setting rmid_en = 0 in [1] disables counting of kernel usage for
>> RMID 1 (from ctrl1).
> 
> I've been reviewing these patches and went back to the AMD hardware
> manual (Publication #69193, Rev 1.00, March 2026) to understand the
> RMID_EN semantics.
> 
> The spec defines RMID_EN (bit 31 of PQR_PLZA_ASSOC, MSR C000_03FCh):
> 
>      "RMID_EN (PLZA Resource Monitoring Identifier Association Enable)
>       - bit 31. When set and PLZA_EN is set, the Resource Monitoring
>       Identifier (RMID) for this logical processor executing at CPL=0
>       is specified in the RMID field instead of PQR_ASSOC[RMID]."
> 
> Reading "instead of PQR_ASSOC[RMID]", my understanding is that when
> RMID_EN is clear, the hardware falls back to PQR_ASSOC[RMID] - the
> user process's RMID - rather than disabling monitoring entirely.
> If that reading is correct, RMID_EN would be a source selector
> between PLZA and PQR_ASSOC, not an on/off switch for counting.
> 
> Babu, could you confirm whether that is the intended hardware
> behavior?

Yes. That is correct. RMID_EN is a source selector.

> 
>> The key difference between the two modes is:
>>
>> In one mode, user and kernel usage are counted together.
>> In the other mode, kernel usage is counted separately from user usage.
> 
> If RMID_EN=0 does fall back to PQR_ASSOC[RMID], then the "counted
> together" behavior only holds when the user process happens to be in
> the same group as the PLZA-bound group.  Taking Tony's example:
> 
>    # mkdir ctrl1   # CLOSID=1, RMID=1, bound to inherit_mon via PLZA
>    # mkdir ctrl2   # CLOSID=2, RMID=2
>    # echo $$ > ctrl2/tasks
> 
> With rmid_en=1 (current code): when the shell (in ctrl2, PQR_ASSOC
> RMID=2) enters kernel mode, kernel activity is counted under PLZA
> RMID=1.  The user process's RMID is NOT inherited.
> 
> With rmid_en=0: kernel mode would fall back to PQR_ASSOC RMID=2,
> correctly inheriting the monitoring identity of the current user
> process - which seems to be what "inherit_mon" intends.
> 
> If this reading is right, Tony's suggestion of adding a parameter to
> control rmid_en based on the mode would be the right fix:
> 
>    void resctrl_arch_configure_kmode(const struct cpumask *cpu_mask,
>                                      u32 closid, u32 rmid,
>                                      bool assign_rmid, bool enable)
> 
> where assign_rmid=true sets RMID_EN=1 (assign_mon) and
> assign_rmid=false sets RMID_EN=0 (inherit_mon).

Yes. You are right.   I will fix it next revision.
> 
> ---
> 
> Separately, I have a question about the group type constraint for
> global_assign_ctrl_assign_mon_per_cpu (assign_mon mode).
> 
> In patch 08/12 ("fs/resctrl: Make info/kernel_mode writable and
> identify the bound group"), resctrl_kernel_mode_write() enforces that
> assign_mon must bind to an RDTMON_GROUP:
> 
>    if (kmode == BIT(GLOBAL_ASSIGN_CTRL_ASSIGN_MON_PER_CPU) &&
>        rdtgrp->type != RDTMON_GROUP) {
> 
> This forces the user to create a ctrl group plus a monitor sub-group.
> But since the kernel-mode group is dedicated to kernel work and no
> user tasks are assigned to it, the ctrl group's own RMID (allocated
> via alloc_rmid() at mkdir time) should be clean and usable.
> Requiring an extra monitor group seems to waste a scarce RMID.
> 
> Would it make sense to relax this constraint so that assign_mon also
> accepts an RDTCTRL_GROUP?  The path infrastructure
> (rdtgroup_by_kmode_path and resctrl_kernel_mode_show) already handles
> the "<ctrl>//" form, so only the check above would need to change:
> 
>    mkdir /sys/fs/resctrl/kernel_ctrl
>    echo "global_assign_ctrl_assign_mon_per_cpu:group=kernel_ctrl//" \
>         > info/kernel_mode
> 

Yes. That is reasonable.

assign_mon  can be  RDTMON_GROUP or RDTCTRL_GROUP.

inherit_mon can only be RDTCTRL_GROUP.

Thanks

Babu


  reply	other threads:[~2026-06-08 18:17 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30 23:24 [PATCH v3 00/12] [PATCH v3 00/12] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
2026-04-30 23:24 ` [PATCH v3 01/12] x86/resctrl: Support Privilege-Level Zero Association (PLZA) Babu Moger
2026-06-11 23:23   ` Reinette Chatre
2026-06-12 16:56     ` Moger, Babu
2026-06-12 17:00       ` Moger, Babu
2026-06-17  0:00       ` Reinette Chatre
2026-06-17 16:28         ` Babu Moger
2026-04-30 23:24 ` [PATCH v3 02/12] x86/resctrl: Add data structures and definitions for PLZA configuration Babu Moger
2026-06-11 23:40   ` Reinette Chatre
2026-06-12 15:40     ` Luck, Tony
2026-06-12 17:46       ` Moger, Babu
2026-06-12 17:32     ` Moger, Babu
2026-06-12 17:49       ` Moger, Babu
2026-04-30 23:24 ` [PATCH v3 03/12] fs/resctrl: Add kernel mode (kmode) data structures and arch hook Babu Moger
2026-06-16 23:30   ` Reinette Chatre
2026-06-17 19:36     ` Babu Moger
2026-04-30 23:24 ` [PATCH v3 04/12] x86,fs/resctrl: Program PLZA through kmode arch hooks Babu Moger
2026-05-19 20:59   ` Luck, Tony
2026-05-20 17:49     ` Babu Moger
2026-05-20 22:16       ` Luck, Tony
2026-05-20 23:09         ` Moger, Babu
2026-06-05 10:06           ` Qinyun Tan
2026-06-08 18:17             ` Babu Moger [this message]
2026-06-11 11:44           ` Peter Newman
2026-06-11 14:46             ` Babu Moger
2026-06-16 23:33   ` Reinette Chatre
2026-06-17 23:15     ` Moger, Babu
2026-04-30 23:24 ` [PATCH v3 05/12] x86/resctrl: Initialize supported kernel modes for PLZA Babu Moger
2026-06-16 23:35   ` Reinette Chatre
2026-06-18 16:20     ` Babu Moger
2026-04-30 23:24 ` [PATCH v3 06/12] fs/resctrl: Initialize the global kernel-mode policy at subsystem init Babu Moger
2026-06-16 23:36   ` Reinette Chatre
2026-06-18 17:14     ` Babu Moger
2026-06-22 16:21       ` Reinette Chatre
2026-06-22 16:38         ` Babu Moger
2026-04-30 23:24 ` [PATCH v3 07/12] fs/resctrl: Add info/kernel_mode for kernel-mode policy introspection Babu Moger
2026-06-16 23:38   ` Reinette Chatre
2026-06-18 19:16     ` Babu Moger
2026-04-30 23:24 ` [PATCH v3 08/12] fs/resctrl: Make info/kernel_mode writable and identify the bound group Babu Moger
2026-06-16 23:42   ` Reinette Chatre
2026-06-19  1:29     ` Babu Moger
2026-06-22 16:47       ` Reinette Chatre
2026-06-22 19:03         ` Babu Moger
2026-04-30 23:24 ` [PATCH v3 09/12] fs/resctrl: Reset kernel-mode binding when its rdtgroup goes away Babu Moger
2026-06-16 23:42   ` Reinette Chatre
2026-06-19 20:22     ` Babu Moger
2026-04-30 23:24 ` [PATCH v3 10/12] fs/resctrl: Expose kmode_cpus / kmode_cpus_list per rdtgroup Babu Moger
2026-04-30 23:24 ` [PATCH v3 11/12] resctrl: Hide kmode_cpus[_list] on groups not bound to kernel-mode Babu Moger
2026-04-30 23:24 ` [PATCH v3 12/12] fs/resctrl: Allow user space to write kmode_cpus / kmode_cpus_list Babu Moger
2026-06-08  9:23 ` [PATCH v3 00/12] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Qinyun Tan
2026-06-09 14:10   ` Babu Moger
2026-06-10  1:40     ` qinyuntan
2026-06-11 11:17 ` [PATCH 0/4] x86,fs/resctrl: kernel-mode (PLZA) fixes found during review Qinyun Tan
2026-06-11 21:02   ` Babu Moger
2026-06-11 11:17 ` [PATCH 1/4] resctrl: Add kmode arch stubs for ARM MPAM and hide kernel_mode on non-PLZA platforms Qinyun Tan
2026-06-11 11:33   ` [PATCH v2 1/4] resctrl: Add kmode arch stubs for ARM MPAM Qinyun Tan
2026-06-11 11:17 ` [PATCH 2/4] resctrl: Fix PLZA RMID_EN to be mode-based and relax RDTMON_GROUP constraint for assign_mon Qinyun Tan
2026-06-11 11:17 ` [PATCH 3/4] fs/resctrl: make a failed kernel-mode switch a no-op Qinyun Tan
2026-06-11 11:17 ` [PATCH 4/4] fs/resctrl: program PLZA on a CPU that comes online under a binding Qinyun Tan
2026-06-11 21:53 ` [PATCH v3 00/12] [PATCH v3 00/12] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Reinette Chatre
2026-06-12 15:37   ` Moger, Babu
2026-06-17  4:34     ` Reinette Chatre
2026-06-17 15:56       ` Babu Moger
2026-06-17 17:33         ` Reinette Chatre
2026-06-17 19:55           ` Babu Moger
2026-06-26 15:55 ` Luck, Tony
2026-06-29 13:20   ` 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=1d7c79bf-1e40-4db7-8f66-45f234b6d87e@amd.com \
    --to=babu.moger@amd.com \
    --cc=Dave.Martin@arm.com \
    --cc=bmoger@amd.com \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=feng.tang@linux.alibaba.com \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qinyuntan@linux.alibaba.com \
    --cc=reinette.chatre@intel.com \
    --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

Powered by JetHome