Skip to contentSkip to conversation

arm,x86,fs/resctrl: Generic schema description Proof of Concept

RFC In review Reinette Chatre 9 participants 56 messages Aug 4 – Nov 19

Subsystems (3)
lore
Share & tools
lore

Reinette Chatre

author maintainer
#0 lore raw

Hi Everybody,

I understand that folks are eager for this work to settle so that features that depend on it can make progress.

I do have a request if you have a feature that depends on this PoC:

Please do not fork this PoC and keep changes to the PoC code in your fork to meet the requirements of the feature you are working on. This is resulting in duplicate (even triplicate) changes to PoC floating around. Instead, please collaborate on this PoC by responding to the patches that need changes/fixes to support your feature. If the patches do not exist yet, please participate in the discussions that plan these changes so the work adding the discussed features is not duplicated. If you already have the code, please feel free to send as fixups. Doing so will help this PoC to settle faster and help meet the requirements of the feature(s) a couple of folks are working on.

RFC v1: https://lore.kernel.org/lkml/[email protected]/
git://git.kernel.org/pub/scm/linux/kernel/git/reinette/linux.git branch resctrl/controls_rfc_v1

RFC v2 of this PoC can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/reinette/linux.git branch resctrl/controls_rfc_v2

The list of changes is long. For an overview of the new interfaces, please see the new documentation patch:
https://git.kernel.org/pub/scm/linux/kernel/git/reinette/linux.git/patch/?id=2e2d0140e857eae2ba3e71e8d9c595897649599a

Remaining Opens:
---------------
- MPAM only compile tested.
- Only "SAMPLE" code provided for x86 to demonstrate emulated controls.
- Architecture should take care to restore control value of legacy control when switching mode from "native" to "legacy". This may be complicated by a legacy control backed by multiple native controls and thus best handled by architecture. This adds a complication that resctrl cannot promise that switching between control modes will not be destructive since a reverse mapping may not exist.
- When switching control mode to native the top level control info files stop returning information. This could be considered "work as intended"?
- Add relationships between controls. For example, cannot set "MIN" control value to be larger than "MAX. Unclear how to do this in resctrl fs when considering that the relationship may span between enabled and disabled controls. This is potentially something that needs to be managed by architecture and thus potentially without a consistent failure to user space.

Changes since RFC v1:
--------------------
There are many changes since RFC v1 since I aimed to address all feedback (but please see the deferred/dropped list below). If I missed anything it was not intentional. Please feel free to point it out to me.

User visible changes:
--------------------
- Expose bitmap control properties to user space.
-- Only expose two properties:
- resctrl_ctrl_bitmap::min_cbm_bits exposed via new file "min_bits".
This drops the familiar "cbm" term to not make the control specific
to capacity.
- resctrl_ctrl_bitmap::cbm_len exposed via "max" file
-- While "shareable_bits" is technically a bitmap control property this does
seem an opportunity to deprecate it since the IO alloc support proved
that it does not accurately represent shared allocations, "bit_usage"
is the best for that.
- Add support for control flags with "linear" as first flag of the "scalar"
control and "sparse" the first flag of the "bitmap" control.
Include flags in output of the "type" file.
Suggested by Chenyu: https://lore.kernel.org/lkml/[email protected]/
- Add a "default" field to a control using the "reset_val" name suggested
by Drew and return that instead of always using "max" for the scalar control.
The "MIN" control can return its minimum value as default.
Suggested by Ben in https://lore.kernel.org/lkml/[email protected]/
Use case from Drew: https://lore.kernel.org/lkml/aiCBratZchVFVhws@gen8/
Drew suggested name as "reset_val" https://lore.kernel.org/lkml/aiOrznnZjTGywMna@thelio>
- Change "resource_schemata" to "schemata".
Fenghua: https://lore.kernel.org/lkml/[email protected]/
- Fix the control alignment. (Chenyu and Tony)
- Drop the "per control" scope. Move the "scope" back to being per-resource and
do not expose a per control "scope" file. This helps to support new resources like node scoped MBA that cannot emulate the legacy MB control. Also
supports emulated controls by ensuring that all controls associated with
a resource have the same scope.
- Support emulating legacy control.
- Support multiple backing controls for a legacy control.
- Expose new per-resource "control_mode" file that user space can use to
switch between legacy and native controls. Only the enabled controls
are shown to user in schemata file.
- The new "native" control mode is only supported for the MBA resource.
The solution is generic but there are implications for, for example, the resctrl features that rely on the legacy cache control (cache pseudo-locking and IO alloc). Defer support for other resource since there are no immediate plans to have, for example, the legacy cache control backed by something else.
- Architecture differences imply a lot of architecture flexibility in
support for emulating controls.
Architecture can expect resctrl fs to only stage control values in
controls that are enabled. Within architecture there could be rules
that determine what to program based on the control's emulated controls
or it could dynamically program update callbacks when the user changes
the control mode. RFC includes sample code identified by "SAMPLE" for the latter that demonstrates one way to solve the x86 variant where the hardware self supports both legacy and finer grained controls.
- The top level legacy control property files stop returning data when
the mode switches to "native".
- Draft of documentation that describes multiple controls and emulated
controls.
- Fix Intel MBA tolerance to be 10 to match the "round-up" implementation.

Changes not user visible:
-------------------------
- Rebase on tip x86/cache with following applied on top:
"x86,fs/resctrl: Improve resctrl quality and consistency"

    https://lore.kernel.org/lkml/[email protected]/
  "x86,fs/resctrl,arm_mpam: Factor MBA parse-time conversion to be per-arch"
    https://lore.kernel.org/lkml/[email protected]/

- Fix initialization of controls list in MPAM. (Ben)
- Dan Carpenter reported an issue with missing unlocks in
rdt_bit_usage_show() that was resolved as part of rebase on top of the
new info_kn_lock()/info_kn_unlock() helpers.
- Drop "mpam,x86,fs/resctrl: Make memory bandwidth delay a resource
property" so that memory bandwidth delay linear flag can be a control flag instead.
- Separate adding the control to struct msr_param from the change that
makes hardware update functions part of control.
("x86/resctrl: Make control update properties part of the control") to
create new patch that is moved earlier in series to support bandwidth
linear flag property being part of control.
New patch: "x86/resctrl: Include control with information controlling hardware change"
- Rename the controls to match their type to reduce confusion.
Suggested by Chenyu: https://lore.kernel.org/lkml/[email protected]/
New names:
struct resctrl_membw -> struct resctrl_ctrl_scalar
struct resctrl_cache -> struct resctrl_ctrl_bitmap
resctrl_ctrl::membw -> resctrl_ctrl::scalar
resctrl_ctrl::cache -> resctrl_ctrl::bitmap
- Switch subject prefix to be "arm,x86,fs/resctrl: ..." when changing both architectures and resctrl fs code.
- Switch to MPAM subject prefix of "arm_mpam: resctrl:" when only changing
MPAM code.

Changes deferred/dropped:
------------------------
- Let "scope" form part of the control name.
Drop this since the current plan is to have the scope be part of the resource name for new resources.
- Introduce new per-control "status" that can be "enabled" or "disabled". Drop this. While controls now have an "enabled" or "disabled" state internally, this is not exposed to user space via a file. Instead, the "enabled" or "disabled" state is exposed to user space via the entries appearing in schemata file. This simplifies the subtleties when the hardware self supports both legacy and finer grained interfaces (aka RDT's region-aware).
- Defer emulated control support for cache controls.
- Supporting different monitoring scope is not part of this PoC.

Any feedback is appreciated.

Reinette

maintainer
#1 lore raw

Hi Reinette,

Quoted 152 lines · Reinette Chatre

Hi Everybody,

I understand that folks are eager for this work to settle so that features that depend on it can make progress.

I do have a request if you have a feature that depends on this PoC:

Please do not fork this PoC and keep changes to the PoC code in your fork to meet the requirements of the feature you are working on. This is resulting in duplicate (even triplicate) changes to PoC floating around. Instead, please collaborate on this PoC by responding to the patches that need changes/fixes to support your feature. If the patches do not exist yet, please participate in the discussions that plan these changes so the work adding the discussed features is not duplicated. If you already have the code, please feel free to send as fixups. Doing so will help this PoC to settle faster and help meet the requirements of the feature(s) a couple of folks are working on.

RFC v1: https://lore.kernel.org/lkml/[email protected]/
git://git.kernel.org/pub/scm/linux/kernel/git/reinette/linux.git branch resctrl/controls_rfc_v1

RFC v2 of this PoC can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/reinette/linux.git branch resctrl/controls_rfc_v2

The list of changes is long. For an overview of the new interfaces, please see the new documentation patch:
https://git.kernel.org/pub/scm/linux/kernel/git/reinette/linux.git/patch/?id=2e2d0140e857eae2ba3e71e8d9c595897649599a

Remaining Opens:
---------------
- MPAM only compile tested.
- Only "SAMPLE" code provided for x86 to demonstrate emulated controls.
- Architecture should take care to restore control value of legacy control when switching mode from "native" to "legacy". This may be complicated by a legacy control backed by multiple native controls and thus best handled by architecture. This adds a complication that resctrl cannot promise that switching between control modes will not be destructive since a reverse mapping may not exist.
- When switching control mode to native the top level control info files stop returning information. This could be considered "work as intended"?
- Add relationships between controls. For example, cannot set "MIN" control value to be larger than "MAX. Unclear how to do this in resctrl fs when considering that the relationship may span between enabled and disabled controls. This is potentially something that needs to be managed by architecture and thus potentially without a consistent failure to user space.

Changes since RFC v1:
--------------------
There are many changes since RFC v1 since I aimed to address all feedback (but please see the deferred/dropped list below). If I missed anything it was not intentional. Please feel free to point it out to me.

User visible changes:
--------------------
- Expose bitmap control properties to user space.
-- Only expose two properties:
- resctrl_ctrl_bitmap::min_cbm_bits exposed via new file "min_bits".
This drops the familiar "cbm" term to not make the control specific
to capacity.
- resctrl_ctrl_bitmap::cbm_len exposed via "max" file
-- While "shareable_bits" is technically a bitmap control property this does
seem an opportunity to deprecate it since the IO alloc support proved
that it does not accurately represent shared allocations, "bit_usage"
is the best for that.
- Add support for control flags with "linear" as first flag of the "scalar"
control and "sparse" the first flag of the "bitmap" control.
Include flags in output of the "type" file.
Suggested by Chenyu: https://lore.kernel.org/lkml/[email protected]/
- Add a "default" field to a control using the "reset_val" name suggested
by Drew and return that instead of always using "max" for the scalar control.
The "MIN" control can return its minimum value as default.
Suggested by Ben in https://lore.kernel.org/lkml/[email protected]/
Use case from Drew: https://lore.kernel.org/lkml/aiCBratZchVFVhws@gen8/
Drew suggested name as "reset_val" https://lore.kernel.org/lkml/aiOrznnZjTGywMna@thelio>
- Change "resource_schemata" to "schemata".
Fenghua: https://lore.kernel.org/lkml/[email protected]/
- Fix the control alignment. (Chenyu and Tony)
- Drop the "per control" scope. Move the "scope" back to being per-resource and
do not expose a per control "scope" file. This helps to support new resources like node scoped MBA that cannot emulate the legacy MB control. Also
supports emulated controls by ensuring that all controls associated with
a resource have the same scope.
- Support emulating legacy control.
- Support multiple backing controls for a legacy control.
- Expose new per-resource "control_mode" file that user space can use to
switch between legacy and native controls. Only the enabled controls
are shown to user in schemata file.
- The new "native" control mode is only supported for the MBA resource.
The solution is generic but there are implications for, for example, the resctrl features that rely on the legacy cache control (cache pseudo-locking and IO alloc). Defer support for other resource since there are no immediate plans to have, for example, the legacy cache control backed by something else.
- Architecture differences imply a lot of architecture flexibility in
support for emulating controls.
Architecture can expect resctrl fs to only stage control values in
controls that are enabled. Within architecture there could be rules
that determine what to program based on the control's emulated controls
or it could dynamically program update callbacks when the user changes
the control mode. RFC includes sample code identified by "SAMPLE" for the latter that demonstrates one way to solve the x86 variant where the hardware self supports both legacy and finer grained controls.
- The top level legacy control property files stop returning data when
the mode switches to "native".
- Draft of documentation that describes multiple controls and emulated
controls.
- Fix Intel MBA tolerance to be 10 to match the "round-up" implementation.

Changes not user visible:
-------------------------
- Rebase on tip x86/cache with following applied on top:
"x86,fs/resctrl: Improve resctrl quality and consistency"

    https://lore.kernel.org/lkml/[email protected]/
  "x86,fs/resctrl,arm_mpam: Factor MBA parse-time conversion to be per-arch"
    https://lore.kernel.org/lkml/[email protected]/

- Fix initialization of controls list in MPAM. (Ben)
- Dan Carpenter reported an issue with missing unlocks in
rdt_bit_usage_show() that was resolved as part of rebase on top of the
new info_kn_lock()/info_kn_unlock() helpers.
- Drop "mpam,x86,fs/resctrl: Make memory bandwidth delay a resource
property" so that memory bandwidth delay linear flag can be a control flag instead.
- Separate adding the control to struct msr_param from the change that
makes hardware update functions part of control.
("x86/resctrl: Make control update properties part of the control") to
create new patch that is moved earlier in series to support bandwidth
linear flag property being part of control.
New patch: "x86/resctrl: Include control with information controlling hardware change"
- Rename the controls to match their type to reduce confusion.
Suggested by Chenyu: https://lore.kernel.org/lkml/[email protected]/
New names:
struct resctrl_membw -> struct resctrl_ctrl_scalar
struct resctrl_cache -> struct resctrl_ctrl_bitmap
resctrl_ctrl::membw -> resctrl_ctrl::scalar
resctrl_ctrl::cache -> resctrl_ctrl::bitmap
- Switch subject prefix to be "arm,x86,fs/resctrl: ..." when changing both architectures and resctrl fs code.
- Switch to MPAM subject prefix of "arm_mpam: resctrl:" when only changing
MPAM code.

Changes deferred/dropped:
------------------------
- Let "scope" form part of the control name.
Drop this since the current plan is to have the scope be part of the resource name for new resources.
- Introduce new per-control "status" that can be "enabled" or "disabled". Drop this. While controls now have an "enabled" or "disabled" state internally, this is not exposed to user space via a file. Instead, the "enabled" or "disabled" state is exposed to user space via the entries appearing in schemata file. This simplifies the subtleties when the hardware self supports both legacy and finer grained interfaces (aka RDT's region-aware).
- Defer emulated control support for cache controls.
- Supporting different monitoring scope is not part of this PoC.

Quoted 1 line

Any feedback is appreciated.

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +2 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
        case RDT_RESOURCE_L3:
                mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP;
                mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
                __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags);
                mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                r->ctrl_scope = RESCTRL_L3_CACHE;
                mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
                r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

I haven't a good look at the code yet but from the list of changes you have above it seems to be heading in the right direction. Thank you for all the work on this and for always considering MPAM in the design. I'm out of office for a couple of weeks but I'll give this a better look when I'm back.

One little thing that seems odd is that control_mode shows 'native' as an option even if there are no emulated controls.

$ cat info/L3/control_mode
[legacy] native

Thanks,

Ben

Quoted 2 lines

Reinette

author maintainer
#2 lore raw

Hi Ben,

Quoted 16 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +1 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
        case RDT_RESOURCE_L3:
                mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP;
                mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
                __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags);
                mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 7 lines
drivers/resctrl/mpam_resctrl.c +1 -0
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                r->ctrl_scope = RESCTRL_L3_CACHE;
                mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
                r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Quoted 9 lines

I haven't a good look at the code yet but from the list of changes you have above it seems to be heading in the right direction. Thank you for all the work on this and for always considering MPAM in the design. I'm out of office for a couple of weeks but I'll give this a better look when I'm back.

One little thing that seems odd is that control_mode shows 'native' as an option even if there are no emulated controls.

$ cat info/L3/control_mode
[legacy] native

Yes, that is odd. Especially for the L3 resource that, on top of not having no emulated controls, does not even support switching of the control mode. I'll fix this. Thank you very much.

Reinette

maintainer
#3 lore raw
Quoted 25 lines · Reinette Chatre

Hi Ben,

Quoted 22 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +2 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
        case RDT_RESOURCE_L3:
                mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP;
                mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
                __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags);
                mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                r->ctrl_scope = RESCTRL_L3_CACHE;
                mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
Quoted 3 lines

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 1 line
drivers/resctrl/mpam_resctrl.c +0 -0
                r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

-Tony

author maintainer
#4 lore raw

Hi Tony,

Quoted 26 lines · Tony
Quoted 25 lines · Reinette Chatre

Hi Ben,

Quoted 22 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +2 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
        case RDT_RESOURCE_L3:
                mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP;
                mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
                __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags);
                mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                r->ctrl_scope = RESCTRL_L3_CACHE;
                mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
Quoted 6 lines
Quoted 3 lines

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 1 line
drivers/resctrl/mpam_resctrl.c +0 -0
                r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Reinette

#5 lore raw

Hi Reinette,

Thanks for the patches. I am yet to look at all the patches.

Quoted 35 lines · Reinette Chatre

Hi Tony,

Quoted 26 lines · Tony
Quoted 25 lines · Reinette Chatre

Hi Ben,

Quoted 22 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +2 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
         case RDT_RESOURCE_L3:
                 mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP;
                 mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                 INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
                 __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags);
                 mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                 r->ctrl_scope = RESCTRL_L3_CACHE;
                 mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                 mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                 INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
Quoted 6 lines
Quoted 3 lines

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 1 line
drivers/resctrl/mpam_resctrl.c +0 -0
                 r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

Quoted 9 lines

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Looking at the commit:

commit 3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

Based on the patch description, emulated controls are intended to be used only when there is a difference between the native and legacy controls. If no such difference exists, both modes should operate identically.

For MBA(AMD) and GMBA, there does not appear to be any difference between the two modes. Is that understanding correct?

Thanks
Babu

author maintainer
#6 lore raw

Hi Babu,

Quoted 42 lines · Babu
Quoted 31 lines · Reinette Chatre
Quoted 24 lines · Tony
Quoted 23 lines · Reinette Chatre
Quoted 22 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +0 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)

         case RDT_RESOURCE_L3:
                 mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP; mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by); INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains); __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags); mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;

drivers/resctrl/mpam_resctrl.c +1 -0
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                  r->ctrl_scope = RESCTRL_L3_CACHE;
                  mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                  mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                  INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
Quoted 6 lines
Quoted 3 lines

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 1 line
drivers/resctrl/mpam_resctrl.c +0 -0
                  r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

Quoted 9 lines

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Quoted 8 lines

Looking at the commit:

commit 3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

Based on the patch description, emulated controls are intended to be used only when there is a difference between the native and legacy controls. If no such difference exists, both modes should operate identically.

