Skip to contentSkip to conversation

x86/resctrl : Support AMD Assignable Bandwidth Monitoring Counters (ABMC)

PATCH Superseded Babu Moger 8 participants 209 messages Jan 22, 2025 – Mar 21, 2025 Page 3 of 3

Subsystems (3)

v11 of 18 Superseded Latest is v18 →

lore
Share & tools
lore
maintainer
#183 lore raw
In reply to Moger, Babu

Hi Babu,

Quoted 609 lines · Babu

Hi Reinette,

Quoted 606 lines · Reinette Chatre

Hi Babu,

Quoted 580 lines · Babu

Hi Reinette,

Quoted 560 lines · Reinette Chatre

Hi Babu,

Quoted 549 lines · Babu

Hi All,

Quoted 546 lines · Reinette Chatre
Quoted 408 lines · Babu

Hi Tony,

Quoted 405 lines · Tony
Quoted 404 lines · Babu

Hi All,

Quoted 401 lines · Babu

Hi Peter,

Quoted 388 lines · Peter Newman

Hi Babu,

Quoted 385 lines · Babu

Hi Peter,

Quoted 377 lines · Peter Newman

On Mon, Mar 3, 2025 at 8:16 PM Moger, Babu <[email protected]> wrote:

Hi Peter/Reinette,

On 2/26/25 07:27, Peter Newman wrote:
Hi Babu,

On Tue, Feb 25, 2025 at 10:31 PM Moger, Babu <[email protected]> wrote:

Hi Peter,

On 2/25/25 11:11, Peter Newman wrote:
Hi Reinette,

On Fri, Feb 21, 2025 at 11:43 PM Reinette Chatre
<[email protected]> wrote:

Hi Peter,

On 2/21/25 5:12 AM, Peter Newman wrote:
On Thu, Feb 20, 2025 at 7:36 PM Reinette Chatre
<[email protected]> wrote:
On 2/20/25 6:53 AM, Peter Newman wrote:
On Wed, Feb 19, 2025 at 7:21 PM Reinette Chatre
<[email protected]> wrote:
On 2/19/25 3:28 AM, Peter Newman wrote:
On Tue, Feb 18, 2025 at 6:50 PM Reinette Chatre
<[email protected]> wrote:
On 2/17/25 2:26 AM, Peter Newman wrote:
On Fri, Feb 14, 2025 at 8:18 PM Reinette Chatre
<[email protected]> wrote:
On 2/14/25 10:31 AM, Moger, Babu wrote:
On 2/14/2025 12:26 AM, Reinette Chatre wrote:
On 2/13/25 9:37 AM, Dave Martin wrote:
On Wed, Feb 12, 2025 at 03:33:31PM -0800, Reinette Chatre wrote:
On 2/12/25 9:46 AM, Dave Martin wrote:
On Wed, Jan 22, 2025 at 02:20:08PM -0600, Babu Moger wrote:

(quoting relevant parts with goal to focus discussion on new possible syntax)

I see the support for MPAM events distinct from the support of assignable counters.
Once the MPAM events are sorted, I think that they can be assigned with existing interface.
Please help me understand if you see it differently.

Doing so would need to come up with alphabetical letters for these events,
which seems to be needed for your proposal also? If we use possible flags of:

mbm_local_read_bytes a
mbm_local_write_bytes b

Then mbm_assign_control can be used as:
# echo '//0=ab;1=b' >/sys/fs/resctrl/info/L3_MON/mbm_assign_control
# cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_read_bytes
<value>
# cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes
<sum of mbm_local_read_bytes and mbm_local_write_bytes>

One issue would be when resctrl needs to support more than 26 events (no more flags available),
assuming that upper case would be used for "shared" counters (unless this interface is defined
differently and only few uppercase letters used for it). Would this be too low of a limit?

As mentioned above, one possible issue with existing interface is that
it is limited to 26 events (assuming only lower case letters are used). The limit
is low enough to be of concern.

The events which can be monitored by a single counter on ABMC and MPAM
so far are combinable, so 26 counters per group today means it limits
breaking down MBM traffic for each group 26 ways. If a user complained
that a 26-way breakdown of a group's MBM traffic was limiting their
investigation, I would question whether they know what they're looking
for.

The key here is "so far" as well as the focus on MBM only.

It is impossible for me to predict what we will see in a couple of years
from Intel RDT, AMD PQoS, and Arm MPAM that now all rely on resctrl interface
to support their users. Just looking at the Intel RDT spec the event register
has space for 32 events for each "CPU agent" resource. That does not take into
account the "non-CPU agents" that are enumerated via ACPI. Tony already mentioned
that he is working on patches [1] that will add new events and shared the idea
that we may be trending to support "perf" like events associated with RMID. I
expect AMD PQoS and Arm MPAM to provide related enhancements to support their
customers.
This all makes me think that resctrl should be ready to support more events than 26.

I was thinking of the letters as representing a reusable, user-defined
event-set for applying to a single counter rather than as individual
events, since MPAM and ABMC allow us to choose the set of events each
one counts. Wherever we define the letters, we could use more symbolic
event names.

Thank you for clarifying.

In the letters as events model, choosing the events assigned to a
group wouldn't be enough information, since we would want to control
which events should share a counter and which should be counted by
separate counters. I think the amount of information that would need
to be encoded into mbm_assign_control to represent the level of
configurability supported by hardware would quickly get out of hand.

Maybe as an example, one counter for all reads, one counter for all
writes in ABMC would look like...

(L3_QOS_ABMC_CFG.BwType field names below)

(per domain)
group 0:
   counter 0: LclFill,RmtFill,LclSlowFill,RmtSlowFill
   counter 1: VictimBW,LclNTWr,RmtNTWr
group 1:
   counter 2: LclFill,RmtFill,LclSlowFill,RmtSlowFill
   counter 3: VictimBW,LclNTWr,RmtNTWr
...

I think this may also be what Dave was heading towards in [2] but in that
example and above the counter configuration appears to be global. You do mention
"configurability supported by hardware" so I wonder if per-domain counter
configuration is a requirement?

If it's global and we want a particular group to be watched by more
counters, I wouldn't want this to result in allocating more counters
for that group in all domains, or allocating counters in domains where
they're not needed. I want to encourage my users to avoid allocating
monitoring resources in domains where a job is not allowed to run so
there's less pressure on the counters.

In Dave's proposal it looks like global configuration means
globally-defined "named counter configurations", which works because
it's really per-domain assignment of the configurations to however
many counters the group needs in each domain.

I think I am becoming lost. Would a global configuration not break your
view of "event-set applied to a single counter"? If a counter is configured
globally then it would not make it possible to support the full configurability
of the hardware.
Before I add more confusion, let me try with an example that builds on your
earlier example copied below:

(per domain)
group 0:
   counter 0: LclFill,RmtFill,LclSlowFill,RmtSlowFill
   counter 1: VictimBW,LclNTWr,RmtNTWr
group 1:
   counter 2: LclFill,RmtFill,LclSlowFill,RmtSlowFill
   counter 3: VictimBW,LclNTWr,RmtNTWr
...

Since the above states "per domain" I rewrite the example to highlight that as
I understand it:

group 0:
   domain 0:
    counter 0: LclFill,RmtFill,LclSlowFill,RmtSlowFill
    counter 1: VictimBW,LclNTWr,RmtNTWr
   domain 1:
    counter 0: LclFill,RmtFill,LclSlowFill,RmtSlowFill
    counter 1: VictimBW,LclNTWr,RmtNTWr
group 1:
   domain 0:
    counter 2: LclFill,RmtFill,LclSlowFill,RmtSlowFill
    counter 3: VictimBW,LclNTWr,RmtNTWr
   domain 1:
    counter 2: LclFill,RmtFill,LclSlowFill,RmtSlowFill
    counter 3: VictimBW,LclNTWr,RmtNTWr

You mention that you do not want counters to be allocated in domains that they
are not needed in. So, let's say group 0 does not need counter 0 and counter 1
in domain 1, resulting in:

group 0:
   domain 0:
    counter 0: LclFill,RmtFill,LclSlowFill,RmtSlowFill
    counter 1: VictimBW,LclNTWr,RmtNTWr
group 1:
   domain 0:
    counter 2: LclFill,RmtFill,LclSlowFill,RmtSlowFill
    counter 3: VictimBW,LclNTWr,RmtNTWr
   domain 1:
    counter 2: LclFill,RmtFill,LclSlowFill,RmtSlowFill
    counter 3: VictimBW,LclNTWr,RmtNTWr

With counter 0 and counter 1 available in domain 1, these counters could
theoretically be configured to give group 1 more data in domain 1:

group 0:
   domain 0:
    counter 0: LclFill,RmtFill,LclSlowFill,RmtSlowFill
    counter 1: VictimBW,LclNTWr,RmtNTWr
group 1:
   domain 0:
    counter 2: LclFill,RmtFill,LclSlowFill,RmtSlowFill
    counter 3: VictimBW,LclNTWr,RmtNTWr
   domain 1:
    counter 0: LclFill,RmtFill
    counter 1: LclNTWr,RmtNTWr
    counter 2: LclSlowFill,RmtSlowFill
    counter 3: VictimBW

The counters are shown with different per-domain configurations that seems to
match with earlier goals of (a) choose events counted by each counter and
(b) do not allocate counters in domains where they are not needed. As I
understand the above does contradict global counter configuration though.
Or do you mean that only the *name* of the counter is global and then
that it is reconfigured as part of every assignment?

Yes, I meant only the *name* is global. I assume based on a particular
system configuration, the user will settle on a handful of useful
groupings to count.

Perhaps mbm_assign_control syntax is the clearest way to express an example...

   # define global configurations (in ABMC terms), not necessarily in this
   # syntax and probably not in the mbm_assign_control file.

   r=LclFill,RmtFill,LclSlowFill,RmtSlowFill
   w=VictimBW,LclNTWr,RmtNTWr

   # legacy "total" configuration, effectively r+w
   t=LclFill,RmtFill,LclSlowFill,RmtSlowFill,VictimBW,LclNTWr,RmtNTWr

   /group0/0=t;1=t
   /group1/0=t;1=t
   /group2/0=_;1=t
   /group3/0=rw;1=_

- group2 is restricted to domain 0
- group3 is restricted to domain 1
- the rest are unrestricted
- In group3, we decided we need to separate read and write traffic

This consumes 4 counters in domain 0 and 3 counters in domain 1.

I see. Thank you for the example.

resctrl supports per-domain configurations with the following possible when
using mbm_total_bytes_config and mbm_local_bytes_config:

t(domain 0)=LclFill,RmtFill,LclSlowFill,RmtSlowFill,VictimBW,LclNTWr,RmtNTWr
t(domain 1)=LclFill,RmtFill,VictimBW,LclNTWr,RmtNTWr

     /group0/0=t;1=t
     /group1/0=t;1=t

Even though the flags are identical in all domains, the assigned counters will
be configured differently in each domain.

With this supported by hardware and currently also supported by resctrl it seems
reasonable to carry this forward to what will be supported next.

The hardware supports both a per-domain mode, where all groups in a
domain use the same configurations and are limited to two events per
group and a per-group mode where every group can be configured and
assigned freely. This series is using the legacy counter access mode
where only counters whose BwType matches an instance of QOS_EVT_CFG_n
in the domain can be read. If we chose to read the assigned counter
directly (QM_EVTSEL[ExtendedEvtID]=1, QM_EVTSEL[EvtID]=L3CacheABMC)
rather than asking the hardware to find the counter by RMID, we would
not be limited to 2 counters per group/domain and the hardware would
have the same flexibility as on MPAM.

In extended mode, the contents of a specific counter can be read by
setting the following fields in QM_EVTSEL: [ExtendedEvtID]=1,
[EvtID]=L3CacheABMC and setting [RMID] to the desired counter ID. Reading
QM_CTR will then return the contents of the specified counter.

It is documented below.
https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf
   Section: 19.3.3.3 Assignable Bandwidth Monitoring (ABMC)

We previously discussed this with you (off the public list) and I
initially proposed the extended assignment mode.

Yes, the extended mode allows greater flexibility by enabling multiple
counters to be assigned to the same group, rather than being limited to
just two.

However, the challenge is that we currently lack the necessary interfaces
to configure multiple events per group. Without these interfaces, the
extended mode is not practical at this time.

Therefore, we ultimately agreed to use the legacy mode, as it does not
require modifications to the existing interface, allowing us to continue
using it as is.

(I might have said something confusing in my last messages because I
had forgotten that I switched to the extended assignment mode when
prototyping with soft-ABMC and MPAM.)

Forcing all groups on a domain to share the same 2 counter
configurations would not be acceptable for us, as the example I gave
earlier is one I've already been asked about.

I don’t see this as a blocker. It should be considered an extension to the
current ABMC series. We can easily build on top of this series once we
finalize how to configure the multiple event interface for each group.

I don't think it is, either. Only being able to use ABMC to assign
counters is fine for our use as an incremental step. My longer-term
concern is the domain-scoped mbm_total_bytes_config and
mbm_local_bytes_config files, but they were introduced with BMEC, so
there's already an expectation that the files are present when BMEC is
supported.

On ABMC hardware that also supports BMEC, I'm concerned about enabling
ABMC when only the BMEC-style event configuration interface exists.
The scope of my issue is just whether enabling "full" ABMC support
will require an additional opt-in, since that could remove the BMEC
interface. If it does, it's something we can live with.

As you know, this series is currently blocked without further feedback.

I’d like to begin reworking these patches to incorporate Peter’s feedback.
Any input or suggestions would be appreciated.

Here’s what we’ve learned so far:

1. Assignments should be independent of BMEC.
2. We should be able to specify multiple event types to a counter (e.g.,
read, write, victimBM, etc.). This is also called shared counter
3. There should be an option to assign events per domain.
4. Currently, only two counters can be assigned per group, but the design
should allow flexibility to assign more in the future as the interface
evolves.
5. Utilize the extended RMID read mode.