The original AMD MBA enabling did not follow the original percentage based MBA control so resctrl essentially has *two* "legacy" MB controls today: one for AMD and one for Intel, MPAM, and RISC-V (planned afaik). That cannot be changed now. AMD would continue to expose the MB control that is not the percentage based "legacy" control but actually AMD's native control. In short, yes, on AMD's "MB" control the "legacy" and "native" control modes should operate identically.
At least now users could use the files in info/MB/schemata/MB/* to learn the properties of the control.

Quoted 2 lines

For MBA(AMD) and GMBA, there does not appear to be any difference between the two modes. Is that understanding correct?

It is not clear to me how resctrl should support AMD's GLBE. Note I am intentionally not using GMBA since that already makes an assumption on how resctrl will support this. Do you perhaps have an answer for Ben's question in
https://lore.kernel.org/lkml/[email protected]/ ?

GLBE claims to enable users to allocate memory bandwidth at node scope but the memory is managed at L3. This results in scenarios where, for example, a NUMA node can be online and used but resctrl cannot expose it for bandwidth allocation when all the CPUs at that NUMA node scope are offline. GLBE is thus not actually allocating memory bandwidth at the NUMA node.

Should resctrl prepare for some future where an AMD system may support memory bandwidth allocation at the NUMA node while also supporting GLBE (memory bandwidth allocation at L3)?

Reinette

#7 lore raw

Hi Reinette/Ben,

Quoted 62 lines · Reinette Chatre

Hi Babu,

Quoted 42 lines · Babu
Quoted 31 lines · Reinette Chatre
Quoted 24 lines · Tony
Quoted 23 lines · Reinette Chatre
Quoted 22 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +2 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
          case RDT_RESOURCE_L3:
                  mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP;
                  mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                  INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
                  __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags);
                  mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                  r->ctrl_scope = RESCTRL_L3_CACHE;
                  mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                  mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                  INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
Quoted 6 lines
Quoted 3 lines

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 1 line
drivers/resctrl/mpam_resctrl.c +0 -0
                  r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

Quoted 9 lines

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Quoted 8 lines

Looking at the commit:

commit 3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

Based on the patch description, emulated controls are intended to be used only when there is a difference between the native and legacy controls. If no such difference exists, both modes should operate identically.

The original AMD MBA enabling did not follow the original percentage based MBA control so resctrl essentially has *two* "legacy" MB controls today: one for AMD and one for Intel, MPAM, and RISC-V (planned afaik). That cannot be changed now. AMD would continue to expose the MB control that is not the percentage based "legacy" control but actually AMD's native control. In short, yes, on AMD's "MB" control the "legacy" and "native" control modes should operate identically.
At least now users could use the files in info/MB/schemata/MB/* to learn the properties of the control.

Quoted 6 lines
Quoted 2 lines

For MBA(AMD) and GMBA, there does not appear to be any difference between the two modes. Is that understanding correct?

It is not clear to me how resctrl should support AMD's GLBE. Note I am intentionally not using GMBA since that already makes an assumption on how resctrl will support this. Do you perhaps have an answer for Ben's question in
https://lore.kernel.org/lkml/[email protected]/ ?

Yes. We are already at RFC v2. Let me respond here. Please see my response below.

Quoted 6 lines

GLBE claims to enable users to allocate memory bandwidth at node scope but the memory is managed at L3. This results in scenarios where, for example, a NUMA node can be online and used but resctrl cannot expose it for bandwidth allocation when all the CPUs at that NUMA node scope are offline. GLBE is thus not actually allocating memory bandwidth at the NUMA node.

Yea. That is correct.

There are a couple of key differences when compared to the pure NUMA scope.

1. In some cases, a NUMA node is treated as the entire system.

https://lore.kernel.org/lkml/8f77f498b1c77fa8fd8f5d5687f03ae598068544.1776980182.git.babu.moger@amd.com/

2. When a user updates the settings on a GLBE for a specific node, we need to update the MSRs within that node at the L3 scope:

https://lore.kernel.org/lkml/a2a06bd290e68f902be9e7cc3ad35f0a2211b950.1776980182.git.babu.moger@amd.com/

Considering these differences, I think we should probably treat GLBE separate from MB_NODE scope. What do you think?

Quoted 3 lines

Should resctrl prepare for some future where an AMD system may support memory bandwidth allocation at the NUMA node while also supporting GLBE (memory bandwidth allocation at L3)?

No, I don't believe that's the case. At least, I haven't come across any information suggesting that.

Thanks,
Babu

author maintainer
#8 lore raw

Hi Babu and Ben,

Quoted 90 lines · Babu

Hi Reinette/Ben,

Quoted 62 lines · Reinette Chatre

Hi Babu,

Quoted 42 lines · Babu
Quoted 31 lines · Reinette Chatre
Quoted 24 lines · Tony
Quoted 23 lines · Reinette Chatre
Quoted 22 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +0 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)

          case RDT_RESOURCE_L3:
                  mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP; mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by); INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains); __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags); mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;

drivers/resctrl/mpam_resctrl.c +1 -0
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                   r->ctrl_scope = RESCTRL_L3_CACHE;
                   mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                   mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                   INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
Quoted 6 lines
Quoted 3 lines

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 1 line
drivers/resctrl/mpam_resctrl.c +0 -0
                   r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

Quoted 9 lines

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Quoted 8 lines

Looking at the commit:

commit 3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

Based on the patch description, emulated controls are intended to be used only when there is a difference between the native and legacy controls. If no such difference exists, both modes should operate identically.

The original AMD MBA enabling did not follow the original percentage based MBA control so resctrl essentially has *two* "legacy" MB controls today: one for AMD and one for Intel, MPAM, and RISC-V (planned afaik). That cannot be changed now. AMD would continue to expose the MB control that is not the percentage based "legacy" control but actually AMD's native control. In short, yes, on AMD's "MB" control the "legacy" and "native" control modes should operate identically.
At least now users could use the files in info/MB/schemata/MB/* to learn the properties of the control.

Quoted 6 lines
Quoted 2 lines

For MBA(AMD) and GMBA, there does not appear to be any difference between the two modes. Is that understanding correct?

It is not clear to me how resctrl should support AMD's GLBE. Note I am intentionally not using GMBA since that already makes an assumption on how resctrl will support this. Do you perhaps have an answer for Ben's question in
https://lore.kernel.org/lkml/[email protected]/ ?

Yes. We are already at RFC v2. Let me respond here. Please see my response below.

Quoted 6 lines

GLBE claims to enable users to allocate memory bandwidth at node scope but the memory is managed at L3. This results in scenarios where, for example, a NUMA node can be online and used but resctrl cannot expose it for bandwidth allocation when all the CPUs at that NUMA node scope are offline. GLBE is thus not actually allocating memory bandwidth at the NUMA node.

Yea. That is correct.

There are a couple of key differences when compared to the pure NUMA scope.

1. In some cases, a NUMA node is treated as the entire system.


https://lore.kernel.org/lkml/8f77f498b1c77fa8fd8f5d5687f03ae598068544.1776980182.git.babu.moger@amd.com/

Quoted 7 lines

2. When a user updates the settings on a GLBE for a specific node, we need to update the MSRs within that node at the L3 scope:

https://lore.kernel.org/lkml/a2a06bd290e68f902be9e7cc3ad35f0a2211b950.1776980182.git.babu.moger@amd.com/

Considering these differences, I think we should probably treat GLBE separate from MB_NODE scope. What do you think?

I think so too, but to Ben's point we need to be clear on terminology here. There are two usages of "scope" to consider:
1) The scope of the *resource* being allocated.
Here "scope" applies to the resource. For cache there is L2 and L3 that indicates the scope of the cache resource. There is also now two different scope to consider for memory bandwidth allocation, "L3 scope" for memory bandwidth at egress from L3 and "NUMA/node" scope for memory bandwidth at ingress to NUMA node.

2) The scope of the *control* used to allocate the resource.
So far the scope of the resource has been assumed that to be the same as the scope of the control. That is, a resource at particular scope is allocated at that same scope. GLBE taught us this is not always the case - memory bandwidth at L3 scope can be allocated at NUMA(with some caveat as you point out) scope.

We have gone back and forth on this. Currently upstream resctrl has control scope as a property of the resource with expectation that the resource and its controls have the same scope. As a change to this RFC v1 of this PoC had "scope" as a property of the control to support a control to have different scope as resource. After deciding to treat MB_NODE as a new resource to support the CPU-less nodes, RFC v2 changed this back to have scope a property of the resource.

First, it looks to me as though the RFC v1 separating control scope from resource scope needs to return.

Second, how to name these resources/controls needs to be decided. This is what prompted my question about future considerations to you because my original proposal in
https://lore.kernel.org/lkml/[email protected]/
was able to convey the resource and allocation scope via info hierarchy but it used the same name in the schemata file that Ben highlighted could be problematic.

I believe there is agreement that the resource should include the resource scope in its name. This is currently done for L2 and L3, and planned to be done for MB_NODE (the "MB" resource does not have "L3" in its name, this cannot be changed now, but "MB" resource is implicitly "L3" scope). The "NODE" in MB_NODE is thus memory bandwidth allocation at NUMA node scope - "NODE" in MB_NODE is the *resource* scope.

Considering this I do not think that GLBE should use MB_NODE as you also state above. Since it does not allocate memory bandwidth *resource* at node scope.

We also discussed before (https://lore.kernel.org/lkml/[email protected]/ ) of having the control's scope part of the control's name.

We could have a rule of thumb to include both resource scope and control scope in the control name but only one instance is displayed if they are the same.

For example, what do you think of something like below as an alternate proposal of what I mentioned in
https://lore.kernel.org/lkml/[email protected]/:

GLBE (booted with NPS < 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
    └── schemata/
        ├── MB/          /* control scope = L3 */
        └── MB_L3NODE/   /* control scope = node ("L3" resource scope + "node" control scope) */

GLBE (booted with NPS = 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
    └── schemata/
        ├── MB/          /* control scope = L3 */
        └── MB_L3SYSTEM/ /* control scope = system ("L3" resource scope + "system" control scope*/

MPAM MSC:
info/

├── MB/                /* memory bandwidth allocation at L3 scope */
│   └── schemata/
│       └── MB/        /* control scope = L3 */
└── MB_NODE/           /* memory bandwidth allocation at node scope */
    └── schemata/
        └── MB_NODE/   /* control scope = node */

The GLBE controls make it clear that the *same* resource is allocated using two different controls that have different scope. This creates an implicit dependency between the two that is not quite captured but having two controls for the same resource would already give user space some insight that their control values need to be considered with care.

I'd appreciate your, Ben's, and anybody else's thoughts on this.

Quoted 4 lines
Quoted 2 lines

Should resctrl prepare for some future where an AMD system may support memory bandwidth allocation at the NUMA node while also supporting GLBE (memory bandwidth allocation at L3)?

No, I don't believe that's the case. At least, I haven't come across any information suggesting that.

Apologies, this was an unreasonable question from my side. We cannot predict the future. We try to prepare for it with what we know today but new features always seem to come with unique capabilities.

Reinette

reviewer
#9 lore raw

Hi Reinette,

Quoted 109 lines · Reinette Chatre

Hi Babu and Ben,

Quoted 90 lines · Babu

Hi Reinette/Ben,

Quoted 62 lines · Reinette Chatre

Hi Babu,

Quoted 42 lines · Babu
Quoted 31 lines · Reinette Chatre
Quoted 24 lines · Tony
Quoted 23 lines · Reinette Chatre
Quoted 22 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +2 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
           case RDT_RESOURCE_L3:
                   mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP;
                   mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                   INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
                   __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags);
                   mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                   r->ctrl_scope = RESCTRL_L3_CACHE;
                   mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                   mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                   INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
Quoted 6 lines
Quoted 3 lines

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 1 line
drivers/resctrl/mpam_resctrl.c +0 -0
                   r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

Quoted 9 lines

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Quoted 8 lines

Looking at the commit:

commit 3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

Based on the patch description, emulated controls are intended to be used only when there is a difference between the native and legacy controls. If no such difference exists, both modes should operate identically.

The original AMD MBA enabling did not follow the original percentage based MBA control so resctrl essentially has *two* "legacy" MB controls today: one for AMD and one for Intel, MPAM, and RISC-V (planned afaik). That cannot be changed now. AMD would continue to expose the MB control that is not the percentage based "legacy" control but actually AMD's native control. In short, yes, on AMD's "MB" control the "legacy" and "native" control modes should operate identically.
At least now users could use the files in info/MB/schemata/MB/* to learn the properties of the control.

Quoted 6 lines
Quoted 2 lines

For MBA(AMD) and GMBA, there does not appear to be any difference between the two modes. Is that understanding correct?

It is not clear to me how resctrl should support AMD's GLBE. Note I am intentionally not using GMBA since that already makes an assumption on how resctrl will support this. Do you perhaps have an answer for Ben's question in
https://lore.kernel.org/lkml/[email protected]/ ?

Yes. We are already at RFC v2. Let me respond here. Please see my response below.

Quoted 6 lines

GLBE claims to enable users to allocate memory bandwidth at node scope but the memory is managed at L3. This results in scenarios where, for example, a NUMA node can be online and used but resctrl cannot expose it for bandwidth allocation when all the CPUs at that NUMA node scope are offline. GLBE is thus not actually allocating memory bandwidth at the NUMA node.

Yea. That is correct.

There are a couple of key differences when compared to the pure NUMA scope.

1. In some cases, a NUMA node is treated as the entire system.

https://lore.kernel.org/lkml/8f77f498b1c77fa8fd8f5d5687f03ae598068544.1776980182.git.babu.moger@amd.com/

Quoted 7 lines

2. When a user updates the settings on a GLBE for a specific node, we need to update the MSRs within that node at the L3 scope:

https://lore.kernel.org/lkml/a2a06bd290e68f902be9e7cc3ad35f0a2211b950.1776980182.git.babu.moger@amd.com/

Considering these differences, I think we should probably treat GLBE separate from MB_NODE scope. What do you think?

I think so too, but to Ben's point we need to be clear on terminology here. There are two usages of "scope" to consider:
1) The scope of the *resource* being allocated.
Here "scope" applies to the resource. For cache there is L2 and L3 that indicates the scope of the cache resource. There is also now two different scope to consider for memory bandwidth allocation, "L3 scope" for memory bandwidth at egress from L3 and "NUMA/node" scope for memory bandwidth at ingress to NUMA node.

Quoted 5 lines

2) The scope of the *control* used to allocate the resource.
So far the scope of the resource has been assumed that to be the same as the scope of the control. That is, a resource at particular scope is allocated at that same scope. GLBE taught us this is not always the case - memory bandwidth at L3 scope can be allocated at NUMA(with some caveat as you point out) scope.

Yes. This description correctly fits our requirements here. Thanks

Quoted 9 lines

We have gone back and forth on this. Currently upstream resctrl has control scope as a property of the resource with expectation that the resource and its controls have the same scope. As a change to this RFC v1 of this PoC had "scope" as a property of the control to support a control to have different scope as resource. After deciding to treat MB_NODE as a new resource to support the CPU-less nodes, RFC v2 changed this back to have scope a property of the resource.

First, it looks to me as though the RFC v1 separating control scope from resource scope needs to return.

Yes. I agree.

Quoted 32 lines

Second, how to name these resources/controls needs to be decided. This is what prompted my question about future considerations to you because my original proposal in
https://lore.kernel.org/lkml/[email protected]/
was able to convey the resource and allocation scope via info hierarchy but it used the same name in the schemata file that Ben highlighted could be problematic.

I believe there is agreement that the resource should include the resource scope in its name. This is currently done for L2 and L3, and planned to be done for MB_NODE (the "MB" resource does not have "L3" in its name, this cannot be changed now, but "MB" resource is implicitly "L3" scope). The "NODE" in MB_NODE is thus memory bandwidth allocation at NUMA node scope - "NODE" in MB_NODE is the *resource* scope.

Considering this I do not think that GLBE should use MB_NODE as you also state above. Since it does not allocate memory bandwidth *resource* at node scope.

We also discussed before (https://lore.kernel.org/lkml/[email protected]/ ) of having the control's scope part of the control's name.

We could have a rule of thumb to include both resource scope and control scope in the control name but only one instance is displayed if they are the same.

For example, what do you think of something like below as an alternate proposal of what I mentioned in
https://lore.kernel.org/lkml/[email protected]/:

GLBE (booted with NPS < 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
     └── schemata/
         ├── MB/          /* control scope = L3 */
         └── MB_L3NODE/   /* control scope = node ("L3" resource scope + "node" control scope) */
Quoted 6 lines

GLBE (booted with NPS = 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
     └── schemata/
         ├── MB/          /* control scope = L3 */
         └── MB_L3SYSTEM/ /* control scope = system ("L3" resource scope + "system" control scope*/

Can the names here MB_L3NODE and MB_L3SYSTEM be simplified to MB_NODE and MB_SYSTEM? The L3 scope is already implied by the higher-level hierarchy.

Quoted 10 lines

ii
MPAM MSC:
info/

├── MB/                /* memory bandwidth allocation at L3 scope */
│   └── schemata/
│       └── MB/        /* control scope = L3 */
└── MB_NODE/           /* memory bandwidth allocation at node scope */
     └── schemata/
         └── MB_NODE/   /* control scope = node */
Quoted 7 lines

The GLBE controls make it clear that the *same* resource is allocated using two different controls that have different scope. This creates an implicit dependency between the two that is not quite captured but having two controls for the same resource would already give user space some insight that their control values need to be considered with care.

I'd appreciate your, Ben's, and anybody else's thoughts on this.

Looks good to me.

There is one more point I'd like to bring up regarding GLBE.

Consider the following example with 16 CPUs, 2 NUMA domains, and 2 L3 domains per NUMA node:

NUMA0

 ├─ L3_0: CPUs 0-3
 └─ L3_1: CPUs 4-7

NUMA1

 ├─ L3_2: CPUs 8-11
 └─ L3_3: CPUs 12-15

When updating NUMA0, we need to update one CPU from each L3 domain. However, this relationship is not currently represented in our domain data structure. The domain's hdr.cpumask simply contains CPUs 0-7 and does not provide any information about the underlying L3-domain boundaries.

This was the reason we needed additional processing while programming the MSRs:

https://lore.kernel.org/lkml/a2a06bd290e68f902be9e7cc3ad35f0a2211b950.1776980182.git.babu.moger@amd.com/

I'm wondering whether this relationship should be represented explicitly in the control data structure, or whether that would be exposing details that are too specific to a particular hardware implementation.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Should resctrl prepare for some future where an AMD system may support memory bandwidth allocation at the NUMA node while also supporting GLBE (memory bandwidth allocation at L3)?

No, I don't believe that's the case. At least, I haven't come across any information suggesting that.

Apologies, this was an unreasonable question from my side. We cannot predict the future. We try to prepare for it with what we know today but new features always seem to come with unique capabilities.

No Worries.

Thanks
Babu

author maintainer
#10 lore raw

Hi Babu,

Quoted 1 line · Babu Moger

On 8/7/26 17:53, Reinette Chatre wrote:

...

Quoted 40 lines
Quoted 32 lines

Second, how to name these resources/controls needs to be decided. This is what prompted my question about future considerations to you because my original proposal in
https://lore.kernel.org/lkml/[email protected]/
was able to convey the resource and allocation scope via info hierarchy but it used the same name in the schemata file that Ben highlighted could be problematic.

I believe there is agreement that the resource should include the resource scope in its name. This is currently done for L2 and L3, and planned to be done for MB_NODE (the "MB" resource does not have "L3" in its name, this cannot be changed now, but "MB" resource is implicitly "L3" scope). The "NODE" in MB_NODE is thus memory bandwidth allocation at NUMA node scope - "NODE" in MB_NODE is the *resource* scope.

Considering this I do not think that GLBE should use MB_NODE as you also state above. Since it does not allocate memory bandwidth *resource* at node scope.

We also discussed before (https://lore.kernel.org/lkml/[email protected]/ ) of having the control's scope part of the control's name.

We could have a rule of thumb to include both resource scope and control scope in the control name but only one instance is displayed if they are the same.

For example, what do you think of something like below as an alternate proposal of what I mentioned in
https://lore.kernel.org/lkml/[email protected]/:

GLBE (booted with NPS < 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
     └── schemata/
         ├── MB/          /* control scope = L3 */
         └── MB_L3NODE/   /* control scope = node ("L3" resource scope + "node" control scope) */
Quoted 6 lines

GLBE (booted with NPS = 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
     └── schemata/
         ├── MB/          /* control scope = L3 */
         └── MB_L3SYSTEM/ /* control scope = system ("L3" resource scope + "system" control scope*/
Quoted 3 lines

Can the names here MB_L3NODE and MB_L3SYSTEM be simplified to MB_NODE and MB_SYSTEM? The L3 scope is already implied by the higher- level hierarchy.

This would be the alternate proposal I mention above but Ben highlighted in
https://lore.kernel.org/lkml/[email protected]/ that such naming would result in a conflict if GLBE is ever combined with some actual node based MBA that would result in two controllers named "MB_NODE" that need to be accommodated by schemata file. This is what prompted my question to you with the conclusion that we cannot predict the future. The above proposal prepares resctrl for some hypothetical scenario where a GLBE style system also supports actual node MBA.

Quoted 34 lines
Quoted 10 lines

ii
MPAM MSC:
info/

├── MB/                /* memory bandwidth allocation at L3 scope */
│   └── schemata/
│       └── MB/        /* control scope = L3 */
└── MB_NODE/           /* memory bandwidth allocation at node scope */
     └── schemata/
         └── MB_NODE/   /* control scope = node */
Quoted 7 lines

The GLBE controls make it clear that the *same* resource is allocated using two different controls that have different scope. This creates an implicit dependency between the two that is not quite captured but having two controls for the same resource would already give user space some insight that their control values need to be considered with care.

I'd appreciate your, Ben's, and anybody else's thoughts on this.

Looks good to me.

There is one more point I'd like to bring up regarding GLBE.

Consider the following example with 16 CPUs, 2 NUMA domains, and 2 L3 domains per NUMA node:

NUMA0

 ├─ L3_0: CPUs 0-3
 └─ L3_1: CPUs 4-7

NUMA1

 ├─ L3_2: CPUs 8-11
 └─ L3_3: CPUs 12-15
Quoted 5 lines

When updating NUMA0, we need to update one CPU from each L3 domain. However, this relationship is not currently represented in our domain data structure. The domain's hdr.cpumask simply contains CPUs 0-7 and does not provide any information about the underlying L3-domain boundaries.

I expect that the domain associated with a control that has node scope would include all CPUs associated with that node in is cpumask. In your example I thus expect there to only be two domains, domain ID 0 would have CPUs 0 - 7 in its cpumask and domain ID 1 would have CPUs 8 to 15 in its cpumask.

Quoted 9 lines

This was the reason we needed additional processing while programming the MSRs:

https://lore.kernel.org/lkml/a2a06bd290e68f902be9e7cc3ad35f0a2211b950.1776980182.git.babu.moger@amd.com/

I'm wondering whether this relationship should be represented explicitly in the control data structure, or whether that would be exposing details that are too specific to a particular hardware implementation.

From what I understand this is already accommodated. What am I missing? Reinette

reviewer
#11 lore raw

Hi Reinette,

Quoted 51 lines · Reinette Chatre

Hi Babu,

Quoted 1 line · Babu Moger

On 8/7/26 17:53, Reinette Chatre wrote:

...

Quoted 40 lines
Quoted 32 lines

Second, how to name these resources/controls needs to be decided. This is what prompted my question about future considerations to you because my original proposal in
https://lore.kernel.org/lkml/[email protected]/
was able to convey the resource and allocation scope via info hierarchy but it used the same name in the schemata file that Ben highlighted could be problematic.

I believe there is agreement that the resource should include the resource scope in its name. This is currently done for L2 and L3, and planned to be done for MB_NODE (the "MB" resource does not have "L3" in its name, this cannot be changed now, but "MB" resource is implicitly "L3" scope). The "NODE" in MB_NODE is thus memory bandwidth allocation at NUMA node scope - "NODE" in MB_NODE is the *resource* scope.

Considering this I do not think that GLBE should use MB_NODE as you also state above. Since it does not allocate memory bandwidth *resource* at node scope.

We also discussed before (https://lore.kernel.org/lkml/[email protected]/ ) of having the control's scope part of the control's name.

We could have a rule of thumb to include both resource scope and control scope in the control name but only one instance is displayed if they are the same.

For example, what do you think of something like below as an alternate proposal of what I mentioned in
https://lore.kernel.org/lkml/[email protected]/:

GLBE (booted with NPS < 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
      └── schemata/
          ├── MB/          /* control scope = L3 */
          └── MB_L3NODE/   /* control scope = node ("L3" resource scope + "node" control scope) */
Quoted 6 lines

GLBE (booted with NPS = 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
      └── schemata/
          ├── MB/          /* control scope = L3 */
          └── MB_L3SYSTEM/ /* control scope = system ("L3" resource scope + "system" control scope*/
Quoted 3 lines

Can the names here MB_L3NODE and MB_L3SYSTEM be simplified to MB_NODE and MB_SYSTEM? The L3 scope is already implied by the higher- level hierarchy.

Quoted 6 lines

This would be the alternate proposal I mention above but Ben highlighted in
https://lore.kernel.org/lkml/[email protected]/ that such naming would result in a conflict if GLBE is ever combined with some actual node based MBA that would result in two controllers named "MB_NODE" that need to be accommodated by schemata file. This is what prompted my question to you with the conclusion that we cannot predict the future. The above proposal prepares resctrl for some hypothetical scenario where a GLBE style system also supports actual node MBA.

Oh, okay. As the hypothetical case doesn't exist at this time, I'll leave the decision to you and Ben. I'm fine either way.

Quoted 40 lines
Quoted 34 lines
Quoted 10 lines

ii
MPAM MSC:
info/

├── MB/                /* memory bandwidth allocation at L3 scope */
│   └── schemata/
│       └── MB/        /* control scope = L3 */
└── MB_NODE/           /* memory bandwidth allocation at node scope */
      └── schemata/
          └── MB_NODE/   /* control scope = node */
Quoted 7 lines

The GLBE controls make it clear that the *same* resource is allocated using two different controls that have different scope. This creates an implicit dependency between the two that is not quite captured but having two controls for the same resource would already give user space some insight that their control values need to be considered with care.

I'd appreciate your, Ben's, and anybody else's thoughts on this.

Looks good to me.

There is one more point I'd like to bring up regarding GLBE.

Consider the following example with 16 CPUs, 2 NUMA domains, and 2 L3 domains per NUMA node:

NUMA0

  ├─ L3_0: CPUs 0-3
  └─ L3_1: CPUs 4-7

NUMA1

  ├─ L3_2: CPUs 8-11
  └─ L3_3: CPUs 12-15
Quoted 5 lines

When updating NUMA0, we need to update one CPU from each L3 domain. However, this relationship is not currently represented in our domain data structure. The domain's hdr.cpumask simply contains CPUs 0-7 and does not provide any information about the underlying L3-domain boundaries.

Quoted 4 lines

I expect that the domain associated with a control that has node scope would include all CPUs associated with that node in is cpumask. In your example I thus expect there to only be two domains, domain ID 0 would have CPUs 0 - 7 in its cpumask and domain ID 1 would have CPUs 8 to 15 in its cpumask.

Yes, that's correct. However, when updating the NUMA nodes, we cannot call smp_call_function_any(0-7) and smp_call_function_any(8-15) as we are currently doing.

Instead, we need to perform the operation at the L3 cache domain level, for example:

NUMA0

  ├─ L3_0: CPUs 0-3   -> smp_call_function_any(0-3)
  └─ L3_1: CPUs 4-7   -> smp_call_function_any(4-7)

NUMA1

  ├─ L3_2: CPUs 8-11  -> smp_call_function_any(8-11)
  └─ L3_3: CPUs 12-15 -> smp_call_function_any(12-15)

In other words, the target CPU should be selected from each L3 cache group rather than from the entire NUMA node. The current approach chooses one CPU from the full NUMA domain, which does not guarantee coverage across all L3 cache domains within that NUMA node.

Quoted 4 lines
Quoted 4 lines

This was the reason we needed additional processing while programming the MSRs:

Quoted 10 lines
Quoted 8 lines

https://lore.kernel.org/lkml/a2a06bd290e68f902be9e7cc3ad35f0a2211b950.1776980182.git.babu.moger@amd.com/

I'm wondering whether this relationship should be represented explicitly in the control data structure, or whether that would be exposing details that are too specific to a particular hardware implementation.

From what I understand this is already accommodated. What am I missing? Reinette

Please see the response above. Hope it clears the explanation.

Thanks
Babu

author maintainer
#12 lore raw

Hi Babu,

Quoted 11 lines · Babu Moger

Yes, that's correct. However, when updating the NUMA nodes, we cannot call smp_call_function_any(0-7) and smp_call_function_any(8-15) as we are currently doing.

Instead, we need to perform the operation at the L3 cache domain level, for example:

NUMA0

  ├─ L3_0: CPUs 0-3   -> smp_call_function_any(0-3)
  └─ L3_1: CPUs 4-7   -> smp_call_function_any(4-7)

NUMA1

Quoted 8 lines
  ├─ L3_2: CPUs 8-11  -> smp_call_function_any(8-11)
  └─ L3_3: CPUs 12-15 -> smp_call_function_any(12-15)

In other words, the target CPU should be selected from each L3 cache group rather than from the entire NUMA node. The current approach chooses one CPU from the full NUMA domain, which does not guarantee coverage across all L3 cache domains within that NUMA node.

I see. I do not have a clear proposal to deal with this. One (high level) idea to consider connected to this PoC is possibly changing resctrl_hw_ctrl::msr_update() to be something more generic. In this version there is a branch where, if resctrl_hw_ctrl::msr_update() is NULL then it uses a hardcoded program_backing_controls() to program an emulated control's backing controls instead of the emulated control. These are still at different scope, msr_update() expects to be called on the CPU needing an update while program_backing_controls() will make sure to pick the right CPU(s), but having a generic callback that can schedule on right CPUs and do updates may provide a way to help GLBE and emulated controls.

Reinette

reviewer
#13 lore raw

Hi Reinette,

Quoted 23 lines · Reinette Chatre

Hi Babu,

Quoted 11 lines · Babu Moger

Yes, that's correct. However, when updating the NUMA nodes, we cannot call smp_call_function_any(0-7) and smp_call_function_any(8-15) as we are currently doing.

Instead, we need to perform the operation at the L3 cache domain level, for example:

NUMA0

   ├─ L3_0: CPUs 0-3   -> smp_call_function_any(0-3)
   └─ L3_1: CPUs 4-7   -> smp_call_function_any(4-7)

NUMA1

Quoted 8 lines
   ├─ L3_2: CPUs 8-11  -> smp_call_function_any(8-11)
   └─ L3_3: CPUs 12-15 -> smp_call_function_any(12-15)

In other words, the target CPU should be selected from each L3 cache group rather than from the entire NUMA node. The current approach chooses one CPU from the full NUMA domain, which does not guarantee coverage across all L3 cache domains within that NUMA node.

Quoted 10 lines

I see. I do not have a clear proposal to deal with this. One (high level) idea to consider connected to this PoC is possibly changing resctrl_hw_ctrl::msr_update() to be something more generic. In this version there is a branch where, if resctrl_hw_ctrl::msr_update() is NULL then it uses a hardcoded program_backing_controls() to program an emulated control's backing controls instead of the emulated control. These are still at different scope, msr_update() expects to be called on the CPU needing an update while program_backing_controls() will make sure to pick the right CPU(s), but having a generic callback that can schedule on right CPUs and do updates may provide a way to help GLBE and emulated controls.

Yes, the current msr_update implementation is fairly specialized. If we refactor it into a more generic handler, each resource can implement its own handler, providing greater flexibility and extensibility.

Thanks,
Babu

maintainer
#14 lore raw
In reply to Reinette Chatre

Hi Reinette, Babu,

Quoted 155 lines · Reinette Chatre

Hi Babu and Ben,

Quoted 90 lines · Babu

Hi Reinette/Ben,

Quoted 62 lines · Reinette Chatre

Hi Babu,

Quoted 42 lines · Babu
Quoted 31 lines · Reinette Chatre
Quoted 24 lines · Tony
Quoted 23 lines · Reinette Chatre
Quoted 22 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +0 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)

          case RDT_RESOURCE_L3:
                  mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP; mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by); INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains); __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags); mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;

drivers/resctrl/mpam_resctrl.c +1 -0
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                   r->ctrl_scope = RESCTRL_L3_CACHE;
                   mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                   mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                   INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
Quoted 6 lines
Quoted 3 lines

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 1 line
drivers/resctrl/mpam_resctrl.c +0 -0
                   r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

Quoted 9 lines

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Quoted 8 lines

Looking at the commit:

commit 3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

Based on the patch description, emulated controls are intended to be used only when there is a difference between the native and legacy controls. If no such difference exists, both modes should operate identically.

The original AMD MBA enabling did not follow the original percentage based MBA control so resctrl essentially has *two* "legacy" MB controls today: one for AMD and one for Intel, MPAM, and RISC-V (planned afaik). That cannot be changed now. AMD would continue to expose the MB control that is not the percentage based "legacy" control but actually AMD's native control. In short, yes, on AMD's "MB" control the "legacy" and "native" control modes should operate identically.
At least now users could use the files in info/MB/schemata/MB/* to learn the properties of the control.

Quoted 6 lines
Quoted 2 lines

For MBA(AMD) and GMBA, there does not appear to be any difference between the two modes. Is that understanding correct?

It is not clear to me how resctrl should support AMD's GLBE. Note I am intentionally not using GMBA since that already makes an assumption on how resctrl will support this. Do you perhaps have an answer for Ben's question in
https://lore.kernel.org/lkml/[email protected]/ ?

Yes. We are already at RFC v2. Let me respond here. Please see my response below.

Quoted 6 lines

GLBE claims to enable users to allocate memory bandwidth at node scope but the memory is managed at L3. This results in scenarios where, for example, a NUMA node can be online and used but resctrl cannot expose it for bandwidth allocation when all the CPUs at that NUMA node scope are offline. GLBE is thus not actually allocating memory bandwidth at the NUMA node.

Yea. That is correct.

There are a couple of key differences when compared to the pure NUMA scope.

1. In some cases, a NUMA node is treated as the entire system.


https://lore.kernel.org/lkml/8f77f498b1c77fa8fd8f5d5687f03ae598068544.1776980182.git.babu.moger@amd.com/

Quoted 7 lines

2. When a user updates the settings on a GLBE for a specific node, we need to update the MSRs within that node at the L3 scope:

https://lore.kernel.org/lkml/a2a06bd290e68f902be9e7cc3ad35f0a2211b950.1776980182.git.babu.moger@amd.com/

Considering these differences, I think we should probably treat GLBE separate from MB_NODE scope. What do you think?

I think so too, but to Ben's point we need to be clear on terminology here. There are two usages of "scope" to consider:
1) The scope of the *resource* being allocated.
Here "scope" applies to the resource. For cache there is L2 and L3 that indicates the scope of the cache resource. There is also now two different scope to consider for memory bandwidth allocation, "L3 scope" for memory bandwidth at egress from L3 and "NUMA/node" scope for memory bandwidth at ingress to NUMA node.

2) The scope of the *control* used to allocate the resource.
So far the scope of the resource has been assumed that to be the same as the scope of the control. That is, a resource at particular scope is allocated at that same scope. GLBE taught us this is not always the case - memory bandwidth at L3 scope can be allocated at NUMA(with some caveat as you point out) scope.

We have gone back and forth on this. Currently upstream resctrl has control scope as a property of the resource with expectation that the resource and its controls have the same scope. As a change to this RFC v1 of this PoC had "scope" as a property of the control to support a control to have different scope as resource. After deciding to treat MB_NODE as a new resource to support the CPU-less nodes, RFC v2 changed this back to have scope a property of the resource.

First, it looks to me as though the RFC v1 separating control scope from resource scope needs to return.

Second, how to name these resources/controls needs to be decided. This is what prompted my question about future considerations to you because my original proposal in
https://lore.kernel.org/lkml/[email protected]/
was able to convey the resource and allocation scope via info hierarchy but it used the same name in the schemata file that Ben highlighted could be problematic.

I believe there is agreement that the resource should include the resource scope in its name. This is currently done for L2 and L3, and planned to be done for MB_NODE (the "MB" resource does not have "L3" in its name, this cannot be changed now, but "MB" resource is implicitly "L3" scope). The "NODE" in MB_NODE is thus memory bandwidth allocation at NUMA node scope - "NODE" in MB_NODE is the *resource* scope.

Considering this I do not think that GLBE should use MB_NODE as you also state above. Since it does not allocate memory bandwidth *resource* at node scope.

We also discussed before (https://lore.kernel.org/lkml/[email protected]/ ) of having the control's scope part of the control's name.

We could have a rule of thumb to include both resource scope and control scope in the control name but only one instance is displayed if they are the same.

For example, what do you think of something like below as an alternate proposal of what I mentioned in
https://lore.kernel.org/lkml/[email protected]/:

GLBE (booted with NPS < 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
    └── schemata/
        ├── MB/          /* control scope = L3 */
        └── MB_L3NODE/   /* control scope = node ("L3" resource scope + "node" control scope) */
Quoted 6 lines

GLBE (booted with NPS = 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
    └── schemata/
        ├── MB/          /* control scope = L3 */
        └── MB_L3SYSTEM/ /* control scope = system ("L3" resource scope + "system" control scope*/

I think this separation of control scope and resource scope works. My understanding is that, as the scope of the resource is L3, we can infer that the lifecycle of the resctrl domain is linked to the L3 cache and so the cpu hotplug lifecycle. The new part is that the size of the domain is determined by the control scope, a single L3 (L3 control scope as per current resctrl) or a collection of L3 instances as identified by a NUMA node id (NODE) or the whole system (SYSTEM).

Quoted 9 lines

MPAM MSC:
info/

├── MB/                /* memory bandwidth allocation at L3 scope */
│   └── schemata/
│       └── MB/        /* control scope = L3 */
└── MB_NODE/           /* memory bandwidth allocation at node scope */
    └── schemata/
        └── MB_NODE/   /* control scope = node */

Yes to the general structure. You may have just omitted this for clarity but I don't think we should introduce a control just called MB_NODE, it should be specify the type too, so one of MB_NODE_MIN, MB_NODE_MAX, MB_NODE_PROP etc.

Thanks,

Ben

Quoted 19 lines

The GLBE controls make it clear that the *same* resource is allocated using two different controls that have different scope. This creates an implicit dependency between the two that is not quite captured but having two controls for the same resource would already give user space some insight that their control values need to be considered with care.

I'd appreciate your, Ben's, and anybody else's thoughts on this.

Quoted 4 lines
Quoted 2 lines

Should resctrl prepare for some future where an AMD system may support memory bandwidth allocation at the NUMA node while also supporting GLBE (memory bandwidth allocation at L3)?

No, I don't believe that's the case. At least, I haven't come across any information suggesting that.

Apologies, this was an unreasonable question from my side. We cannot predict the future. We try to prepare for it with what we know today but new features always seem to come with unique capabilities.

Reinette

author maintainer
#15 lore raw

Hi Ben,

Quoted 157 lines · Ben Horgan
Quoted 149 lines · Reinette Chatre
Quoted 86 lines · Babu
Quoted 60 lines · Reinette Chatre
Quoted 42 lines · Babu
Quoted 31 lines · Reinette Chatre
Quoted 24 lines · Tony
Quoted 23 lines · Reinette Chatre
Quoted 22 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +0 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)

          case RDT_RESOURCE_L3:
                  mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP; mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by); INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains); __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags); mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;

drivers/resctrl/mpam_resctrl.c +1 -0
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                   r->ctrl_scope = RESCTRL_L3_CACHE;
                   mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                   mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                   INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
Quoted 6 lines
Quoted 3 lines

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 1 line
drivers/resctrl/mpam_resctrl.c +0 -0
                   r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

Quoted 9 lines

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Quoted 8 lines

Looking at the commit:

commit 3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

Based on the patch description, emulated controls are intended to be used only when there is a difference between the native and legacy controls. If no such difference exists, both modes should operate identically.

The original AMD MBA enabling did not follow the original percentage based MBA control so resctrl essentially has *two* "legacy" MB controls today: one for AMD and one for Intel, MPAM, and RISC-V (planned afaik). That cannot be changed now. AMD would continue to expose the MB control that is not the percentage based "legacy" control but actually AMD's native control. In short, yes, on AMD's "MB" control the "legacy" and "native" control modes should operate identically.
At least now users could use the files in info/MB/schemata/MB/* to learn the properties of the control.

Quoted 6 lines
Quoted 2 lines

For MBA(AMD) and GMBA, there does not appear to be any difference between the two modes. Is that understanding correct?

It is not clear to me how resctrl should support AMD's GLBE. Note I am intentionally not using GMBA since that already makes an assumption on how resctrl will support this. Do you perhaps have an answer for Ben's question in
https://lore.kernel.org/lkml/[email protected]/ ?

Yes. We are already at RFC v2. Let me respond here. Please see my response below.

Quoted 6 lines

GLBE claims to enable users to allocate memory bandwidth at node scope but the memory is managed at L3. This results in scenarios where, for example, a NUMA node can be online and used but resctrl cannot expose it for bandwidth allocation when all the CPUs at that NUMA node scope are offline. GLBE is thus not actually allocating memory bandwidth at the NUMA node.

Yea. That is correct.

There are a couple of key differences when compared to the pure NUMA scope.

1. In some cases, a NUMA node is treated as the entire system.


https://lore.kernel.org/lkml/8f77f498b1c77fa8fd8f5d5687f03ae598068544.1776980182.git.babu.moger@amd.com/

Quoted 7 lines

2. When a user updates the settings on a GLBE for a specific node, we need to update the MSRs within that node at the L3 scope:

https://lore.kernel.org/lkml/a2a06bd290e68f902be9e7cc3ad35f0a2211b950.1776980182.git.babu.moger@amd.com/

Considering these differences, I think we should probably treat GLBE separate from MB_NODE scope. What do you think?

I think so too, but to Ben's point we need to be clear on terminology here. There are two usages of "scope" to consider:
1) The scope of the *resource* being allocated.
Here "scope" applies to the resource. For cache there is L2 and L3 that indicates the scope of the cache resource. There is also now two different scope to consider for memory bandwidth allocation, "L3 scope" for memory bandwidth at egress from L3 and "NUMA/node" scope for memory bandwidth at ingress to NUMA node.

2) The scope of the *control* used to allocate the resource.
So far the scope of the resource has been assumed that to be the same as the scope of the control. That is, a resource at particular scope is allocated at that same scope. GLBE taught us this is not always the case - memory bandwidth at L3 scope can be allocated at NUMA(with some caveat as you point out) scope.

We have gone back and forth on this. Currently upstream resctrl has control scope as a property of the resource with expectation that the resource and its controls have the same scope. As a change to this RFC v1 of this PoC had "scope" as a property of the control to support a control to have different scope as resource. After deciding to treat MB_NODE as a new resource to support the CPU-less nodes, RFC v2 changed this back to have scope a property of the resource.

First, it looks to me as though the RFC v1 separating control scope from resource scope needs to return.

Second, how to name these resources/controls needs to be decided. This is what prompted my question about future considerations to you because my original proposal in
https://lore.kernel.org/lkml/[email protected]/
was able to convey the resource and allocation scope via info hierarchy but it used the same name in the schemata file that Ben highlighted could be problematic.

I believe there is agreement that the resource should include the resource scope in its name. This is currently done for L2 and L3, and planned to be done for MB_NODE (the "MB" resource does not have "L3" in its name, this cannot be changed now, but "MB" resource is implicitly "L3" scope). The "NODE" in MB_NODE is thus memory bandwidth allocation at NUMA node scope - "NODE" in MB_NODE is the *resource* scope.

Considering this I do not think that GLBE should use MB_NODE as you also state above. Since it does not allocate memory bandwidth *resource* at node scope.

We also discussed before (https://lore.kernel.org/lkml/[email protected]/ ) of having the control's scope part of the control's name.

We could have a rule of thumb to include both resource scope and control scope in the control name but only one instance is displayed if they are the same.

For example, what do you think of something like below as an alternate proposal of what I mentioned in
https://lore.kernel.org/lkml/[email protected]/:

GLBE (booted with NPS < 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
    └── schemata/
        ├── MB/          /* control scope = L3 */
        └── MB_L3NODE/   /* control scope = node ("L3" resource scope + "node" control scope) */
Quoted 6 lines

GLBE (booted with NPS = 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
    └── schemata/
        ├── MB/          /* control scope = L3 */
        └── MB_L3SYSTEM/ /* control scope = system ("L3" resource scope + "system" control scope*/
Quoted 5 lines

I think this separation of control scope and resource scope works. My understanding is that, as the scope of the resource is L3, we can infer that the lifecycle of the resctrl domain is linked to the L3 cache and so the cpu hotplug lifecycle. The new part is that the size of the domain is determined by the control scope, a single L3 (L3 control scope as per current resctrl) or a collection of L3 instances as identified by a NUMA node id (NODE) or the whole system (SYSTEM).

Thank you very much. I agree. An additional way I use to simplify this is that the new "control scope" is how resctrl communicates to user space what the domain ID used in, for example, schemata file represents.

One caveat is that the above layout is not something that the filesystem can enforce so for this interface to remain consistent will depend on the support from all architectures.

Quoted 10 lines
Quoted 9 lines

MPAM MSC:
info/

├── MB/                /* memory bandwidth allocation at L3 scope */
│   └── schemata/
│       └── MB/        /* control scope = L3 */
└── MB_NODE/           /* memory bandwidth allocation at node scope */
    └── schemata/
        └── MB_NODE/   /* control scope = node */
Quoted 3 lines

Yes to the general structure. You may have just omitted this for clarity but I don't think we should introduce a control just called MB_NODE, it should be specify the type too, so one of MB_NODE_MIN, MB_NODE_MAX, MB_NODE_PROP etc.

I agree. One uncertainty here is how the MB_NODE resource's control mode should be presented to user space. I think it may be most intuitive to present "native" as the one and only control mode option? In the current implementation the "native" and "legacy" control mode of a resource without any emulated controls will result in the same controls enabled.

Reinette

maintainer
#16 lore raw

Hi Reinette,

Quoted 183 lines · Reinette Chatre

Hi Ben,

Quoted 157 lines · Ben Horgan
Quoted 149 lines · Reinette Chatre
Quoted 86 lines · Babu
Quoted 60 lines · Reinette Chatre
Quoted 42 lines · Babu
Quoted 31 lines · Reinette Chatre
Quoted 24 lines · Tony
Quoted 23 lines · Reinette Chatre
Quoted 22 lines · Ben Horgan

Just given a go at running this on a model with MPAM and I can mount resctrl with this small patch to initialise the emulated_by lists so that list_empty() behaves.

drivers/resctrl/mpam_resctrl.c +0 -0
index 21dcbf5764cc..638095649151 100644
@@ -1018,6 +1018,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)

          case RDT_RESOURCE_L3:
                  mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP; mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by); INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains); __set_bit(RESCTRL_BITMAP_FLAG_SPARSE, mpam_ctrl->r_ctrl.bitmap.flags); mpam_ctrl->r_ctrl.bitmap.cbm_len = class->props.cpbm_wd;

drivers/resctrl/mpam_resctrl.c +1 -0
@@ -1048,6 +1049,7 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
                   r->ctrl_scope = RESCTRL_L3_CACHE;
                   mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
                   mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
+               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);
                   INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
 
Quoted 6 lines
Quoted 3 lines

drivers/resctrl/mpam_resctrl.c static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) · line 1055

Quoted 1 line
drivers/resctrl/mpam_resctrl.c +0 -0
                   r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;

Thank you for this. Added this and it is now available in branch resctrl/controls_rfc_v2.1

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

Quoted 9 lines

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Quoted 8 lines

Looking at the commit:

commit 3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

Based on the patch description, emulated controls are intended to be used only when there is a difference between the native and legacy controls. If no such difference exists, both modes should operate identically.

The original AMD MBA enabling did not follow the original percentage based MBA control so resctrl essentially has *two* "legacy" MB controls today: one for AMD and one for Intel, MPAM, and RISC-V (planned afaik). That cannot be changed now. AMD would continue to expose the MB control that is not the percentage based "legacy" control but actually AMD's native control. In short, yes, on AMD's "MB" control the "legacy" and "native" control modes should operate identically.
At least now users could use the files in info/MB/schemata/MB/* to learn the properties of the control.

Quoted 6 lines
Quoted 2 lines

For MBA(AMD) and GMBA, there does not appear to be any difference between the two modes. Is that understanding correct?

It is not clear to me how resctrl should support AMD's GLBE. Note I am intentionally not using GMBA since that already makes an assumption on how resctrl will support this. Do you perhaps have an answer for Ben's question in
https://lore.kernel.org/lkml/[email protected]/ ?

Yes. We are already at RFC v2. Let me respond here. Please see my response below.

Quoted 6 lines

GLBE claims to enable users to allocate memory bandwidth at node scope but the memory is managed at L3. This results in scenarios where, for example, a NUMA node can be online and used but resctrl cannot expose it for bandwidth allocation when all the CPUs at that NUMA node scope are offline. GLBE is thus not actually allocating memory bandwidth at the NUMA node.

Yea. That is correct.

There are a couple of key differences when compared to the pure NUMA scope.

1. In some cases, a NUMA node is treated as the entire system.


https://lore.kernel.org/lkml/8f77f498b1c77fa8fd8f5d5687f03ae598068544.1776980182.git.babu.moger@amd.com/

Quoted 7 lines

2. When a user updates the settings on a GLBE for a specific node, we need to update the MSRs within that node at the L3 scope:

https://lore.kernel.org/lkml/a2a06bd290e68f902be9e7cc3ad35f0a2211b950.1776980182.git.babu.moger@amd.com/

Considering these differences, I think we should probably treat GLBE separate from MB_NODE scope. What do you think?

I think so too, but to Ben's point we need to be clear on terminology here. There are two usages of "scope" to consider:
1) The scope of the *resource* being allocated.
Here "scope" applies to the resource. For cache there is L2 and L3 that indicates the scope of the cache resource. There is also now two different scope to consider for memory bandwidth allocation, "L3 scope" for memory bandwidth at egress from L3 and "NUMA/node" scope for memory bandwidth at ingress to NUMA node.

2) The scope of the *control* used to allocate the resource.
So far the scope of the resource has been assumed that to be the same as the scope of the control. That is, a resource at particular scope is allocated at that same scope. GLBE taught us this is not always the case - memory bandwidth at L3 scope can be allocated at NUMA(with some caveat as you point out) scope.

We have gone back and forth on this. Currently upstream resctrl has control scope as a property of the resource with expectation that the resource and its controls have the same scope. As a change to this RFC v1 of this PoC had "scope" as a property of the control to support a control to have different scope as resource. After deciding to treat MB_NODE as a new resource to support the CPU-less nodes, RFC v2 changed this back to have scope a property of the resource.

First, it looks to me as though the RFC v1 separating control scope from resource scope needs to return.

Second, how to name these resources/controls needs to be decided. This is what prompted my question about future considerations to you because my original proposal in
https://lore.kernel.org/lkml/[email protected]/
was able to convey the resource and allocation scope via info hierarchy but it used the same name in the schemata file that Ben highlighted could be problematic.

I believe there is agreement that the resource should include the resource scope in its name. This is currently done for L2 and L3, and planned to be done for MB_NODE (the "MB" resource does not have "L3" in its name, this cannot be changed now, but "MB" resource is implicitly "L3" scope). The "NODE" in MB_NODE is thus memory bandwidth allocation at NUMA node scope - "NODE" in MB_NODE is the *resource* scope.

Considering this I do not think that GLBE should use MB_NODE as you also state above. Since it does not allocate memory bandwidth *resource* at node scope.

We also discussed before (https://lore.kernel.org/lkml/[email protected]/ ) of having the control's scope part of the control's name.

We could have a rule of thumb to include both resource scope and control scope in the control name but only one instance is displayed if they are the same.

For example, what do you think of something like below as an alternate proposal of what I mentioned in
https://lore.kernel.org/lkml/[email protected]/:

GLBE (booted with NPS < 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
    └── schemata/
        ├── MB/          /* control scope = L3 */
        └── MB_L3NODE/   /* control scope = node ("L3" resource scope + "node" control scope) */