Here is my proposal using Peter's earlier example:

# define event configurations

========================================================
Bits    Mnemonics       Description
====   ========================================================
6       VictimBW        Dirty Victims from all types of memory
5       RmtSlowFill     Reads to slow memory in the non-local NUMA domain
4       LclSlowFill     Reads to slow memory in the local NUMA domain
3       RmtNTWr         Non-temporal writes to non-local NUMA domain
2       LclNTWr         Non-temporal writes to local NUMA domain
1       mtFill          Reads to memory in the non-local NUMA domain
0       LclFill         Reads to memory in the local NUMA domain
====    ========================================================

#Define flags based on combination of above event types.

t = LclFill,RmtFill,LclSlowFill,RmtSlowFill,VictimBW,LclNTWr,RmtNTWr
l = LclFill, LclNTWr, LclSlowFill
r = LclFill,RmtFill,LclSlowFill,RmtSlowFill
w = VictimBW,LclNTWr,RmtNTWr
v = VictimBW

Peter suggested the following format earlier :

/group0/0=t;1=t
/group1/0=t;1=t
/group2/0=_;1=t
/group3/0=rw;1=_

After some inquiries within Google, it sounds like nobody has invested
much into the current mbm_assign_control format yet, so it would be
best to drop it and distribute the configuration around the filesystem
hierarchy[1], which should allow us to produce something more flexible
and cleaner to implement.

Roughly what I had in mind:

Use mkdir in a info/<resource>_MON subdirectory to create free-form
names for the assignable configurations rather than being restricted
to single letters.  In the resulting directory, populate a file where
we can specify the set of events the config should represent. I think
we should use symbolic names for the events rather than raw BMEC field
values. Moving forward we could come up with portable names for common
events and only support the BMEC names on AMD machines for users who
want specific events and don't care about portability.

I’m still processing this. Let me start with some initial questions.

Quoted 7 lines
Quoted 5 lines

So, we are creating event configurations here, which seems reasonable.

Yes, we should use portable names and are not limited to BMEC names.

How many configurations should we allow? Do we know?

Do we need an upper limit?

I think so. This needs to be maintained in some data structure. We can start with 2 default configurations for now.

There is a big difference between no upper limit and 2. The hardware is capable of supporting per-domain configurations so more flexibility is certainly possible. Consider the example presented by Peter in:
https://lore.kernel.org/lkml/CALPaoCi0mFZ9TycyNs+SCR+2tuRJovQ2809jYMun4HtC64hJmA@mail.gmail.com/

Quoted 120 lines
Quoted 111 lines
Quoted 111 lines
Quoted 111 lines
Quoted 16 lines
Quoted 9 lines
Quoted 7 lines

Next, put assignment-control file nodes in per-domain directories
(i.e., mon_data/mon_L3_00/assign_{exclusive,shared}). Writing a
counter-configuration name into the file would then allocate a counter
in the domain, apply the named configuration, and monitor the parent
group-directory. We can also put a group/resource-scoped assign_* file
higher in the hierarchy to make it easier for users who want to
configure all domains the same for a group.

What is the difference between shared and exclusive?

Shared assignment[1] means that non-exclusively-assigned counters in each domain will be scheduled round-robin to the groups requesting shared access to a counter. In my tests, I assigned the counters long enough to produce a single 1-second MB/s sample for the per-domain aggregation files[2].

Quoted 3 lines

These do not need to be implemented immediately, but knowing that they work addresses the overhead and scalability concerns of reassigning counters and reading their values.

Ok. Lets focus on exclusive assignments for now.

Quoted 6 lines
Quoted 6 lines

Having three files—assign_shared, assign_exclusive, and unassign—for each domain seems excessive. In a system with 32 groups and 12 domains, this results in 32 × 12 × 3 files, which is quite large.

Quoted 8 lines
Quoted 4 lines

There should be a more efficient way to handle this.

Initially, we started with a group-level file for this interface, but it was rejected due to the high number of sysfs calls, making it inefficient.

I had rejected it due to the high-frequency of access of a large number of files, which has since been addressed by shared assignment (or automatic reassignment) and aggregated mbps files.

I think we should address this as well. Creating three extra files for each group isn’t ideal when there are more efficient alternatives.

Quoted 9 lines
Quoted 5 lines

Additionally, how can we list all assignments with a single sysfs call?

That was another problem we need to address.

This is not a requirement I was aware of. If the user forgot where they assigned counters (or forgot to disable auto-assignment), they can read multiple sysfs nodes to remind themselves.

I suggest, we should provide users with an option to list the assignments of all groups in a single command. As the number of groups increases, it becomes cumbersome to query each group individually.

To achieve this, we can reuse our existing mbm_assign_control interface for this purpose. More details on this below.

Quoted 28 lines
Quoted 16 lines
Quoted 15 lines

The configuration names listed in assign_* would result in files of
the same name in the appropriate mon_data domain directories from
which the count values can be read.

   # mkdir info/L3_MON/counter_configs/mbm_local_bytes
   # echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
   # echo LclNTWr > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
   # echo LclSlowFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
   # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclFill
LclNTWr
LclSlowFill

Quoted 1 line

I feel we can just have the configs. event_filter file is not required.

That's right, I forgot that we can implement kernfs_ops::open(). I was only looking at struct kernfs_syscall_ops

Quoted 6 lines

#cat info/L3_MON/counter_configs/mbm_local_bytes
LclFill <-rename these to generic names.
LclNTWr
LclSlowFill

Quoted 5 lines

I think portable and non-portable event names should both be available as options. There are simple bandwidth measurement mechanisms that will be applied in general, but when they turn up an issue, it can often lead to a more focused investigation, requiring more precise events.

I aggree. We should provide both portable and non-portable event names.

Here is my draft proposal based on the discussion so far and reusing some of the current interface. Idea here is to start with basic assigment feature with options to enhance it in the future. Feel free to comment/suggest.

1. Event configurations will be in /sys/fs/resctrl/info/L3_MON/counter_configs/.

     There will be two pre-defined configurations by default.

     #cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes LclFill, LclNTWr,LclSlowFill,VictimBM,RmtSlowFill,LclSlowFill,RmtFill

     #cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes LclFill, LclNTWr, LclSlowFill

2. Users will have options to update these configurations.

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

     #echo "LclFill, LclNTWr, RmtFill" > /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes

This part seems odd to me. Now the "mbm_local_bytes" files aren't reporting "local_bytes" any more. They report something different, and users only know if they come to check the options currently configured in this file. Changing the contents without changing the name seems confusing to me.

Quoted 4 lines

It is the same behaviour right now with BMEC. It is configurable.
By default it is mbm_local_bytes, but users can configure whatever they want to monitor using /info/L3_MON/mbm_local_bytes_config.

We can continue the same behaviour with ABMC, but the configuration will be in /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes.

This could be supported by following Peter's original proposal where the name of the counter configuration is provided by the user via a mkdir:
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Quoted 7 lines
Quoted 1 line

As he mentioned there could be pre-populated mbm_local_bytes/mbm_total_bytes.

Sure. We can do that. I was thinking in the first phase, just provide the default pre-defined configuration and option to update the configuration.

We can add the mkdir support later. That way we can provide basic ABMC support without too much code complexity with mkdir support.

Quoted 6 lines

This is not clear to me how you envision the "first phase". Is it what you proposed above, for example:
#echo "LclFill, LclNTWr, RmtFill" >
/sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes

In above the counter configuration name is a file.

Yes. That is correct.

There will be two configuration files by default when resctrl is mounted when ABMC is enabled. /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes

Quoted 2 lines

How could mkdir support be added to this later if there are already files present?

Quoted 7 lines

We already have these directories when resctrl is mounted. /sys/fs/resctrl/test/mon_data/mon_L3_00/mbm_total_bytes /sys/fs/resctrl/test/mon_data/mon_L3_00/mbm_local_bytes /sys/fs/resctrl/test/mon_data/mon_L3_01/mbm_total_bytes /sys/fs/resctrl/test/mon_data/mon_L3_01/mbm_local_bytes

We dont need "mkdir" support for default configurations.

I was referring to the "mkdir" support for additional configurations that I understood you are thinking about adding later. For example, (copied from Peter's message
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/):

 # mkdir info/L3_MON/counter_configs/mbm_local_bytes
 # echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 # echo LclNTWr > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 # echo LclSlowFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclFill
LclNTWr
LclSlowFill
Quoted 5 lines
Quoted 1 line

Any "later" work needs to be backward compatible with the first phase.

Actually, we dont need extra file "event_filter".
This was discussed here.
https://lore.kernel.org/lkml/CALPaoChLL8p49eANYgQ0dJiFs7G=223fGae+LJyx3DwEhNeR8A@mail.gmail.com/

I undestand from that exchange that it is possible to read/write from an *existing* kernfs file but it is not obvious to me how that file is planned to be created.

My understanding of the motivation behind support for "mkdir" is to enable user space to create custom counter configurations.

I understand that ABMC support aims to start with existing mbm_total_bytes/mbm_local_bytes configurations but I believe the consensus is that custom configurations need to be supported in the future.
If resctrl starts with support where counter configuration as
managed with a *file*, for example:
/sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes
how will user space create future custom configurations?
As I understand that is only possible with mkdir.

Quoted 9 lines
# echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes
# echo LclNTWr > info/L3_MON/counter_configs/mbm_local_bytes
# echo LclSlowFill > info/L3_MON/counter_configs/mbm_local_bytes
# cat info/L3_MON/counter_configs/mbm_local_bytes
 LclFill
 LclNTWr
 LclSlowFill
Quoted 3 lines

In the future, we can add mkdir support.

# mkdir info/L3_MON/counter_configs/mbm_read_only

This is exactly my concern. resctrl should not start with a user space where a counter configuration is a file (mbm_local_bytes/mbm_total_bytes) and then switch user space interface to have counter configuration be done with directories.

Quoted 3 lines
# echo LclFill > info/L3_MON/counter_configs/mbm_read_only
# cat info/L3_MON/counter_configs/mbm_read_only
  LclFill

... wait ... user space writes to the directory?

Quoted 6 lines

#echo mbm_read_only > test/mon_data/mon_L3_00/assign_exclusive

Which would result in the creation of test/mon_data/mon_L3_*/mbm_read_only

So, there is not breakage of backword compatibility.

The way I understand it I am seeing many incompatibilities. Perhaps I am missing something. Could you please provide detailed steps of how first phase and second phase would look?

Quoted 214 lines
Quoted 8 lines

If the first phase starts with a file:
/sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes
... I do not see how second phase can be backward compatible when that work needs a directory with the same name that contains a file for configuration:
/sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Quoted 53 lines

sidenote: I think interactions with the "event_filter" file needs more descriptions since it is not clear with the provided example how user space may want to interact with the file when adding vs replacing event configurations.

Quoted 49 lines

My plan was to support only the default configurations in the first phase. That way there is no difference in the usage model with ABMC when mounted.

Quoted 44 lines
Quoted 34 lines
Quoted 34 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines

     # #cat /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes LclFill, LclNTWr, RmtFill

3. The default configurations will be used when user mounts the resctrl.

     mount  -t resctrl resctrl /sys/fs/resctrl/
     mkdir /sys/fs/resctrl/test/

4. The resctrl group/domains can be in one of these assingnment states.
     e: Exclusive
     s: Shared
     u: Unassigned

     Exclusive mode is supported now. Shared mode will be supported in the future.

5. We can use the current /sys/fs/resctrl/info/L3_MON/mbm_assign_control to list the assignment state of all the groups.

     Format:
     "<CTRL_MON group>/<MON group>/<confguration>:<domain_id>=<assign state>"

    # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control
     test//mbm_total_bytes:0=e;1=e
     test//mbm_local_bytes:0=e;1=e
     //mbm_total_bytes:0=e;1=e
     //mbm_local_bytes:0=e;1=e
Quoted 8 lines
Quoted 4 lines

This would make mbm_assign_control even more unwieldy and quicker to exceed a page of data (these examples never seem to reflect those AMD systems with the many L3 domains). How to handle resctrl files larger than 4KB needs to be well understood and solved when/if going this route.

This problem is not specific this series. I feel it is a generic problem to many of the semilar interfaces. I dont know how it is addressed. May have to investigate on this. Any pointers would be helpful.

Dave Martin already did a lot of analysis here. What other pointers do you need?

Yea. He did. I still need little more details on implementation of that. Will come back to that when we decide which way to go.

Quoted 148 lines
Quoted 146 lines
Quoted 145 lines
Quoted 143 lines
Quoted 10 lines

There seems to be two opinions about this file at moment. Would it be possible to summarize the discussion with pros/cons raised to make an informed selection? I understand that Google as represented by Peter no longer requires/requests this file but the motivation for this change seems new and does not seem to reduce the original motivation for this file. We may also want to separate requirements for reading from and writing to this file.

Yea. We can just use mbm_assign_control for reading the assignment states.

Summary: We have two proposals.

First one from Peter:

https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Pros
a. Allows flexible creation of free-form names for assignable configurations, stored in info/L3_MON/counter_configs/.

b. Events can be accessed using corresponding free-form names in the mon_data directory, making it clear to users what each event represents.

Cons:
a. Requires three separate files for assignment in each group (assign_exclusive, assign_shared, unassign), which might be excessive.

b. No built-in listing support, meaning users must query each group individually to check assignment states.

Second Proposal (Mine)

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

Pros:

a. Maintains the flexibility of free-form names for assignable configurations (info/L3_MON/counter_configs/).

b. Events remain accessible via free-form names in mon_data, ensuring clarity on their purpose.

c. Adds the ability to list assignment states for all groups in a single command.