Quoted 6 lines

GLBE (booted with NPS = 4):
info/

└── MB/                /* memory bandwidth allocation implicitly/legacy at L3 scope, think of this as "MB_L3" */
    └── schemata/
        ├── MB/          /* control scope = L3 */
        └── MB_L3SYSTEM/ /* control scope = system ("L3" resource scope + "system" control scope*/
Quoted 5 lines

I think this separation of control scope and resource scope works. My understanding is that, as the scope of the resource is L3, we can infer that the lifecycle of the resctrl domain is linked to the L3 cache and so the cpu hotplug lifecycle. The new part is that the size of the domain is determined by the control scope, a single L3 (L3 control scope as per current resctrl) or a collection of L3 instances as identified by a NUMA node id (NODE) or the whole system (SYSTEM).

Thank you very much. I agree. An additional way I use to simplify this is that the new "control scope" is how resctrl communicates to user space what the domain ID used in, for example, schemata file represents.

One caveat is that the above layout is not something that the filesystem can enforce so for this interface to remain consistent will depend on the support from all architectures.

Quoted 10 lines
Quoted 9 lines

MPAM MSC:
info/

├── MB/                /* memory bandwidth allocation at L3 scope */
│   └── schemata/
│       └── MB/        /* control scope = L3 */
└── MB_NODE/           /* memory bandwidth allocation at node scope */
    └── schemata/
        └── MB_NODE/   /* control scope = node */
Quoted 7 lines
Quoted 3 lines

Yes to the general structure. You may have just omitted this for clarity but I don't think we should introduce a control just called MB_NODE, it should be specify the type too, so one of MB_NODE_MIN, MB_NODE_MAX, MB_NODE_PROP etc.

I agree. One uncertainty here is how the MB_NODE resource's control mode should be presented to user space. I think it may be most intuitive to present "native" as the one and only control mode option?

Yes, "native" being the only option here makes sense to me.

Thanks,

Ben

Quoted 6 lines

In the current implementation the "native" and "legacy" control mode of a resource without any emulated controls will result in the same controls enabled.

Reinette

#17 lore raw
In reply to Moger, Babu

Hi Babu,

On 8/7/2026 10:14 PM, Moger, Babu wrote:

[ ... ]

Quoted 12 lines
Quoted 11 lines
Quoted 2 lines

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Quoted 8 lines

Looking at the commit:

commit 3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

Based on the patch description, emulated controls are intended to be used only when there is a difference between the native and legacy controls. If no such difference exists, both modes should operate identically.

For MBA(AMD) and GMBA, there does not appear to be any difference between the two modes. Is that understanding correct?

Yes I think so. __rdt_get_mem_config_amd() does INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by), so the list is a valid empty one and resctrl_enabled_ctrl_iter_next() short-circuits on list_empty() regardless of ctrl_mode, meaning MBA expose the same single control in either mode.

thanks,
Chenyu

#18 lore raw

Hi Chenyu,

Quoted 24 lines · Yu C

Hi Babu,

On 8/7/2026 10:14 PM, Moger, Babu wrote:

[ ... ]

Quoted 18 lines
Quoted 11 lines
Quoted 2 lines

Is same needed for x86? I don't see any initialization of the "r_ctrl.emulated_by" lists in similar initialization functions.

x86 "emulated_by" list initialization should be in both branches.

Branch resctrl/controls_rfc_v2.1 combined all "emulated_by" list initialization (for x86 and MPAM) into commit:
3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

In the original resctrl/controls_rfc_v2 the x86 "emulated_by" list initialization can be found in commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls")

Looking at the commit:

commit 3407e523c988 ("fs/resctrl: Introduce emulated controls and control mode")

Based on the patch description, emulated controls are intended to be used only when there is a difference between the native and legacy controls. If no such difference exists, both modes should operate identically.

Quoted 9 lines
Quoted 2 lines

For MBA(AMD) and GMBA, there does not appear to be any difference between the two modes. Is that understanding correct?

Yes I think so. __rdt_get_mem_config_amd() does INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by), so the list is a valid empty one and resctrl_enabled_ctrl_iter_next() short-circuits on list_empty() regardless of ctrl_mode, meaning MBA expose the same single control in either mode.

Got it,
Thank you
Babu

#19 lore raw
In reply to Reinette Chatre

Hi Reinette,

Thank you very much for providing this version,

Quoted 8 lines · Reinette Chatre

- Only "SAMPLE" code provided for x86 to demonstrate emulated controls.

- Add relationships between controls. For example, cannot set "MIN" control value to be larger than "MAX. Unclear how to do this in resctrl fs when considering that the relationship may span between enabled and disabled controls. This is potentially something that needs to be managed by architecture and thus potentially without a consistent failure to user space.

I have tested this version, and it exhibits the expected behavior according to my understanding:

The following is the legacy schemata:
[root@ resctrl]# cat schemata

            MB:0=100;1=100;2=100;3=100

and the following is the native schemata:
[root@ resctrl]# echo native > /sys/fs/resctrl/info/MB/control_mode [root@ resctrl]# cat schemata MB_REGION0_MAX:0=200;1=200;2=200;3=200 MB_REGION0_MIN:0=1;1=1;2=1;3=1

I have a minor question I'd like to confirm:

item 1.
In legacy mode, we intend to always let the "native" controller emulate the "legacy" controller - at least for the region‑aware RDT case.
Q1: Is this understanding correct?

item 2.
In commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls"), during resctrl initialization, __get_mem_config_intel() clears the legacy controller's hw_ctrl->msr_update to NULL, and sets its emulation controllers in hw_ctrl->r_ctrl.emulated_by to the region-aware related controllers. So legacy controller is emulated by region-aware controllers.

item 3.
In resctrl_arch_control_mode_set(), when switching to "legacy" mode, the legacy controller is set to:
hw_ctrl->msr_update = update_temporary_legacy_MB; while the emulating controller is set to NULL:
hw_ctrl->msr_update = NULL;
That means, the emulated controllers will not take effect.

Q2:Does item 3 contradict item 1?

thanks,
Chenyu

author maintainer
#20 lore raw

Hi Chenyu,

Quoted 15 lines · Yu C

On 8/4/2026 1:26 PM, Reinette Chatre wrote:

I have tested this version, and it exhibits the expected behavior according to my understanding:

The following is the legacy schemata:
[root@ resctrl]# cat schemata
            MB:0=100;1=100;2=100;3=100

and the following is the native schemata:
[root@ resctrl]# echo native > /sys/fs/resctrl/info/MB/control_mode [root@ resctrl]# cat schemata MB_REGION0_MAX:0=200;1=200;2=200;3=200 MB_REGION0_MIN:0=1;1=1;2=1;3=1

Quoted 7 lines

I have a minor question I'd like to confirm:

item 1.
In legacy mode, we intend to always let the "native" controller emulate the "legacy" controller - at least for the region‑aware RDT case.
Q1: Is this understanding correct?

As I understand region-aware is what actually makes this impossible to do since there is no mapping from "legacy" percentage based control value to "native" control value. Even more, the hardware self has two separate interfaces:
"legacy" uses MSR interface and "native" uses ACPI interface. As I see it a region aware system in "legacy" mode is using the "legacy" MSR interface and not use the "native" ACPI interface *at all*.

Quoted 16 lines

item 2.
In commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls"), during resctrl initialization, __get_mem_config_intel() clears the legacy controller's hw_ctrl->msr_update to NULL, and sets its emulation controllers in hw_ctrl->r_ctrl.emulated_by to the region-aware related controllers. So legacy controller is emulated by region-aware controllers.

item 3.
In resctrl_arch_control_mode_set(), when switching to "legacy" mode, the legacy controller is set to:
hw_ctrl->msr_update = update_temporary_legacy_MB; while the emulating controller is set to NULL:
hw_ctrl->msr_update = NULL;
That means, the emulated controllers will not take effect.

Quoted 1 line

Q2:Does item 3 contradict item 1?

The switching of .msr_update() is sample code to present a PoC of how region-aware could be supported based on my understanding described above. I expected that, for example, when user space switches the control mode between "legacy"/"native" then the region-aware code would disable/enable region-aware mode via the RDT_CTRL register and adjust the .msr_update() to match what hardware interface is active.

If at some point in future it becomes possible for resctrl to know how to map a legacy control value to a native control value for region aware then this switching should no longer be necessary and the "native" fine grained controller can always be used to emulate the "legacy" percentage based controller and to support this the ACPI interface would be enabled all the time.

I do not think any of the other architectures' features would need something like this.

Reinette

#21 lore raw

Hi Reinette,

On 8/10/2026 11:53 PM, Reinette Chatre wrote:

[ ... ]

Quoted 6 lines
Quoted 5 lines

item 1.
In legacy mode, we intend to always let the "native" controller emulate the "legacy" controller - at least for the region‑aware RDT case.
Q1: Is this understanding correct?

Quoted 7 lines

As I understand region-aware is what actually makes this impossible to do since there is no mapping from "legacy" percentage based control value to "native" control value. Even more, the hardware self has two separate interfaces:
"legacy" uses MSR interface and "native" uses ACPI interface. As I see it a region aware system in "legacy" mode is using the "legacy" MSR interface and not use the "native" ACPI interface *at all*.

OK. Previously I might have misunderstood what "legacy" means in this context:
"legacy control means using the existing MB interface in the schemata to
change the percentage value. That is to say, no matter whether
the underlying mechanism is based on MSR or MMIO, it is transparent to the
resctrl user."
which was discussed here:https://lore.kernel.org/lkml/[email protected]/ I think "legacy" now refers to "MSR" in the context of region-aware RDT,
due to lack of mapping between MSR-based and MMIO-based values.

Quoted 24 lines
Quoted 16 lines

item 2.
In commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls"), during resctrl initialization, __get_mem_config_intel() clears the legacy controller's hw_ctrl->msr_update to NULL, and sets its emulation controllers in hw_ctrl->r_ctrl.emulated_by to the region-aware related controllers. So legacy controller is emulated by region-aware controllers.

item 3.
In resctrl_arch_control_mode_set(), when switching to "legacy" mode, the legacy controller is set to:
hw_ctrl->msr_update = update_temporary_legacy_MB; while the emulating controller is set to NULL:
hw_ctrl->msr_update = NULL;
That means, the emulated controllers will not take effect.

Quoted 1 line

Q2:Does item 3 contradict item 1?

The switching of .msr_update() is sample code to present a PoC of how region-aware could be supported based on my understanding described above. I expected that, for example, when user space switches the control mode between "legacy"/"native" then the region-aware code would disable/enable region-aware mode via the RDT_CTRL register and adjust the .msr_update() to match what hardware interface is active.

Quoted 6 lines

If at some point in future it becomes possible for resctrl to know how to map a legacy control value to a native control value for region aware then this switching should no longer be necessary and the "native" fine grained controller can always be used to emulate the "legacy" percentage based controller and to support this the ACPI interface would be enabled all the time.

Then for the current region-aware MBA, should we add region-aware controllers as the same level as legacy controller, instead of adding them in legacy controllers' emulated_by list, since the legacy controller is not emulated by region-aware controllers? And we might need to introduce enable/disable flag per controller, which could be switched on/off when switching between legacy and native.

thanks,
Chenyu

Quoted 6 lines

I do not think any of the other architectures' features would need something like this.

Reinette

author maintainer
#22 lore raw

Hi Chenyu,

Quoted 20 lines · Yu C

Hi Reinette,

On 8/10/2026 11:53 PM, Reinette Chatre wrote:

[ ... ]

Quoted 6 lines
Quoted 5 lines

item 1.
In legacy mode, we intend to always let the "native" controller emulate the "legacy" controller - at least for the region‑aware RDT case.
Q1: Is this understanding correct?

Quoted 7 lines

As I understand region-aware is what actually makes this impossible to do since there is no mapping from "legacy" percentage based control value to "native" control value. Even more, the hardware self has two separate interfaces:
"legacy" uses MSR interface and "native" uses ACPI interface. As I see it a region aware system in "legacy" mode is using the "legacy" MSR interface and not use the "native" ACPI interface *at all*.

Quoted 6 lines

OK. Previously I might have misunderstood what "legacy" means in this context:
"legacy control means using the existing MB interface in the schemata to
change the percentage value. That is to say, no matter whether
the underlying mechanism is based on MSR or MMIO, it is transparent to the
resctrl user."
which was discussed here:https://lore.kernel.org/lkml/[email protected]/

Right ... but if the existing MB user space interface can only be supported by MSR then it becomes the only "underlying mechanism".

Quoted 2 lines

I think "legacy" now refers to "MSR" in the context of region-aware RDT, due to lack of mapping between MSR-based and MMIO-based values.

From user space view "legacy" is the existing percentage based MB control that user space has been using until now. The only way to support this "legacy" user interface with region-aware hardware is to use the MSR interface, no? User space does not care whether the hardware uses MSR or MMIO, it just uses the MB interface.
That is, as you also say, until it is possible to map legacy control value to region-aware control value at which point the MMIO interface can be used and user space can continue to use the MB control without interruption.

Quoted 31 lines
Quoted 24 lines
Quoted 16 lines

item 2.
In commit fbed64f80515 ("x86/resctrl: SAMPLE: Emulated controls"), during resctrl initialization, __get_mem_config_intel() clears the legacy controller's hw_ctrl->msr_update to NULL, and sets its emulation controllers in hw_ctrl->r_ctrl.emulated_by to the region-aware related controllers. So legacy controller is emulated by region-aware controllers.

item 3.
In resctrl_arch_control_mode_set(), when switching to "legacy" mode, the legacy controller is set to:
hw_ctrl->msr_update = update_temporary_legacy_MB; while the emulating controller is set to NULL:
hw_ctrl->msr_update = NULL;
That means, the emulated controllers will not take effect.

Quoted 1 line

Q2:Does item 3 contradict item 1?

The switching of .msr_update() is sample code to present a PoC of how region-aware could be supported based on my understanding described above. I expected that, for example, when user space switches the control mode between "legacy"/"native" then the region-aware code would disable/enable region-aware mode via the RDT_CTRL register and adjust the .msr_update() to match what hardware interface is active.

Quoted 6 lines

If at some point in future it becomes possible for resctrl to know how to map a legacy control value to a native control value for region aware then this switching should no longer be necessary and the "native" fine grained controller can always be used to emulate the "legacy" percentage based controller and to support this the ACPI interface would be enabled all the time.

Quoted 6 lines

Then for the current region-aware MBA, should we add region-aware controllers as the same level as legacy controller, instead of adding them in legacy controllers' emulated_by list, since the legacy controller is not emulated by region-aware controllers? And we might need to introduce enable/disable flag per controller, which could be switched on/off when switching between legacy and native.

Please consider what will be required to support per-controller dynamic ("enable" vs "disable")
state: resctrl fs needs to expose interfaces that accept control changes from user space after initialization that needs to be supported by architecture. In the current design resctrl fs expects controllers to be set and configured at the time it starts so such change would require new locking between resctrl fs and architecture. This complexity does not seem necessary to me since switching between legacy and native accomplishes the same, no?

I find "region-aware controllers at the same level as legacy controller" together with "per controller enable/disable" conflicting since it creates impression that user space can enable/disable the controllers independently while there is a required dependency among the different controllers based on whether hardware has region-aware MBA enabled or not. Even here there would be a requirement to communicate to userspace which controllers could be enabled/disabled together ... which is the same as the emulated list, no?

Also consider the future:
(a) Would it be possible to map legacy control value to region aware control value in the future? I believe the answer is "yes". If resctrl starts by displaying the region-aware controllers as emulating the legacy controller in info/ then the transition to support this will be smooth.

(b) Would MSR interface always be available?
I do not think resctrl should always assume this to be the case. Here I also find that starting with exposing region aware controllers as emulating the legacy controller in info/ to support a smooth transition.

What problem(s) do you envision?

Reinette

#23 lore raw

Hi Reinette,

Quoted 7 lines · Reinette Chatre

Hi Chenyu,

Quoted 2 lines

I think "legacy" now refers to "MSR" in the context of region-aware RDT, due to lack of mapping between MSR-based and MMIO-based values.

From user space view "legacy" is the existing percentage based MB control
that user space has been using until now. The only way to support this "legacy" user interface with region-aware hardware is to use the MSR interface, no?

Yes, agreed.

Quoted 6 lines
Quoted 6 lines

Then for the current region-aware MBA, should we add region-aware controllers as the same level as legacy controller, instead of adding them in legacy controllers' emulated_by list, since the legacy controller is not emulated by region-aware controllers? And we might need to introduce enable/disable flag per controller, which could be switched on/off when switching between legacy and native.

Quoted 7 lines

Please consider what will be required to support per-controller dynamic ("enable" vs "disable")
state: resctrl fs needs to expose interfaces that accept control changes from user space after initialization that needs to be supported by architecture. In the current design resctrl fs expects controllers to be set and configured at the time it starts so such change would require new locking between resctrl fs and architecture. This complexity does not seem necessary to me since switching between legacy and native accomplishes the same, no?

OK, agreed.

Quoted 6 lines

I find "region-aware controllers at the same level as legacy controller" together with "per controller enable/disable" conflicting since it creates impression that user space can enable/disable the controllers independently while there is a required dependency among the different controllers based on whether hardware has region-aware MBA enabled or not. Even here there would be a requirement to communicate to userspace which controllers could be enabled/disabled together ... which is the same as the emulated list, no?

I see. So we actually need a single option (control_mode) to switch between modes (legacy vs. native, mutually exclusive), rather than giving each controller its own independent enable/disable toggle. The emulated list is one way to implement control_mode, ensuring "legacy" and "native" are mutually exclusive.

Quoted 7 lines

Also consider the future:
(a) Would it be possible to map legacy control value to region aware control value in the future? I believe the answer is "yes". If resctrl starts by displaying the region-aware controllers as emulating the legacy controller in info/ then the transition to support this will be smooth.

Quoted 7 lines

(b) Would MSR interface always be available?
I do not think resctrl should always assume this to be the case. Here I also find that starting with exposing region aware controllers as emulating the legacy controller in info/ to support a smooth transition.

What problem(s) do you envision?

Based on this design, I don’t see any issues. So putting native controllers under the legacy controller could be a viable approach that can be extended in the future.

thanks,
Chenyu

#24 lore raw
Quoted 7 lines · Yu C
Quoted 6 lines

I find "region-aware controllers at the same level as legacy controller" together with "per controller enable/disable" conflicting since it creates impression that user space can enable/disable the controllers independently while there is a required dependency among the different controllers based on whether hardware has region-aware MBA enabled or not. Even here there would be a requirement to communicate to userspace which controllers could be enabled/disabled together ... which is the same as the emulated list, no?

Quoted 8 lines

I see. So we actually need a single option (control_mode) to switch between modes (legacy vs.
native, mutually exclusive), rather than giving each controller its own independent enable/disable
toggle. The emulated list is one way to implement control_mode, ensuring "legacy" and "native"
are mutually exclusive.

While adjusting the region aware code on this emulation part, a minor issue is found in commit ("fs/resctrl: Support emulated controls")

fs/resctrl/rdtgroup.c +1 -1
index cac4b3293cef..ab7d3fa3f337 100644
@@ -124,7 +124,7 @@ void rdt_staged_configs_clear(void)
                        if (list_empty(&ctrl->emulated_by))
                                continue;
                        list_for_each_entry(em_ctrl, &ctrl->emulated_by, entry) {
-                               list_for_each_entry_rcu(dom, &ctrl->domains, hdr.list, lockdep_is_cpus_held())
+                               list_for_each_entry_rcu(dom, &em_ctrl->domains, hdr.list, lockdep_is_cpus_held())
                                        memset(dom->staged_config, 0, sizeof(dom->staged_config));
                        }
                }

thanks,
Chenyu

author maintainer
#25 lore raw

Hi Chenyu,

Quoted 25 lines · Chen Yu
Quoted 7 lines · Yu C
Quoted 6 lines

I find "region-aware controllers at the same level as legacy controller" together with "per controller enable/disable" conflicting since it creates impression that user space can enable/disable the controllers independently while there is a required dependency among the different controllers based on whether hardware has region-aware MBA enabled or not. Even here there would be a requirement to communicate to userspace which controllers could be enabled/disabled together ... which is the same as the emulated list, no?

Quoted 8 lines

I see. So we actually need a single option (control_mode) to switch between modes (legacy vs.
native, mutually exclusive), rather than giving each controller its own independent enable/disable
toggle. The emulated list is one way to implement control_mode, ensuring "legacy" and "native"
are mutually exclusive.

While adjusting the region aware code on this emulation part, a minor issue is found in commit ("fs/resctrl: Support emulated controls")

fs/resctrl/rdtgroup.c +0 -0
index cac4b3293cef..ab7d3fa3f337 100644

fs/resctrl/rdtgroup.c void rdt_staged_configs_clear(void) · line 130

Quoted 8 lines
fs/resctrl/rdtgroup.c +1 -1
@@ -124,7 +124,7 @@ void rdt_staged_configs_clear(void)
                        if (list_empty(&ctrl->emulated_by))
                                continue;
                        list_for_each_entry(em_ctrl, &ctrl->emulated_by, entry) {
-                               list_for_each_entry_rcu(dom, &ctrl->domains, hdr.list, lockdep_is_cpus_held())
+                               list_for_each_entry_rcu(dom, &em_ctrl->domains, hdr.list, lockdep_is_cpus_held())
                                        memset(dom->staged_config, 0, sizeof(dom->staged_config));
                        }
                }

Thank you very much. Squashed and available in branch resctrl/controls_rfc_v2.2

Reinette

#26 lore raw
Quoted 16 lines · Reinette Chatre

fs/resctrl/rdtgroup.c void rdt_staged_configs_clear(void) · line 130

Quoted 13 lines · Chen Yu
fs/resctrl/rdtgroup.c +1 -1
index cac4b3293cef..ab7d3fa3f337 100644
@@ -124,7 +124,7 @@ void rdt_staged_configs_clear(void)
                        if (list_empty(&ctrl->emulated_by))
                                continue;
                        list_for_each_entry(em_ctrl, &ctrl->emulated_by, entry) {
-                               list_for_each_entry_rcu(dom, &ctrl->domains, hdr.list, lockdep_is_cpus_held())
+                               list_for_each_entry_rcu(dom, &em_ctrl->domains, hdr.list, lockdep_is_cpus_held())
                                        memset(dom->staged_config, 0, sizeof(dom->staged_config));
                        }
                }

Thank you very much. Squashed and available in branch resctrl/controls_rfc_v2.2

:) Another minor one
otherwise a schemata write on Haswell would only update rdt_hw_ctrl_domain::ctrl_val[] and never reach MSR_IA32_L3_CBM_BASE.

arch/x86/kernel/cpu/resctrl/core.c +4 -0
@@ -175,6 +175,10 @@ static inline void cache_alloc_hsw_probe(void)
 	hw_ctrl->r_ctrl.bitmap.cbm_len = 20;
 	hw_ctrl->r_ctrl.bitmap.shareable_bits = 0xc0000;
 	hw_ctrl->r_ctrl.bitmap.min_cbm_bits = 2;
+
+	hw_ctrl->msr_base = MSR_IA32_L3_CBM_BASE;
+	hw_ctrl->hw_update = cat_wrmsr;
+
 	list_add(&hw_ctrl->r_ctrl.entry, &r->controls);
 
 	hw_res->num_closid = 4;

thanks,
Chenyu

author maintainer
#27 lore raw

Hi Chenyu,

Quoted 25 lines · Chen Yu
Quoted 16 lines · Reinette Chatre

fs/resctrl/rdtgroup.c void rdt_staged_configs_clear(void) · line 130

Quoted 13 lines · Chen Yu
fs/resctrl/rdtgroup.c +1 -1
index cac4b3293cef..ab7d3fa3f337 100644
@@ -124,7 +124,7 @@ void rdt_staged_configs_clear(void)
                        if (list_empty(&ctrl->emulated_by))
                                continue;
                        list_for_each_entry(em_ctrl, &ctrl->emulated_by, entry) {
-                               list_for_each_entry_rcu(dom, &ctrl->domains, hdr.list, lockdep_is_cpus_held())
+                               list_for_each_entry_rcu(dom, &em_ctrl->domains, hdr.list, lockdep_is_cpus_held())
                                        memset(dom->staged_config, 0, sizeof(dom->staged_config));
                        }
                }

Thank you very much. Squashed and available in branch resctrl/controls_rfc_v2.2

:) Another minor one
otherwise a schemata write on Haswell would only update rdt_hw_ctrl_domain::ctrl_val[] and never reach MSR_IA32_L3_CBM_BASE.

arch/x86/kernel/cpu/resctrl/core.c static inline void cache_alloc_hsw_probe(void) · line 181

Quoted 7 lines
arch/x86/kernel/cpu/resctrl/core.c +4 -0
@@ -175,6 +175,10 @@ static inline void cache_alloc_hsw_probe(void)
 	hw_ctrl->r_ctrl.bitmap.cbm_len = 20;
 	hw_ctrl->r_ctrl.bitmap.shareable_bits = 0xc0000;
 	hw_ctrl->r_ctrl.bitmap.min_cbm_bits = 2;
+
+	hw_ctrl->msr_base = MSR_IA32_L3_CBM_BASE;
+	hw_ctrl->hw_update = cat_wrmsr;
+

Thank you very much.

This seems to be a patch that requires additional changes that are not in the PoC. I squashed this after a change to use msr_update instead of hw_update, now available in resctrl/controls_rfc_v2.4.

We could do the rename of these function pointers as part of the PoC but that would also require adjustments to the parameters that would need more insight into the future requirements.

Reinette

#28 lore raw
In reply to Reinette Chatre

Hi Reinette,

Quoted 10 lines · Reinette Chatre

From user space view "legacy" is the existing percentage based MB control that user space has been using until now. The only way to support this "legacy" user interface with region-aware hardware is to use the MSR interface, no? User space does not care whether the hardware uses MSR or MMIO, it just uses the MB interface.
That is, as you also say, until it is possible to map legacy control value to region-aware control value at which point the MMIO interface can be used and user space can continue to use the MB control without interruption.

While looking at the context of control_mode under the info directory, it is currently used only for the controller to switch between "legacy" and "native". However, there is also an explicit requirement for the MBM to switch between "legacy" and "native" TOGETHER with the MBA.

According to the RDT spec 6.1.3.1 RDT Control Register for CPU Agents, it discourages mixing legacy MSR for MBM with region aware MBA:
"It is recommended that software use Region Aware MBM when Region Aware MBA is enabled and vice versa. Mixed mode use (e.g, legacy MSR interfaces for MBM with Region Aware MBA or vice versa) is not supported and may lead to inconsistent behavior"

That is to say, I'm trying to add logic in the code so that, if control_mode has switched, the corresponding "mode" for MBM will also be adjusted to the same mode. The code can enable/create both legacy MBM events/sysfs and region-aware MBM events/sysfs during bootup, and make one of them visible according to control_mode, similar to what Babu does in PLZA when hiding a file in
https://lore.kernel.org/lkml/f7bcf19ac8113a1e3d9575739c1a6400c455ce6d.1787772750.git.babu.moger@amd.com/

May I know whether this approach is doable?

thanks,
Chenyu

author maintainer
#29 lore raw

Hi Chenyu,

Quoted 26 lines · Chen Yu

Hi Reinette,

Quoted 10 lines · Reinette Chatre

From user space view "legacy" is the existing percentage based MB control that user space has been using until now. The only way to support this "legacy" user interface with region-aware hardware is to use the MSR interface, no? User space does not care whether the hardware uses MSR or MMIO, it just uses the MB interface.
That is, as you also say, until it is possible to map legacy control value to region-aware control value at which point the MMIO interface can be used and user space can continue to use the MB control without interruption.

While looking at the context of control_mode under the info directory, it is currently used only for the controller to switch between "legacy" and "native". However, there is also an explicit requirement for the MBM to switch between "legacy" and "native" TOGETHER with the MBA.

According to the RDT spec 6.1.3.1 RDT Control Register for CPU Agents, it discourages mixing legacy MSR for MBM with region aware MBA:
"It is recommended that software use Region Aware MBM when Region Aware MBA is enabled and vice versa. Mixed mode use (e.g, legacy MSR interfaces for MBM with Region Aware MBA or vice versa) is not supported and may lead to inconsistent behavior"

Quoted 8 lines

That is to say, I'm trying to add logic in the code so that, if control_mode has switched, the corresponding "mode" for MBM will also be adjusted to the same mode. The code can enable/create both legacy MBM events/sysfs and region-aware MBM events/sysfs during bootup, and make one of them visible according to control_mode, similar to what Babu does in PLZA when hiding a file in
https://lore.kernel.org/lkml/f7bcf19ac8113a1e3d9575739c1a6400c455ce6d.1787772750.git.babu.moger@amd.com/

May I know whether this approach is doable?

This sounds reasonable to me. Since so many changes are between current resctrl and those changes it is difficult to envision how clean such change would be. We should aim to avoid sprinkling "if ("region aware") then" checks all over the place.

A switch like this will force "region aware" to support the same number of CLOS/RMID as the MSR interface. Is this a concern?

Reinette

#30 lore raw

Hi Reinette,

Quoted 33 lines · Reinette Chatre

Hi Chenyu,

Quoted 31 lines · Reinette Chatre
Quoted 10 lines

From user space view "legacy" is the existing percentage based MB control
that user space has been using until now. The only way to support this "legacy" user interface with region-aware hardware is to use the MSR interface, no? User space does not care whether the hardware uses MSR or MMIO, it just uses the MB interface.
That is, as you also say, until it is possible to map legacy control value to region-aware control value at which point the MMIO interface can be used and user space can continue to use the MB control without interruption.

While looking at the context of control_mode under the info directory, it is currently used only for the controller to switch between "legacy" and "native". However, there is also an explicit requirement for the MBM to switch between "legacy" and "native" TOGETHER with the MBA.

According to the RDT spec 6.1.3.1 RDT Control Register for CPU Agents, it discourages mixing legacy MSR for MBM with region aware MBA:
"It is recommended that software use Region Aware MBM when Region Aware MBA is enabled and vice versa. Mixed mode use (e.g, legacy MSR interfaces for MBM with Region Aware MBA or vice versa) is not supported and may lead to inconsistent behavior"

That is to say, I'm trying to add logic in the code so that, if control_mode has switched, the corresponding "mode" for MBM will also be adjusted to the same mode. The code can enable/create both legacy MBM events/sysfs and region-aware MBM events/sysfs during bootup, and make one of them visible according to control_mode, similar to what Babu does in PLZA when hiding a file in
https://lore.kernel.org/lkml/f7bcf19ac8113a1e3d9575739c1a6400c455ce6d.1787772750.git.babu.moger@amd.com/

Quoted 8 lines
Quoted 1 line

May I know whether this approach is doable?

This sounds reasonable to me. Since so many changes are between current resctrl and those changes it is difficult to envision how clean such change would be. We should aim to avoid sprinkling "if ("region aware") then" checks all over the place.

A switch like this will force "region aware" to support the same number of CLOS/RMID as the MSR interface. Is this a concern?

It seems that taking the weakest link (minimum) across all sources is a pervasive convention in resctrl, which can be used to avoid out-of-bounds CLOS/RMID access. If a future platform does not support the CPUID/MSR interfaces, we can only rely on the ACPI table to get the max RMID/CLOSID.

thanks,
Chenyu

author maintainer
#31 lore raw

Hi Chenyu,

Quoted 39 lines · Yu C
Quoted 38 lines · Reinette Chatre

Hi Chenyu,

Quoted 24 lines · Reinette Chatre
Quoted 10 lines

 From user space view "legacy" is the existing percentage based MB control that user space has been using until now. The only way to support this "legacy" user interface with region-aware hardware is to use the MSR interface, no? User space does not care whether the hardware uses MSR or MMIO, it just uses the MB interface.
That is, as you also say, until it is possible to map legacy control value to region-aware control value at which point the MMIO interface can be used and user space can continue to use the MB control without interruption.

While looking at the context of control_mode under the info directory, it is currently used only for the controller to switch between "legacy" and "native". However, there is also an explicit requirement for the MBM to switch between "legacy" and "native" TOGETHER with the MBA.

According to the RDT spec 6.1.3.1 RDT Control Register for CPU Agents, it discourages mixing legacy MSR for MBM with region aware MBA:
"It is recommended that software use Region Aware MBM when Region Aware MBA is enabled and vice versa. Mixed mode use (e.g, legacy MSR interfaces for MBM with Region Aware MBA or vice versa) is not supported and may lead to inconsistent behavior"

Quoted 8 lines

That is to say, I'm trying to add logic in the code so that, if control_mode has switched, the corresponding "mode" for MBM will also be adjusted to the same mode. The code can enable/create both legacy MBM events/sysfs and region-aware MBM events/sysfs during bootup, and make one of them visible according to control_mode, similar to what Babu does in PLZA when hiding a file in
https://lore.kernel.org/lkml/f7bcf19ac8113a1e3d9575739c1a6400c455ce6d.1787772750.git.babu.moger@amd.com/

May I know whether this approach is doable?

This sounds reasonable to me. Since so many changes are between current resctrl and those changes it is difficult to envision how clean such change would be. We should aim to avoid sprinkling "if ("region aware") then" checks all over the place.

Quoted 6 lines
Quoted 3 lines

A switch like this will force "region aware" to support the same number of CLOS/RMID as the MSR interface. Is this a concern?

It seems that taking the weakest link (minimum) across all sources is a pervasive convention in resctrl, which can be used to avoid out-of-bounds CLOS/RMID access.

Right. My question is what is expected if a resource supports different number of CLOSID/RMID depending on the interface used to manage the resource? More specifically, resctrl can now interact with the MB resource using two interfaces: MSR and ACPI. Each interface separately enumerates how many CLOSID/RMID it supports. Thus, it seems possible, that the MB resource may support X CLOSID over MSR interface and Y CLOSID over ACPI interface.

resctrl exposes the per-resource CLOSID/RMID to user space and today thus needs to pick whether it exposes the CLOSID/RMID from MSR interface or from ACPI interface and that will guide how many resctrl will support during the mount. As you state resctrl uses the minimum.

If the user has no intention of using the interface that enforces the minimum then there is no way today for the user to indicate this and thus obtain benefit of all supported IDs.

Can it be assumed that a system that supports both MSR and ACPI interfaces will enumerate the same number of CLOSID and RMID on both interfaces?

Quoted 2 lines

If a future platform does not support the CPUID/MSR interfaces, we can only rely on the ACPI table to get the max RMID/CLOSID.

ack.

Reinette

#32 lore raw

Hi Reinette,Tony,

Quoted 57 lines · Reinette Chatre

Hi Chenyu,

Quoted 36 lines
Quoted 36 lines
Quoted 24 lines · Reinette Chatre
Quoted 10 lines

 From user space view "legacy" is the existing percentage based MB control
that user space has been using until now. The only way to support this "legacy" user interface with region-aware hardware is to use the MSR interface, no? User space does not care whether the hardware uses MSR or MMIO, it just uses the MB interface.
That is, as you also say, until it is possible to map legacy control value to region-aware control value at which point the MMIO interface can be used and user space can continue to use the MB control without interruption.

While looking at the context of control_mode under the info directory, it is currently used only for the controller to switch between "legacy" and "native". However, there is also an explicit requirement for the MBM to switch between "legacy" and "native" TOGETHER with the MBA.

According to the RDT spec 6.1.3.1 RDT Control Register for CPU Agents, it discourages mixing legacy MSR for MBM with region aware MBA:
"It is recommended that software use Region Aware MBM when Region Aware MBA is enabled and vice versa. Mixed mode use (e.g, legacy MSR interfaces for MBM with Region Aware MBA or vice versa) is not supported and may lead to inconsistent behavior"

Quoted 8 lines

That is to say, I'm trying to add logic in the code so that, if control_mode has switched, the corresponding "mode" for MBM will also be adjusted to the same mode. The code can enable/create both legacy MBM events/sysfs and region-aware MBM events/sysfs during bootup, and make one of them visible according to control_mode, similar to what Babu does in PLZA when hiding a file in
https://lore.kernel.org/lkml/f7bcf19ac8113a1e3d9575739c1a6400c455ce6d.1787772750.git.babu.moger@amd.com/

May I know whether this approach is doable?

This sounds reasonable to me. Since so many changes are between current resctrl and those changes it is difficult to envision how clean such change would be. We should aim to avoid sprinkling "if ("region aware") then" checks all over the place.

Quoted 6 lines
Quoted 3 lines

A switch like this will force "region aware" to support the same number of CLOS/RMID as the MSR interface. Is this a concern?

It seems that taking the weakest link (minimum) across all sources is a pervasive convention in resctrl, which can be used to avoid out-of-bounds CLOS/RMID access.

Right. My question is what is expected if a resource supports different number of CLOSID/RMID depending on the interface used to manage the resource? More specifically, resctrl can now interact with the MB resource using two interfaces: MSR and ACPI. Each interface separately enumerates how many CLOSID/RMID it supports. Thus, it seems possible, that the MB resource may support X CLOSID over MSR interface and Y CLOSID over ACPI interface.

resctrl exposes the per-resource CLOSID/RMID to user space and today thus needs to pick whether it exposes the CLOSID/RMID from MSR interface or from ACPI interface and that will guide how many resctrl will support during the mount. As you state resctrl uses the minimum.

Quoted 7 lines

If the user has no intention of using the interface that enforces the minimum then there is no way today for the user to indicate this and thus obtain benefit of all supported IDs.

Can it be assumed that a system that supports both MSR and ACPI interfaces will enumerate the same number of CLOSID and RMID on both interfaces?

Yes, per inquiry with the architect team,
"Regarding Region aware/ERDT MAX RMID value: It should match to CPUID Global Max. Our intent moving forward is to support a consistent RMID space across all features within a given domain type."

Besides, as mentioned by Tony, the max RMID/CLOSID exposed by CPUID is the global gating factor regardless of whether the MSR or MMIO interface is used:
[Section 19.18.6 Monitoring Resource RMID Association]
"software must use CPUID to query the maximum RMID supported by the processor. If a value larger than the maximum RMID is written to IA32_PQR_ASSOC.RMID, a #GP(0) fault will be generated."
So this min() can be used as a safeguard to protect against bogus max RMID/CLOSID from the ACPI table.

thanks,
Chenyu

Quoted 5 lines
Quoted 2 lines

If a future platform does not support the CPUID/MSR interfaces, we can only rely on the ACPI table to get the max RMID/CLOSID.

ack.

Reinette

maintainer
#33 lore raw
In reply to Chen, Yu C
Quoted 5 lines

It seems that taking the weakest link (minimum) across all sources is a pervasive convention in resctrl, which can be used to avoid out-of-bounds CLOS/RMID access.
If a future platform does not support the CPUID/MSR interfaces, we can only rely on the ACPI table to get the max RMID/CLOSID.

The CPUID enumeration will always define the maximum values that can be written to the IA32_PQR_ASSOC.{CLOS,RMID} fields regardless of whether MSR interfaces are provided. There should[1] be a #GP fault if the OS attempts to write a larger value to either field.

If an ACPI table (or VSEC enumeration) supplies some larger values they should be over-ridden by limits from CPUID.

-Tony

[1] I've a vague recollection that some early RDT supporting Xeon didn't #GP for out of range RMID ... but that might have only been on a pre-production stepping.

reviewer
#34 lore raw
In reply to Reinette Chatre

Hi, Reinette,

Quoted 152 lines · Reinette Chatre

Hi Everybody,

I understand that folks are eager for this work to settle so that features that depend on it can make progress.

I do have a request if you have a feature that depends on this PoC:

Please do not fork this PoC and keep changes to the PoC code in your fork
to meet the requirements of the feature you are working on. This is resulting in duplicate (even triplicate) changes to PoC floating around. Instead, please collaborate on this PoC by responding to the patches that need changes/fixes to support your feature. If the patches do not exist yet, please participate in the discussions that plan these changes so the work adding the discussed features
is not duplicated. If you already have the code, please feel free to send as fixups.
Doing so will help this PoC to settle faster and help meet the requirements of the feature(s) a couple of folks are working on.

RFC v1: https://lore.kernel.org/lkml/[email protected]/
git://git.kernel.org/pub/scm/linux/kernel/git/reinette/linux.git branch resctrl/controls_rfc_v1

RFC v2 of this PoC can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/reinette/linux.git branch resctrl/controls_rfc_v2

The list of changes is long. For an overview of the new interfaces, please see the new documentation patch:
https://git.kernel.org/pub/scm/linux/kernel/git/reinette/linux.git/patch/?id=2e2d0140e857eae2ba3e71e8d9c595897649599a

Remaining Opens:
---------------
- MPAM only compile tested.
- Only "SAMPLE" code provided for x86 to demonstrate emulated controls.
- Architecture should take care to restore control value of legacy control when switching mode from "native" to "legacy". This may be complicated by a legacy control backed by multiple native controls and thus best handled by architecture. This adds a complication that resctrl cannot promise that switching between control modes will not be destructive since a reverse mapping may not exist.
- When switching control mode to native the top level control info files stop returning information. This could be considered "work as intended"?
- Add relationships between controls. For example, cannot set "MIN" control value to be larger than "MAX. Unclear how to do this in resctrl fs when considering that the relationship may span between enabled and disabled controls. This is potentially something that needs to be managed by architecture and thus potentially without a consistent failure to user space.

Changes since RFC v1:
--------------------
There are many changes since RFC v1 since I aimed to address all feedback (but please see the deferred/dropped list below). If I missed anything it was not intentional. Please feel free to point it out to me.

User visible changes:
--------------------
- Expose bitmap control properties to user space.
-- Only expose two properties:
- resctrl_ctrl_bitmap::min_cbm_bits exposed via new file "min_bits".
This drops the familiar "cbm" term to not make the control specific
to capacity.
- resctrl_ctrl_bitmap::cbm_len exposed via "max" file
-- While "shareable_bits" is technically a bitmap control property this does
seem an opportunity to deprecate it since the IO alloc support proved
that it does not accurately represent shared allocations, "bit_usage"
is the best for that.
- Add support for control flags with "linear" as first flag of the "scalar"
control and "sparse" the first flag of the "bitmap" control.
Include flags in output of the "type" file.
Suggested by Chenyu: https://lore.kernel.org/lkml/[email protected]/
- Add a "default" field to a control using the "reset_val" name suggested
by Drew and return that instead of always using "max" for the scalar control.
The "MIN" control can return its minimum value as default.
Suggested by Ben in https://lore.kernel.org/lkml/[email protected]/
Use case from Drew: https://lore.kernel.org/lkml/aiCBratZchVFVhws@gen8/
Drew suggested name as "reset_val" https://lore.kernel.org/lkml/aiOrznnZjTGywMna@thelio>
- Change "resource_schemata" to "schemata".
Fenghua: https://lore.kernel.org/lkml/[email protected]/
- Fix the control alignment. (Chenyu and Tony)
- Drop the "per control" scope. Move the "scope" back to being per-resource and
do not expose a per control "scope" file. This helps to support new resources like node scoped MBA that cannot emulate the legacy MB control. Also
supports emulated controls by ensuring that all controls associated with
a resource have the same scope.
- Support emulating legacy control.
- Support multiple backing controls for a legacy control.
- Expose new per-resource "control_mode" file that user space can use to
switch between legacy and native controls. Only the enabled controls
are shown to user in schemata file.
- The new "native" control mode is only supported for the MBA resource.
The solution is generic but there are implications for, for example, the resctrl features that rely on the legacy cache control (cache pseudo-locking and IO alloc). Defer support for other resource since there are no immediate plans to have, for example, the legacy cache control backed by something else.
- Architecture differences imply a lot of architecture flexibility in
support for emulating controls.
Architecture can expect resctrl fs to only stage control values in
controls that are enabled. Within architecture there could be rules
that determine what to program based on the control's emulated controls
or it could dynamically program update callbacks when the user changes
the control mode. RFC includes sample code identified by "SAMPLE" for the latter that demonstrates one way to solve the x86 variant where the hardware self supports both legacy and finer grained controls.
- The top level legacy control property files stop returning data when
the mode switches to "native".
- Draft of documentation that describes multiple controls and emulated
controls.
- Fix Intel MBA tolerance to be 10 to match the "round-up" implementation.

Changes not user visible:
-------------------------
- Rebase on tip x86/cache with following applied on top:
"x86,fs/resctrl: Improve resctrl quality and consistency"

     https://lore.kernel.org/lkml/[email protected]/
   "x86,fs/resctrl,arm_mpam: Factor MBA parse-time conversion to be per-arch"
     https://lore.kernel.org/lkml/[email protected]/

- Fix initialization of controls list in MPAM. (Ben)
- Dan Carpenter reported an issue with missing unlocks in
rdt_bit_usage_show() that was resolved as part of rebase on top of the
new info_kn_lock()/info_kn_unlock() helpers.
- Drop "mpam,x86,fs/resctrl: Make memory bandwidth delay a resource
property" so that memory bandwidth delay linear flag can be a control flag instead.
- Separate adding the control to struct msr_param from the change that
makes hardware update functions part of control.
("x86/resctrl: Make control update properties part of the control") to
create new patch that is moved earlier in series to support bandwidth
linear flag property being part of control.
New patch: "x86/resctrl: Include control with information controlling hardware change"
- Rename the controls to match their type to reduce confusion.
Suggested by Chenyu: https://lore.kernel.org/lkml/[email protected]/
New names:

   struct resctrl_membw -> struct resctrl_ctrl_scalar
   struct resctrl_cache -> struct resctrl_ctrl_bitmap
   resctrl_ctrl::membw -> resctrl_ctrl::scalar
   resctrl_ctrl::cache -> resctrl_ctrl::bitmap