Cons:
a. Potential buffer overflow issues when handling a large number of groups and domains and code complexity to fix the issue.

Third Option: A Hybrid Approach

We could combine elements from both proposals:

a. Retain the free-form naming approach for assignable configurations in info/L3_MON/counter_configs/.

b. Use the assignment method from the first proposal:
$mkdir test
$echo mbm_local_bytes > test/mon_data/mon_L3_00/assign_exclusive

c. Introduce listing support via the info/L3_MON/mbm_assign_control interface, enabling users to read assignment states for all groups in one place. Only reading support.

Quoted 70 lines
Quoted 60 lines
Quoted 60 lines
Quoted 30 lines
Quoted 30 lines

6. Users can modify the assignment state by writing to mbm_assign_control.

     Format:
     “<CTRL_MON group>/<MON group>/<configuration>:<domain_id>=<assign state>”

     #echo "test//mbm_local_bytes:0=e;1=e" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_control

     #echo "test//mbm_local_bytes:0=u;1=u" >
/sys/fs/resctrl/info/L3_MON/mbm_assign_control

     # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control
     test//mbm_total_bytes:0=u;1=u
     test//mbm_local_bytes:0=u;1=u
     //mbm_total_bytes:0=e;1=e
     //mbm_local_bytes:0=e;1=e

     The corresponding events will be read in

     /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_bytes /sys/fs/resctrl/mon_data/mon_L3_01/mbm_total_bytes /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes /sys/fs/resctrl/mon_data/mon_L3_01/mbm_local_bytes /sys/fs/resctrl/test/mon_data/mon_L3_00/mbm_total_bytes /sys/fs/resctrl/test/mon_data/mon_L3_01/mbm_total_bytes /sys/fs/resctrl/test/mon_data/mon_L3_00/mbm_local_bytes /sys/fs/resctrl/test/mon_data/mon_L3_01/mbm_local_bytes

Quoted 6 lines
Quoted 6 lines

7. In the first stage, only two configurations(mbm_total_bytes and mbm_local_bytes) will be supported.

8. In the future, there will be options to create multiple configurations and corresponding directory will be created in /sysf/fs/resctrl/test/mon_data/mon_L3_00/<configation name>.

Would this be done by creating a new file in the /sys/fs/resctrl/info/L3_MON/counter_configs directory? Like this:

# echo "LclFill, LclNTWr, RmtFill" >
         /sys/fs/resctrl/info/L3_MON/counter_configs/cache_stuff

This seems OK (dependent on the user picking meaningful names for the set of attributes picked ... but if they want to name this monitor file "brian" then they have to live with any confusion that they bring on themselves).

Would this involve an extension to kernfs? I don't see a function pointer callback for file creation in kernfs_syscall_ops.

Quoted 8 lines
Quoted 1 line

I know you are all busy with multiple series going on parallel. I am still waiting for the inputs on this. It will be great if you can spend some time on this to see if we can find common ground on the interface.

Thanks
Babu

Quoted 6 lines
Quoted 2 lines

-Tony

thanks
Babu

Reinette

author reviewer
#184 lore raw

Hi Reinette,

Quoted 14 lines · Reinette Chatre

Hi Babu,

Quoted 11 lines · Babu

Hi Reinette,

Quoted 8 lines · Reinette Chatre

Hi Babu,

Quoted 5 lines · Babu

Hi Reinette,

Quoted 2 lines · Reinette Chatre

Hi Babu,

..

Quoted 45 lines
Quoted 45 lines
Quoted 44 lines
Quoted 20 lines
Quoted 9 lines
Quoted 2 lines

We can add the mkdir support later. That way we can provide basic ABMC support without too much code complexity with mkdir support.

This is not clear to me how you envision the "first phase". Is it what you proposed above, for example:
#echo "LclFill, LclNTWr, RmtFill" >
/sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes

In above the counter configuration name is a file.

Yes. That is correct.

There will be two configuration files by default when resctrl is mounted when ABMC is enabled. /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes

Quoted 2 lines

How could mkdir support be added to this later if there are already files present?

Quoted 7 lines

We already have these directories when resctrl is mounted. /sys/fs/resctrl/test/mon_data/mon_L3_00/mbm_total_bytes /sys/fs/resctrl/test/mon_data/mon_L3_00/mbm_local_bytes /sys/fs/resctrl/test/mon_data/mon_L3_01/mbm_total_bytes /sys/fs/resctrl/test/mon_data/mon_L3_01/mbm_local_bytes

We dont need "mkdir" support for default configurations.

I was referring to the "mkdir" support for additional configurations that I understood you are thinking about adding later. For example, (copied from Peter's message
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/):

 # mkdir info/L3_MON/counter_configs/mbm_local_bytes
 # echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 # echo LclNTWr > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 # echo LclSlowFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclFill
LclNTWr
LclSlowFill

Any "later" work needs to be backward compatible with the first phase.

Quoted 7 lines
Quoted 3 lines

Actually, we dont need extra file "event_filter".
This was discussed here.
https://lore.kernel.org/lkml/CALPaoChLL8p49eANYgQ0dJiFs7G=223fGae+LJyx3DwEhNeR8A@mail.gmail.com/

I undestand from that exchange that it is possible to read/write from an *existing* kernfs file but it is not obvious to me how that file is planned to be created.

My bad.. I misspoke here. We need "event_filter" file under each configuration.

Quoted 4 lines

My understanding of the motivation behind support for "mkdir" is to enable user space to create custom counter configurations.

That is correct.

Quoted 27 lines

I understand that ABMC support aims to start with existing mbm_total_bytes/mbm_local_bytes configurations but I believe the consensus is that custom configurations need to be supported in the future.
If resctrl starts with support where counter configuration as
managed with a *file*, for example:
/sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes
how will user space create future custom configurations?
As I understand that is only possible with mkdir.

Quoted 9 lines
# echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes
# echo LclNTWr > info/L3_MON/counter_configs/mbm_local_bytes
# echo LclSlowFill > info/L3_MON/counter_configs/mbm_local_bytes
# cat info/L3_MON/counter_configs/mbm_local_bytes
 LclFill
 LclNTWr
 LclSlowFill
Quoted 3 lines

In the future, we can add mkdir support.

# mkdir info/L3_MON/counter_configs/mbm_read_only

This is exactly my concern. resctrl should not start with a user space where a counter configuration is a file (mbm_local_bytes/mbm_total_bytes) and then switch user space interface to have counter configuration be done with directories.

Quoted 6 lines
Quoted 3 lines
# echo LclFill > info/L3_MON/counter_configs/mbm_read_only
# cat info/L3_MON/counter_configs/mbm_read_only
  LclFill

... wait ... user space writes to the directory?

My bad. This is wrong. Let me rewrite the steps below.

Quoted 5 lines
Quoted 5 lines

#echo mbm_read_only > test/mon_data/mon_L3_00/assign_exclusive

Quoted 7 lines
Quoted 3 lines

Which would result in the creation of test/mon_data/mon_L3_*/mbm_read_only

So, there is not breakage of backword compatibility.

The way I understand it I am seeing many incompatibilities. Perhaps I am missing something. Could you please provide detailed steps of how first phase and second phase would look?

No. You didn't miss anything. I misspoke on few steps.

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

1. Mount the resctrl
mount -t resctrl resctrl /sys/fs/resctrl

2. When ABMC is supported two default configurations will be created.

a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

These files will be populated with default total and local events

  # cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
    VictimBW
    RmtSlowFill
    RmtNTWr
    RmtFill
    LclFill
    LclNTWr
    LclSlowFill
  # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
   LclFill,
   LclNTWr
   LclSlowFill

3. Users will have options to update the event configuration. echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

4. As usual the events can be read from the mon_data directories. #mkdir /sys/fs/resctrl/test
#cd /sys/fs/resctr/test
#cat test/mon_data/mon_data/mon_L3_00/mbm_tota_bytes 101010
#cat test/mon_data/mon_data/mon_L3_00/mbm_local_bytes
32323

5. There will be 3 files created in each group's mon_data directory when ABMC is supported.

a. test/mon_data/mon_L3_00/assign_exclusive
b. test/mon_data/mon_L3_00/assign_shared
c. test/mon_data/mon_L3_00/unassign

6. Events can be assigned/unassigned by these commands

 # echo mbm_total_bytes > test/mon_data/mon_L3_00/assign_exclusive
 # echo mbm_local_bytes > test/mon_data/mon_L3_01/assign_exclusive
 # echo mbm_local_bytes > test/mon_data/mon_L3_01/unassign

Note:
I feel 3 files are excessive here. We can probably achieve everything in just one file.

Not sure about mbm_assign_control interface as there are concerns with group listing holding the lock for long.

-----------------------------------------------------------------------
Second phase, we can add support for "mkdir"

1. mkdir info/L3_MON/counter_configs/mbm_read_only

2. mkdir option will create "event_filter" file. info/L3_MON/counter_configs/mbm_read_only/event_filter

3. Users can modify event configuration.
echo LclFill > info/L3_MON/counter_configs/mbm_read_only/event_filter

4. Users can assign the events

echo mbm_read_only > test/mon_data/mon_L3_00/assign_exclusive

5. Events can be read in

test/mon_data/mon_data/mon_L3_00/mbm_read_only

Signature · 2 lines
Thanks
Babu Moger
maintainer
#185 lore raw
Quoted 156 lines · Babu

Hi Reinette,

Quoted 14 lines · Reinette Chatre

Hi Babu,

Quoted 11 lines · Babu

Hi Reinette,

Quoted 8 lines · Reinette Chatre

Hi Babu,

Quoted 5 lines · Babu

Hi Reinette,

Quoted 2 lines · Reinette Chatre

Hi Babu,

..

Quoted 45 lines
Quoted 45 lines
Quoted 44 lines
Quoted 20 lines
Quoted 9 lines
Quoted 2 lines

We can add the mkdir support later. That way we can provide basic ABMC support without too much code complexity with mkdir support.

This is not clear to me how you envision the "first phase". Is it what you proposed above, for example:
#echo "LclFill, LclNTWr, RmtFill" >
/sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes

In above the counter configuration name is a file.

Yes. That is correct.

There will be two configuration files by default when resctrl is mounted when ABMC is enabled. /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes /sys/fs/resctrl/info/L3_MON/counter_configs/mbm_local_bytes

Quoted 2 lines

How could mkdir support be added to this later if there are already files present?

Quoted 7 lines

We already have these directories when resctrl is mounted. /sys/fs/resctrl/test/mon_data/mon_L3_00/mbm_total_bytes /sys/fs/resctrl/test/mon_data/mon_L3_00/mbm_local_bytes /sys/fs/resctrl/test/mon_data/mon_L3_01/mbm_total_bytes /sys/fs/resctrl/test/mon_data/mon_L3_01/mbm_local_bytes

We dont need "mkdir" support for default configurations.

I was referring to the "mkdir" support for additional configurations that I understood you are thinking about adding later. For example, (copied from Peter's message
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/):

 # mkdir info/L3_MON/counter_configs/mbm_local_bytes
 # echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 # echo LclNTWr > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 # echo LclSlowFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclFill
LclNTWr
LclSlowFill

Any "later" work needs to be backward compatible with the first phase.

Quoted 7 lines
Quoted 3 lines

Actually, we dont need extra file "event_filter".
This was discussed here.
https://lore.kernel.org/lkml/CALPaoChLL8p49eANYgQ0dJiFs7G=223fGae+LJyx3DwEhNeR8A@mail.gmail.com/

I undestand from that exchange that it is possible to read/write from an *existing* kernfs file but it is not obvious to me how that file is planned to be created.

My bad.. I misspoke here. We need "event_filter" file under each configuration.

Quoted 4 lines

My understanding of the motivation behind support for "mkdir" is to enable user space to create custom counter configurations.

That is correct.

Quoted 27 lines

I understand that ABMC support aims to start with existing mbm_total_bytes/mbm_local_bytes configurations but I believe the consensus is that custom configurations need to be supported in the future.
If resctrl starts with support where counter configuration as
managed with a *file*, for example:
/sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes
how will user space create future custom configurations?
As I understand that is only possible with mkdir.

Quoted 9 lines
# echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes
# echo LclNTWr > info/L3_MON/counter_configs/mbm_local_bytes
# echo LclSlowFill > info/L3_MON/counter_configs/mbm_local_bytes
# cat info/L3_MON/counter_configs/mbm_local_bytes
 LclFill
 LclNTWr
 LclSlowFill
Quoted 3 lines

In the future, we can add mkdir support.

# mkdir info/L3_MON/counter_configs/mbm_read_only

This is exactly my concern. resctrl should not start with a user space where a counter configuration is a file (mbm_local_bytes/mbm_total_bytes) and then switch user space interface to have counter configuration be done with directories.

Quoted 6 lines
Quoted 3 lines
# echo LclFill > info/L3_MON/counter_configs/mbm_read_only
# cat info/L3_MON/counter_configs/mbm_read_only
  LclFill

... wait ... user space writes to the directory?

My bad. This is wrong. Let me rewrite the steps below.

Quoted 5 lines
Quoted 5 lines

#echo mbm_read_only > test/mon_data/mon_L3_00/assign_exclusive

Quoted 7 lines
Quoted 3 lines

Which would result in the creation of test/mon_data/mon_L3_*/mbm_read_only

So, there is not breakage of backword compatibility.

The way I understand it I am seeing many incompatibilities. Perhaps I am missing something. Could you please provide detailed steps of how first phase and second phase would look?

No. You didn't miss anything. I misspoke on few steps.

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

1. Mount the resctrl
mount -t resctrl resctrl /sys/fs/resctrl

2. When ABMC is supported two default configurations will be created.

a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

These files will be populated with default total and local events

  # cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
    VictimBW
    RmtSlowFill
    RmtNTWr
    RmtFill
    LclFill
    LclNTWr
    LclSlowFill