- Switch subject prefix to be "arm,x86,fs/resctrl: ..." when changing both architectures and resctrl fs code.
- Switch to MPAM subject prefix of "arm_mpam: resctrl:" when only changing MPAM code.

Changes deferred/dropped:
------------------------
- Let "scope" form part of the control name.
Drop this since the current plan is to have the scope be part of the resource name for new resources.
- Introduce new per-control "status" that can be "enabled" or "disabled". Drop this. While controls now have an "enabled" or "disabled" state internally, this is not exposed to user space via a file. Instead, the "enabled" or "disabled" state is exposed to user space via the entries appearing in schemata file. This simplifies the subtleties when the hardware self supports both legacy and finer grained interfaces (aka RDT's region-aware).
- Defer emulated control support for cache controls.
- Supporting different monitoring scope is not part of this PoC.

Quoted 1 line

Any feedback is appreciated.

With minor MPAM changes, I can do simple tests on MPAM:
- INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by);
+ INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

- INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by);
+ INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

There is a branch resctrl/controls_rfc_v2.1. Seems no diff from controls_rfc_v2. Is either branch OK for base code?

* @emulated_by:List of controls that emulate this control. When set
the containing
* struct resctrl_ctrl is likely a legacy control and
@emulated_by
* are the finer grained hardware controls used to back
the legacy
* control. This emulation is hidden from user in schemata
file when

 *              rdt_resource::ctrl_mode is RESCTRL_CTRL_MODE_LEGACY and
 *              exposed when rdt_resource::ctrl_mode is
 *              RESCTRL_CTRL_MODE_NATIVE.
 */
struct resctrl_ctrl {
...
        struct list_head        emulated_by;
};

Does this mean a legacy resctrl control can be emulated by a few resctrl controls (which is stored in the list)?

e.g. legacy MB control can be emulated by a few controls? I thought "MB:" line is emulated by only one native control. e.g. "MB:" line is emulated by "MB_NODE:" line.

Thanks.

-Fenghua

#35 lore raw

Hi Fenghua,
On 8/10/2026 10:55 AM, Fenghua Yu wrote:

[ ... ]

Quoted 9 lines

struct resctrl_ctrl {
...
        struct list_head        emulated_by;
};

Does this mean a legacy resctrl control can be emulated by a few resctrl controls (which is stored in the list)?

e.g. legacy MB control can be emulated by a few controls? I thought "MB:" line is emulated by only one native control. e.g. "MB:" line is emulated by "MB_NODE:" line.

If I understand correctly, for region-aware RDT, the legacy MB control may be emulated collectively by region0_control, region1_control, ..., regionN_control. In the original definition, MB represents the traffic that misses the L3 cache and is refilled from all sources, which could include DRAM (region0), CXL (region1), and others.

thanks,
Chenyu

reviewer
#36 lore raw

Hi, Chen,

Quoted 12 lines · Yu C

Hi Fenghua,
On 8/10/2026 10:55 AM, Fenghua Yu wrote:

[ ... ]

Quoted 7 lines

struct resctrl_ctrl {
...
         struct list_head        emulated_by;
};

Does this mean a legacy resctrl control can be emulated by a few resctrl controls (which is stored in the list)?

Quoted 8 lines
Quoted 2 lines

e.g. legacy MB control can be emulated by a few controls? I thought "MB:" line is emulated by only one native control. e.g. "MB:" line is emulated by "MB_NODE:" line.

If I understand correctly, for region-aware RDT, the legacy MB control may be emulated collectively by region0_control, region1_control, ..., regionN_control. In the original definition, MB represents the traffic that misses the L3 cache and is refilled from all sources, which could include DRAM (region0), CXL (region1), and others.

I may misunderstand "emulation" concept here.

I was thinking emulation mode is for backward compatibility, i.e. a native MB control is emulating "MB:" line: writing and reading both lines are same. So legacy user app won't be broken on new control.

For a list of resctrl controls (region0_control, region1_control, etc), which one is for legacy "MB:" control so that reading/wring the control is same as writing/reading "MB:"line?

Thanks.

-Fenghua

#37 lore raw

Hi Fenghua,

Quoted 18 lines · Fenghua Yu

Hi, Chen,

Quoted 15 lines · Yu C

Hi Fenghua,
On 8/10/2026 10:55 AM, Fenghua Yu wrote:

[ ... ]

Quoted 9 lines

struct resctrl_ctrl {
...
         struct list_head        emulated_by;
};

Does this mean a legacy resctrl control can be emulated by a few resctrl controls (which is stored in the list)?

e.g. legacy MB control can be emulated by a few controls? I thought "MB:" line is emulated by only one native control. e.g. "MB:" line is emulated by "MB_NODE:" line.

Quoted 8 lines
Quoted 5 lines

If I understand correctly, for region-aware RDT, the legacy MB control may be emulated collectively by region0_control, region1_control, ..., regionN_control. In the original definition, MB represents the traffic that misses the L3 cache and is refilled from all sources, which could include DRAM (region0), CXL (region1), and others.

I may misunderstand "emulation" concept here.

I was thinking emulation mode is for backward compatibility, i.e. a

Yes, this is also my understanding.

Quoted 1 line

native MB control is emulating "MB:" line: writing and reading both lines are same. So legacy user app won't be broken on new control.

For legacy MB, it is currently percentage-based with a valid range of [1, 100]. Userspace might still want to write using percentage-based values to maintain backward compatibility.

The native MB control, on the other hand, may have a valid range of [1, 255]. Therefore, a mapping is required to convert user-provided[1, 100]
to [1, 255] before writing to the underlying hardware.

Quoted 3 lines

For a list of resctrl controls (region0_control, region1_control, etc), which one is for legacy "MB:" control so that reading/wring the control is same as writing/reading "MB:"line?

My understanding is that all of them will be written to the same value, which has been mapped from [1, 100] to [1, 255].
According to the change:
https://git.kernel.org/pub/scm/linux/kernel/git/reinette/linux.git/commit/?h=resctrl/controls_rfc_v2.1&id=2b4fa1beb03848555090a4e8a3d2bb80524e0478

list_for_each_entry(em_ctrl, &ctrl->emulated_by, entry) {
	//every domain for each emulating controller will write the same value
}

thanks,
Chenyu

author maintainer
#38 lore raw
In reply to Fenghua Yu

Hi Fenghua,

Quoted 9 lines · Fenghua Yu

On 8/3/26 22:26, Reinette Chatre wrote:
With minor MPAM changes, I can do simple tests on MPAM:
-               INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by); +               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

-               INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by); +               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

There is a branch resctrl/controls_rfc_v2.1. Seems no diff from controls_rfc_v2. Is either branch OK for base code?

hmmm ... branch resctrl/controls_rfc_v2.1 should have the change you note above and would be the right branch for you to use.
That is the only difference with resctrl/controls_rfc_v2.

Quoted 14 lines

 * @emulated_by:List of controls that emulate this control. When set the containing *              struct resctrl_ctrl is likely a legacy control and @emulated_by *              are the finer grained hardware controls used to back the legacy *              control. This emulation is hidden from user in schemata file when *              rdt_resource::ctrl_mode is RESCTRL_CTRL_MODE_LEGACY and *              exposed when rdt_resource::ctrl_mode is
 *              RESCTRL_CTRL_MODE_NATIVE.
 */
struct resctrl_ctrl {
...
        struct list_head        emulated_by;
};

Quoted 6 lines

Does this mean a legacy resctrl control can be emulated by a few resctrl controls (which is stored in the list)?

e.g. legacy MB control can be emulated by a few controls? I thought "MB:" line is emulated by only one native control. e.g. "MB:" line is emulated by "MB_NODE:" line.

As Chenyu highlighted this is to support region-aware.

While I did originally suggest MB_NODE to emulate MB I learned from Ben just how troublesome this can be. I am still trying to untangle how MPAM MSC and AMD GLBE can be supported in this new interface. Could you please consider the most recent message on this topic:
https://lore.kernel.org/lkml/[email protected]/

You can find more context in thread starting at
https://lore.kernel.org/lkml/[email protected]/

Thank you very much.

Reinette

author maintainer
#39 lore raw

Hi Fenghua,

Quoted 8 lines · Reinette Chatre

Hi Fenghua,

Quoted 5 lines · Fenghua Yu

On 8/3/26 22:26, Reinette Chatre wrote:
With minor MPAM changes, I can do simple tests on MPAM:
-               INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by); +               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

Quoted 8 lines
Quoted 4 lines

-               INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by); +               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

There is a branch resctrl/controls_rfc_v2.1. Seems no diff from controls_rfc_v2. Is either branch OK for base code?

hmmm ... branch resctrl/controls_rfc_v2.1 should have the change you note above and would be the right branch for you to use.
That is the only difference with resctrl/controls_rfc_v2.

I did not apply the original fix correctly and then I misread your message about it. My apologies. This should be fixed on resctrl/controls_rfc_v2.3 now.

Reinette

maintainer
#40 lore raw
In reply to Reinette Chatre

Hi Reinette, Fenghua,

A couple more thoughts on emulation.

Quoted 38 lines · Reinette Chatre

Hi Fenghua,

Quoted 9 lines · Fenghua Yu

On 8/3/26 22:26, Reinette Chatre wrote:
With minor MPAM changes, I can do simple tests on MPAM:
-               INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by); +               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

-               INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by); +               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

There is a branch resctrl/controls_rfc_v2.1. Seems no diff from controls_rfc_v2. Is either branch OK for base code?

hmmm ... branch resctrl/controls_rfc_v2.1 should have the change you note above and would be the right branch for you to use.
That is the only difference with resctrl/controls_rfc_v2.

Quoted 14 lines

 * @emulated_by:List of controls that emulate this control. When set the containing *              struct resctrl_ctrl is likely a legacy control and @emulated_by *              are the finer grained hardware controls used to back the legacy *              control. This emulation is hidden from user in schemata file when *              rdt_resource::ctrl_mode is RESCTRL_CTRL_MODE_LEGACY and *              exposed when rdt_resource::ctrl_mode is
 *              RESCTRL_CTRL_MODE_NATIVE.
 */
struct resctrl_ctrl {
...
        struct list_head        emulated_by;
};

Quoted 6 lines

Does this mean a legacy resctrl control can be emulated by a few resctrl controls (which is stored in the list)?

e.g. legacy MB control can be emulated by a few controls? I thought "MB:" line is emulated by only one native control. e.g. "MB:" line is emulated by "MB_NODE:" line.

Quoted 7 lines

As Chenyu highlighted this is to support region-aware.

While I did originally suggest MB_NODE to emulate MB I learned from Ben just how troublesome this can be. I am still trying to untangle how MPAM MSC and AMD GLBE can be supported in this new interface. Could you please consider the most recent message on this topic:
https://lore.kernel.org/lkml/[email protected]/

For the emulation of MB. I think in the case where the MPAM driver currently uses the memory class to back it (single L3/single NUMA node) then it would be most correct for the MB control to become MB_NODE_MAX when switching from legacy to native. As previously discussed, in the other case when MB is backed by a cache class then I don't think it makes sense for MB_NODE to emulate MB.

I'm wondering if it would be best to make the legacy/native switch a mount option (--native). By not being resource specific it allows controls to move between resources where that is appropriate. A mount option would also allow multiple user programs to interact with the schemata and size files without worrying that the format would change under their feet. What do you think?

Thanks,

Ben

Quoted 7 lines

You can find more context in thread starting at
https://lore.kernel.org/lkml/[email protected]/

Thank you very much.

Reinette

author maintainer
#41 lore raw

Hi Ben,

Quoted 51 lines · Ben Horgan

Hi Reinette, Fenghua,

A couple more thoughts on emulation.

Quoted 38 lines · Reinette Chatre

Hi Fenghua,

Quoted 9 lines · Fenghua Yu

On 8/3/26 22:26, Reinette Chatre wrote:
With minor MPAM changes, I can do simple tests on MPAM:
-               INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by); +               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

-               INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by); +               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

There is a branch resctrl/controls_rfc_v2.1. Seems no diff from controls_rfc_v2. Is either branch OK for base code?

hmmm ... branch resctrl/controls_rfc_v2.1 should have the change you note above and would be the right branch for you to use.
That is the only difference with resctrl/controls_rfc_v2.

Quoted 14 lines

 * @emulated_by:List of controls that emulate this control. When set the containing *              struct resctrl_ctrl is likely a legacy control and @emulated_by *              are the finer grained hardware controls used to back the legacy *              control. This emulation is hidden from user in schemata file when *              rdt_resource::ctrl_mode is RESCTRL_CTRL_MODE_LEGACY and *              exposed when rdt_resource::ctrl_mode is
 *              RESCTRL_CTRL_MODE_NATIVE.
 */
struct resctrl_ctrl {
...
        struct list_head        emulated_by;
};

Quoted 6 lines

Does this mean a legacy resctrl control can be emulated by a few resctrl controls (which is stored in the list)?

e.g. legacy MB control can be emulated by a few controls? I thought "MB:" line is emulated by only one native control. e.g. "MB:" line is emulated by "MB_NODE:" line.

Quoted 7 lines

As Chenyu highlighted this is to support region-aware.

While I did originally suggest MB_NODE to emulate MB I learned from Ben just how troublesome this can be. I am still trying to untangle how MPAM MSC and AMD GLBE can be supported in this new interface. Could you please consider the most recent message on this topic:
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

For the emulation of MB. I think in the case where the MPAM driver currently uses the memory class to back it (single L3/single NUMA node) then it would be most correct for the MB control to become MB_NODE_MAX when switching from legacy to native. As previously discussed, in the other case when MB is backed by a cache class then I don't think it makes sense for MB_NODE to emulate MB.

I'm wondering if it would be best to make the legacy/native switch a mount option (--native). By not being resource specific it allows controls to move between resources where that is appropriate. A

In the current design switching between legacy and native only involves changing which controls belonging to a resource are exposed to user space. No matter if legacy or native is active the controls remain associated with the same resource without ever changing the relationship between control and resource, nor changing the relationship between controls. Practically speaking: the info file hierarchy does not change.

Moving controls between resources sounds like something entirely different and a significant new change.

So far the model has been for the architecture driver to own and "build" the resources, their associated controls, and their control and monitoring domains. After the architecture establishes these relationships the data is shared with resctrl fs but architecture driver always owns it. Letting resctrl fs make adjustments to any of these relationships is unexpected to me. More so when this can change from mount to mount.

Changing the "shape" of a system seems to be something that the architecture should own?

Are you instead saying that resctrl should expose a node scoped control as that of a L3 scope control?

I aimed to document how I understand the different scopes and how to communicate this to user space in:

	https://lore.kernel.org/lkml/[email protected]/

Are you instead saying that MPAM plans to create a control that pretends to be for a node scoped resource but placed under the L3 scoped resource like below?

info/

└── MB/
    └── schemata/
        └── MB/
            └── MB_NODE_MAX/

Something like above does not follow the relationships that the hierarchy aims to communicate, which is that the resource has L3 scope.

If you are already considering scenarios where user space would need new mount options, would you perhaps consider instead some new command line parameter, similar to the existing "rdt=" ones that adjust how resources are exposed? With something like this MPAM driver can control which "shape" the system should have in resctrl.

Quoted 2 lines

mount option would also allow multiple user programs to interact with the schemata and size files without worrying that the format would change under their feet. What do you think?

Reinette

maintainer
#42 lore raw

Hi Reinette,

Quoted 69 lines · Reinette Chatre

Hi Ben,

Quoted 51 lines · Ben Horgan

Hi Reinette, Fenghua,

A couple more thoughts on emulation.

Quoted 38 lines · Reinette Chatre

Hi Fenghua,

Quoted 9 lines · Fenghua Yu

On 8/3/26 22:26, Reinette Chatre wrote:
With minor MPAM changes, I can do simple tests on MPAM:
-               INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by); +               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

-               INIT_LIST_HEAD(&hw_ctrl->r_ctrl.emulated_by); +               INIT_LIST_HEAD(&mpam_ctrl->r_ctrl.emulated_by);

There is a branch resctrl/controls_rfc_v2.1. Seems no diff from controls_rfc_v2. Is either branch OK for base code?

hmmm ... branch resctrl/controls_rfc_v2.1 should have the change you note above and would be the right branch for you to use.
That is the only difference with resctrl/controls_rfc_v2.

Quoted 14 lines

 * @emulated_by:List of controls that emulate this control. When set the containing *              struct resctrl_ctrl is likely a legacy control and @emulated_by *              are the finer grained hardware controls used to back the legacy *              control. This emulation is hidden from user in schemata file when *              rdt_resource::ctrl_mode is RESCTRL_CTRL_MODE_LEGACY and *              exposed when rdt_resource::ctrl_mode is
 *              RESCTRL_CTRL_MODE_NATIVE.
 */
struct resctrl_ctrl {
...
        struct list_head        emulated_by;
};

Quoted 6 lines

Does this mean a legacy resctrl control can be emulated by a few resctrl controls (which is stored in the list)?

e.g. legacy MB control can be emulated by a few controls? I thought "MB:" line is emulated by only one native control. e.g. "MB:" line is emulated by "MB_NODE:" line.

Quoted 7 lines

As Chenyu highlighted this is to support region-aware.

While I did originally suggest MB_NODE to emulate MB I learned from Ben just how troublesome this can be. I am still trying to untangle how MPAM MSC and AMD GLBE can be supported in this new interface. Could you please consider the most recent message on this topic:
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

For the emulation of MB. I think in the case where the MPAM driver currently uses the memory class to back it (single L3/single NUMA node) then it would be most correct for the MB control to become MB_NODE_MAX when switching from legacy to native. As previously discussed, in the other case when MB is backed by a cache class then I don't think it makes sense for MB_NODE to emulate MB.

I'm wondering if it would be best to make the legacy/native switch a mount option (--native). By not being resource specific it allows controls to move between resources where that is appropriate. A

In the current design switching between legacy and native only involves changing which controls belonging to a resource are exposed to user space. No matter if legacy or native is active the controls remain associated with the same resource without ever changing the relationship between control and resource, nor changing the relationship between controls. Practically speaking: the info file hierarchy does not change.

Moving controls between resources sounds like something entirely different and a significant new change.

Quoted 8 lines

So far the model has been for the architecture driver to own and "build" the resources, their associated controls, and their control and monitoring domains. After the architecture establishes these relationships the data is shared with resctrl fs but architecture driver always owns it. Letting resctrl fs make adjustments to any of these relationships is unexpected to me. More so when this can change from mount to mount.

Changing the "shape" of a system seems to be something that the architecture should own?

Are you instead saying that resctrl should expose a node scoped control as that of a L3 scope control?

The problem is that this already happens, for MPAM, in the degenerate case. This is the consequence of allowing memory MSC to pretend to be L3 scoped MSC and so represented by the MB resource. This only happens when there is a single L3 and a single NUMA node with no caches in between so that the traffic at either end of the path is effectively equivalent and the scope for both is global as you can't turn off the last CPU or the only NUMA node. In want of a better term, let's call this "L3 is NUMA". These shenanigans are what lead to the complexity of having more that one MPAM class backing a resource which we discuss at [1]. The need for the association is that, where possible, the memory allocation and memory bandwidth counters are exposed to the user using the existing resctrl interface and, as such, existing software will continue to work.

What I was suggesting, is that in "native" mode we do away with any pretending. That is, memory MSC always back resources with NODE scope even in the degenerate "L3 is NUMA" case. One benefit of this is that the resctrl hierarchy can be more correct. I was about to write that a second benefit was that if there is a L3 cache MPAM class and a memory MPAM class which both provide memory allocation they could both be displayed in resctrl, MB and MB_NODE. The same consideration applies for memory bandwidth counters. However, as the MPAM driver in the "L3 is NUMA" case, always chooses the L3 MPAM class to back MB over other classes, the MPAM driver can just be extended to back MB_NODE with the memory class that was not chosen. In this way it will works the same way as in the non-degenerate cases and the same mechanism is in place for memory bandwidth counters.

Hence, the only benefit would be a slightly closer description of the hardware in resctrl in the "L3 is NUMA" case. In performing this exercise of laying out my reasons for allowing the native/legacy control to move things across resources I see it is unnecessary and so the native/legacy switch should, as per your proposal, *not* move controls between resources. Thank you for your patience.

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/

Quoted 7 lines

I aimed to document how I understand the different scopes and how to communicate this to user space in:

	https://lore.kernel.org/lkml/[email protected]/

Are you instead saying that MPAM plans to create a control that pretends to be for a node scoped resource but placed under the L3 scoped resource like below?

Quoted 8 lines

info/

└── MB/
    └── schemata/
        └── MB/
            └── MB_NODE_MAX/

Something like above does not follow the relationships that the hierarchy aims to communicate, which is that the resource has L3 scope.

No.. I wasn't thinking of that.

Quoted 5 lines

If you are already considering scenarios where user space would need new mount options, would you perhaps consider instead some new command line parameter, similar to the existing "rdt=" ones that adjust how resources are exposed? With something like this MPAM driver can control which "shape" the system should have in resctrl.

Luckily, we don't need these. Out of interest, why is that consider mount options the last resort?

Thanks,

Ben

Quoted 7 lines
Quoted 4 lines

mount option would also allow multiple user programs to interact with the schemata and size files without worrying that the format would change under their feet. What do you think?

Reinette

author maintainer
#43 lore raw

Hi Ben,

Quoted 13 lines · Ben Horgan

Hi Reinette,

Quoted 10 lines · Reinette Chatre

Hi Ben,

Quoted 7 lines · Ben Horgan

Hi Reinette, Fenghua,

A couple more thoughts on emulation.

Quoted 2 lines · Reinette Chatre
Quoted 1 line · Fenghua Yu

On 8/3/26 22:26, Reinette Chatre wrote:

...>>>>>  * @emulated_by:List of controls that emulate this control. When set the containing

Quoted 71 lines
Quoted 42 lines
Quoted 27 lines
Quoted 19 lines
Quoted 12 lines

 *              struct resctrl_ctrl is likely a legacy control and @emulated_by *              are the finer grained hardware controls used to back the legacy *              control. This emulation is hidden from user in schemata file when *              rdt_resource::ctrl_mode is RESCTRL_CTRL_MODE_LEGACY and *              exposed when rdt_resource::ctrl_mode is
 *              RESCTRL_CTRL_MODE_NATIVE.
 */
struct resctrl_ctrl {
...
        struct list_head        emulated_by;
};

Quoted 6 lines

Does this mean a legacy resctrl control can be emulated by a few resctrl controls (which is stored in the list)?

e.g. legacy MB control can be emulated by a few controls? I thought "MB:" line is emulated by only one native control. e.g. "MB:" line is emulated by "MB_NODE:" line.

Quoted 7 lines

As Chenyu highlighted this is to support region-aware.

While I did originally suggest MB_NODE to emulate MB I learned from Ben just how troublesome this can be. I am still trying to untangle how MPAM MSC and AMD GLBE can be supported in this new interface. Could you please consider the most recent message on this topic:
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

For the emulation of MB. I think in the case where the MPAM driver currently uses the memory class to back it (single L3/single NUMA node) then it would be most correct for the MB control to become MB_NODE_MAX when switching from legacy to native. As previously discussed, in the other case when MB is backed by a cache class then I don't think it makes sense for MB_NODE to emulate MB.