Quoted 7 lines
  # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
   LclFill,
   LclNTWr
   LclSlowFill

3. Users will have options to update the event configuration. echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Once the "mkdir" support described below is implemented users will not need to redefine these legacy event file names. That makes me happy.

Quoted 19 lines

4. As usual the events can be read from the mon_data directories. #mkdir /sys/fs/resctrl/test
#cd /sys/fs/resctr/test
#cat test/mon_data/mon_data/mon_L3_00/mbm_tota_bytes 101010
#cat test/mon_data/mon_data/mon_L3_00/mbm_local_bytes
32323

5. There will be 3 files created in each group's mon_data directory when ABMC is supported.

   a. test/mon_data/mon_L3_00/assign_exclusive
   b. test/mon_data/mon_L3_00/assign_shared
   c. test/mon_data/mon_L3_00/unassign

6. Events can be assigned/unassigned by these commands

Quoted 8 lines
 # echo mbm_total_bytes > test/mon_data/mon_L3_00/assign_exclusive
 # echo mbm_local_bytes > test/mon_data/mon_L3_01/assign_exclusive
 # echo mbm_local_bytes > test/mon_data/mon_L3_01/unassign

Note:
I feel 3 files are excessive here. We can probably achieve everything in just one file.

Maybe the one file could look like:

# cat mon_L3_assignments
mbm_total_bytes: exclusive
mbm_local_bytes: shared
mbm_read_only: unassigned

with new lines appearing when mkdir creates new events, and the obvious write semantics:

# echo "mbm_total_bytes: unassigned" > mon_L3_assignments

to make updates.

Quoted 14 lines

Not sure about mbm_assign_control interface as there are concerns with group listing holding the lock for long.

-----------------------------------------------------------------------
Second phase, we can add support for "mkdir"

1. mkdir info/L3_MON/counter_configs/mbm_read_only

2. mkdir option will create "event_filter" file. info/L3_MON/counter_configs/mbm_read_only/event_filter

3. Users can modify event configuration.
echo LclFill > info/L3_MON/counter_configs/mbm_read_only/event_filter

Quoted 7 lines

4. Users can assign the events

echo mbm_read_only > test/mon_data/mon_L3_00/assign_exclusive

5. Events can be read in

   test/mon_data/mon_data/mon_L3_00/mbm_read_only

Is there a matching "rmdir" to make this go away again?

Quoted 3 lines
Signature · 2 lines
Thanks
Babu Moger
maintainer
#187 lore raw
In reply to Moger, Babu

Hi Babu,

Quoted 9 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Babu
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Babu

On 3/12/25 10:07, Reinette Chatre wrote:

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Thank you very much for detailing the steps. It is starting the fall into place for me.

Quoted 4 lines

1. Mount the resctrl
mount -t resctrl resctrl /sys/fs/resctrl

I assume that on ABMC system the plan remains to have ABMC enabled by default, which will continue to depend on BMEC.

How would the existing BMEC implementation be impacted in this case?

Without any changes to BMEC support the mbm_total_bytes_config and mbm_local_bytes_config files will remain and user space may continue to use them to change the event configurations with confusing expecations/results on an ABMC system.

One possibility may be that a user may see below on ABMC system even if BMEC is supported:

# cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes

With the above a user cannot be expected to want to interact with mbm_total_bytes_config and mbm_local_bytes_config, which may be the simplest to do.

To follow that, we should also consider how "mon_features" will change with this implementation.

Quoted 7 lines

2. When ABMC is supported two default configurations will be created.

a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

These files will be populated with default total and local events

Quoted 8 lines
  # cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
    VictimBW
    RmtSlowFill
    RmtNTWr
    RmtFill
    LclFill
    LclNTWr
    LclSlowFill

Looks good. Here we could perhaps start nitpicking about naming and line separation. I think it may be easier if the fields are separated by comma, but more on that below ...

Quoted 8 lines
  # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
   LclFill,
   LclNTWr
   LclSlowFill

3. Users will have options to update the event configuration. echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

We need to be clear on how user space interacts with this file. For example, can user space "append" configurations? Specifically, if the file has contents like your earlier example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 LclFill
 LclNTWr
 LclSlowFill

Should above be created with (note "append" needed for second and third):
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclNTWr >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclSlowFill >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it possible to set multiple configurations in one write like below?
echo "LclFill,LclNTWr,LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

(note above where it may be easier for user space to use comma (or some other field separator) when providing multiple configurations at a time, with this, to match, having output in commas may be easier since it makes user interface copy&paste easier)

If file has content like:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 LclNTWr
 LclSlowFill

What is impact of the following:
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it (append):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 LclFill
 LclNTWr
 LclSlowFill

or (overwrite):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 LclFill

I do think the interface will be more intuitive it if follows regular file operations wrt "append" and such. I have not looked into how kernfs supports "append".

As alternative, we can try to work the previous mbm_assign_control syntax in here (use + and -).

For example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclNTWr
# echo "+LclFill,-LclNTWr,+LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclFill,LclSlowFill

With something like above resctrl just deals with file writes as before.

Quoted 19 lines

4. As usual the events can be read from the mon_data directories. #mkdir /sys/fs/resctrl/test
#cd /sys/fs/resctr/test
#cat test/mon_data/mon_data/mon_L3_00/mbm_tota_bytes 101010
#cat test/mon_data/mon_data/mon_L3_00/mbm_local_bytes
32323

5. There will be 3 files created in each group's mon_data directory when ABMC is supported.

   a. test/mon_data/mon_L3_00/assign_exclusive
   b. test/mon_data/mon_L3_00/assign_shared
   c. test/mon_data/mon_L3_00/unassign

6. Events can be assigned/unassigned by these commands

Quoted 8 lines
 # echo mbm_total_bytes > test/mon_data/mon_L3_00/assign_exclusive
 # echo mbm_local_bytes > test/mon_data/mon_L3_01/assign_exclusive
 # echo mbm_local_bytes > test/mon_data/mon_L3_01/unassign

Note:
I feel 3 files are excessive here. We can probably achieve everything in just one file.

Could you please elaborate what your concern is? You mention that it is excessive but it is not clear to me what issues may arise by having three files instead of one.

I do think, and Peter also mentioned [1] this, that it may be useful, to "put a group/resource-scoped assign_* file higher in the hierarchy to make it easier for users who want to configure all domains the same for a group."

Placing *additional* files higher in hierarchy (used to manage counters in all domains) may be more useful that trying to provide the shared/exclusive/unassign in one file per domain.

Quoted 4 lines

Not sure about mbm_assign_control interface as there are concerns with group listing holding the lock for long.

Quoted 8 lines

-----------------------------------------------------------------------
Second phase, we can add support for "mkdir"

1. mkdir info/L3_MON/counter_configs/mbm_read_only

2. mkdir option will create "event_filter" file. info/L3_MON/counter_configs/mbm_read_only/event_filter

Got it!

Quoted 11 lines

3. Users can modify event configuration.
echo LclFill > info/L3_MON/counter_configs/mbm_read_only/event_filter

4. Users can assign the events

echo mbm_read_only > test/mon_data/mon_L3_00/assign_exclusive

5. Events can be read in

   test/mon_data/mon_data/mon_L3_00/mbm_read_only

Related to comment from Tony [2] about rmdir, please also consider that original mbm_local_bytes/mbm_total_bytes could also be removed because at this point they should not appear different from other counter configurations ... apart from being pre-populated for backward compatibility.

Thank you.

Reinette

[1] https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/
[2] https://lore.kernel.org/lkml/Z9NB0wd8ZewLjNAd@agluck-desk3/

author reviewer
#186 lore raw
In reply to Luck, Tony

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Tony,

Quoted 46 lines · Tony
Quoted 45 lines · Babu

Hi Reinette,

Quoted 5 lines · Reinette Chatre

Hi Babu,

Quoted 2 lines

#echo mbm_read_only > test/mon_data/mon_L3_00/assign_exclusive

Quoted 7 lines
Quoted 3 lines

Which would result in the creation of test/mon_data/mon_L3_*/mbm_read_only

So, there is not breakage of backword compatibility.

The way I understand it I am seeing many incompatibilities. Perhaps I am missing something. Could you please provide detailed steps of how first phase and second phase would look?

No. You didn't miss anything. I misspoke on few steps.

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

1. Mount the resctrl
mount -t resctrl resctrl /sys/fs/resctrl

2. When ABMC is supported two default configurations will be created.

a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

These files will be populated with default total and local events

   # cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
     VictimBW
     RmtSlowFill
     RmtNTWr
     RmtFill
     LclFill
     LclNTWr
     LclSlowFill
   # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
    LclFill,
    LclNTWr
    LclSlowFill
Quoted 5 lines
Quoted 2 lines

3. Users will have options to update the event configuration. echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Once the "mkdir" support described below is implemented users will not need to redefine these legacy event file names. That makes me happy.

Yea. That is correct.

Quoted 36 lines
Quoted 20 lines

4. As usual the events can be read from the mon_data directories.

    #mkdir /sys/fs/resctrl/test
    #cd   /sys/fs/resctr/test
    #cat  test/mon_data/mon_data/mon_L3_00/mbm_tota_bytes
    101010
    #cat   test/mon_data/mon_data/mon_L3_00/mbm_local_bytes
    32323

5. There will be 3 files created in each group's mon_data directory when ABMC is supported.

    a. test/mon_data/mon_L3_00/assign_exclusive
    b. test/mon_data/mon_L3_00/assign_shared
    c. test/mon_data/mon_L3_00/unassign

6. Events can be assigned/unassigned by these commands

Quoted 8 lines
  # echo mbm_total_bytes > test/mon_data/mon_L3_00/assign_exclusive
  # echo mbm_local_bytes > test/mon_data/mon_L3_01/assign_exclusive
  # echo mbm_local_bytes > test/mon_data/mon_L3_01/unassign

Note:
I feel 3 files are excessive here. We can probably achieve everything in just one file.

Maybe the one file could look like:

# cat mon_L3_assignments
mbm_total_bytes: exclusive
mbm_local_bytes: shared
mbm_read_only: unassigned
Quoted 6 lines

with new lines appearing when mkdir creates new events, and the obvious write semantics:

# echo "mbm_total_bytes: unassigned" > mon_L3_assignments

to make updates.

Yes. That would work. Also we could move the file to group's main directory like we have other files already.

#cat /sys/fs/resctrl/test/mon_L3_assignments
mbm_total_bytes: 0=unassigned; 1=unassigned
mbm_local_bytes: 0=unassigned; 1=unassigned

To assign mbm_total_bytes config on domain 0.

$echo "mbm_total_bytes: 0=exclusive " > mon_L3_assignments

To assign mbm_total_bytes config on all the domains.

$echo "mbm_total_bytes: *=exclusive " > mon_L3_assignments

#cat /sys/fs/resctrl/test/mon_L3_assignments
mbm_total_bytes: 0=exclusive; 1=exclusive
mbm_local_bytes: 0=unassigned; 1=unassigned

Quoted 17 lines
Quoted 17 lines

Not sure about mbm_assign_control interface as there are concerns with group listing holding the lock for long.

-----------------------------------------------------------------------
Second phase, we can add support for "mkdir"

1. mkdir info/L3_MON/counter_configs/mbm_read_only

2. mkdir option will create "event_filter" file. info/L3_MON/counter_configs/mbm_read_only/event_filter

3. Users can modify event configuration.
echo LclFill > info/L3_MON/counter_configs/mbm_read_only/event_filter

4. Users can assign the events

Quoted 8 lines
Quoted 5 lines

echo mbm_read_only > test/mon_data/mon_L3_00/assign_exclusive

5. Events can be read in

    test/mon_data/mon_data/mon_L3_00/mbm_read_only

Is there a matching "rmdir" to make this go away again?

I would think so.

Thanks
Babu

#188 lore raw
In reply to Reinette Chatre

Hi Reinette,

Quoted 18 lines · Reinette Chatre

Hi Babu,

Quoted 9 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Babu
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Babu

On 3/12/25 10:07, Reinette Chatre wrote:

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Thank you very much for detailing the steps. It is starting the fall into place for me.

Quoted 2 lines
Quoted 5 lines
Quoted 2 lines

1. Mount the resctrl
mount -t resctrl resctrl /sys/fs/resctrl

I assume that on ABMC system the plan remains to have ABMC enabled by default, which will continue to depend on BMEC.

Yes. ABMC will be enabled by default. ABMC will use the configurations from info/L3_MON/counter_configs. ABMC will not depend on BMEC.

Quoted 1 line

How would the existing BMEC implementation be impacted in this case?

BMEC will only work with pre-ABMC(or default) mode.

Quoted 5 lines

Without any changes to BMEC support the mbm_total_bytes_config and mbm_local_bytes_config files will remain and user space may continue to use them to change the event configurations with confusing expecations/results on an ABMC system.

Quoted 8 lines

One possibility may be that a user may see below on ABMC system even if BMEC is supported:

# cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes

With the above a user cannot be expected to want to interact with mbm_total_bytes_config and mbm_local_bytes_config, which may be the simplest to do.

yes.

Quoted 3 lines

To follow that, we should also consider how "mon_features" will change with this implementation.

May be

# cat /sys/fs/resctrl/info/L3_MON/mon_features
 llc_occupancy
 mbm_total_bytes
 mbm_local_bytes
 counter_configs/mbm_total_bytes/event_filter
 counter_configs/mbm_local_bytes/event_filter
Quoted 38 lines
Quoted 8 lines

2. When ABMC is supported two default configurations will be created.

a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

These files will be populated with default total and local events

Quoted 8 lines
   # cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
     VictimBW
     RmtSlowFill
     RmtNTWr
     RmtFill
     LclFill
     LclNTWr
     LclSlowFill

Looks good. Here we could perhaps start nitpicking about naming and line separation. I think it may be easier if the fields are separated by comma, but more on that below ...

Quoted 8 lines
   # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
    LclFill,
    LclNTWr
    LclSlowFill

3. Users will have options to update the event configuration. echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

We need to be clear on how user space interacts with this file. For example, can user space "append" configurations? Specifically, if the file has contents like your earlier example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill
  LclNTWr
  LclSlowFill
Quoted 7 lines

Should above be created with (note "append" needed for second and third):
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclNTWr >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclSlowFill >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it possible to set multiple configurations in one write like below?
echo "LclFill,LclNTWr,LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Yes. We should support that.

Quoted 19 lines

(note above where it may be easier for user space to use comma (or some other field separator) when providing multiple configurations at a time, with this, to match, having output in commas may be easier since it makes user interface copy&paste easier)

If file has content like:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclNTWr
  LclSlowFill

What is impact of the following:
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it (append):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill
  LclNTWr
  LclSlowFill
Quoted 7 lines

or (overwrite):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill

I do think the interface will be more intuitive it if follows regular file operations wrt "append" and such. I have not looked into how kernfs supports "append".

Just searching quickly, I have not seen any append operations on kernfs.

Quoted 11 lines

As alternative, we can try to work the previous mbm_assign_control syntax in here (use + and -).

For example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclNTWr
# echo "+LclFill,-LclNTWr,+LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclFill,LclSlowFill

With something like above resctrl just deals with file writes as before.

Or without complicating much we can just support basic operations.

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill, LclNTWr, LclSlowFill
# echo "LclFill, LclNTWr, LclSlowFill, VictimBW" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill, LclNTWr, LclSlowFill, VictimBW
# echo "LclFill, LclNTWr" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill, LclNTWr
Quoted 26 lines
Quoted 26 lines

4. As usual the events can be read from the mon_data directories.

    #mkdir /sys/fs/resctrl/test
    #cd   /sys/fs/resctr/test
    #cat  test/mon_data/mon_data/mon_L3_00/mbm_tota_bytes
    101010
    #cat   test/mon_data/mon_data/mon_L3_00/mbm_local_bytes
    32323

5. There will be 3 files created in each group's mon_data directory when ABMC is supported.

    a. test/mon_data/mon_L3_00/assign_exclusive
    b. test/mon_data/mon_L3_00/assign_shared
    c. test/mon_data/mon_L3_00/unassign

6. Events can be assigned/unassigned by these commands

  # echo mbm_total_bytes > test/mon_data/mon_L3_00/assign_exclusive
  # echo mbm_local_bytes > test/mon_data/mon_L3_01/assign_exclusive
  # echo mbm_local_bytes > test/mon_data/mon_L3_01/unassign
Quoted 7 lines
Quoted 3 lines

Note:
I feel 3 files are excessive here. We can probably achieve everything in just one file.

Could you please elaborate what your concern is? You mention that it is excessive but it is not clear to me what issues may arise by having three files instead of one.

All these 3 properties are mutually exclusive. Only one can true at a time. Example:
#cat assign_exclusive
0
#cat assign_shared
0
#cat uassigned
1

Three operations to find out the assign state.

Instead of that
#cat mon_l3_assignments
unassigned

Quoted 9 lines

I do think, and Peter also mentioned [1] this, that it may be useful, to "put a group/resource-scoped assign_* file higher in the hierarchy to make it easier for users who want to configure all domains the same for a group."

Placing *additional* files higher in hierarchy (used to manage counters in all domains) may be more useful that trying to provide the shared/exclusive/unassign in one file per domain.

Yea. To make it better we can add "mon_l3_assignments" in groups main directory. We can do all the operation in just one file.

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

Quoted 25 lines
Quoted 5 lines

Not sure about mbm_assign_control interface as there are concerns with group listing holding the lock for long.

Quoted 8 lines

-----------------------------------------------------------------------
Second phase, we can add support for "mkdir"

1. mkdir info/L3_MON/counter_configs/mbm_read_only

2. mkdir option will create "event_filter" file. info/L3_MON/counter_configs/mbm_read_only/event_filter

Got it!

Quoted 9 lines

3. Users can modify event configuration.
echo LclFill > info/L3_MON/counter_configs/mbm_read_only/event_filter

4. Users can assign the events

echo mbm_read_only > test/mon_data/mon_L3_00/assign_exclusive

5. Events can be read in

Quoted 7 lines
Quoted 2 lines
    test/mon_data/mon_data/mon_L3_00/mbm_read_only

Related to comment from Tony [2] about rmdir, please also consider that original mbm_local_bytes/mbm_total_bytes could also be removed because at this point they should not appear different from other counter configurations ... apart from being pre-populated for backward compatibility.

Sure.

Quoted 9 lines

Thank you.

Reinette

[1] https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/
[2] https://lore.kernel.org/lkml/Z9NB0wd8ZewLjNAd@agluck-desk3/

Thanks
Babu

#193 lore raw
In reply to Reinette Chatre

Hi Reinette,

Quoted 31 lines · Reinette Chatre

Hi Babu,

Quoted 9 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Babu
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Babu

On 3/12/25 10:07, Reinette Chatre wrote:

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Thank you very much for detailing the steps. It is starting the fall into place for me.

Quoted 4 lines

1. Mount the resctrl
mount -t resctrl resctrl /sys/fs/resctrl

I assume that on ABMC system the plan remains to have ABMC enabled by default, which will continue to depend on BMEC.

How would the existing BMEC implementation be impacted in this case?

Without any changes to BMEC support the mbm_total_bytes_config and mbm_local_bytes_config files will remain and user space may continue to use them to change the event configurations with confusing expecations/results on an ABMC system.

Quoted 8 lines

One possibility may be that a user may see below on ABMC system even if BMEC is supported:

# cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes

With the above a user cannot be expected to want to interact with mbm_total_bytes_config and mbm_local_bytes_config, which may be the simplest to do.

How about making mbm_local_bytes and mbm_total_bytes always be configured using mbm_{local,total}_bytes_config and only allowing the full ABMC configurability on user-defined configurations. This could resolve the issue of backwards compatibility with the BMEC files and remove the need for the user opting-in to ABMC mode.

It will be less clean implementation-wise, since there will be two classes of event configuration to deal with, but I think it seems logical from the user's side.

Quoted 67 lines

To follow that, we should also consider how "mon_features" will change with this implementation.

Quoted 7 lines

2. When ABMC is supported two default configurations will be created.

a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

These files will be populated with default total and local events

Quoted 8 lines
  # cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
    VictimBW
    RmtSlowFill
    RmtNTWr
    RmtFill
    LclFill
    LclNTWr
    LclSlowFill

Looks good. Here we could perhaps start nitpicking about naming and line separation. I think it may be easier if the fields are separated by comma, but more on that below ...

Quoted 8 lines
  # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
   LclFill,
   LclNTWr
   LclSlowFill

3. Users will have options to update the event configuration. echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

We need to be clear on how user space interacts with this file. For example, can user space "append" configurations? Specifically, if the file has contents like your earlier example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 LclFill
 LclNTWr
 LclSlowFill

Should above be created with (note "append" needed for second and third):
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclNTWr >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclSlowFill >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it possible to set multiple configurations in one write like below?
echo "LclFill,LclNTWr,LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

(note above where it may be easier for user space to use comma (or some other field separator) when providing multiple configurations at a time, with this, to match, having output in commas may be easier since it makes user interface copy&paste easier)

If file has content like:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 LclNTWr
 LclSlowFill

What is impact of the following:
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it (append):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 LclFill
 LclNTWr
 LclSlowFill
Quoted 7 lines

or (overwrite):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
 LclFill

I do think the interface will be more intuitive it if follows regular file operations wrt "append" and such. I have not looked into how kernfs supports "append".

I expect specifying counter_configs to be a rare or one-time operation, so I think ease-of-use is the only concern. I think multiple, appending writes is the most straightforward to implement and invoke (for a shell user), but I think commas are easy enough to support as well, even though it would look better when reading back to see the entries on separate lines.

I believe you can inspect the file descriptor's flags from the kernfs_open_file reference: of->file->f_flags & O_APPEND

I haven't tried this, though.

-Peter

#194 lore raw

Hi Peter,

Quoted 41 lines · Peter Newman

Hi Reinette,

Quoted 37 lines · Reinette Chatre

Hi Babu,

Quoted 9 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Babu
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Babu

On 3/12/25 10:07, Reinette Chatre wrote:

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Thank you very much for detailing the steps. It is starting the fall into place for me.

Quoted 4 lines

1. Mount the resctrl
mount -t resctrl resctrl /sys/fs/resctrl

I assume that on ABMC system the plan remains to have ABMC enabled by default, which will continue to depend on BMEC.

How would the existing BMEC implementation be impacted in this case?

Without any changes to BMEC support the mbm_total_bytes_config and mbm_local_bytes_config files will remain and user space may continue to use them to change the event configurations with confusing expecations/results on an ABMC system.

One possibility may be that a user may see below on ABMC system even if BMEC is supported:

# cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes
Quoted 8 lines
Quoted 2 lines

With the above a user cannot be expected to want to interact with mbm_total_bytes_config and mbm_local_bytes_config, which may be the simplest to do.

How about making mbm_local_bytes and mbm_total_bytes always be configured using mbm_{local,total}_bytes_config and only allowing the full ABMC configurability on user-defined configurations. This could resolve the issue of backwards compatibility with the BMEC files and remove the need for the user opting-in to ABMC mode.

There is no opt-in mode. ABMC will be enabled by default if supported. Users will have option to go back to legacy mode.

The default configurations will be used for total(0x7f equivalent to enable all) and local(0x15 equivalent to all local events).

Same thing will show up at
a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Quoted 94 lines

It will be less clean implementation-wise, since there will be two classes of event configuration to deal with, but I think it seems logical from the user's side.

Quoted 67 lines

To follow that, we should also consider how "mon_features" will change with this implementation.

Quoted 7 lines

2. When ABMC is supported two default configurations will be created.

a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

These files will be populated with default total and local events

Quoted 8 lines
   # cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
     VictimBW
     RmtSlowFill
     RmtNTWr
     RmtFill
     LclFill
     LclNTWr
     LclSlowFill

Looks good. Here we could perhaps start nitpicking about naming and line separation. I think it may be easier if the fields are separated by comma, but more on that below ...

Quoted 8 lines
   # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
    LclFill,
    LclNTWr
    LclSlowFill

3. Users will have options to update the event configuration. echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

We need to be clear on how user space interacts with this file. For example, can user space "append" configurations? Specifically, if the file has contents like your earlier example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill
  LclNTWr
  LclSlowFill

Should above be created with (note "append" needed for second and third):
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclNTWr >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclSlowFill >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it possible to set multiple configurations in one write like below?
echo "LclFill,LclNTWr,LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

(note above where it may be easier for user space to use comma (or some other field separator) when providing multiple configurations at a time, with this, to match, having output in commas may be easier since it makes user interface copy&paste easier)

If file has content like:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclNTWr
  LclSlowFill

What is impact of the following:
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it (append):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill
  LclNTWr
  LclSlowFill
Quoted 7 lines

or (overwrite):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill

I do think the interface will be more intuitive it if follows regular file operations wrt "append" and such. I have not looked into how kernfs supports "append".

I expect specifying counter_configs to be a rare or one-time operation, so I think ease-of-use is the only concern. I think multiple, appending writes is the most straightforward to implement and invoke (for a shell user), but I think commas are easy enough to support as well, even though it would look better when reading back to see the entries on separate lines.

I believe you can inspect the file descriptor's flags from the kernfs_open_file reference: of->file->f_flags & O_APPEND

I haven't tried this, though.

-Peter

maintainer
#189 lore raw
In reply to Moger, Babu

Hi Babu,

Quoted 17 lines · Babu
Quoted 16 lines · Reinette Chatre
Quoted 9 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Babu
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Babu

On 3/12/25 10:07, Reinette Chatre wrote:

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Thank you very much for detailing the steps. It is starting the fall into place for me.

Quoted 2 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

1. Mount the resctrl
    mount -t resctrl resctrl /sys/fs/resctrl

I assume that on ABMC system the plan remains to have ABMC enabled by default, which will continue to depend on BMEC.

Yes. ABMC will be enabled by default. ABMC will use the configurations from info/L3_MON/counter_configs. ABMC will not depend on BMEC.

I see. The previous dependency was thus just something enforced by OS to support the chosen implementation?
Looks like the two features share some registers.

Quoted 4 lines
Quoted 2 lines

How would the existing BMEC implementation be impacted in this case?

BMEC will only work with pre-ABMC(or default) mode.

ok. Does this mean that if a user boots kernel with "rdt=!bmec" then ABMC will keep working?

Quoted 19 lines
Quoted 4 lines

Without any changes to BMEC support the mbm_total_bytes_config and mbm_local_bytes_config files will remain and user space may continue to use them to change the event configurations with confusing expecations/results on an ABMC system.

Quoted 8 lines

One possibility may be that a user may see below on ABMC system even if BMEC is supported:

# cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes

With the above a user cannot be expected to want to interact with mbm_total_bytes_config and mbm_local_bytes_config, which may be the simplest to do.

yes.

Quoted 3 lines

To follow that, we should also consider how "mon_features" will change with this implementation.

Quoted 9 lines

May be

# cat /sys/fs/resctrl/info/L3_MON/mon_features
 llc_occupancy
 mbm_total_bytes
 mbm_local_bytes
 counter_configs/mbm_total_bytes/event_filter
 counter_configs/mbm_local_bytes/event_filter

I read the docs again to understand what kind of flexibility we have here. As I interpret it the "mon_features" is associated with "events" and there is a clear documented association between the "events" listed in this file and which files a user can expect to exist in the "mon_data" directory. Considering this I think it may be helpful to provide the counter configurations in this file. This matches well with mbm_total_bytes/mbm_local_bytes being treated as "counter configurations".