I'm wondering if it would be best to make the legacy/native switch a mount option (--native). By not being resource specific it allows controls to move between resources where that is appropriate. A

In the current design switching between legacy and native only involves changing which controls belonging to a resource are exposed to user space. No matter if legacy or native is active the controls remain associated with the same resource without ever changing the relationship between control and resource, nor changing the relationship between controls. Practically speaking: the info file hierarchy does not change.

Moving controls between resources sounds like something entirely different and a significant new change.

Quoted 8 lines

So far the model has been for the architecture driver to own and "build" the resources, their associated controls, and their control and monitoring domains. After the architecture establishes these relationships the data is shared with resctrl fs but architecture driver always owns it. Letting resctrl fs make adjustments to any of these relationships is unexpected to me. More so when this can change from mount to mount.

Changing the "shape" of a system seems to be something that the architecture should own?

Are you instead saying that resctrl should expose a node scoped control as that of a L3 scope control?

The problem is that this already happens, for MPAM, in the degenerate case. This is the consequence of allowing memory MSC to pretend to be L3 scoped MSC and so represented by the MB resource. This only happens when there is a single L3 and a single NUMA node with no caches in between so that the traffic at either end of the path is effectively equivalent and the scope for both is global as you can't turn off the last CPU or the only NUMA node. In want of a better term, let's call this "L3 is NUMA". These shenanigans are what lead to the complexity of having more that one MPAM class backing a resource which we discuss at [1]. The need for the association is that, where possible, the memory allocation and memory bandwidth counters are exposed to the user using the existing resctrl interface and, as such, existing software will continue to work.

What I was suggesting, is that in "native" mode we do away with any pretending. That is, memory MSC always back resources with NODE scope even in the degenerate "L3 is NUMA" case. One benefit of this is that the resctrl hierarchy can be more correct. I was about to write that a second benefit was that if there is a L3 cache MPAM class and a memory MPAM class which both provide memory allocation they could both be displayed in resctrl, MB and MB_NODE. The same consideration applies for memory bandwidth counters. However, as the MPAM driver in the "L3 is NUMA" case, always chooses the L3 MPAM class to back MB over other classes, the MPAM driver can just be extended to back MB_NODE with the memory class that was not chosen. In this way it will works the same way as in the non-degenerate cases and the same mechanism is in place for memory bandwidth counters.

Quoted 6 lines

Hence, the only benefit would be a slightly closer description of the hardware in resctrl in the "L3 is NUMA" case. In performing this exercise of laying out my reasons for allowing the native/legacy control to move things across resources I see it is unnecessary and so the native/legacy switch should, as per your proposal, *not* move controls between resources. Thank you for your patience.

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/

If I understand correctly an "L3 is NUMA" would be presented to user space as:

info/

├── MB/
│   └── schemata/
│       ├── MB/
│       │   └── MB_L3_MAX/
│       └── MB_L3_MIN/
└── MB_NODE/
    └── schemata/
        ├── MB_NODE_MAX/
        └── MB_NODE_MIN/

with the "MB" resource backed by the "L3 cache MPAM class" and the "MB_NODE" resource backed by the "memory MPAM class". Is this getting close?

It sounds to me as though both resources would be able to concurrently support monitoring so resctrl can be expected to expose NODE scoped memory bandwidth monitoring events retrieved from the "memory MPAM class" and L3 scoped memory bandwidth monitoring events retrieved from the "L3 cache MPAM class"?

So far I've viewed support for monitoring events at different scope as "after multiple controls" work that the "CPU-less NUMA nodes" depends on but looks like it is needed sooner.

Quoted 18 lines
Quoted 6 lines

I aimed to document how I understand the different scopes and how to communicate this to user space in:

	https://lore.kernel.org/lkml/[email protected]/

Are you instead saying that MPAM plans to create a control that pretends to be for a node scoped resource but placed under the L3 scoped resource like below?

Quoted 8 lines

info/

└── MB/
    └── schemata/
        └── MB/
            └── MB_NODE_MAX/

Something like above does not follow the relationships that the hierarchy aims to communicate, which is that the resource has L3 scope.

No.. I wasn't thinking of that.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

If you are already considering scenarios where user space would need new mount options, would you perhaps consider instead some new command line parameter, similar to the existing "rdt=" ones that adjust how resources are exposed? With something like this MPAM driver can control which "shape" the system should have in resctrl.

Luckily, we don't need these. Out of interest, why is that consider mount options the last resort?

In this case I asked about a command line parameter because I viewed the solution as needing MPAM driver to change how it describes the "shape" of the system to resctrl. Since this is something that needs to happen before resctrl fs is mounted a mount option did not seem practical to me.

Speaking just in general about mount options I do think we need to take care how user space is expected to interact with the filesystem. Previously user space could query /proc/cpuinfo to determine which features are supported by the system and then mount resctrl fs based on that information. For example, the user queries /proc/cpuinfo whether CDP is supported and then knows which CDP related mount options can be used. New features no longer by default add flags to /proc/cpuinfo. The expectation is that users can mount resctrl fs, discover which features are supported, and directly interact with those features. Without knowing which features a system supports we should thus be careful that a new mount option does not mean that the user needs to mount resctrl fs, query what is supported, and then remount resctrl fs with mount options that enable the use of the new features. Please note that a mount fails when there is an unrecognized mount option.

Reinette

maintainer
#44 lore raw

Hi Reinette,

Quoted 109 lines · Reinette Chatre

Hi Ben,

Quoted 13 lines · Ben Horgan

Hi Reinette,

Quoted 10 lines · Reinette Chatre

Hi Ben,

Quoted 7 lines · Ben Horgan

Hi Reinette, Fenghua,

A couple more thoughts on emulation.

Quoted 2 lines · Reinette Chatre
Quoted 1 line · Fenghua Yu

On 8/3/26 22:26, Reinette Chatre wrote:

...>>>>>  * @emulated_by:List of controls that emulate this control. When set the containing

Quoted 71 lines
Quoted 42 lines
Quoted 27 lines
Quoted 19 lines
Quoted 12 lines

 *              struct resctrl_ctrl is likely a legacy control and @emulated_by *              are the finer grained hardware controls used to back the legacy *              control. This emulation is hidden from user in schemata file when *              rdt_resource::ctrl_mode is RESCTRL_CTRL_MODE_LEGACY and *              exposed when rdt_resource::ctrl_mode is
 *              RESCTRL_CTRL_MODE_NATIVE.
 */
struct resctrl_ctrl {
...
        struct list_head        emulated_by;
};

Quoted 6 lines

Does this mean a legacy resctrl control can be emulated by a few resctrl controls (which is stored in the list)?

e.g. legacy MB control can be emulated by a few controls? I thought "MB:" line is emulated by only one native control. e.g. "MB:" line is emulated by "MB_NODE:" line.

Quoted 7 lines

As Chenyu highlighted this is to support region-aware.

While I did originally suggest MB_NODE to emulate MB I learned from Ben just how troublesome this can be. I am still trying to untangle how MPAM MSC and AMD GLBE can be supported in this new interface. Could you please consider the most recent message on this topic:
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

For the emulation of MB. I think in the case where the MPAM driver currently uses the memory class to back it (single L3/single NUMA node) then it would be most correct for the MB control to become MB_NODE_MAX when switching from legacy to native. As previously discussed, in the other case when MB is backed by a cache class then I don't think it makes sense for MB_NODE to emulate MB.

I'm wondering if it would be best to make the legacy/native switch a mount option (--native). By not being resource specific it allows controls to move between resources where that is appropriate. A

In the current design switching between legacy and native only involves changing which controls belonging to a resource are exposed to user space. No matter if legacy or native is active the controls remain associated with the same resource without ever changing the relationship between control and resource, nor changing the relationship between controls. Practically speaking: the info file hierarchy does not change.

Moving controls between resources sounds like something entirely different and a significant new change.

Quoted 8 lines

So far the model has been for the architecture driver to own and "build" the resources, their associated controls, and their control and monitoring domains. After the architecture establishes these relationships the data is shared with resctrl fs but architecture driver always owns it. Letting resctrl fs make adjustments to any of these relationships is unexpected to me. More so when this can change from mount to mount.

Changing the "shape" of a system seems to be something that the architecture should own?

Are you instead saying that resctrl should expose a node scoped control as that of a L3 scope control?

The problem is that this already happens, for MPAM, in the degenerate case. This is the consequence of allowing memory MSC to pretend to be L3 scoped MSC and so represented by the MB resource. This only happens when there is a single L3 and a single NUMA node with no caches in between so that the traffic at either end of the path is effectively equivalent and the scope for both is global as you can't turn off the last CPU or the only NUMA node. In want of a better term, let's call this "L3 is NUMA". These shenanigans are what lead to the complexity of having more that one MPAM class backing a resource which we discuss at [1]. The need for the association is that, where possible, the memory allocation and memory bandwidth counters are exposed to the user using the existing resctrl interface and, as such, existing software will continue to work.

What I was suggesting, is that in "native" mode we do away with any pretending. That is, memory MSC always back resources with NODE scope even in the degenerate "L3 is NUMA" case. One benefit of this is that the resctrl hierarchy can be more correct. I was about to write that a second benefit was that if there is a L3 cache MPAM class and a memory MPAM class which both provide memory allocation they could both be displayed in resctrl, MB and MB_NODE. The same consideration applies for memory bandwidth counters. However, as the MPAM driver in the "L3 is NUMA" case, always chooses the L3 MPAM class to back MB over other classes, the MPAM driver can just be extended to back MB_NODE with the memory class that was not chosen. In this way it will works the same way as in the non-degenerate cases and the same mechanism is in place for memory bandwidth counters.

Quoted 6 lines

Hence, the only benefit would be a slightly closer description of the hardware in resctrl in the "L3 is NUMA" case. In performing this exercise of laying out my reasons for allowing the native/legacy control to move things across resources I see it is unnecessary and so the native/legacy switch should, as per your proposal, *not* move controls between resources. Thank you for your patience.

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/

If I understand correctly an "L3 is NUMA" would be presented to user space as:

info/

├── MB/
│   └── schemata/
│       ├── MB/
│       │   └── MB_L3_MAX/
│       └── MB_L3_MIN/
└── MB_NODE/
    └── schemata/
        ├── MB_NODE_MAX/
        └── MB_NODE_MIN/
Quoted 2 lines

with the "MB" resource backed by the "L3 cache MPAM class" and the "MB_NODE" resource backed by the "memory MPAM class". Is this getting close?

In the case when there is an L3 cache MPAM class and a memory MPAM class both support memory bandwidth allocation then yes. However, I don't know of systems like this today and this isn't dependent on the "L3 is NUMA". If there are multiple L3 and multiple NUMA nodes you would still get this structure. It just relies on both the L3 cache MPAM class and the memory MPAM class supporting bandwidth allocation (mbw_max/mbw_min). The "L3 is NUMA" is all about pretending a memory MPAM class is a L3 cache MPAM class so that it fits into the existing expectations of the resctrl interface.

Quoted 5 lines

It sounds to me as though both resources would be able to concurrently support monitoring so resctrl can be expected to expose NODE scoped memory bandwidth monitoring events retrieved from the "memory MPAM class" and L3 scoped memory bandwidth monitoring events retrieved from the "L3 cache MPAM class"?

Yes. Unless we are in a "L3 is NUMA" setup to expose memory bandwidth counters from a memory MPAM class they would need to have node scope and they could co-exist with other memory bandwidth counters at L3 scope.

Quoted 3 lines

So far I've viewed support for monitoring events at different scope as "after multiple controls" work that the "CPU-less NUMA nodes" depends on but looks like it is needed sooner.

Why do you think it needs to be sooner rather than just a next step? Is there some contradiction or incompatibility I'm missing. I thought that the monitors would just remain unexposed to resctrl until there is an interface.

Quoted 30 lines
Quoted 19 lines
Quoted 7 lines

I aimed to document how I understand the different scopes and how to communicate this to user space in:

	https://lore.kernel.org/lkml/[email protected]/

Are you instead saying that MPAM plans to create a control that pretends to be for a node scoped resource but placed under the L3 scoped resource like below?

Quoted 8 lines

info/

└── MB/
    └── schemata/
        └── MB/
            └── MB_NODE_MAX/

Something like above does not follow the relationships that the hierarchy aims to communicate, which is that the resource has L3 scope.

No.. I wasn't thinking of that.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

If you are already considering scenarios where user space would need new mount options, would you perhaps consider instead some new command line parameter, similar to the existing "rdt=" ones that adjust how resources are exposed? With something like this MPAM driver can control which "shape" the system should have in resctrl.

Luckily, we don't need these. Out of interest, why is that consider mount options the last resort?

In this case I asked about a command line parameter because I viewed the solution as needing MPAM driver to change how it describes the "shape" of the system to resctrl. Since this is something that needs to happen before resctrl fs is mounted a mount option did not seem practical to me.

Quoted 10 lines

Speaking just in general about mount options I do think we need to take care how user space is expected to interact with the filesystem. Previously user space could query /proc/cpuinfo to determine which features are supported by the system and then mount resctrl fs based on that information. For example, the user queries /proc/cpuinfo whether CDP is supported and then knows which CDP related mount options can be used. New features no longer by default add flags to /proc/cpuinfo. The expectation is that users can mount resctrl fs, discover which features are supported, and directly interact with those features. Without knowing which features a system supports we should thus be careful that a new mount option does not mean that the user needs to mount resctrl fs, query what is supported, and then remount resctrl fs with mount options that enable the use of the new features. Please note that a mount fails when there is an unrecognized mount option.

Ok, thanks for the explanation.

Ben

Quoted 3 lines

Reinette

author maintainer
#45 lore raw

Hi Ben,

Quoted 3 lines · Ben Horgan
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Ben Horgan

On 18/09/2026 23:47, Reinette Chatre wrote:

...>>>>

Quoted 45 lines
Quoted 42 lines
Quoted 22 lines
Quoted 1 line

Are you instead saying that resctrl should expose a node scoped control as that of a L3 scope control?

The problem is that this already happens, for MPAM, in the degenerate case. This is the consequence of allowing memory MSC to pretend to be L3 scoped MSC and so represented by the MB resource. This only happens when there is a single L3 and a single NUMA node with no caches in between so that the traffic at either end of the path is effectively equivalent and the scope for both is global as you can't turn off the last CPU or the only NUMA node. In want of a better term, let's call this "L3 is NUMA". These shenanigans are what lead to the complexity of having more that one MPAM class backing a resource which we discuss at [1]. The need for the association is that, where possible, the memory allocation and memory bandwidth counters are exposed to the user using the existing resctrl interface and, as such, existing software will continue to work.

What I was suggesting, is that in "native" mode we do away with any pretending. That is, memory MSC always back resources with NODE scope even in the degenerate "L3 is NUMA" case. One benefit of this is that the resctrl hierarchy can be more correct. I was about to write that a second benefit was that if there is a L3 cache MPAM class and a memory MPAM class which both provide memory allocation they could both be displayed in resctrl, MB and MB_NODE. The same consideration applies for memory bandwidth counters. However, as the MPAM driver in the "L3 is NUMA" case, always chooses the L3 MPAM class to back MB over other classes, the MPAM driver can just be extended to back MB_NODE with the memory class that was not chosen. In this way it will works the same way as in the non-degenerate cases and the same mechanism is in place for memory bandwidth counters.

Quoted 6 lines

Hence, the only benefit would be a slightly closer description of the hardware in resctrl in the "L3 is NUMA" case. In performing this exercise of laying out my reasons for allowing the native/legacy control to move things across resources I see it is unnecessary and so the native/legacy switch should, as per your proposal, *not* move controls between resources. Thank you for your patience.

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/

If I understand correctly an "L3 is NUMA" would be presented to user space as:

info/

├── MB/
│   └── schemata/
│       ├── MB/
│       │   └── MB_L3_MAX/
│       └── MB_L3_MIN/
└── MB_NODE/
    └── schemata/
        ├── MB_NODE_MAX/
        └── MB_NODE_MIN/
Quoted 2 lines

with the "MB" resource backed by the "L3 cache MPAM class" and the "MB_NODE" resource backed by the "memory MPAM class". Is this getting close?

Quoted 6 lines

In the case when there is an L3 cache MPAM class and a memory MPAM class both support memory bandwidth allocation then yes. However, I don't know of systems like this today and this isn't dependent on the "L3 is NUMA". If there are multiple L3 and multiple NUMA nodes you would still get this structure. It just relies on both the L3 cache MPAM class and the memory MPAM class supporting bandwidth allocation (mbw_max/mbw_min). The "L3 is NUMA" is all about pretending a memory MPAM class is a L3 cache MPAM class so that it fits into the existing expectations of the resctrl interface.

I am missing something

From earlier description ("... the complexity of having more that one MPAM class backing a resource which we discuss at [1]... ") I understood that "L3 is NUMA" scenario has two classes available and currently just uses one to back the MB resource. Further, that the new interface makes it possible for "the MPAM driver can just be extended to back MB_NODE with the memory class that was not chosen".

Above seems to state that such systems that have two classes do not exist?

My concern is the impact on the user interface. When MPAM "stops pretending", could a system that exposes an MB resource before the new interface boot into new kernel with the new interface and no longer have an MB resource but instead just have an MB_NODE resource?

Quoted 8 lines
Quoted 4 lines

It sounds to me as though both resources would be able to concurrently support monitoring so resctrl can be expected to expose NODE scoped memory bandwidth monitoring events retrieved from the "memory MPAM class" and L3 scoped memory bandwidth monitoring events retrieved from the "L3 cache MPAM class"?

Yes. Unless we are in a "L3 is NUMA" setup to expose memory bandwidth counters from a memory MPAM class they would need to have node scope and they could co-exist with other memory bandwidth counters at L3 scope.

It is starting to sound more and more that the new interfaces may result in user interface changes on MPAM systems?

Apologies but I do not think the MPAM plan is clear to me.

Quoted 6 lines
Quoted 2 lines

So far I've viewed support for monitoring events at different scope as "after multiple controls" work that the "CPU-less NUMA nodes" depends on but looks like it is needed sooner.

Why do you think it needs to be sooner rather than just a next step? Is there some contradiction or incompatibility I'm missing. I thought that the monitors would just remain unexposed to resctrl until there is an interface.

No, you are not missing anything. My comment was based on my realization that the monitoring scope changes are needed by more systems than I originally thought.

Reinette

maintainer
#46 lore raw

Hi Reinette,

Quoted 60 lines · Reinette Chatre

Hi Ben,

Quoted 3 lines · Ben Horgan
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Ben Horgan

On 18/09/2026 23:47, Reinette Chatre wrote:

...>>>>

Quoted 45 lines
Quoted 42 lines
Quoted 22 lines
Quoted 1 line

Are you instead saying that resctrl should expose a node scoped control as that of a L3 scope control?

The problem is that this already happens, for MPAM, in the degenerate case. This is the consequence of allowing memory MSC to pretend to be L3 scoped MSC and so represented by the MB resource. This only happens when there is a single L3 and a single NUMA node with no caches in between so that the traffic at either end of the path is effectively equivalent and the scope for both is global as you can't turn off the last CPU or the only NUMA node. In want of a better term, let's call this "L3 is NUMA". These shenanigans are what lead to the complexity of having more that one MPAM class backing a resource which we discuss at [1]. The need for the association is that, where possible, the memory allocation and memory bandwidth counters are exposed to the user using the existing resctrl interface and, as such, existing software will continue to work.

What I was suggesting, is that in "native" mode we do away with any pretending. That is, memory MSC always back resources with NODE scope even in the degenerate "L3 is NUMA" case. One benefit of this is that the resctrl hierarchy can be more correct. I was about to write that a second benefit was that if there is a L3 cache MPAM class and a memory MPAM class which both provide memory allocation they could both be displayed in resctrl, MB and MB_NODE. The same consideration applies for memory bandwidth counters. However, as the MPAM driver in the "L3 is NUMA" case, always chooses the L3 MPAM class to back MB over other classes, the MPAM driver can just be extended to back MB_NODE with the memory class that was not chosen. In this way it will works the same way as in the non-degenerate cases and the same mechanism is in place for memory bandwidth counters.

Quoted 6 lines

Hence, the only benefit would be a slightly closer description of the hardware in resctrl in the "L3 is NUMA" case. In performing this exercise of laying out my reasons for allowing the native/legacy control to move things across resources I see it is unnecessary and so the native/legacy switch should, as per your proposal, *not* move controls between resources. Thank you for your patience.

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/

If I understand correctly an "L3 is NUMA" would be presented to user space as:

info/

├── MB/
│   └── schemata/
│       ├── MB/
│       │   └── MB_L3_MAX/
│       └── MB_L3_MIN/
└── MB_NODE/
    └── schemata/
        ├── MB_NODE_MAX/
        └── MB_NODE_MIN/
Quoted 2 lines

with the "MB" resource backed by the "L3 cache MPAM class" and the "MB_NODE" resource backed by the "memory MPAM class". Is this getting close?

Quoted 6 lines

In the case when there is an L3 cache MPAM class and a memory MPAM class both support memory bandwidth allocation then yes. However, I don't know of systems like this today and this isn't dependent on the "L3 is NUMA". If there are multiple L3 and multiple NUMA nodes you would still get this structure. It just relies on both the L3 cache MPAM class and the memory MPAM class supporting bandwidth allocation (mbw_max/mbw_min). The "L3 is NUMA" is all about pretending a memory MPAM class is a L3 cache MPAM class so that it fits into the existing expectations of the resctrl interface.

Quoted 8 lines

I am missing something

From earlier description ("... the complexity of having more that one MPAM class backing a resource which we discuss at [1]... ") I understood that "L3 is NUMA" scenario has two classes available and currently just uses one to back the MB resource. Further, that the new interface makes it possible for "the MPAM driver can just be extended to back MB_NODE with the memory class that was not chosen".

Above seems to state that such systems that have two classes do not exist?

Hmmm, there is a distinction but I obviously haven't made clear. Let me expand on that here. You can certainly have more than one MPAM class backing the monitors in a resource but each class backs different monitors (mbm_total/llc_occupancy). As currently resctrl expects all monitors to be at the L3 when the system allows it we "pretend" (this the "L3 is NUMA") and so the llc_occupancy counts would be taken from the MPAM L3 class and mbm_total from the MPAM memory class. What doesn't currently exist, but could, is a system where the MPAM L3 class and the MPAM memory class both support memory bandwidth monitoring. Currently, in such a system the MB mbm_total will always be backed by the MPAM L3 class and the memory bandwidth monitoring in the MPAM memory class would be left unused. Once the MB_NODE support is introduced the unused bandwidth monitoring at the MPAM memory class the mbm_total can be exposed there. Even once MB_NODE support is added we can continue exposing mbm_total counters form the memory class as MB in the same case as before, they aren't support in the L3 MPAM class and it's "L3 is NUMA" (single L3 and single NUMA with nothing inbetween).

It's similar for controls although the only control that we have currently that is effected is maximum bandwidth, MB (MB_L3_MAX). If it's implemented if mbw_max is just at the L3 we expose it as MB as would be expected and if mbw_max is just at the memory class, then if it's "L3 is NUMA" then we can expose it. When MB_NODE is added this doesn't change but for a system with mbw_max at the L3 class and at the memory class the L3 version will be exposed at the MB resource and the memory version at the MB_NODE. Each resource is only back by a single MPAM class and so we wouldn't have e.g. MB_MAX provided by L3 class and MB_MIN provided by the memory class (These two controls also have an interdependence in h/w so the behaviour may be confusing if they are split). In a system with mbw_max at the L3 and cache occupancy at the L3 then the L3 class will back both the L3 resource and the MB resource.