Whether counter configuration is supported could be determined by existence of the "counter_configs" directory?

For example,

# cat /sys/fs/resctrl/info/L3_MON/mon_features
 llc_occupancy
 mbm_total_bytes
 mbm_local_bytes
# mkdir /sys/fs/resctrl/info/L3_MON/counter_configs/only_read_fills
# cat /sys/fs/resctrl/info/L3_MON/mon_features
 llc_occupancy
 mbm_total_bytes
 mbm_local_bytes
 only_read_fills

This could possibly be a way to support user interface when configuring the counter. For example, a user may easily create a new counter configuration by creating a directory, but there may be some requirements wrt its configuration that need to be met before that configuration/event may appear in the "mon_features" file.

Quoted 41 lines
Quoted 41 lines
Quoted 6 lines

2. When ABMC is supported two default configurations will be created.

   a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

   These files will be populated with default total and local events

Quoted 8 lines
   # cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
     VictimBW
     RmtSlowFill
     RmtNTWr
     RmtFill
     LclFill
     LclNTWr
     LclSlowFill

Looks good. Here we could perhaps start nitpicking about naming and line separation. I think it may be easier if the fields are separated by comma, but more on that below ...

Quoted 8 lines
   # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
    LclFill,
    LclNTWr
    LclSlowFill

3. Users will have options to update the event configuration. echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

We need to be clear on how user space interacts with this file. For example, can user space "append" configurations? Specifically, if the file has contents like your earlier example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill
  LclNTWr
  LclSlowFill

Should above be created with (note "append" needed for second and third):
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclNTWr >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclSlowFill >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Quoted 4 lines
Quoted 2 lines

Is it possible to set multiple configurations in one write like below?
echo "LclFill,LclNTWr,LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Yes. We should support that.

Reading Peter's response (https://lore.kernel.org/lkml/CALPaoCj7aSVxHisQTdKQ5KN0-aNzN8rRkRPVc7pjGMLSxfPvrA@mail.gmail.com/)
it sounds as though this part is now in the fine-tuning phase.
If there are other formats that is more convenient for user space then we should surely
consider that.

Quoted 50 lines
Quoted 20 lines

(note above where it may be easier for user space to use comma (or some other field separator) when providing multiple configurations at a time, with this, to match, having output in commas may be easier since it makes user interface copy&paste easier)

If file has content like:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclNTWr
  LclSlowFill

What is impact of the following:
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it (append):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill
  LclNTWr
  LclSlowFill
Quoted 7 lines

or (overwrite):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill

I do think the interface will be more intuitive it if follows regular file operations wrt "append" and such. I have not looked into how kernfs supports "append".

Just searching quickly, I have not seen any append operations on kernfs.

Quoted 11 lines

As alternative, we can try to work the previous mbm_assign_control syntax in here (use + and -).

For example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclNTWr
# echo "+LclFill,-LclNTWr,+LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclFill,LclSlowFill

With something like above resctrl just deals with file writes as before.

Or without complicating much we can just support basic operations.

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill, LclNTWr, LclSlowFill
# echo "LclFill, LclNTWr, LclSlowFill, VictimBW" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
Quoted 8 lines
# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill, LclNTWr, LclSlowFill, VictimBW
# echo "LclFill, LclNTWr" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill, LclNTWr

Looks good to me. As I see it this could be expanded to support "append" if needed.

Quoted 42 lines
Quoted 26 lines
Quoted 26 lines

4. As usual the events can be read from the mon_data directories. #mkdir /sys/fs/resctrl/test
    #cd   /sys/fs/resctr/test
    #cat  test/mon_data/mon_data/mon_L3_00/mbm_tota_bytes 101010
    #cat   test/mon_data/mon_data/mon_L3_00/mbm_local_bytes 32323

5. There will be 3 files created in each group's mon_data directory when ABMC is supported.

    a. test/mon_data/mon_L3_00/assign_exclusive
    b. test/mon_data/mon_L3_00/assign_shared
    c. test/mon_data/mon_L3_00/unassign

6. Events can be assigned/unassigned by these commands

  # echo mbm_total_bytes > test/mon_data/mon_L3_00/assign_exclusive
  # echo mbm_local_bytes > test/mon_data/mon_L3_01/assign_exclusive
  # echo mbm_local_bytes > test/mon_data/mon_L3_01/unassign
Quoted 7 lines
Quoted 3 lines

Note:
I feel 3 files are excessive here. We can probably achieve everything in just one file.

Could you please elaborate what your concern is? You mention that it is excessive but it is not clear to me what issues may arise by having three files instead of one.

All these 3 properties are mutually exclusive. Only one can true at a time. Example:
#cat assign_exclusive
0
#cat assign_shared
0
#cat uassigned
1

Quoted 1 line

Three operations to find out the assign state.

ah - good point.

Quoted 12 lines

Instead of that
#cat mon_l3_assignments
unassigned

Quoted 6 lines

I do think, and Peter also mentioned [1] this, that it may be useful, to "put a group/resource-scoped assign_* file higher in the hierarchy to make it easier for users who want to configure all domains the same for a group."

Quoted 7 lines
Quoted 3 lines

Placing *additional* files higher in hierarchy (used to manage counters in all domains) may be more useful that trying to provide the shared/exclusive/unassign in one file per domain.

Yea. To make it better we can add "mon_l3_assignments" in groups main directory. We can do all the operation in just one file.

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

I am hesitant to respond to that message considering the corporate preamble that sneaked in so I'll just add some thoughts here:

Having the file higher in hierarchy does seem more useful. It may be useful to reduce amount of parsing to get to needed information. Compare with below two examples that can be used to convey the same information:

# cat /sys/fs/resctrl/test/mon_L3_assignments
mbm_total_bytes: 0=unassigned; 1=unassigned
mbm_local_bytes: 0=unassigned; 1=unassigned

#cat /sys/fs/resctrl/test/mon_L3_assignments
0=_; 1=_

We need to take care that it is always clear what "0" or "1" means ... Tony has been mentioning a lot of interesting things about scope changes. I assume the "L3" in mon_L3_assignments will dictate the scope?

With a syntax like above the needed information can be presented in one line. For example,

#cat /sys/fs/resctrl/test/mon_L3_assignments
0=mbm_total_bytes; 1=mbm_local_bytes

The caveat is that is only for assigned counters, not shared, so this needs to change.

To support shared assignment ... I wonder if it will be useful to users to get the information on which other monitor groups the counter is shared _with_?

Some examples:

a) Just indicate whether a counter is shared or dedicated. (Introduce flags). #cat /sys/fs/resctrl/test/mon_L3_assignments
0=mbm_total_bytes:s; 1=mbm_local_bytes:d

b) Indicate which groups a counter is shared with:
#cat /sys/fs/resctrl/testA/mon_L3_assignments
0=mbm_total_bytes:s(testB); 1=mbm_local_bytes:d(not needed but perhaps empty for consistent interface?) #cat /sys/fs/resctrl/testB/mon_L3_assignments
0=mbm_total_bytes:s(testA); 1=mbm_local_bytes:d(?)

... (b) may just be overkill and we should instead follow Tony's guideline (see https://lore.kernel.org/lkml/Z9CiwLrhuTODruCj@agluck-desk3/ ) that users should be able to keep track themselves.

Reinette

maintainer
#195 lore raw
In reply to Moger, Babu

Hi Babu and Peter,

Quoted 52 lines · Babu

Hi Peter,

Quoted 49 lines · Peter Newman

Hi Reinette,

Quoted 31 lines · Reinette Chatre

Hi Babu,

Quoted 9 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Babu
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Babu

On 3/12/25 10:07, Reinette Chatre wrote:

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Thank you very much for detailing the steps. It is starting the fall into place for me.

Quoted 4 lines

1. Mount the resctrl
    mount -t resctrl resctrl /sys/fs/resctrl

I assume that on ABMC system the plan remains to have ABMC enabled by default, which will continue to depend on BMEC.

How would the k existing BMEC implementation be impacted in this case?

Without any changes to BMEC support the mbm_total_bytes_config and mbm_local_bytes_config files will remain and user space may continue to use them to change the event configurations with confusing expecations/results on an ABMC system.

Quoted 8 lines

One possibility may be that a user may see below on ABMC system even if BMEC is supported:

# cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes

With the above a user cannot be expected to want to interact with mbm_total_bytes_config and mbm_local_bytes_config, which may be the simplest to do.

How about making mbm_local_bytes and mbm_total_bytes always be configured using mbm_{local,total}_bytes_config and only allowing the full ABMC configurability on user-defined configurations. This could resolve the issue of backwards compatibility with the BMEC files and remove the need for the user opting-in to ABMC mode.

hmmm, yes, backward compatibility is a big issue with an earlier suggestion from me. Users with scripts/tools using mbm_{local,total}_bytes_config would expect that to continue to work on systems that support BMEC. resctrl could continue to use mbm_{local,total}_bytes_config even though the inconsistent interface is not ideal

Quoted 3 lines

There is no opt-in mode. ABMC will be enabled by default if supported. Users will have option to go back to legacy mode.

I assume there will still be the opt-in for automatic counter assignment on monitor group creation (mkdir)?

Quoted 6 lines

The default configurations will be used for total(0x7f equivalent to enable all) and local(0x15 equivalent to all local events).

Same thing will show up at
a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

These files could possibly be read-only but the moment user space uses mbm_{local,total}_bytes_config to change the configurations between domains this will be invalid. In this case the file could also perhaps read "Configured using <path to>mbm_{local,total}_bytes_config". It is not clear to me what would be most intuitive to user space.

Quoted 81 lines
Quoted 81 lines

It will be less clean implementation-wise, since there will be two classes of event configuration to deal with, but I think it seems logical from the user's side.

Quoted 74 lines

To follow that, we should also consider how "mon_features" will change with this implementation.

Quoted 7 lines

2. When ABMC is supported two default configurations will be created.

   a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

   These files will be populated with default total and local events

Quoted 8 lines
   # cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
     VictimBW
     RmtSlowFill
     RmtNTWr
     RmtFill
     LclFill
     LclNTWr
     LclSlowFill

Looks good. Here we could perhaps start nitpicking about naming and line separation. I think it may be easier if the fields are separated by comma, but more on that below ...

Quoted 8 lines
   # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
    LclFill,
    LclNTWr
    LclSlowFill

3. Users will have options to update the event configuration. echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

We need to be clear on how user space interacts with this file. For example, can user space "append" configurations? Specifically, if the file has contents like your earlier example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill
  LclNTWr
  LclSlowFill

Should above be created with (note "append" needed for second and third):
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclNTWr >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclSlowFill >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it possible to set multiple configurations in one write like below?
echo "LclFill,LclNTWr,LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

(note above where it may be easier for user space to use comma (or some other field separator) when providing multiple configurations at a time, with this, to match, having output in commas may be easier since it makes user interface copy&paste easier)

If file has content like:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclNTWr
  LclSlowFill

What is impact of the following:
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it (append):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill
  LclNTWr
  LclSlowFill

or (overwrite):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill

I do think the interface will be more intuitive it if follows regular file operations wrt "append" and such. I have not looked into how kernfs supports "append".

Quoted 6 lines
Quoted 6 lines

I expect specifying counter_configs to be a rare or one-time operation, so I think ease-of-use is the only concern. I think multiple, appending writes is the most straightforward to implement and invoke (for a shell user), but I think commas are easy enough to support as well, even though it would look better when reading back to see the entries on separate lines.

When the counter configuration consist out of multiple events then it may be convenient to just write it all in one go and having a shell user use newline as field separator does not seem convenient. Appending writes sound good no matter the field separator.
Reading back we may have to consider both what looks good to user space and what is easy to parse by a script.

Quoted 5 lines
Quoted 5 lines

I believe you can inspect the file descriptor's flags from the kernfs_open_file reference: of->file->f_flags & O_APPEND

I haven't tried this, though.

Thanks for looking this up.

Reinette

author reviewer
#190 lore raw
In reply to Reinette Chatre

Hi Reinette,

Quoted 23 lines · Reinette Chatre

Hi Babu,

Quoted 20 lines · Babu
Quoted 19 lines · Reinette Chatre
Quoted 9 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Babu
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Babu

On 3/12/25 10:07, Reinette Chatre wrote:

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Thank you very much for detailing the steps. It is starting the fall into place for me.

Quoted 4 lines

1. Mount the resctrl
    mount -t resctrl resctrl /sys/fs/resctrl

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I assume that on ABMC system the plan remains to have ABMC enabled by default, which will continue to depend on BMEC.

Yes. ABMC will be enabled by default. ABMC will use the configurations from info/L3_MON/counter_configs. ABMC will not depend on BMEC.

I see. The previous dependency was thus just something enforced by OS to support the chosen implementation?

Yes. That is correct. We went that route mainly not to change the rmid_read operation.

With ABMC, we need to set Extended EVTID and ABMC bit in QM_EVTSEL register while reading the cntr_id events. Will add those patches in next version to make it clear.

Quoted 8 lines

Looks like the two features share some registers.

Quoted 4 lines
Quoted 2 lines

How would the existing BMEC implementation be impacted in this case?

BMEC will only work with pre-ABMC(or default) mode.

ok. Does this mean that if a user boots kernel with "rdt=!bmec" then ABMC will keep working?

Yes. That is correct.

Quoted 55 lines
Quoted 21 lines
Quoted 6 lines

Without any changes to BMEC support the mbm_total_bytes_config and mbm_local_bytes_config files will remain and user space may continue to use them to change the event configurations with confusing expecations/results on an ABMC system.

Quoted 8 lines

One possibility may be that a user may see below on ABMC system even if BMEC is supported:

# cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes

With the above a user cannot be expected to want to interact with mbm_total_bytes_config and mbm_local_bytes_config, which may be the simplest to do.

yes.

Quoted 3 lines

To follow that, we should also consider how "mon_features" will change with this implementation.

Quoted 9 lines

May be

# cat /sys/fs/resctrl/info/L3_MON/mon_features
 llc_occupancy
 mbm_total_bytes
 mbm_local_bytes
 counter_configs/mbm_total_bytes/event_filter
 counter_configs/mbm_local_bytes/event_filter

I read the docs again to understand what kind of flexibility we have here. As I interpret it the "mon_features" is associated with "events" and there is a clear documented association between the "events" listed in this file and which files a user can expect to exist in the "mon_data" directory. Considering this I think it may be helpful to provide the counter configurations in this file. This matches well with mbm_total_bytes/mbm_local_bytes being treated as "counter configurations".

Whether counter configuration is supported could be determined by existence of the "counter_configs" directory?

For example,

# cat /sys/fs/resctrl/info/L3_MON/mon_features
 llc_occupancy
 mbm_total_bytes
 mbm_local_bytes
# mkdir /sys/fs/resctrl/info/L3_MON/counter_configs/only_read_fills
# cat /sys/fs/resctrl/info/L3_MON/mon_features
 llc_occupancy
 mbm_total_bytes
 mbm_local_bytes
 only_read_fills
Quoted 5 lines

This could possibly be a way to support user interface when configuring the counter. For example, a user may easily create a new counter configuration by creating a directory, but there may be some requirements wrt its configuration that need to be met before that configuration/event may appear in the "mon_features" file.

Yes. I am fine with this approach.

Quoted 45 lines
Quoted 45 lines
Quoted 44 lines
Quoted 7 lines

2. When ABMC is supported two default configurations will be created.

   a. info/L3_MON/counter_configs/mbm_total_bytes/event_filter b. info/L3_MON/counter_configs/mbm_local_bytes/event_filter

   These files will be populated with default total and local events

Quoted 8 lines
   # cat info/L3_MON/counter_configs/mbm_total_bytes/event_filter
     VictimBW
     RmtSlowFill
     RmtNTWr
     RmtFill
     LclFill
     LclNTWr
     LclSlowFill

Looks good. Here we could perhaps start nitpicking about naming and line separation. I think it may be easier if the fields are separated by comma, but more on that below ...

Quoted 8 lines
   # cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
    LclFill,
    LclNTWr
    LclSlowFill

3. Users will have options to update the event configuration. echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

We need to be clear on how user space interacts with this file. For example, can user space "append" configurations? Specifically, if the file has contents like your earlier example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill
  LclNTWr
  LclSlowFill

Should above be created with (note "append" needed for second and third):
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclNTWr >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter echo LclSlowFill >> info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it possible to set multiple configurations in one write like below?
echo "LclFill,LclNTWr,LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Quoted 6 lines
Quoted 1 line

Yes. We should support that.

Reading Peter's response (https://lore.kernel.org/lkml/CALPaoCj7aSVxHisQTdKQ5KN0-aNzN8rRkRPVc7pjGMLSxfPvrA@mail.gmail.com/)
it sounds as though this part is now in the fine-tuning phase.
If there are other formats that is more convenient for user space then we should surely
consider that.

I aggee. We can revise it further as we review.

Quoted 54 lines
Quoted 54 lines
Quoted 21 lines

(note above where it may be easier for user space to use comma (or some other field separator) when providing multiple configurations at a time, with this, to match, having output in commas may be easier since it makes user interface copy&paste easier)

If file has content like:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclNTWr
  LclSlowFill

What is impact of the following:
echo LclFill > info/L3_MON/counter_configs/mbm_local_bytes/event_filter

Is it (append):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill
  LclNTWr
  LclSlowFill
Quoted 7 lines

or (overwrite):

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill

I do think the interface will be more intuitive it if follows regular file operations wrt "append" and such. I have not looked into how kernfs supports "append".

Just searching quickly, I have not seen any append operations on kernfs.

Quoted 11 lines

As alternative, we can try to work the previous mbm_assign_control syntax in here (use + and -).

For example:

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclNTWr
# echo "+LclFill,-LclNTWr,+LclSlowFill" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
LclFill,LclSlowFill

With something like above resctrl just deals with file writes as before.

Or without complicating much we can just support basic operations.

# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill, LclNTWr, LclSlowFill
# echo "LclFill, LclNTWr, LclSlowFill, VictimBW" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill, LclNTWr, LclSlowFill, VictimBW
Quoted 7 lines
Quoted 5 lines
# echo "LclFill, LclNTWr" > info/L3_MON/counter_configs/mbm_local_bytes/event_filter
# cat info/L3_MON/counter_configs/mbm_local_bytes/event_filter
  LclFill, LclNTWr

Looks good to me. As I see it this could be expanded to support "append" if needed.

thanks.

Quoted 63 lines
Quoted 43 lines
Quoted 27 lines
Quoted 27 lines

4. As usual the events can be read from the mon_data directories. #mkdir /sys/fs/resctrl/test
    #cd   /sys/fs/resctr/test
    #cat  test/mon_data/mon_data/mon_L3_00/mbm_tota_bytes 101010
    #cat   test/mon_data/mon_data/mon_L3_00/mbm_local_bytes 32323

5. There will be 3 files created in each group's mon_data directory when ABMC is supported.

    a. test/mon_data/mon_L3_00/assign_exclusive
    b. test/mon_data/mon_L3_00/assign_shared
    c. test/mon_data/mon_L3_00/unassign

6. Events can be assigned/unassigned by these commands

  # echo mbm_total_bytes > test/mon_data/mon_L3_00/assign_exclusive
  # echo mbm_local_bytes > test/mon_data/mon_L3_01/assign_exclusive
  # echo mbm_local_bytes > test/mon_data/mon_L3_01/unassign
Quoted 7 lines
Quoted 3 lines

Note:
I feel 3 files are excessive here. We can probably achieve everything in just one file.

Could you please elaborate what your concern is? You mention that it is excessive but it is not clear to me what issues may arise by having three files instead of one.

All these 3 properties are mutually exclusive. Only one can true at a time. Example:
#cat assign_exclusive
0
#cat assign_shared
0
#cat uassigned
1

Quoted 1 line

Three operations to find out the assign state.

ah - good point.

Quoted 16 lines

Instead of that
#cat mon_l3_assignments
unassigned

Quoted 9 lines

I do think, and Peter also mentioned [1] this, that it may be useful, to "put a group/resource-scoped assign_* file higher in the hierarchy to make it easier for users who want to configure all domains the same for a group."

Placing *additional* files higher in hierarchy (used to manage counters in all domains) may be more useful that trying to provide the shared/exclusive/unassign in one file per domain.

Quoted 6 lines
Quoted 3 lines

Yea. To make it better we can add "mon_l3_assignments" in groups main directory. We can do all the operation in just one file.

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

I am hesitant to respond to that message considering the corporate preamble that sneaked in so I'll just add some thoughts here:

Yea. I noticed it later. Will take care next time.

Quoted 9 lines

Having the file higher in hierarchy does seem more useful. It may be useful to reduce amount of parsing to get to needed information. Compare with below two examples that can be used to convey the same information:

# cat /sys/fs/resctrl/test/mon_L3_assignments
mbm_total_bytes: 0=unassigned; 1=unassigned
mbm_local_bytes: 0=unassigned; 1=unassigned
Quoted 6 lines

#cat /sys/fs/resctrl/test/mon_L3_assignments
0=_; 1=_

We need to take care that it is always clear what "0" or "1" means ... Tony has been mentioning a lot of interesting things about scope changes. I assume the "L3" in mon_L3_assignments will dictate the scope?

I didnt think about the scope here. I was thinking of changing it to "mbm_assignments".

Quoted 19 lines

With a syntax like above the needed information can be presented in one line. For example,

#cat /sys/fs/resctrl/test/mon_L3_assignments
0=mbm_total_bytes; 1=mbm_local_bytes

The caveat is that is only for assigned counters, not shared, so this needs to change.

To support shared assignment ... I wonder if it will be useful to users to get the information on which other monitor groups the counter is shared _with_?

Some examples:

a) Just indicate whether a counter is shared or dedicated. (Introduce flags). #cat /sys/fs/resctrl/test/mon_L3_assignments
0=mbm_total_bytes:s; 1=mbm_local_bytes:d

Quoted 5 lines

b) Indicate which groups a counter is shared with:
#cat /sys/fs/resctrl/testA/mon_L3_assignments
0=mbm_total_bytes:s(testB); 1=mbm_local_bytes:d(not needed but perhaps empty for consistent interface?) #cat /sys/fs/resctrl/testB/mon_L3_assignments
0=mbm_total_bytes:s(testA); 1=mbm_local_bytes:d(?)

This format does not tell what is going on with all other domains. We need to display all the domains. I think that is important because users need to know what to expect reading the events on specific domains.

I think we need to convey all the following information to the user.

1. Event Configuation: What is event configuration applied here?

2. Domains: To which all the domains the configaration is applied? This is useful in multi-domain configuration.
We also need to know if which domains are assigned or unassigned.

3. Type of assignment: Exclusive(e or d) or Shared(s) or Unassigned(_)

4. Finally: Where to read the events?
This is important when we add "mkdir" support in the future,
mon_data/mon_l3_*/config_name will be created.

With that in mind this might be helpful.

# cat /sys/fs/resctrl/test/mon_L3_assignments
mbm_total_bytes: 0=e; 1=_
mbm_local_bytes: 0=_; 1=s

This format tells the user all the information. mbm_total_bytes and mbm_local_bytes configurations are applied and configuration are coming from counter_configs.

User can read the events in
mon_data/mon_L3_*/mbm_total_bytes
mon_data/mon_L3_*/mbm_local_bytes

mbm_total_bytes is assigned on domain 0 and not on domain 1. Reading the mbm_total_bytes on domain 1 will report "unassigned".

mbm_local_bytes is not assigned on domain 0 and assigned on domain 1. Reading the mbm_local_bytes on domain 0 will report "unassigned".

I dont have much information on shared assignment at this point. Dont know if we can display shared group.

Quoted 7 lines

... (b) may just be overkill and we should instead follow Tony's guideline (see https://lore.kernel.org/lkml/Z9CiwLrhuTODruCj@agluck-desk3/ ) that users should be able to keep track themselves.

Reinette

Signature · 2 lines
Thanks
Babu Moger
author reviewer
#196 lore raw
In reply to Reinette Chatre

Hi Reinette,

Quoted 63 lines · Reinette Chatre

Hi Babu and Peter,

Quoted 52 lines · Babu

Hi Peter,

Quoted 49 lines · Peter Newman

Hi Reinette,

Quoted 31 lines · Reinette Chatre

Hi Babu,

Quoted 9 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Babu
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Babu

On 3/12/25 10:07, Reinette Chatre wrote:

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Thank you very much for detailing the steps. It is starting the fall into place for me.

Quoted 4 lines

1. Mount the resctrl
    mount -t resctrl resctrl /sys/fs/resctrl

I assume that on ABMC system the plan remains to have ABMC enabled by default, which will continue to depend on BMEC.

How would the k existing BMEC implementation be impacted in this case?

Without any changes to BMEC support the mbm_total_bytes_config and mbm_local_bytes_config files will remain and user space may continue to use them to change the event configurations with confusing expecations/results on an ABMC system.

Quoted 8 lines

One possibility may be that a user may see below on ABMC system even if BMEC is supported:

# cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes

With the above a user cannot be expected to want to interact with mbm_total_bytes_config and mbm_local_bytes_config, which may be the simplest to do.

How about making mbm_local_bytes and mbm_total_bytes always be configured using mbm_{local,total}_bytes_config and only allowing the full ABMC configurability on user-defined configurations. This could resolve the issue of backwards compatibility with the BMEC files and remove the need for the user opting-in to ABMC mode.

hmmm, yes, backward compatibility is a big issue with an earlier suggestion from me. Users with scripts/tools using mbm_{local,total}_bytes_config would expect that to continue to work on systems that support BMEC. resctrl could continue to use mbm_{local,total}_bytes_config even though the inconsistent interface is not ideal

Quoted 1 line
Quoted 5 lines
Quoted 2 lines

There is no opt-in mode. ABMC will be enabled by default if supported. Users will have option to go back to legacy mode.

I assume there will still be the opt-in for automatic counter assignment on monitor group creation (mkdir)?

Yes. It will be available.

Signature · 2 lines
Thanks
Babu Moger
maintainer
#191 lore raw
In reply to Moger, Babu

Hi Babu,

Quoted 34 lines · Babu

Hi Reinette,

Quoted 23 lines · Reinette Chatre

Hi Babu,

Quoted 20 lines · Babu
Quoted 19 lines · Reinette Chatre
Quoted 9 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Babu
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Babu

On 3/12/25 10:07, Reinette Chatre wrote:

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Thank you very much for detailing the steps. It is starting the fall into place for me.

Quoted 4 lines

1. Mount the resctrl
    mount -t resctrl resctrl /sys/fs/resctrl

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I assume that on ABMC system the plan remains to have ABMC enabled by default, which will continue to depend on BMEC.

Yes. ABMC will be enabled by default. ABMC will use the configurations from info/L3_MON/counter_configs. ABMC will not depend on BMEC.

I see. The previous dependency was thus just something enforced by OS to support the chosen implementation?

Quoted 6 lines

Yes. That is correct. We went that route mainly not to change the rmid_read operation.

With ABMC, we need to set Extended EVTID and ABMC bit in QM_EVTSEL register while reading the cntr_id events. Will add those patches in next version to make it clear.

Thank you.

Quoted 11 lines
Quoted 9 lines

Looks like the two features share some registers.

Quoted 4 lines
Quoted 2 lines