Quoted 4 lines

My concern is the impact on the user interface. When MPAM "stops pretending", could a system that exposes an MB resource before the new interface boot into new kernel with the new interface and no longer have an MB resource but instead just have an MB_NODE resource?

No, I did briefly entertain the idea of stopping pretending based on legacy/native view (which is surely the source of some of the confusion) but anything that is currently exposed as a control or monitor at the MB resource will stay for perpetuity at the MB resource. MPAM has no need to "stop pretending". The only systems where the mbw_max control in the MPAM memory class is exposed as MB is when there is no mbw_max control on the MPAM L3 class and its a "L3 is NUMA" system. If the MPAM L3 class can back "MB_L3_MAX" then it will. We should keep it this way.

When new controls are exposed to resctrl the MPAM driver will have to be careful to not break the existing interface in the "L3 is NUMA" case.

On adding a new control e.g. mbw_min it will have to still be mbw_max that determines whether the pretending occurs so the rules remain the same. If the L3 class supports mbw_max then it will always back the MB resource and if the L3 class doesn't support mbw_max and it's a "L3 is NUMA" then if the memory class supports mbw_max then the memory class backs MB. For the other cases MB can always be backed by the L3 class and MB_NODE by the memory class. This for instance means that in, the unlikely case of, an "L3 is NUMA" system which doesn't support mbw_max but supports mbw_min at the memory class, then it will only every expose MIN at the MB_NODE resource, MB_MIN_NODE. I need to revisit my patches exposing mbw_min to resctrl to make sure it never changes which class backs the MB resource.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

It sounds to me as though both resources would be able to concurrently support monitoring so resctrl can be expected to expose NODE scoped memory bandwidth monitoring events retrieved from the "memory MPAM class" and L3 scoped memory bandwidth monitoring events retrieved from the "L3 cache MPAM class"?

Quoted 6 lines
Quoted 3 lines

Yes. Unless we are in a "L3 is NUMA" setup to expose memory bandwidth counters from a memory MPAM class they would need to have node scope and they could co-exist with other memory bandwidth counters at L3 scope.

It is starting to sound more and more that the new interfaces may result in user interface changes on MPAM systems?

No, we should definitely avoid the interface changing for the user (other than adding new things) but please do call out if there is anything else that may cause that.

Quoted 2 lines

Apologies but I do not think the MPAM plan is clear to me.

No worries, I hope I've made things at a bit clearer but please carry on asking where things are still murky.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

So far I've viewed support for monitoring events at different scope as "after multiple controls" work that the "CPU-less NUMA nodes" depends on but looks like it is needed sooner.

Why do you think it needs to be sooner rather than just a next step? Is there some contradiction or incompatibility I'm missing. I thought that the monitors would just remain unexposed to resctrl until there is an interface.

No, you are not missing anything. My comment was based on my realization that the monitoring scope changes are needed by more systems than I originally thought.

Ok, yeah, all the MPAM MSC can have monitors and the ones at the memory bandwidth counters at the memory are likely to be of particular interest.

Thanks,

Ben

Quoted 2 lines

Reinette

maintainer
#47 lore raw

cover Suggestions for cache scalar controls

In reply to Reinette Chatre

Hi Reinette,

I'm posting as a reply to your series to try and keep things together. These patches should just be taken as suggestions. The first two patches make the printing of the schema name simpler while keeping it out of the arch code. The last add support for scalar cache controls in the size file. I found these sufficient to add support for CMIN/CMAX on top of MPAM. I'll post these separately but if makes sense to you feel free to incorporate them in your PoC.

Thanks,

Ben

Ben Horgan (3):
fs/resctrl: Add schema_name to struct resctrl_ctrl fs/resctrl: Use correct schema name in bw_validate() last_cmd_status
messages
fs/resctrl: display size for scalar cache controls

 fs/resctrl/ctrlmondata.c |  59 ++++++---------------
 fs/resctrl/internal.h    |   4 +-
 fs/resctrl/pseudo_lock.c |   2 +-
 fs/resctrl/rdtgroup.c    | 110 +++++++++++++++++++++++++--------------
 include/linux/resctrl.h  |   1 +
 5 files changed, 91 insertions(+), 85 deletions(-)
Signature · 1 line
2.43.0
maintainer
#48 lore raw

RFC PATCH 1/3 fs/resctrl: Add schema_name to struct resctrl_ctrl

In order to properly align the schema in the schemata and size file the maximum of length of all the schema names needs to be
known. resctrl_resource_ctrl_max_len() makes this calculation but stops short of actually constructing and storing the schema names. As the schema name is based on the resource name and the schema name with some special cases for legacy controls this leads to a lot of conditional formatting when displaying the schema name.

Construct the schema name and save it to struct resctrl when mounting resctrl. This makes displaying the schema name easy whilst control of the naming stays within resctrl.

---
 fs/resctrl/ctrlmondata.c | 51 ++++++-----------------------
 fs/resctrl/rdtgroup.c    | 69 +++++++++++++++++++++++++---------------
 include/linux/resctrl.h  |  1 +
 3 files changed, 55 insertions(+), 66 deletions(-)
fs/resctrl/ctrlmondata.c +10 -41
index 675531009136..efeb36e0db25 100644
@@ -379,6 +379,9 @@ int resctrl_prefix_width_adjust(struct resctrl_ctrl *ctrl)
 {
 	int len;
 
+	if (resctrl_ctrl_is_default(ctrl))
+		return max_name_width;
+
 	len = max_name_width - 1 - strlen(resctrl_ctrl_name_str(ctrl->name));
 	if (len < 0)
 		return 0;
@@ -456,33 +459,6 @@ static struct resctrl_ctrl *resctrl_resource_ctrl_get(struct rdt_resource *r,
 	return NULL;
 }
 
-/*
- * Return length needed to display longest control suffix.
- * Add 1 for the "_" character when control name exists.
- */
-size_t resctrl_resource_ctrl_max_len(struct rdt_resource *r)
-{
-	struct resctrl_ctrl *ctrl, *em_ctrl;
-	size_t total = 0;
-	size_t len;
-
-	for_each_resource_ctrl(ctrl,r) {
-		/* Remove duplicate code. */
-		len = strlen(resctrl_ctrl_name_str(ctrl->name));
-		if (len)
-			total = max(total, 1 + len);
-		if (list_empty(&ctrl->emulated_by))
-			continue;
-		list_for_each_entry(em_ctrl, &ctrl->emulated_by, entry) {
-			len = strlen(resctrl_ctrl_name_str(em_ctrl->name));
-			if (len)
-				total = max(total, 1 + len);
-		}
-	}
-
-	return total;
-}
-
 static int rdtgroup_parse_ctrl(char *ctrlname, char *tok,
 			       struct rdtgroup *rdtgrp)
 {
@@ -595,14 +571,8 @@ static void show_doms(struct seq_file *s, struct rdt_resource_final *f,
 	/* Walking ctrl->domains, ensure it can't race with cpuhp */
 	lockdep_assert_cpus_held();
 
-	if (print_ctrl) {
-		if (resctrl_ctrl_is_default(ctrl)) {
-			seq_printf(s, "%*s:", max_name_width, f->name);
-		} else {
-			seq_printf(s, "%*s_%s:", resctrl_prefix_width_adjust(ctrl),
-				   f->name, resctrl_ctrl_name_str(ctrl->name));
-		}
-	}
+	if (print_ctrl)
+		seq_printf(s, "%*s:", max_name_width, ctrl->schema_name);
 	list_for_each_entry_rcu(dom, &ctrl->domains, hdr.list, lockdep_is_cpus_held()) {
 		if (sep)
 			seq_puts(s, ";");
@@ -638,18 +608,17 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of,
 	if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
 		list_for_each_entry(f, &rdt_resource_final_all, list) {
 			for_each_enabled_ctrl(ctrl, f->res)
-				seq_printf(s, "%s%s%s:uninitialized\n", f->name,
-					   resctrl_ctrl_is_default(ctrl) ? "" : "_",
-					   resctrl_ctrl_is_default(ctrl) ?
-					    "" : resctrl_ctrl_name_str(ctrl->name));
+				seq_printf(s, "%*s:uninitialized\n",
+					   max_name_width, ctrl->schema_name);
 		}
 	} else if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) {
 		if (!rdtgrp->plr->d) {
 			rdt_last_cmd_puts("Cache domain offline\n");
 			ret = -ENODEV;
 		} else {
-			seq_printf(s, "%s:%d=%x\n",
-				   rdtgrp->plr->f->res->name,
+			ctrl = resctrl_resource_ctrl_get_default(f->res);
+			seq_printf(s, "%*s:%d=%x\n",
+				   max_name_width, ctrl->schema_name,
 				   rdtgrp->plr->d->hdr.id,
 				   rdtgrp->plr->cbm);
 		}
fs/resctrl/rdtgroup.c +44 -25

92 lines not on this page · raw message

include/linux/resctrl.h +1 -0
index 54fec07bd173..5be8991d45eb 100644
@@ -437,6 +437,7 @@ struct resctrl_ctrl {
 	struct list_head	domains;
 	enum resctrl_ctrl_type	type;
 	enum resctrl_ctrl_name	name;
+	char			schema_name[32];
 	union {
 		struct resctrl_ctrl_bitmap	bitmap;
 		struct resctrl_ctrl_scalar	scalar;
Signature · 1 line
2.43.0
#49 lore raw

Re: [RFC PATCH 1/3] fs/resctrl: Add schema_name to struct resctrl_ctrl

Quoted 20 lines · Ben Horgan

In order to properly align the schema in the schemata and size file the maximum of length of all the schema names needs to be
known. resctrl_resource_ctrl_max_len() makes this calculation but stops short of actually constructing and storing the schema names. As the schema name is based on the resource name and the schema name with some special cases for legacy controls this leads to a lot of conditional formatting when displaying the schema name.

Construct the schema name and save it to struct resctrl when mounting resctrl. This makes displaying the schema name easy whilst control of the naming stays within resctrl.

---
 fs/resctrl/ctrlmondata.c | 51 ++++++-----------------------
 fs/resctrl/rdtgroup.c    | 69 +++++++++++++++++++++++++---------------
 include/linux/resctrl.h  |  1 +
 3 files changed, 55 insertions(+), 66 deletions(-)
fs/resctrl/ctrlmondata.c +0 -0

[..]

Quoted 9 lines
fs/resctrl/ctrlmondata.c +1 -4
@@ -638,18 +608,17 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of,
 	if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
 		list_for_each_entry(f, &rdt_resource_final_all, list) {
 			for_each_enabled_ctrl(ctrl, f->res)
-				seq_printf(s, "%s%s%s:uninitialized\n", f->name,
-					   resctrl_ctrl_is_default(ctrl) ? "" : "_",
-					   resctrl_ctrl_is_default(ctrl) ?
-					    "" : resctrl_ctrl_name_str(ctrl->name));
+				seq_printf(s, "%*s:uninitialized\n",

fs/resctrl/ctrlmondata.c int rdtgroup_schemata_show(struct kernfs_open_file *of, · line 619

Quoted 10 lines
fs/resctrl/ctrlmondata.c +2 -2
+					   max_name_width, ctrl->schema_name);
 		}
 	} else if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) {
 		if (!rdtgrp->plr->d) {
 			rdt_last_cmd_puts("Cache domain offline\n");
 			ret = -ENODEV;
 		} else {
-			seq_printf(s, "%s:%d=%x\n",
-				   rdtgrp->plr->f->res->name,
+			ctrl = resctrl_resource_ctrl_get_default(f->res);

I think f is only set in the for loops, so should this be rdtgrp->plr->f->res instead of f->res?

Thanks,
Drew

maintainer
#50 lore raw

Re: [RFC PATCH 1/3] fs/resctrl: Add schema_name to struct resctrl_ctrl

Hi Drew,

Quoted 36 lines · Drew Fustini
Quoted 20 lines · Ben Horgan

In order to properly align the schema in the schemata and size file the maximum of length of all the schema names needs to be
known. resctrl_resource_ctrl_max_len() makes this calculation but stops short of actually constructing and storing the schema names. As the schema name is based on the resource name and the schema name with some special cases for legacy controls this leads to a lot of conditional formatting when displaying the schema name.

Construct the schema name and save it to struct resctrl when mounting resctrl. This makes displaying the schema name easy whilst control of the naming stays within resctrl.

---
 fs/resctrl/ctrlmondata.c | 51 ++++++-----------------------
 fs/resctrl/rdtgroup.c    | 69 +++++++++++++++++++++++++---------------
 include/linux/resctrl.h  |  1 +
 3 files changed, 55 insertions(+), 66 deletions(-)
fs/resctrl/ctrlmondata.c +0 -0

[..]

Quoted 14 lines
fs/resctrl/ctrlmondata.c +2 -4
@@ -638,18 +608,17 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of,
 	if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
 		list_for_each_entry(f, &rdt_resource_final_all, list) {
 			for_each_enabled_ctrl(ctrl, f->res)
-				seq_printf(s, "%s%s%s:uninitialized\n", f->name,
-					   resctrl_ctrl_is_default(ctrl) ? "" : "_",
-					   resctrl_ctrl_is_default(ctrl) ?
-					    "" : resctrl_ctrl_name_str(ctrl->name));
+				seq_printf(s, "%*s:uninitialized\n",
+					   max_name_width, ctrl->schema_name);
 		}
 	} else if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) {
 		if (!rdtgrp->plr->d) {
 			rdt_last_cmd_puts("Cache domain offline\n");
Quoted 8 lines

fs/resctrl/ctrlmondata.c int rdtgroup_schemata_show(struct kernfs_open_file *of, · line 619

Quoted 5 lines
fs/resctrl/ctrlmondata.c +1 -2
 			ret = -ENODEV;
 		} else {
-			seq_printf(s, "%s:%d=%x\n",
-				   rdtgrp->plr->f->res->name,
+			ctrl = resctrl_resource_ctrl_get_default(f->res);

I think f is only set in the for loops, so should this be rdtgrp->plr->f->res instead of f->res?

Yes, it should be. I only ran this on MPAM so didn't encounter this.

Thanks,

Ben

Quoted 3 lines

Thanks,
Drew

author maintainer
#51 lore raw

Re: [RFC PATCH 1/3] fs/resctrl: Add schema_name to struct resctrl_ctrl

In reply to Ben Horgan

Hi Ben,

Quoted 7 lines · Ben Horgan

In order to properly align the schema in the schemata and size file the maximum of length of all the schema names needs to be
known. resctrl_resource_ctrl_max_len() makes this calculation but stops short of actually constructing and storing the schema names. As the schema name is based on the resource name and the schema name with some special cases for legacy controls this leads to a lot of conditional formatting when displaying the schema name.

The schema name is based on the "final" resource name. This becomes significant when CDP is enabled since there may then be two "final" resources, one per CDP type, but they are backed by the same underlying resource. The two "final" (CODE/DATA) resources thus share the same controls.

Quoted 6 lines

Construct the schema name and save it to struct resctrl when mounting resctrl. This makes displaying the schema name easy whilst control of the naming stays within resctrl.

---

...

Quoted 33 lines
fs/resctrl/rdtgroup.c +6 -16
+
 static int final_resources_list_add(struct rdt_resource *r, enum resctrl_conf_type type)
 {
+	struct resctrl_ctrl *ctrl, *em_ctrl;
 	struct rdt_resource_final *f;
 	const char *suffix = "";
-	int ret, cl;
+	int ret;
 
 	f = kzalloc_obj(*f);
 	if (!f)
@@ -3409,24 +3420,32 @@ static int final_resources_list_add(struct rdt_resource *r, enum resctrl_conf_ty
 		return -EINVAL;
 	}
 
-	cl = strlen(f->name);
-
-	/*
-	 * Maintain tabular format by taking into account the names of all
-	 * the resource's controls.
-	 */
-	cl += resctrl_resource_ctrl_max_len(f->res);
-
-	/*
-	 * If CDP is supported by this resource, but not enabled,
-	 * include the suffix. This ensures the tabular format of the
-	 * schemata file does not change between mounts of the filesystem.
-	 */
-	if (r->cdp_capable && !resctrl_arch_get_cdp_enabled(r))
-		cl += 4;
+	for_each_resource_ctrl(ctrl, r) {
+		if (resctrl_ctrl_is_default(ctrl)) {
+			ret = snprintf(ctrl->schema_name, sizeof(ctrl->schema_name),

fs/resctrl/rdtgroup.c static int final_resources_list_add(struct rdt_resource *r, enum resctrl_conf_ty · line 3435

Quoted 10 lines
fs/resctrl/rdtgroup.c +10 -0
+				       "%s", f->name);
+		} else {
+			ret = snprintf(ctrl->schema_name, sizeof(ctrl->schema_name),
+				       "%s_%s", f->name, resctrl_ctrl_name_str(ctrl->name));
+		}
+		if (ret >= sizeof(ctrl->schema_name)) {
+			kfree(f);
+			return -EINVAL;
+		}
+		update_max_name_width(r, ctrl->schema_name);

When CDP is enabled final_resources_list_add() is called once per CDP type. Since the CDP types have the same underlying resource the two calls iterate over the same control objects with the second iteration overwriting the resctrl_ctrl::schema_name generated during the first iteration.

I am reworking this area to address the conclusions about control naming reached during RFC v2 discussion. These changes that you have not seen yet make it difficult to discuss new ways to make the schema name easier to display. I am working on addressing this issue as part of v3. We can revisit then.

Reinette

maintainer
#52 lore raw

RFC PATCH 2/3 fs/resctrl: Use correct schema name in bw_validate() last_cmd_status messages

In reply to Ben Horgan

As bw_validate() is now used for all scalar controls update the last_cmd_status messages to display the actual schema name rather than unconditionally using "MB".

---
 fs/resctrl/ctrlmondata.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
fs/resctrl/ctrlmondata.c +5 -3
index efeb36e0db25..968eb04046e9 100644
@@ -131,7 +131,8 @@ static bool bw_validate(char *buf, u32 *data, struct rdt_resource *r,
 
 	ret = kstrtou32(buf, 10, &bw);
 	if (ret) {
-		rdt_last_cmd_printf("Invalid MB value %s\n", buf);
+		rdt_last_cmd_printf("Invalid %s value %s\n", ctrl->schema_name, buf);
+
 		return false;
 	}
 
@@ -142,8 +143,9 @@ static bool bw_validate(char *buf, u32 *data, struct rdt_resource *r,
 	}
 
 	if (bw < ctrl->scalar.min || bw > ctrl->scalar.max) {
-		rdt_last_cmd_printf("MB value %u out of range [%d,%d]\n",
-				    bw, ctrl->scalar.min, ctrl->scalar.max);
+		rdt_last_cmd_printf("%s value %u out of range [%d,%d]\n",
+				    ctrl->schema_name, bw, ctrl->scalar.min, ctrl->scalar.max);
+
 		return false;
 	}
 
Signature · 1 line
2.43.0
maintainer
#53 lore raw

RFC PATCH 3/3 fs/resctrl: display size for scalar cache controls

In reply to Ben Horgan

resctrl allows controls specifying a minimum or maximum cache allocation but does not display their sizes in the 'size' file.

Calculate the size of any scalar cache controls and add them to the 'size' file.

---
 fs/resctrl/internal.h    |  4 ++--
 fs/resctrl/pseudo_lock.c |  2 +-
 fs/resctrl/rdtgroup.c    | 41 +++++++++++++++++++++++++++-------------
 3 files changed, 31 insertions(+), 16 deletions(-)
fs/resctrl/internal.h +2 -2
index 4bd09b1541c7..119f702a4f1f 100644
@@ -362,8 +362,8 @@ bool rdtgroup_cbm_overlaps(struct rdt_resource_final *f, struct rdt_ctrl_domain
 			   unsigned long cbm, int closid, bool exclusive,
 			   struct resctrl_ctrl *ctrl);
 
-unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct resctrl_ctrl *ctrl,
-				  struct rdt_ctrl_domain *d, unsigned long cbm);
+unsigned int rdtgroup_cache_ctrl_to_size(struct rdt_resource *r, struct resctrl_ctrl *ctrl,
+					 struct rdt_ctrl_domain *d, unsigned long ctrl_val);
 
 enum rdtgrp_mode rdtgroup_mode_by_closid(int closid);
 
fs/resctrl/pseudo_lock.c +1 -1
index 17b99a075eaf..36881491d074 100644
@@ -255,7 +255,7 @@ static int pseudo_lock_region_init(struct pseudo_lock_region *plr)
 	ci = get_cpu_cacheinfo_level(plr->cpu, scope);
 	if (ci) {
 		plr->line_size = ci->coherency_line_size;
-		plr->size = rdtgroup_cbm_to_size(plr->f->res, ctrl, plr->d, plr->cbm);
+		plr->size = rdtgroup_cache_ctrl_to_size(plr->f->res, ctrl, plr->d, plr->cbm);
 		return 0;
 	}
 
fs/resctrl/rdtgroup.c +28 -13

69 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#54 lore raw

Re: [RFC PATCH 0/3] Suggestions for cache scalar controls

In reply to Ben Horgan
Quoted 9 lines · Ben Horgan

Hi Reinette,

I'm posting as a reply to your series to try and keep things together. These patches should just be taken as suggestions. The first two patches make the printing of the schema name simpler while keeping it out of the arch code. The last add support for scalar cache controls in the size file. I found these sufficient to add support for CMIN/CMAX on top of MPAM. I'll post these separately but if makes sense to you feel free to incorporate them in your PoC.

I've just put these MPAM changes on a branch here rather than making too much noise on the list.

https://gitlab.arm.com/linux-arm/linux-bh/ mpam_controls_on_generic_schema_poc

Ben

Quoted 18 lines

Thanks,

Ben

Ben Horgan (3):
fs/resctrl: Add schema_name to struct resctrl_ctrl fs/resctrl: Use correct schema name in bw_validate() last_cmd_status
messages
fs/resctrl: display size for scalar cache controls

 fs/resctrl/ctrlmondata.c |  59 ++++++---------------
 fs/resctrl/internal.h    |   4 +-
 fs/resctrl/pseudo_lock.c |   2 +-
 fs/resctrl/rdtgroup.c    | 110 +++++++++++++++++++++++++--------------
 include/linux/resctrl.h  |   1 +
 5 files changed, 91 insertions(+), 85 deletions(-)
#55 lore raw

Re: [RFC PATCH 0/3] Suggestions for cache scalar controls

In reply to Ben Horgan
Quoted 9 lines · Ben Horgan

Hi Reinette,

I'm posting as a reply to your series to try and keep things together. These patches should just be taken as suggestions. The first two patches make the printing of the schema name simpler while keeping it out of the arch code. The last add support for scalar cache controls in the size file. I found these sufficient to add support for CMIN/CMAX on top of MPAM. I'll post these separately but if makes sense to you feel free to incorporate them in your PoC.

Thanks for posting as these help RISC-V too. CBQRI has minimum reserved bandwidth and a shared bw weight but there is no throttle-based MB control. This should fix the "Invalid MB value" for CBQRI.

I'll rebase the CBQRI support onto resctrl/controls_rfc_v2 and will try these patches in Qemu. The CMIN/CMAX modelling on your branch is helpful for CBQRI scalar controls.

Thanks,
Drew