How would the existing BMEC implementation be impacted in this case?

BMEC will only work with pre-ABMC(or default) mode.

ok. Does this mean that if a user boots kernel with "rdt=!bmec" then ABMC will keep working?

Yes. That is correct.

Just to confirm and bring the two email threads together ... it sounds like the expectation is that existing users of BMEC are expected to use mon_features to know if mbm_{total,local}_bytes_config are supported. If system supports ABMC then BMEC will not be available and thus mon_features will not contain mbm_{total,local}_bytes_config. Existing users that rely on mbm_{total,local}_bytes_config will experience failures and are expected to switch to ABMC?

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 7 lines

Without any changes to BMEC support the mbm_total_bytes_config and mbm_local_bytes_config files will remain and user space may continue to use them to change the event configurations with confusing expecations/results on an ABMC system.

Quoted 8 lines

One possibility may be that a user may see below on ABMC system even if BMEC is supported:

# cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes

With the above a user cannot be expected to want to interact with mbm_total_bytes_config and mbm_local_bytes_config, which may be the simplest to do.

yes.

...

Quoted 31 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

I do think, and Peter also mentioned [1] this, that it may be useful, to "put a group/resource-scoped assign_* file higher in the hierarchy to make it easier for users who want to configure all domains the same for a group."

Placing *additional* files higher in hierarchy (used to manage counters in all domains) may be more useful that trying to provide the shared/exclusive/unassign in one file per domain.

Quoted 6 lines
Quoted 3 lines

Yea. To make it better we can add "mon_l3_assignments" in groups main directory. We can do all the operation in just one file.

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

I am hesitant to respond to that message considering the corporate preamble that sneaked in so I'll just add some thoughts here:

Yea. I noticed it later. Will take care next time.

Quoted 12 lines

Having the file higher in hierarchy does seem more useful. It may be useful to reduce amount of parsing to get to needed information. Compare with below two examples that can be used to convey the same information:

# cat /sys/fs/resctrl/test/mon_L3_assignments
mbm_total_bytes: 0=unassigned; 1=unassigned
mbm_local_bytes: 0=unassigned; 1=unassigned

#cat /sys/fs/resctrl/test/mon_L3_assignments
0=_; 1=_

Quoted 6 lines
Quoted 3 lines

We need to take care that it is always clear what "0" or "1" means ... Tony has been mentioning a lot of interesting things about scope changes. I assume the "L3" in mon_L3_assignments will dictate the scope?

I didnt think about the scope here. I was thinking of changing it to "mbm_assignments".

ah, I see, not a general "monitoring" file but specific to MBM. This still may encounter difficulty if AMD does something like SNC where MBM could be done per numa node. Perhaps we could constrain this even more with a "mbm_L3_assignments". If anything ever shows up that need to do MBM counter assignment at some other scope then at least we have the option to create another file "mbm_?_assignments".

Quoted 59 lines
Quoted 20 lines

With a syntax like above the needed information can be presented in one line. For example,

#cat /sys/fs/resctrl/test/mon_L3_assignments
0=mbm_total_bytes; 1=mbm_local_bytes

The caveat is that is only for assigned counters, not shared, so this needs to change.

To support shared assignment ... I wonder if it will be useful to users to get the information on which other monitor groups the counter is shared _with_?

Some examples:

a) Just indicate whether a counter is shared or dedicated. (Introduce flags). #cat /sys/fs/resctrl/test/mon_L3_assignments
0=mbm_total_bytes:s; 1=mbm_local_bytes:d

Quoted 5 lines

b) Indicate which groups a counter is shared with:
#cat /sys/fs/resctrl/testA/mon_L3_assignments
0=mbm_total_bytes:s(testB); 1=mbm_local_bytes:d(not needed but perhaps empty for consistent interface?) #cat /sys/fs/resctrl/testB/mon_L3_assignments
0=mbm_total_bytes:s(testA); 1=mbm_local_bytes:d(?)

This format does not tell what is going on with all other domains. We need to display all the domains. I think that is important because users need to know what to expect reading the events on specific domains.

I think we need to convey all the following information to the user.

1. Event Configuation: What is event configuration applied here?

2. Domains: To which all the domains the configaration is applied? This is useful in multi-domain configuration.
We also need to know if which domains are assigned or unassigned.

3. Type of assignment: Exclusive(e or d) or Shared(s) or Unassigned(_)

4. Finally: Where to read the events?
This is important when we add "mkdir" support in the future,
mon_data/mon_l3_*/config_name will be created.

With that in mind this might be helpful.

# cat /sys/fs/resctrl/test/mon_L3_assignments
mbm_total_bytes: 0=e; 1=_
mbm_local_bytes: 0=_; 1=s

This format tells the user all the information. mbm_total_bytes and mbm_local_bytes configurations are applied and configuration are coming from counter_configs.

User can read the events in
mon_data/mon_L3_*/mbm_total_bytes
mon_data/mon_L3_*/mbm_local_bytes

Quoted 5 lines

mbm_total_bytes is assigned on domain 0 and not on domain 1. Reading the mbm_total_bytes on domain 1 will report "unassigned".

mbm_local_bytes is not assigned on domain 0 and assigned on domain 1. Reading the mbm_local_bytes on domain 0 will report "unassigned".

Thank you very much for spelling it out. Much appreciated. This looks good to me. Please include your list of requirements for interface in the cover-letter and/or patch that introduces the interface.

Quoted 3 lines

I dont have much information on shared assignment at this point. Dont know if we can display shared group.

The proposed interface accommodates shared counters. The expectation is that users can keep track themselves and if not, then the information can be obtained with a read of every group's counter assignment. The issue here is that this may worst case need a large number of file operations if expectation is that it will still be possible to create num RMID monitoring groups.

Using files inside monitor group for this information may actually not be ideal.
If this information is needed then we could perhaps add a new file. For
example:
/sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes/<file reporting which monitor groups share this counter configuration in different domains> Of course, I do not know if this will be required and this seems manageable as
a later enhancement if needed.

Quoted 9 lines
Quoted 8 lines

... (b) may just be overkill and we should instead follow Tony's guideline (see https://lore.kernel.org/lkml/Z9CiwLrhuTODruCj@agluck-desk3/ ) that users should be able to keep track themselves.

Reinette

Reinette

#192 lore raw

Hi Reinette,

Quoted 58 lines · Reinette Chatre

Hi Babu,

Quoted 34 lines · Babu

Hi Reinette,

Quoted 23 lines · Reinette Chatre

Hi Babu,

Quoted 20 lines · Babu
Quoted 19 lines · Reinette Chatre
Quoted 9 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Babu
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Babu

On 3/12/25 10:07, Reinette Chatre wrote:

Here are the steps. Just copying steps from Peters proposal.
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/

Thank you very much for detailing the steps. It is starting the fall into place for me.

Quoted 4 lines

1. Mount the resctrl
    mount -t resctrl resctrl /sys/fs/resctrl

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I assume that on ABMC system the plan remains to have ABMC enabled by default, which will continue to depend on BMEC.

Yes. ABMC will be enabled by default. ABMC will use the configurations from info/L3_MON/counter_configs. ABMC will not depend on BMEC.

I see. The previous dependency was thus just something enforced by OS to support the chosen implementation?

Quoted 6 lines

Yes. That is correct. We went that route mainly not to change the rmid_read operation.

With ABMC, we need to set Extended EVTID and ABMC bit in QM_EVTSEL register while reading the cntr_id events. Will add those patches in next version to make it clear.

Thank you.

Quoted 11 lines
Quoted 9 lines

Looks like the two features share some registers.

Quoted 4 lines
Quoted 2 lines

How would the existing BMEC implementation be impacted in this case?

BMEC will only work with pre-ABMC(or default) mode.

ok. Does this mean that if a user boots kernel with "rdt=!bmec" then ABMC will keep working?

Yes. That is correct.

Quoted 7 lines

Just to confirm and bring the two email threads together ... it sounds like the expectation is that existing users of BMEC are expected to use mon_features to know if mbm_{total,local}_bytes_config are supported. If system supports ABMC then BMEC will not be available and thus mon_features will not contain mbm_{total,local}_bytes_config. Existing users that rely on mbm_{total,local}_bytes_config will experience failures and are expected to switch to ABMC?

Yes. Exactly.

Quoted 61 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 9 lines

Without any changes to BMEC support the mbm_total_bytes_config and mbm_local_bytes_config files will remain and user space may continue to use them to change the event configurations with confusing expecations/results on an ABMC system.

Quoted 8 lines

One possibility may be that a user may see below on ABMC system even if BMEC is supported:

# cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes

With the above a user cannot be expected to want to interact with mbm_total_bytes_config and mbm_local_bytes_config, which may be the simplest to do.

yes.

...

Quoted 31 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

I do think, and Peter also mentioned [1] this, that it may be useful, to "put a group/resource-scoped assign_* file higher in the hierarchy to make it easier for users who want to configure all domains the same for a group."

Placing *additional* files higher in hierarchy (used to manage counters in all domains) may be more useful that trying to provide the shared/exclusive/unassign in one file per domain.

Quoted 6 lines
Quoted 3 lines

Yea. To make it better we can add "mon_l3_assignments" in groups main directory. We can do all the operation in just one file.

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

I am hesitant to respond to that message considering the corporate preamble that sneaked in so I'll just add some thoughts here:

Yea. I noticed it later. Will take care next time.

Quoted 12 lines

Having the file higher in hierarchy does seem more useful. It may be useful to reduce amount of parsing to get to needed information. Compare with below two examples that can be used to convey the same information:

# cat /sys/fs/resctrl/test/mon_L3_assignments
mbm_total_bytes: 0=unassigned; 1=unassigned
mbm_local_bytes: 0=unassigned; 1=unassigned

#cat /sys/fs/resctrl/test/mon_L3_assignments
0=_; 1=_

Quoted 6 lines
Quoted 3 lines

We need to take care that it is always clear what "0" or "1" means ... Tony has been mentioning a lot of interesting things about scope changes. I assume the "L3" in mon_L3_assignments will dictate the scope?

I didnt think about the scope here. I was thinking of changing it to "mbm_assignments".

Quoted 6 lines

ah, I see, not a general "monitoring" file but specific to MBM. This still may encounter difficulty if AMD does something like SNC where MBM could be done per numa node. Perhaps we could constrain this even more with a "mbm_L3_assignments". If anything ever shows up that need to do MBM counter assignment at some other scope then at least we have the option to create another file "mbm_?_assignments".

Yes. Sounds good to me.

Quoted 63 lines
Quoted 63 lines
Quoted 21 lines

With a syntax like above the needed information can be presented in one line. For example,

#cat /sys/fs/resctrl/test/mon_L3_assignments
0=mbm_total_bytes; 1=mbm_local_bytes

The caveat is that is only for assigned counters, not shared, so this needs to change.

To support shared assignment ... I wonder if it will be useful to users to get the information on which other monitor groups the counter is shared _with_?

Some examples:

a) Just indicate whether a counter is shared or dedicated. (Introduce flags). #cat /sys/fs/resctrl/test/mon_L3_assignments
0=mbm_total_bytes:s; 1=mbm_local_bytes:d

Quoted 5 lines

b) Indicate which groups a counter is shared with:
#cat /sys/fs/resctrl/testA/mon_L3_assignments
0=mbm_total_bytes:s(testB); 1=mbm_local_bytes:d(not needed but perhaps empty for consistent interface?) #cat /sys/fs/resctrl/testB/mon_L3_assignments
0=mbm_total_bytes:s(testA); 1=mbm_local_bytes:d(?)

This format does not tell what is going on with all other domains. We need to display all the domains. I think that is important because users need to know what to expect reading the events on specific domains.

I think we need to convey all the following information to the user.

1. Event Configuation: What is event configuration applied here?

2. Domains: To which all the domains the configaration is applied? This is useful in multi-domain configuration.
We also need to know if which domains are assigned or unassigned.

3. Type of assignment: Exclusive(e or d) or Shared(s) or Unassigned(_)

4. Finally: Where to read the events?
This is important when we add "mkdir" support in the future,
mon_data/mon_l3_*/config_name will be created.

With that in mind this might be helpful.

# cat /sys/fs/resctrl/test/mon_L3_assignments
mbm_total_bytes: 0=e; 1=_
mbm_local_bytes: 0=_; 1=s

This format tells the user all the information. mbm_total_bytes and mbm_local_bytes configurations are applied and configuration are coming from counter_configs.

User can read the events in
mon_data/mon_L3_*/mbm_total_bytes
mon_data/mon_L3_*/mbm_local_bytes

mbm_total_bytes is assigned on domain 0 and not on domain 1. Reading the mbm_total_bytes on domain 1 will report "unassigned".

Quoted 6 lines
Quoted 2 lines

mbm_local_bytes is not assigned on domain 0 and assigned on domain 1. Reading the mbm_local_bytes on domain 0 will report "unassigned".

Thank you very much for spelling it out. Much appreciated. This looks good to me. Please include your list of requirements for interface in the cover-letter and/or patch that introduces the interface.

Sure. Will do.

Quoted 11 lines
Quoted 4 lines

I dont have much information on shared assignment at this point. Dont know if we can display shared group.

The proposed interface accommodates shared counters. The expectation is that users can keep track themselves and if not, then the information can be obtained with a read of every group's counter assignment. The issue here is that this may worst case need a large number of file operations if expectation is that it will still be possible to create num RMID monitoring groups.

Quoted 7 lines

Using files inside monitor group for this information may actually not be ideal.
If this information is needed then we could perhaps add a new file. For
example:
/sys/fs/resctrl/info/L3_MON/counter_configs/mbm_total_bytes/<file reporting which monitor groups share this counter configuration in different domains> Of course, I do not know if this will be required and this seems manageable as
a later enhancement if needed.

Yes. It can be done this way.

Thanks
Babu