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 2 of 3

Subsystems (3)

v11 of 18 Superseded Latest is v18 →

lore
Share & tools
lore
maintainer
#158 lore raw
In reply to Peter Newman

Hi Peter,

Quoted 120 lines · Peter Newman

Hi Reinette,

Quoted 104 lines · Reinette Chatre

Hi Peter,

Quoted 69 lines · Peter Newman

Hi Reinette,

Quoted 54 lines · Reinette Chatre

Hi Peter,

Quoted 41 lines · Peter Newman

Hi Reinette,

Quoted 29 lines · Reinette Chatre

Hi Babu,

Quoted 5 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Dave Martin
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Dave Martin

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)

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

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>
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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?

Quoted 51 lines
Quoted 37 lines

Until now I viewed counter configuration separate from counter assignment, similar to how AMD's counters can be configured via mbm_total_bytes_config and mbm_local_bytes_config before they are assigned. That is still per-domain counter configuration though, not per-counter.

Quoted 13 lines

I assume packing all of this info for a group's desired counter configuration into a single line (with 32 domains per line on many dual-socket AMD configurations I see) would be difficult to look at, even if we could settle on a single letter to represent each universally.

Quoted 7 lines

My goal is for resctrl to have a user interface that can as much as possible be ready for whatever may be required from it years down the line. Of course, I may be wrong and resctrl would never need to support more than 26 events per resource (*). The risk is that resctrl *may* need to support more than 26 events and how could resctrl support that?

Quoted 8 lines
Quoted 5 lines

What is the risk of supporting more than 26 events? As I highlighted earlier the interface I used as demonstration may become unwieldy to parse on a system with many domains that supports many events. This is a concern for me. Any suggestions will be appreciated, especially from you since I know that you are very familiar with issues related to large scale use of resctrl interfaces.

It's mainly just the unwieldiness of all the information in one file. It's already at the limit of what I can visually look through.

I agree.

Quoted 7 lines

I believe that shared assignments will take care of all the high-frequency and performance-intensive batch configuration updates I was originally concerned about, so I no longer see much benefit in finding ways to textually encode all this information in a single file when it would be more manageable to distribute it around the filesystem hierarchy.

Quoted 6 lines

This is significant. The motivation for the single file was to support the "high-frequency and performance-intensive" usage. Would "shared assignments" not also depend on the same files that, if distributed, will require many filesystem operations?
Having the files distributed will be significantly simpler while also avoiding the file size issue that Dave Martin exposed.

The remaining filesystem operations will be assigning or removing shared counter assignments in the applicable domains, which would normally correspond to mkdir/rmdir of groups or changing their CPU affinity. The shared assignments are more "program and forget", while the exclusive assignment approach requires updates for every counter (in every domain) every few seconds to cover a large number of groups.

Quoted 3 lines

When they want to pay extra attention to a particular group, I expect they'll ask for exclusive counters and leave them assigned for a while as they collect extra data.

The single file approach is already unwieldy. The demands that will be placed on it to support the usages currently being discussed would make this interface even harder to use and manage. If the single file is not required then I think we should go back to smaller files distributed in resctrl. This may not even be an either/or argument. One way to view mbm_assign_control could be as a way for user to interact with the distributed counter related files with a single file system operation. Although, without knowing how counter configuration is expected to work this remains unclear.

Reinette

maintainer
#200 lore raw
In reply to Dave Martin

Hi Dave,

Quoted 101 lines · Dave Martin

Hi again,

Quoted 51 lines · Dave Martin

Hi,

Quoted 3 lines · Reinette Chatre

Hi Peter,

On 2/19/25 3:28 AM, Peter Newman wrote:

[...]

Quoted 27 lines
Quoted 12 lines

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)

Quoted 9 lines

(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?

Quoted 4 lines

Until now I viewed counter configuration separate from counter assignment, similar to how AMD's counters can be configured via mbm_total_bytes_config and mbm_local_bytes_config before they are assigned. That is still per-domain counter configuration though, not per-counter.

I hadn't tried to work the design through in any detail: it wasn't intended as a suggestion for something we should definitely do right now; rather, it was just an incomplete sketch of one possible future evolution of the interface.

Either way these feel like future concerns, if the first iteration of ABMC is just to provide the basics so that ABMC hardware can implement resctrl without userspace seeing counters randomly stopping and resetting...

Quoted 10 lines

Peter, can you give a view on whether the ABMC as proposed in this series is a useful stepping-stone? Or are there things that you need that you feel could not be added as a later extension without ABI breakage?

[...]

Quoted 4 lines
Quoted 4 lines

I believe that shared assignments will take care of all the high-frequency and performance-intensive batch configuration updates I was originally concerned about, so I no longer see much benefit in finding ways to textually encode all this information in a single file

jjjk> > > when it would be more manageable to distribute it around the

Quoted 9 lines
Quoted 9 lines
Quoted 1 line

filesystem hierarchy.

This is significant. The motivation for the single file was to support the "high-frequency and performance-intensive" usage. Would "shared assignments" not also depend on the same files that, if distributed, will require many filesystem operations?
Having the files distributed will be significantly simpler while also avoiding the file size issue that Dave Martin exposed.

Quoted 4 lines
Quoted 1 line

Reinette

I still haven't fully understood the "shared assignments" proposal; I need to go back and look at it.

Having taken a quick look at that now, this all seems to duplicate perf's design journey (again).

"rate" events make some sense. The perf equivalent is to keep an accumulated count of the amount of time a counter has been assigned to an event, and another accumulated count of the events counted by the counter during assignment. Only userspace knows what it wants to do with this information: perf exposes the raw accumulated counts.

Perf events can be also pinned so that they are prioritised for assignment to counters; that sounds a lot like the regular, non-shared resctrl counters.

Playing devil's advocate:

It does feel like we are doomed to reinvent perf if we go too far down this road...

Quoted 3 lines

If we split the file, it will be more closely aligned with the design of the rest of the resctrlfs interface.

Quoted 8 lines
Quoted 5 lines

OTOH, the current interface seems workable and I think the file size issue can be addressed without major re-engineering.

So, from my side, I would not consider the current interface design a blocker.

...so, drawing a hard line around the use cases that we intend to address with this interface and avoiding feature creep seems desirable.

This is exactly what I am trying to do ... to understand what use cases the interface is expected to support.

You have mentioned a couple of times now that this interface is sufficient but at the same time you hinted at some features from MPAM that I do not see possible to accommodate with this interface.

Quoted 7 lines

resctrlfs is already in the wild, so providing reasonable baseline compatiblity with that interface for ABMC hardware is a sensible goal. The current series does that.

But I wonder how much additional functionality we should really be adding via the mbm_assign_control interface, once this series is settled.

Are you speculating that MPAM counters may not make use of this interface?

Reinette

author reviewer
#121 lore raw

Re: [PATCH v11 23/23] x86/resctrl: Introduce interface to modify assignment states of the groups

In reply to Dave Martin

Hi Dave,

Quoted 105 lines · Dave Martin

Hi,

Quoted 20 lines · Babu

Hi Dave,

Quoted 17 lines · Dave Martin

Hi,

On Wed, Jan 22, 2025 at 02:20:31PM -0600, Babu Moger wrote:

[...]

Quoted 5 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -0
index 6e29827239e0..299839bcf23f 100644
@@ -1050,6 +1050,244 @@ static int resctrl_mbm_assign_control_show(struct kernfs_open_file *of,

[...]

Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3 -0
+static ssize_t resctrl_mbm_assign_control_write(struct kernfs_open_file *of,
+						char *buf, size_t nbytes, loff_t off)
+{

[...]

Quoted 51 lines
Quoted 42 lines

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +8 -0
+	while ((token = strsep(&buf, "\n")) != NULL) {
+		/*
+		 * The write command follows the following format:
+		 * “<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>”
+		 * Extract the CTRL_MON group.
+		 */
+		cmon_grp = strsep(&token, "/");
+

As when reading this file, I think that the data can grow larger than a page and get split into multiple write() calls.

I don't currently think the file needs to be redesigned, but there are some concerns about how userspace will work with it that need to be sorted out.

Every monitoring group can contribute a line to this file:

	CTRL_GROUP / MON_GROUP / DOMAIN = [t][l] [ ; DOMAIN = [t][l] ]* LF

so, 2 * (NAME_MAX + 1) + NUM_DOMAINS * 5 - 1 + 1

NAME_MAX on Linux is 255, so with, say, up to 16 domains, that's about 600 bytes per monitoring group in the worst case.

We don't need to have many control and monitoring groups for this to grow potentially over 4K.

We could simply place a limit on how much userspace is allowed to write to this file in one go, although this restriction feels difficult for userspace to follow -- but maybe this is workable in the short term, on current systems (?)

Otherwise, since we expect this interface to be written using scripting languages, I think we need to be prepared to accept fully-buffered I/O. That means that the data may be cut at random places, not necessarily at newlines. (For smaller files such as schemata this is not such an issue, since the whole file is likely to be small enough to fit into the default stdio buffers -- this is how sysfs gets away with it IIUC.)

Quoted 8 lines

For fully-buffered I/O, we may have to cache an incomplete line in between write() calls. If there is a dangling incomplete line when the file is closed then it is hard to tell userspace, because people often don't bother to check the return value of close(), fclose() etc. However, since it's an ABI violation for userspace to end this file with a partial line, I think it's sufficient to report that via last_cmd_status. (Making close() return -EIO still seems a good idea though, just in case userspace is listening.)

Quoted 2 lines

Seems like we can add a check in resctrl_mbm_assign_control_write() to compare nbytes > PAGE_SIZE.

This might be a reasonable stopgap approach, if we are confident that the number of RMIDs and monitoring domains is small enough on known platforms that the problem is unlikely to be hit. I can't really judge on this.

Quoted 2 lines

But do we really need this? I have no way of testing this. Help me understand.

It's easy to demonatrate this using the schemata file (which works in a similar way). Open f in /sys/fs/resctrl/schemata, then:

	int n = 0;

	for (n = 0; n < 1000; n++)
		if (fputs("MB:0=100;1=100\n", f) == EOF)
			fprintf(stderr, "Failed on interation %d\n", n);

This will succeed a certain number of times (272, for me) and then fail when the stdio buffer for f overflows, triggering a write().

Putting an explicit fflush() after every fputs() call (or doing a setlinebuf(f) before the loop) makes it work. But this is awkward and unexpected for the user, and doing the right thing from a scripting language may be tricky.

Quoted 8 lines

In this example I am doing something a bit artificial -- we don't officially say what happens when a pre-opened schemata file handle is reused in this way, AFAICT. But for mbm_assign_control it is legitimate to write many lines, and we can hit this kind of problem.

I'll leave it to others to judge whether we _need_ to fix this, but it feels like a problem waiting to happen.

Created the problem using this code using a "test" group.

include <stdio.h>
#include <errno.h>
#include <string.h>

int main()

{
        FILE *file;
        int n;

        file = fopen("/sys/fs/resctrl/info/L3_MON/mbm_assign_control", "w");

        if (file == NULL) {
                printf("Error opening file!\n");
                return 1;
        }

        printf("File opened successfully.\n");

        for (n = 0; n < 100; n++)
                if

(fputs("test//0=tl;1=tl;2=tl;3=tl;4=tl;5=tl;9=tl;10=tl;11=tl\n", file) == EOF)
fprintf(stderr, "Failed on interation %d error
%s\n ", n, strerror(errno));

        if (fclose(file) == 0) {
                printf("File closed successfully.\n");
        } else {
                printf("Error closing file!\n");
        }
}

When the buffer overflow happens the newline will not be there. I have added this error via rdt_last_cmd_puts. At least user knows there is an error.

(quoted diff) +0 -0

b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 484d6009869f..70a96976e3ab 100644

arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -0
@@ -1250,8 +1252,10 @@ static ssize_t

resctrl_mbm_assign_control_write(struct kernfs_open_file *of,

        int ret;

        /* Valid input requires a trailing newline */
-       if (nbytes == 0 || buf[nbytes - 1] != '\n')
+       if (nbytes == 0 || buf[nbytes - 1] != '\n') {
+               rdt_last_cmd_puts("mbm_cntr_assign: buffer invalid\n");
                return -EINVAL;

+ }

        buf[nbytes - 1] = '\0';

I am open to other ideas to handle this case.

Quoted 23 lines
Quoted 4 lines

All these file operations go thru generic call kernfs_fop_write_iter(). Doesn't it take care of buffer check and overflow?

No, this is called for each iovec segment (where userspace used one of the iovec based I/O syscalls). But there is no buffering or concatenation of the data read in: each segment gets passed down to the individual kernfs_file_operations write method for the file:

	len = ops->write(of, buf, len, iocb->ki_pos)

calls down to

	resctrl_mbm_assign_control_write(of, buf, len, iocb->ki_pos).

I'll try to port my buffering hack on top of the series -- that should help to illustrate what I mean.

Cheers
---Dave

Signature · 2 lines
Thanks
Babu Moger
author reviewer
#105 lore raw

Re: [PATCH v11 22/23] x86/resctrl: Introduce interface to list assignment states of all the groups

In reply to Dave Martin

Hi Dave,

Quoted 45 lines · Dave Martin

Hi,

Quoted 6 lines · Babu

Hi Dave,

Quoted 3 lines · Dave Martin
Quoted 2 lines · Babu Moger

Provide the interface to list the assignment states of all the resctrl groups in mbm_cntr_assign mode.

[...]

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
(quoted diff) +3 -0
+static int resctrl_mbm_assign_control_show(struct kernfs_open_file *of,
+					   struct seq_file *s, void *v)
+{

[...]

Quoted 19 lines
Quoted 12 lines

Unlike the other resctrl files, it looks like the total size of this data will scale up with the number of existing monitoring groups and the lengths of the group names (in addition to the number of monitoring domains).

So, this can easily be more than a page, overflowing internal limits in the seq_file and kernfs code.

Do we need to track some state between read() calls? This can be done by overriding the kernfs .open() and .release() methods and hanging some state data (or an rdtgroup_file pointer) on of->priv.

Quoted 6 lines

Also, if we allow the data to be read out in chunks, then we would either have to snapshot all the data in one go and stash the unread tail in the kernel, or we would need to move over to RCU-based enumeration or similar -- otherwise releasing rdtgroup_mutex in the middle of the enumeration in order to return data to userspace is going to be a problem...

Quoted 7 lines

Good catch.

I see similar buffer overflow is handled by calling seq_buf_clear() (look at process_durations() or in show_user_instructions()).

How about handling this by calling rdt_last_cmd_clear() before printing each group?

Quoted 7 lines

Does this work?

Once seq_buf_has_overflowed() returns nonzero, data has been lost, no? So far as I can see, show_user_instructions() just gives up on printing the affected line, while process_durations() tries to anticipate overflow and prints out the accumulated text to dmesg before clearing the buffer.

Yea. Agree,

Quoted 5 lines

In our case, we cannot send more data to userspace than was requested in the read() call, so we might have nowhere to drain the seq_buf contents to in order to free up space.

Quoted 8 lines

sysfs "expects" userspace to do a big enough read() that this problem doesn't happen. In practice this is OK because people usually read through a buffered I/O layer like stdio, and in realistic implementations the user-side I/O buffer is large enough to hide this issue.

But mbm_assign_control data is dynamically generated and potentially much bigger than a typical sysfs file.

I have no idea how to handle this case. We may have to live with this problem. Let us know if there are any ideas.

Quoted 20 lines
Quoted 20 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -0
index 484d6009869f..1828f59eb723 100644
@@ -1026,6 +1026,7 @@ static int resctrl_mbm_assign_control_show(struct
 kernfs_open_file *of,
        }
 
        list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) {
+               rdt_last_cmd_clear();
                seq_printf(s, "%s//", rdtg->kn->name);
 
                sep = false;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -0
@@ -1041,6 +1042,7 @@ static int resctrl_mbm_assign_control_show(struct
 kernfs_open_file *of,
                seq_putc(s, '\n');
 
Quoted 7 lines

arch/x86/kernel/cpu/resctrl/rdtgroup.c static int resctrl_mbm_assign_control_show(struct · line 1047

Quoted 3 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -0
                list_for_each_entry(crg, &rdtg->mon.crdtgrp_list,
 mon.crdtgrp_list) {
+                       rdt_last_cmd_clear();

I don't see how this helps.

Surely last_cmd_status has nothing to do with s?

Correct. Clearly, I misunderstood the problem.

Quoted 6 lines

[...]

Cheers
---Dave

Signature · 2 lines
Thanks
Babu Moger
#159 lore raw
In reply to Reinette Chatre

Hi Reinette,

Quoted 196 lines · Reinette Chatre

Hi Peter,

Quoted 120 lines · Peter Newman

Hi Reinette,

Quoted 104 lines · Reinette Chatre

Hi Peter,

Quoted 69 lines · Peter Newman

Hi Reinette,

Quoted 54 lines · Reinette Chatre

Hi Peter,

Quoted 41 lines · Peter Newman

Hi Reinette,

Quoted 29 lines · Reinette Chatre

Hi Babu,

Quoted 5 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Dave Martin
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Dave Martin

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)

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

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>
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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.

Quoted 56 lines
Quoted 52 lines
Quoted 38 lines

Until now I viewed counter configuration separate from counter assignment, similar to how AMD's counters can be configured via mbm_total_bytes_config and mbm_local_bytes_config before they are assigned. That is still per-domain counter configuration though, not per-counter.

Quoted 13 lines

I assume packing all of this info for a group's desired counter configuration into a single line (with 32 domains per line on many dual-socket AMD configurations I see) would be difficult to look at, even if we could settle on a single letter to represent each universally.

Quoted 7 lines

My goal is for resctrl to have a user interface that can as much as possible be ready for whatever may be required from it years down the line. Of course, I may be wrong and resctrl would never need to support more than 26 events per resource (*). The risk is that resctrl *may* need to support more than 26 events and how could resctrl support that?

Quoted 8 lines
Quoted 5 lines

What is the risk of supporting more than 26 events? As I highlighted earlier the interface I used as demonstration may become unwieldy to parse on a system with many domains that supports many events. This is a concern for me. Any suggestions will be appreciated, especially from you since I know that you are very familiar with issues related to large scale use of resctrl interfaces.

It's mainly just the unwieldiness of all the information in one file. It's already at the limit of what I can visually look through.

I agree.

Quoted 7 lines

I believe that shared assignments will take care of all the high-frequency and performance-intensive batch configuration updates I was originally concerned about, so I no longer see much benefit in finding ways to textually encode all this information in a single file when it would be more manageable to distribute it around the filesystem hierarchy.

Quoted 6 lines

This is significant. The motivation for the single file was to support the "high-frequency and performance-intensive" usage. Would "shared assignments" not also depend on the same files that, if distributed, will require many filesystem operations?
Having the files distributed will be significantly simpler while also avoiding the file size issue that Dave Martin exposed.

The remaining filesystem operations will be assigning or removing shared counter assignments in the applicable domains, which would normally correspond to mkdir/rmdir of groups or changing their CPU affinity. The shared assignments are more "program and forget", while the exclusive assignment approach requires updates for every counter (in every domain) every few seconds to cover a large number of groups.

Quoted 3 lines

When they want to pay extra attention to a particular group, I expect they'll ask for exclusive counters and leave them assigned for a while as they collect extra data.

Quoted 8 lines

The single file approach is already unwieldy. The demands that will be placed on it to support the usages currently being discussed would make this interface even harder to use and manage. If the single file is not required then I think we should go back to smaller files distributed in resctrl. This may not even be an either/or argument. One way to view mbm_assign_control could be as a way for user to interact with the distributed counter related files with a single file system operation. Although, without knowing how counter configuration is expected to work this remains unclear.

If we do both interfaces and the multi-file model gives us more capability to express configurations, we could find situations where there are configurations we cannot represent when reading back from mbm_assign_control, or updates through mbm_assign_control have ambiguous effects on existing configurations which were created with other files.

However, the example I gave above seems to be adequately represented by a minor extension to mbm_assign_control and we all seem to understand it now, so maybe it's not broken yet. It's unfortunate that work went into a requirement that's no longer relevant, but I don't think that on its own is a blocker.

-Peter

reviewer
#122 lore raw

Re: [PATCH v11 23/23] x86/resctrl: Introduce interface to modify assignment states of the groups

In reply to Moger, Babu

Hi,

Quoted 1 line · Babu

Hi Dave,

[...]

Quoted 26 lines

Created the problem using this code using a "test" group.

include <stdio.h>
#include <errno.h>
#include <string.h>

int main()

{
        FILE *file;
        int n;

        file = fopen("/sys/fs/resctrl/info/L3_MON/mbm_assign_control", "w");

        if (file == NULL) {
                printf("Error opening file!\n");
                return 1;
        }

        printf("File opened successfully.\n");

        for (n = 0; n < 100; n++)
                if

(fputs("test//0=tl;1=tl;2=tl;3=tl;4=tl;5=tl;9=tl;10=tl;11=tl\n", file) == EOF)
fprintf(stderr, "Failed on interation %d error
%s\n ", n, strerror(errno));

Quoted 6 lines
        if (fclose(file) == 0) {
                printf("File closed successfully.\n");
        } else {
                printf("Error closing file!\n");
        }
}

Right.

Quoted 23 lines

When the buffer overflow happens the newline will not be there. I have added this error via rdt_last_cmd_puts. At least user knows there is an error.

arch/x86/kernel/cpu/resctrl/rdtgroup.c +3 -1
index 484d6009869f..70a96976e3ab 100644
@@ -1250,8 +1252,10 @@ static ssize_t
 resctrl_mbm_assign_control_write(struct kernfs_open_file *of,
        int ret;
 
        /* Valid input requires a trailing newline */
-       if (nbytes == 0 || buf[nbytes - 1] != '\n')
+       if (nbytes == 0 || buf[nbytes - 1] != '\n') {
+               rdt_last_cmd_puts("mbm_cntr_assign: buffer invalid\n");
                return -EINVAL;
+       }
 
        buf[nbytes - 1] = '\0';
Quoted 1 line

I am open to other ideas to handle this case.

Reinette, what do you think about this as a stopgap approach?

The worst that happens is that userspace gets an unexpected failure in scenarios that seem unlikely in the near future (i.e., where there are a lot of RMIDs available, and at the same time groups have been given stupidly long names).

Since this is an implementation issue rather than an interface issue, we could fix it later on.

Longer term, we may want to define some stuff along the lines of

	struct rdtgroup_file {
		/* persistent data for an rdtgroup open file instance */
	};

	static int rdtgroup_file_open(struct kernfs_open_file *of)
	{
		struct rdtgroup_file *rf;

		rf = kzalloc(sizeof(*rf), GFP_KERNEL);
		if (!rf)
			return -ENOMEM;

		of->priv;
	}

	static void rdtgroup_file_release(struct kernfs_open_file *of)
	{
		/*
		 * Deal with dangling data and do cleanup appropriate
		 * for whatever kind of file this is, then:
		 */
		kfree(of->priv);
	}

Then we'd have somewhere to stash data that needs to be carried over from one read/write call to the next.

I tried to port my schemata buffering hack over, but the requirements are not exactly the same as for mbm_assign_control, so it wasn't trivial. It feels do-able, but it might be better to stabilise this series before going down that road.

(I'm happy to spend some time trying to wire this up if it would be useful, though.)

Cheers
---Dave

reviewer
#106 lore raw

Re: [PATCH v11 22/23] x86/resctrl: Introduce interface to list assignment states of all the groups

In reply to Moger, Babu
Quoted 6 lines · Babu

Hi Dave,

Quoted 3 lines · Dave Martin

Hi,

On Wed, Feb 19, 2025 at 03:09:51PM -0600, Moger, Babu wrote:

[...]

Quoted 29 lines
Quoted 8 lines
Quoted 7 lines

Good catch.

I see similar buffer overflow is handled by calling seq_buf_clear() (look at process_durations() or in show_user_instructions()).

How about handling this by calling rdt_last_cmd_clear() before printing each group?

Quoted 7 lines

Does this work?

Once seq_buf_has_overflowed() returns nonzero, data has been lost, no? So far as I can see, show_user_instructions() just gives up on printing the affected line, while process_durations() tries to anticipate overflow and prints out the accumulated text to dmesg before clearing the buffer.

Yea. Agree,

Quoted 11 lines

In our case, we cannot send more data to userspace than was requested in the read() call, so we might have nowhere to drain the seq_buf contents to in order to free up space.

sysfs "expects" userspace to do a big enough read() that this problem doesn't happen. In practice this is OK because people usually read through a buffered I/O layer like stdio, and in realistic implementations the user-side I/O buffer is large enough to hide this issue.

Quoted 5 lines
Quoted 2 lines

But mbm_assign_control data is dynamically generated and potentially much bigger than a typical sysfs file.

I have no idea how to handle this case. We may have to live with this problem. Let us know if there are any ideas.

I think the current implication is that this will work for now provided that the generated text fits in a page.

Reinette, what's your view on accepting this limitation in the interest of stabilising this series, and tidying up this corner case later?

As for writes to this file, we're unlikely to hit the limit unless there are a lot of RMIDs available and many groups with excessively long names.

This looks perfectly fixable, but it might be better to settle the design of this series first before we worry too much about it.

[...]

Cheers
---Dave

reviewer
#201 lore raw
In reply to Reinette Chatre

Hi Reinette,

Quoted 6 lines · Reinette Chatre

Hi Dave,

Quoted 3 lines · Dave Martin

Hi again,

On Thu, Feb 20, 2025 at 04:46:40PM +0000, Dave Martin wrote:

[...]

Quoted 31 lines
Quoted 22 lines

Having taken a quick look at that now, this all seems to duplicate perf's design journey (again).

"rate" events make some sense. The perf equivalent is to keep an accumulated count of the amount of time a counter has been assigned to an event, and another accumulated count of the events counted by the counter during assignment. Only userspace knows what it wants to do with this information: perf exposes the raw accumulated counts.

Perf events can be also pinned so that they are prioritised for assignment to counters; that sounds a lot like the regular, non-shared resctrl counters.

Playing devil's advocate:

It does feel like we are doomed to reinvent perf if we go too far down this road...

Quoted 3 lines

If we split the file, it will be more closely aligned with the design of the rest of the resctrlfs interface.

Quoted 8 lines
Quoted 5 lines

OTOH, the current interface seems workable and I think the file size issue can be addressed without major re-engineering.

So, from my side, I would not consider the current interface design a blocker.

...so, drawing a hard line around the use cases that we intend to address with this interface and avoiding feature creep seems desirable.

Quoted 6 lines

This is exactly what I am trying to do ... to understand what use cases the interface is expected to support.

You have mentioned a couple of times now that this interface is sufficient but at the same time you hinted at some features from MPAM that I do not see possible to accommodate with this interface.

It's kind of both.

I think the interface is sufficient to be useful, and therefore has value.

The problem being addressed here (shortage of counters) is fully relevant to MPAM (at last on some hardware).

Any architecture may define new metrics and types of event that can be counted, and they're not going to match up exactly between arches -- so I don't think we can expect everything to fit perfectly within a generic interface. But having a generic interface is still useful for making common features convenient to use.

So the interface is useful but not universal, but that doesn't feel like a bug.

Hopefully that makes my position a bit clearer.

Quoted 11 lines
Quoted 7 lines

resctrlfs is already in the wild, so providing reasonable baseline compatiblity with that interface for ABMC hardware is a sensible goal. The current series does that.

But I wonder how much additional functionality we should really be adding via the mbm_assign_control interface, once this series is settled.

Are you speculating that MPAM counters may not make use of this interface?

Reinette

No, I think it makes sense for MPAM to follow this interface, as least as far as what has been proposed so far here.

I think James got his updated rebase working. [1]

perf support would be for the future if we do it, but the ABMC interface may be a useful starting point anyway, because it allows counters to be assigned explicitly -- that provides a natural way to hand over some counters to perf, either because that interface may be a more natural fit for what the user is trying to do, or perhaps to count weird, platform-specific event types that do not merit the effort of integration into resctrlfs proper.

Does that make sense?

Cheers
---Dave

[1] https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git/log/?h=mpam/abmc/v11

reviewer
#83 lore raw

Re: [PATCH v11 17/23] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled

In reply to Reinette Chatre

Hi,

Quoted 8 lines · Reinette Chatre

Hi Dave,

Quoted 5 lines · Dave Martin
Quoted 4 lines · Peter Newman

Hi Reinette,

On Wed, Feb 19, 2025 at 6:55 PM Reinette Chatre
<[email protected]> wrote:

[...]

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 1 line

Could you please remind me how a user will set this flag?

Quoting my original suggestion[1]:

"info/L3_MON/mbm_assign_on_mkdir?

boolean (parsed with kstrtobool()), defaulting to true?"

After mount, any groups that got counters on creation would have to be cleaned up, but at least that can be done with forward progress once the flag is cleared.

I was able to live with that as long as there aren't users polling for resctrl to be mounted and immediately creating groups. For us, a single container manager service manages resctrl.

[...]

Quoted 15 lines
Quoted 15 lines

+1

That's basically my position -- the auto-assignment feels like a _potential_ nuisance for ABMC-aware users, but it depends on what they are trying to do. Migration of non-ABMC-aware users will be easier for basic use cases if auto-assignment occurs by default (as in this series).

Having an explicit way to turn this off seems perfectly reasonable (and could be added later on, if not provided in this series).

What about the question re whether turning mbm_cntr_assign mode on should trigger auto-assignment?

Quoted 6 lines
Quoted 3 lines

Currently turning this mode off and then on again has the effect of removing all automatic assignments for extant groups. This feels surprising and/or unintentional (?)

Connecting to what you start off by saying I also see auto-assignment as the way to provide a smooth transition for "non-ABMC-aware" users.

I agree, and having this on by default also helps non-ABMC-aware users.

Quoted 9 lines

To me a user that turns this mode off and then on again can be considered as a user that is "ABMC-aware" and turning it "off and then on again" seems like an intuitive way to get to a "clean slate" wrt counter assignments. This may also be a convenient way for an "ABMC-aware" user space to unassign all counters and thus also helpful if resctrl supports the flag that Peter proposed. The flag seems to already keep something like this in its context with a name of "mbm_assign_on_mkdir" that could be interpreted as "only auto assign on mkdir"?

Yes, that's reasonable. It could be a good idea to document this behaviour of switching the mbm_cntr_assign mode, if we think it is useful and people are likely to rely on it.

Since mkdir is an implementation detail of the resctrl interface, I'd be tempted to go for a more generic name, say, "mbm_assign_new_mon_groups". But that's just bikeshedding. The proposed behaviour seems fine.

Either way, if this is not included in this series, it could be added later without breaking anything.

Quoted 6 lines

I am not taking a stand for one or the other approach but instead trying to be more specific about pros/cons. Could you please provide more insight in the use case you have in mind so that we can see how resctrl could behave with few surprises?

Reinette

I don't have a strong view either.

I don't have a concrete use case here -- I was just trying to imagine the experience of an ABMC-aware user who wants full control over what counters get assigned.

I agree that the convenience of the non-ABMC-aware user should probably take priority over that of the ABMC-aware user, at least in situations where the expected behaviour is achievable (i.e., where we didn't run out of counters to auto-assign.)

Cheers
---Dave

reviewer
#16 lore raw

Re: [PATCH v11 06/23] x86/resctrl: Add support to enable/disable AMD ABMC feature

In reply to Babu Moger

Hi Babu,

Quoted 19 lines · Babu Moger

Add the functionality to enable/disable AMD ABMC feature.

AMD ABMC feature is enabled by setting enabled bit(0) in MSR L3_QOS_EXT_CFG. When the state of ABMC is changed, the MSR needs to be updated on all the logical processors in the QOS Domain.

Hardware counters will reset when ABMC state is changed.

The ABMC feature details are documented in APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC).

arch/x86/kernel/cpu/resctrl/internal.h +0 -0
index 05358e78147b..ca69f2e0909f 100644

arch/x86/kernel/cpu/resctrl/internal.h void resctrl_file_fflags_init(const char *config, unsigned long fflags); · line 668

Quoted 6 lines
arch/x86/kernel/cpu/resctrl/internal.h +2 -0
@@ -658,4 +663,6 @@ void resctrl_file_fflags_init(const char *config, unsigned long fflags);
 void rdt_staged_configs_clear(void);
 bool closid_allocated(unsigned int closid);
 int resctrl_find_cleanest_closid(void);
+int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable);
+bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r);
 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */

A minor nit - but could these be added to include/linux/resctrl.h instead? This is where they need to end up after the arch/fs split, and its harmless to do it from the beginning.

Thanks,

James

reviewer
#21 lore raw

Re: [PATCH v11 07/23] x86/resctrl: Introduce the interface to display monitor mode

In reply to Babu Moger

Hi Babu,

Quoted 42 lines · Babu Moger

Introduce the interface file "mbm_assign_mode" to list monitor modes supported.

The "mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.

On AMD systems "mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.

The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".

Provide an interface to display the monitor mode on the system.

$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode
[mbm_cntr_assign]
default
Documentation/arch/x86/resctrl.rst +15 -0
index fb90f08e564e..b5defc5bce0e 100644
@@ -257,6 +257,32 @@ with the following files:
 	    # cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config
 	    0=0x30;1=0x30;3=0x15;4=0x15
 
+"mbm_assign_mode":
+	Reports the list of monitoring modes supported. The enclosed brackets
+	indicate which mode is enabled.
+	::
+
+	  # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode
+	  [mbm_cntr_assign]
+	  default
+
+	"mbm_cntr_assign":
+
+	In mbm_cntr_assign, monitoring event can only accumulate data while
+	it is backed by a hardware counter. The user-space is able to specify
+	which of the events in CTRL_MON or MON groups should have a counter
+	assigned using the "mbm_assign_control" file. The number of counters

Documentation/arch/x86/resctrl.rst with the following files: · line 284

Quoted 10 lines
Documentation/arch/x86/resctrl.rst +9 -0
+	available is described in the "num_mbm_cntrs" file. Changing the mode
+	may cause all counters on a resource to reset.
 
+	"default":
+
+	In default mode, resctrl assumes there is a hardware counter for each
+	event within every CTRL_MON and MON group. On AMD platforms, it is
+	recommended to use mbm_cntr_assign mode if supported, because reading
+	"mbm_total_bytes" or "mbm_local_bytes" will report 'Unavailable' if
+	there is no counter associated with that event.

But if you read a value instead of "Unavailable", that doesn't mean the value is correct. For two reads that succeed, the counter may have been reset in the middle.

I'm suggesting something like:

| it is recommended to use mbm_cntr_assign mode if supported, to avoid counters
| being re-allocated by hardware. This can cause a misleading value to be read,
| or if no counter is associated with that event "Unavailable".
Quoted 16 lines
Documentation/arch/x86/resctrl.rst +0 -0
 "max_threshold_occupancy":
 		Read/write file provides the largest value (in
 		bytes) at which a previously used LLC_occupancy
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -0
index f91fe605766f..3880480a41d2 100644
@@ -854,6 +854,30 @@ static int rdtgroup_rmid_show(struct kernfs_open_file *of,
 	return ret;
 }
 
+static int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of,
+					struct seq_file *s, void *v)
+{
+	struct rdt_resource *r = of->kn->parent->priv;
+

arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_rmid_show(struct kernfs_open_file *of, · line 871

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10 -0
+	mutex_lock(&rdtgroup_mutex);
+
+	if (r->mon.mbm_cntr_assignable) {
+		if (resctrl_arch_mbm_cntr_assign_enabled(r)) {
+			seq_puts(s, "[mbm_cntr_assign]\n");
+			seq_puts(s, "default\n");
+		} else {
+			seq_puts(s, "mbm_cntr_assign\n");
+			seq_puts(s, "[default]\n");
+		}

What do you think to an architecture being able to opt-out of this flexibility?

If there aren't enough counters I can expose what the hardware has through this interface
- but if user-space turns it off ... then what?

For MPAM this would need to be some best-effort software allocation strategy that I'd rather not write - its not a problem that can be solved, and any value that is reported is likely to be wrong. For ABMC platforms, existing stable kernels expose a value, so being able to preserve the existing behaviour makes sense. MPAM doesn't have this problem.

Something like this:
----------%<----------
@@ -861,16 +861,21 @@ static int resctrl_mbm_assign_mode_show(struct kernfs_open _file *of,
struct seq_file *s, void *v)

 {
        struct rdt_resource *r = of->kn->parent->priv;

+ bool enabled = resctrl_arch_mbm_cntr_assign_enabled(r);

        mutex_lock(&rdtgroup_mutex);

        if (r->mon.mbm_cntr_assignable) {
-               if (resctrl_arch_mbm_cntr_assign_enabled(r)) {
+               if (enabled)
                        seq_puts(s, "[mbm_cntr_assign]\n");

- seq_puts(s, "default\n");
- } else {
- seq_puts(s, "mbm_cntr_assign\n");
+ else

                        seq_puts(s, "[default]\n");

+
+ if (!IS_ENABLED(CONFIG_RESCTRL_ASSIGN_FIXED) {
+ if (enabled)
+ seq_puts(s, "default\n");
+ else

+                               seq_puts(s, "mbm_cntr_assign\n");
                }
        } else {
                seq_puts(s, "[default]\n");

----------%<----------

x86 wouldn't define CONFIG_RESCTRL_ASSIGN_FIXED, arm64 would, meaning for MPAM the file would be either:
| [default]
or
| [mbm_cntr_assign]

arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_rmid_show(struct kernfs_open_file *of, · line 879

Quoted 8 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +8 -0
+	} else {
+		seq_puts(s, "[default]\n");
+	}
+
+	mutex_unlock(&rdtgroup_mutex);
+
+	return 0;
+}

Thanks,

James

reviewer
#62 lore raw

Re: [PATCH v11 14/23] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC

In reply to Babu Moger

Hi Babu,

Quoted 20 lines · Babu Moger

The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually.

Implement an architecture-specific handler to assign and unassign the counter. Configure counters by writing to the L3_QOS_ABMC_CFG MSR, specifying the counter ID, bandwidth source (RMID), and event configuration.

The feature details are documented in the APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming

    Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth
    Monitoring (ABMC).
arch/x86/kernel/cpu/resctrl/internal.h +0 -0
index acac7972cea4..161d3feb567c 100644

arch/x86/kernel/cpu/resctrl/internal.h unsigned int mon_event_config_index_get(u32 evtid); · line 730

Quoted 7 lines
arch/x86/kernel/cpu/resctrl/internal.h +3 -0
@@ -724,4 +724,7 @@ unsigned int mon_event_config_index_get(u32 evtid);
 void resctrl_arch_mon_event_config_set(void *info);
 u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d,
 				      enum resctrl_event_id eventid);
+int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,
+			     enum resctrl_event_id evtid, u32 rmid, u32 closid,
+			     u32 cntr_id, bool assign);
 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */

Could this be added to include/linux/resctrl.h instead? Its where it needs to end up eventually.

Thanks,

James

reviewer
#95 lore raw

Re: [PATCH v11 20/23] x86/resctrl: Configure mbm_cntr_assign mode if supported

In reply to Babu Moger

Hi Babu,

Quoted 4 lines · Babu Moger

Configure mbm_cntr_assign mode on AMD platforms. On AMD platforms, it is recommended to use mbm_cntr_assign mode if supported, because reading "mbm_total_bytes" or "mbm_local_bytes" will report 'Unavailable' if there is no counter associated with that event.

(If you agree with my comment on patch 7, it would be good to update this wording to match.)

Quoted 11 lines

The mbm_cntr_assign mode, referred to as ABMC (Assignable Bandwidth Monitoring Counters) on AMD, is enabled by default when supported by the system.

Update ABMC across all logical processors within the resctrl domain to ensure proper functionality.

arch/x86/kernel/cpu/resctrl/internal.h +0 -0
index c006c4d8d6ff..2480698b643d 100644

arch/x86/kernel/cpu/resctrl/internal.h int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_domain *d · line 738

Quoted 5 lines
arch/x86/kernel/cpu/resctrl/internal.h +1 -0
@@ -734,4 +734,5 @@ int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_domain *d
 void mbm_cntr_reset(struct rdt_resource *r);
 int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d,
 		 struct rdtgroup *rdtgrp, enum resctrl_event_id evtid);
+void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r);
 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */

Could this be put in include/linux/resctrl.h, its where it needs to end up eventually.

This sequence has me confused:

arch/x86/kernel/cpu/resctrl/monitor.c int __init rdt_get_mon_l3_config(struct rdt_resource *r) · line 1237

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/monitor.c +1 -0
index 3d748fdbcb5f..a9a5dc626a1e 100644
@@ -1233,6 +1233,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
 			r->mon.mbm_cntr_assignable = true;
 			cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx);
 			r->mon.num_mbm_cntrs = (ebx & GENMASK(15, 0)) + 1;
 
+			hw_res->mbm_cntr_assign_enabled = true;

Here the arch code sets ABMC to be enabled by default at boot.

Quoted 7 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -0
index 6922173c4f8f..515969c5f64f 100644
@@ -4302,9 +4302,13 @@ int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d)
 
 void resctrl_online_cpu(unsigned int cpu)

arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d) · line 4313

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -0
 {
+	struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
+
 	mutex_lock(&rdtgroup_mutex);
 	/* The CPU is set in default rdtgroup after online. */
 	cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask);
+	if (r->mon_capable && r->mon.mbm_cntr_assignable)
+		resctrl_arch_mbm_cntr_assign_set_one(r);
 	mutex_unlock(&rdtgroup_mutex);
 }

But here, resctrl has to call back to the arch code to make sure the hardware is in the same state as hw_res->mbm_cntr_assign_enabled.

Could this be done in resctrl_arch_online_cpu() instead? That way resctrl doesn't get CPUs in an inconsistent state that it has to fix up...

Thanks,

James

reviewer
#51 lore raw

Re: [PATCH v11 11/23] x86/resctrl: Introduce mbm_cntr_cfg to track assignable counters at domain

In reply to Babu Moger

Hi Babu,

Quoted 25 lines · Babu Moger

In mbm_cntr_assign mode hardware counters are assigned/unassigned to an MBM event of a monitor group. Hardware counters are assigned/unassigned at monitoring domain level.

Manage a monitoring domain's hardware counters using a per monitoring domain array of struct mbm_cntr_cfg that is indexed by the hardware
counter ID. A hardware counter's configuration contains the MBM event
ID and points to the monitoring group that it is assigned to, with a NULL pointer meaning that the hardware counter is available for assignment.

There is no direct way to determine which hardware counters are assigned
to a particular monitoring group. Check every entry of every hardware
counter configuration array in every monitoring domain to query which
MBM events of a monitoring group is tracked by hardware. Such queries are acceptable because of a very small number of assignable counters.

include/linux/resctrl.h +1 -0
index 511cfce8fc21..9a54e307d340 100644
@@ -94,6 +94,18 @@ struct rdt_ctrl_domain {
 	u32				*mbps_val;
 };
 
+/**

include/linux/resctrl.h struct rdt_ctrl_domain { · line 107

Quoted 10 lines
include/linux/resctrl.h +10 -0
+ * struct mbm_cntr_cfg - assignable counter configuration
+ * @evtid:		 MBM event to which the counter is assigned. Only valid
+ *			 if @rdtgroup is not NULL.
+ * @rdtgroup:		 resctrl group assigned to the counter. NULL if the
+ *			 counter is free.
+ */
+struct mbm_cntr_cfg {
+	enum resctrl_event_id	evtid;
+	struct rdtgroup		*rdtgrp;
+};

struct rdtgroup here suggests this shouldn't be something the arch code is touching.

If its not needed by any arch specific code, (I couldn't find a resctrl_arch helper that takes this) - could it be moved to resctrl's internal.h.

(If this does need to be visible to the arch code, one option would be to replace rdtgroup with the closid/rmid, and a valid flag so that memset() continues to reset these entries)

Thanks,

James

reviewer
#124 lore raw

Re: [PATCH v11 23/23] x86/resctrl: Introduce interface to modify assignment states of the groups

In reply to Babu Moger

Hi Babu,

Quoted 155 lines · Babu Moger

When mbm_cntr_assign mode is enabled, users can designate which of the MBM events in the CTRL_MON or MON groups should have counters assigned.

Provide an interface for assigning MBM events by writing to the file:
/sys/fs/resctrl/info/L3_MON/mbm_assign_control. Using this interface, events can be assigned or unassigned as needed.

Format is similar to the list format with addition of opcode for the assignment operation.
"<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>"

Format for specific type of groups:

* Default CTRL_MON group:

         "//<domain_id><opcode><flags>"

* Non-default CTRL_MON group:

         "<CTRL_MON group>//<domain_id><opcode><flags>"

* Child MON group of default CTRL_MON group:

         "/<MON group>/<domain_id><opcode><flags>"

* Child MON group of non-default CTRL_MON group:

         "<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>"

Domain_id '*' will apply the flags on all the domains.

Opcode can be one of the following:

= Update the assignment to match the flags
+ Assign a new MBM event without impacting existing assignments.
- Unassign a MBM event from currently assigned events.

Assignment flags can be one of the following:
t MBM total event
l MBM local event
tl Both total and local MBM events
_ None of the MBM events. Valid only with '=' opcode. This flag cannot
be combined with other flags.

arch/x86/kernel/cpu/resctrl/rdtgroup.c +107 -0
index 6e29827239e0..299839bcf23f 100644
@@ -1050,6 +1050,244 @@ static int resctrl_mbm_assign_control_show(struct kernfs_open_file *of,
 
+static int resctrl_process_flags(struct rdt_resource *r,
+				 enum rdt_group_type rtype,
+				 char *p_grp, char *c_grp, char *tok)
+{
+	unsigned int op, mon_state, assign_state, unassign_state;
+	char *dom_str, *id_str, *op_str;
+	struct rdt_mon_domain *d;
+	unsigned long dom_id = 0;
+	struct rdtgroup *rdtgrp;
+	char domain[10];
+	bool found;
+	int ret;
+
+	rdtgrp = rdtgroup_find_grp_by_name(rtype, p_grp, c_grp);
+
+	if (!rdtgrp) {
+		rdt_last_cmd_puts("Not a valid resctrl group\n");
+		return -EINVAL;
+	}
+
+next:
+	if (!tok || tok[0] == '\0')
+		return 0;
+
+	/* Start processing the strings for each domain */
+	dom_str = strim(strsep(&tok, ";"));
+
+	op_str = strpbrk(dom_str, "=+-");
+
+	if (op_str) {
+		op = *op_str;
+	} else {
+		rdt_last_cmd_puts("Missing operation =, +, - character\n");
+		return -EINVAL;
+	}
+
+	id_str = strsep(&dom_str, "=+-");
+
+	/* Check for domain id '*' which means all domains */
+	if (id_str && *id_str == '*') {
+		d = NULL;
+		goto check_state;
+	} else if (!id_str || kstrtoul(id_str, 10, &dom_id)) {
+		rdt_last_cmd_puts("Missing domain id\n");
+		return -EINVAL;
+	}
+
+	/* Verify if the dom_id is valid */
+	found = false;
+	list_for_each_entry(d, &r->mon_domains, hdr.list) {
+		if (d->hdr.id == dom_id) {
+			found = true;
+			break;
+		}
+	}
+
+	if (!found) {
+		rdt_last_cmd_printf("Invalid domain id %ld\n", dom_id);
+		return -EINVAL;
+	}
+
+check_state:
+	mon_state = resctrl_str_to_mon_state(dom_str);
+
+	if (mon_state == ASSIGN_INVALID) {
+		rdt_last_cmd_puts("Invalid assign flag\n");
+		goto out_fail;
+	}
+
+	assign_state = 0;
+	unassign_state = 0;
+
+	switch (op) {
+	case '+':
+		if (mon_state == ASSIGN_NONE) {
+			rdt_last_cmd_puts("Invalid assign opcode\n");
+			goto out_fail;
+		}
+		assign_state = mon_state;
+		break;
+	case '-':
+		if (mon_state == ASSIGN_NONE) {
+			rdt_last_cmd_puts("Invalid assign opcode\n");
+			goto out_fail;
+		}
+		unassign_state = mon_state;
+		break;
+	case '=':
+		assign_state = mon_state;
+		unassign_state = (ASSIGN_TOTAL | ASSIGN_LOCAL) & ~assign_state;
+		break;
+	default:
+		break;
+	}
 
 
+	if (unassign_state & ASSIGN_TOTAL) {
+		ret = resctrl_unassign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID);
+		if (ret)
+			goto out_fail;
+	}
+
+	if (unassign_state & ASSIGN_LOCAL) {
+		ret = resctrl_unassign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID);
+		if (ret)
+			goto out_fail;
+	}
+
+	if (assign_state & ASSIGN_TOTAL) {

arch/x86/kernel/cpu/resctrl/rdtgroup.c static int resctrl_mbm_assign_control_show(struct kernfs_open_file *of, · line 1169

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10 -0
+		ret = resctrl_assign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID);
+		if (ret)
+			goto out_fail;
+	}
+
+	if (assign_state & ASSIGN_LOCAL) {
+		ret = resctrl_assign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID);
+		if (ret)
+			goto out_fail;
+	}

This sequence of if's allows the helpers to be called on platforms that doesn't support both local and total. Could we reject such misconfiguration here in the parsing code? You have these checks in rdtgroup_assign_cntrs() added in patch 17.

What do you think to trying to group these four by event type, and passing the event type in as an argument? ... it ends up with a helper that takes a large number of arguments, (both assign_state and unassign_state), but there is less repetition...

Thanks,

James

Quoted 11 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +11 -0
+	goto next;
+
+out_fail:
+	sprintf(domain, d ? "%ld" : "*", dom_id);
+
+	rdt_last_cmd_printf("Assign operation '%s%c%s' failed on the group %s/%s/\n",
+			    domain, op, dom_str, p_grp, c_grp);
+
+	return -EINVAL;
+}
+
reviewer
#208 lore raw
In reply to Babu Moger

Hi Babu,

Quoted 6 lines · Babu Moger

This series adds the support for Assignable Bandwidth Monitoring Counters (ABMC). It is also called QoS RMID Pinning feature

Series is written such that it is easier to support other assignable features supported from different vendors.

Quoted 8 lines

The feature details are documented in the APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). The documentation is available at

The patches are based on top of commit
d361b84d51bfe (tip/master) Merge branch into tip/master: 'x86/tdx'

I've rebased the MPAM tree on top of this v11, here:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git/log/?h=mpam/abmc/v11
Hopefully this is sufficient evidence that this interface works for MPAM.

It would be convenient for MPAM platforms to not have to support a 'default' mode if they are emulating ABMC - this was something that was never supported, and its not a problem that can be solved. (comments on the relevant patches).

Thanks,

James

reviewer
#35 lore raw

Re: [PATCH v11 10/23] x86/resctrl: Remove MSR reading of event configuration value

In reply to Luck, Tony

Hi Tony, Reinette,

Quoted 11 lines · Tony
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

This new arch API has sharp corners because of asymmetry of where resctrl runs the arch function. I do not think it is required to change this since we can only speculate about how this may be used in the future but I do think it will be helpful to add comments that highlight:

resctrl_arch_mon_event_config_get() -> May run on CPU that does not belong to domain. resctrl_arch_mon_event_config_set() -> Runs on CPU that belongs to domain.

Here's a vague data point about the future to help with speculation.

I have something coming along the pipeline that also can run on any CPU.

RISC-V has this - all their controls/monitors are accessible from any CPU. Some MPAM platforms can do this too - but the code has to be structured for those that need the IPI.

Having this be something resctrl can be told sounds like a great idea.

It sounds like all or nothing suits x86/riscv.
The MPAM driver has an accessibility cpumask for each thing it accesses that determines if it needs to do an IPI.

Quoted 12 lines
Quoted 12 lines
Quoted 4 lines

I am contemplating a flag in the rdt_resource structure (in appropriate substructure resctrl_cache/resctrl_membw) to indicate "domain" vs. "any" for operations.

Would something like that be useful here?

hmm ... I cannot envision how this may look. Could you please elaborate?

You mention "a" (singular) flag in rdt_resource while this scenario involves different ops having different scope. This makes me think that this flag may have to be per operation that in turn would need additional infrastructure to manage and track operations.

Quoted 5 lines
Quoted 5 lines

These "arch" functions are evolving as the work to support MPAM is done and so far I think it has been quite ad-hoc to just refactor arch specific code into "arch" helpers instead of keeping track of which scope they are running in. This currently requires any arch implementing an "arch" helper to be well aware of how resctrl will call it.

This is how APIs in linux evolve - only the immediate problem needs solving. Arch code being aware how resctrl uses a function shouldn't be surprising - it is the only user.

Quoted 6 lines

I haven't fleshed it out yet. One option would be to have a "choose_cpu_mask()" function that takes resource and domain parameters (and given your comment about this case an operation code). Then use that as the mask in an smp_call*().

Operations that can run anywhere would return a mask with just bit for the current CPU.

That sounds like extra work. We already have a cpumask, if you set it to the cpu_possible mask at boot, then smp_call_function() and friends will always prefer the current CPU, and it all falls out in the wash.

Thanks,

James

reviewer
#37 lore raw

Re: [PATCH v11 10/23] x86/resctrl: Remove MSR reading of event configuration value

In reply to Dave Martin

Hi Dave,

Quoted 32 lines · Dave Martin
Quoted 25 lines · Reinette Chatre
Quoted 8 lines · Tony
Quoted 7 lines

This new arch API has sharp corners because of asymmetry of where resctrl runs the arch function. I do not think it is required to change this since we can only speculate about how this may be used in the future but I do think it will be helpful to add comments that highlight:

resctrl_arch_mon_event_config_get() -> May run on CPU that does not belong to domain. resctrl_arch_mon_event_config_set() -> Runs on CPU that belongs to domain.

Quoted 8 lines

Here's a vague data point about the future to help with speculation.

I have something coming along the pipeline that also can run on any CPU.

I am contemplating a flag in the rdt_resource structure (in appropriate substructure resctrl_cache/resctrl_membw) to indicate "domain" vs. "any" for operations.

Would something like that be useful here?

hmm ... I cannot envision how this may look. Could you please elaborate?

You mention "a" (singular) flag in rdt_resource while this scenario involves different ops having different scope. This makes me think that this flag may have to be per operation that in turn would need additional infrastructure to manage and track operations.

Quoted 5 lines

These "arch" functions are evolving as the work to support MPAM is done and so far I think it has been quite ad-hoc to just refactor arch specific code into "arch" helpers instead of keeping track of which scope they are running in. This currently requires any arch implementing an "arch" helper to be well aware of how resctrl will call it.

Quoted 3 lines

For MPAM, we must typically do all configuration access from a CPU in a power domain that depends on the power domain of the relevant MPAM MSC, including reads of the configuration.

This is the worst case - but the firmware can describe an MSC as being globally accessible.

Quoted 3 lines

In the MPAM case, the required topology knowledge is not necessarily identical to the resctrl domain topology, so it doesn't feel right to have the resctrl core code making the decisions.

This is up to the MPAM driver to hide. The upshot is that for some calls resctrl needs to schedule work so that the MPAM driver can in turn IPI to get the rest of the work done. The changes for this are already upstream.

Quoted 2 lines

So, in the interest of keeping the arch interface simple, should cross- calling be delegated to the arch code, at least for now?

That's invasive on top of what we already have. Take smp_mon_event_count() as an example, there is a bunch of work that resctrl can do on a CPU that can access the hardware registers. If the cpumask was hidden, then we'd either need more IPI, or to allocate a structure that can describe a long list of monitors to read.

Thanks,

James

#84 lore raw

Re: [PATCH v11 17/23] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled

In reply to Dave Martin

Hi All,

Quoted 70 lines · Dave Martin

Hi,

Quoted 8 lines · Reinette Chatre

Hi Dave,

Quoted 5 lines · Dave Martin
Quoted 4 lines · Peter Newman

Hi Reinette,

On Wed, Feb 19, 2025 at 6:55 PM Reinette Chatre
<[email protected]> wrote:

[...]

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 1 line

Could you please remind me how a user will set this flag?

Quoting my original suggestion[1]:

"info/L3_MON/mbm_assign_on_mkdir?

boolean (parsed with kstrtobool()), defaulting to true?"

After mount, any groups that got counters on creation would have to be cleaned up, but at least that can be done with forward progress once the flag is cleared.

I was able to live with that as long as there aren't users polling for resctrl to be mounted and immediately creating groups. For us, a single container manager service manages resctrl.

[...]

Quoted 15 lines
Quoted 15 lines

+1

That's basically my position -- the auto-assignment feels like a _potential_ nuisance for ABMC-aware users, but it depends on what they are trying to do. Migration of non-ABMC-aware users will be easier for basic use cases if auto-assignment occurs by default (as in this series).

Having an explicit way to turn this off seems perfectly reasonable (and could be added later on, if not provided in this series).

What about the question re whether turning mbm_cntr_assign mode on should trigger auto-assignment?

Quoted 6 lines
Quoted 3 lines

Currently turning this mode off and then on again has the effect of removing all automatic assignments for extant groups. This feels surprising and/or unintentional (?)

Connecting to what you start off by saying I also see auto-assignment as the way to provide a smooth transition for "non-ABMC-aware" users.

I agree, and having this on by default also helps non-ABMC-aware users.

Quoted 9 lines

To me a user that turns this mode off and then on again can be considered as a user that is "ABMC-aware" and turning it "off and then on again" seems like an intuitive way to get to a "clean slate" wrt counter assignments. This may also be a convenient way for an "ABMC-aware" user space to unassign all counters and thus also helpful if resctrl supports the flag that Peter proposed. The flag seems to already keep something like this in its context with a name of "mbm_assign_on_mkdir" that could be interpreted as "only auto assign on mkdir"?

Yes, that's reasonable. It could be a good idea to document this behaviour of switching the mbm_cntr_assign mode, if we think it is useful and people are likely to rely on it.

Quoted 7 lines

Since mkdir is an implementation detail of the resctrl interface, I'd be tempted to go for a more generic name, say, "mbm_assign_new_mon_groups". But that's just bikeshedding. The proposed behaviour seems fine.

Either way, if this is not included in this series, it could be added later without breaking anything.

How about more generic "mbm_cntr_assign_auto" ?

We can add it as part of "struct resctrl_mon" and set it "on" when ABMC is detected. It will be part of check in rdtgroup_assign_cntrs() which is called when new groups are created. Also, provide user interface to disable it. Seems simple to me.

Thanks
Babu

Quoted 23 lines
Quoted 8 lines

I am not taking a stand for one or the other approach but instead trying to be more specific about pros/cons. Could you please provide more insight in the use case you have in mind so that we can see how resctrl could behave with few surprises?

Reinette

I don't have a strong view either.

I don't have a concrete use case here -- I was just trying to imagine the experience of an ABMC-aware user who wants full control over what counters get assigned.

I agree that the convenience of the non-ABMC-aware user should probably take priority over that of the ABMC-aware user, at least in situations where the expected behaviour is achievable (i.e., where we didn't run out of counters to auto-assign.)

Cheers
---Dave

maintainer
#17 lore raw

Re: [PATCH v11 06/23] x86/resctrl: Add support to enable/disable AMD ABMC feature

In reply to James Morse

Hi James,

Quoted 17 lines · James Morse

Hi Babu,

Quoted 12 lines · Babu Moger

Add the functionality to enable/disable AMD ABMC feature.

AMD ABMC feature is enabled by setting enabled bit(0) in MSR L3_QOS_EXT_CFG. When the state of ABMC is changed, the MSR needs to be updated on all the logical processors in the QOS Domain.

Hardware counters will reset when ABMC state is changed.

The ABMC feature details are documented in APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC).

Quoted 15 lines

arch/x86/kernel/cpu/resctrl/internal.h void resctrl_file_fflags_init(const char *config, unsigned long fflags); · line 668

Quoted 11 lines
arch/x86/kernel/cpu/resctrl/internal.h +2 -0
index 05358e78147b..ca69f2e0909f 100644
@@ -658,4 +663,6 @@ void resctrl_file_fflags_init(const char *config, unsigned long fflags);
 void rdt_staged_configs_clear(void);
 bool closid_allocated(unsigned int closid);
 int resctrl_find_cleanest_closid(void);
+int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable);
+bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r);
 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */

A minor nit - but could these be added to include/linux/resctrl.h instead? This is where they need to end up after the arch/fs split, and its harmless to do it from the beginning.

These prototypes were moved back to the internal header to follow guidance from Boris that was received during recent software controller enhancement. Boris advised [1] that items needed by other architecture should only be moved to include/linux/resctrl.h when that support is added.

Reinette

[1] https://lore.kernel.org/lkml/20241209222047.GKZ1dtPxIu5_Hxs1fp@fat_crate.local/

maintainer
#52 lore raw

Re: [PATCH v11 11/23] x86/resctrl: Introduce mbm_cntr_cfg to track assignable counters at domain

In reply to James Morse

Hi James,

Quoted 41 lines · James Morse

Hi Babu,

Quoted 25 lines · Babu Moger

In mbm_cntr_assign mode hardware counters are assigned/unassigned to an MBM event of a monitor group. Hardware counters are assigned/unassigned at monitoring domain level.

Manage a monitoring domain's hardware counters using a per monitoring domain array of struct mbm_cntr_cfg that is indexed by the hardware
counter ID. A hardware counter's configuration contains the MBM event
ID and points to the monitoring group that it is assigned to, with a NULL pointer meaning that the hardware counter is available for assignment.

There is no direct way to determine which hardware counters are assigned
to a particular monitoring group. Check every entry of every hardware
counter configuration array in every monitoring domain to query which
MBM events of a monitoring group is tracked by hardware. Such queries are acceptable because of a very small number of assignable counters.

include/linux/resctrl.h +1 -0
index 511cfce8fc21..9a54e307d340 100644
@@ -94,6 +94,18 @@ struct rdt_ctrl_domain {
 	u32				*mbps_val;
 };
 
+/**

include/linux/resctrl.h struct rdt_ctrl_domain { · line 107

Quoted 10 lines
include/linux/resctrl.h +10 -0
+ * struct mbm_cntr_cfg - assignable counter configuration
+ * @evtid:		 MBM event to which the counter is assigned. Only valid
+ *			 if @rdtgroup is not NULL.
+ * @rdtgroup:		 resctrl group assigned to the counter. NULL if the
+ *			 counter is free.
+ */
+struct mbm_cntr_cfg {
+	enum resctrl_event_id	evtid;
+	struct rdtgroup		*rdtgrp;
+};

struct rdtgroup here suggests this shouldn't be something the arch code is touching.

Quoted 6 lines

If its not needed by any arch specific code, (I couldn't find a resctrl_arch helper that takes this) - could it be moved to resctrl's internal.h.

(If this does need to be visible to the arch code, one option would be to replace rdtgroup with the closid/rmid, and a valid flag so that memset() continues to reset these entries)

Thank you for catching this!

Reinette

#22 lore raw

Re: [PATCH v11 07/23] x86/resctrl: Introduce the interface to display monitor mode

In reply to James Morse

Hi James,

Quoted 59 lines · James Morse

Hi Babu,

Quoted 42 lines · Babu Moger

Introduce the interface file "mbm_assign_mode" to list monitor modes supported.

The "mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned.

On AMD systems "mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default.

The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable".

Provide an interface to display the monitor mode on the system.

$ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode
[mbm_cntr_assign]
default
Documentation/arch/x86/resctrl.rst +15 -0
index fb90f08e564e..b5defc5bce0e 100644
@@ -257,6 +257,32 @@ with the following files:
  	    # cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config
  	    0=0x30;1=0x30;3=0x15;4=0x15
 
+"mbm_assign_mode":
+	Reports the list of monitoring modes supported. The enclosed brackets
+	indicate which mode is enabled.
+	::
+
+	  # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode
+	  [mbm_cntr_assign]
+	  default
+
+	"mbm_cntr_assign":
+
+	In mbm_cntr_assign, monitoring event can only accumulate data while
+	it is backed by a hardware counter. The user-space is able to specify
+	which of the events in CTRL_MON or MON groups should have a counter
+	assigned using the "mbm_assign_control" file. The number of counters

Documentation/arch/x86/resctrl.rst with the following files: · line 284

Quoted 10 lines
Documentation/arch/x86/resctrl.rst +9 -0
+	available is described in the "num_mbm_cntrs" file. Changing the mode
+	may cause all counters on a resource to reset.
 
+	"default":
+
+	In default mode, resctrl assumes there is a hardware counter for each
+	event within every CTRL_MON and MON group. On AMD platforms, it is
+	recommended to use mbm_cntr_assign mode if supported, because reading
+	"mbm_total_bytes" or "mbm_local_bytes" will report 'Unavailable' if
+	there is no counter associated with that event.

But if you read a value instead of "Unavailable", that doesn't mean the value is correct. For two reads that succeed, the counter may have been reset in the middle.

Quoted 5 lines

I'm suggesting something like:

| it is recommended to use mbm_cntr_assign mode if supported, to avoid counters
| being re-allocated by hardware. This can cause a misleading value to be read,
| or if no counter is associated with that event "Unavailable".

Looks good with slight modification.

On AMD platforms, it is recommended to use the mbm_cntr_assign mode, if supported, to prevent the hardware from resetting counters between reads. This can result in misleading values or display "Unavailable" if no counter is assigned to the event.

Quoted 67 lines
Quoted 17 lines
Documentation/arch/x86/resctrl.rst +0 -0
  "max_threshold_occupancy":
  		Read/write file provides the largest value (in
  		bytes) at which a previously used LLC_occupancy
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -0
index f91fe605766f..3880480a41d2 100644
@@ -854,6 +854,30 @@ static int rdtgroup_rmid_show(struct kernfs_open_file *of,
  	return ret;
  }
 
+static int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of,
+					struct seq_file *s, void *v)
+{
+	struct rdt_resource *r = of->kn->parent->priv;
+

arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_rmid_show(struct kernfs_open_file *of, · line 871

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10 -0
+	mutex_lock(&rdtgroup_mutex);
+
+	if (r->mon.mbm_cntr_assignable) {
+		if (resctrl_arch_mbm_cntr_assign_enabled(r)) {
+			seq_puts(s, "[mbm_cntr_assign]\n");
+			seq_puts(s, "default\n");
+		} else {
+			seq_puts(s, "mbm_cntr_assign\n");
+			seq_puts(s, "[default]\n");
+		}

What do you think to an architecture being able to opt-out of this flexibility?

If there aren't enough counters I can expose what the hardware has through this interface
- but if user-space turns it off ... then what?

For MPAM this would need to be some best-effort software allocation strategy that I'd rather not write - its not a problem that can be solved, and any value that is reported is likely to be wrong. For ABMC platforms, existing stable kernels expose a value, so being able to preserve the existing behaviour makes sense. MPAM doesn't have this problem.

Something like this:
----------%<----------

(quoted diff) +9 -4
@@ -861,16 +861,21 @@ static int resctrl_mbm_assign_mode_show(struct kernfs_open
 _file *of,
                                         struct seq_file *s, void *v)
  {
         struct rdt_resource *r = of->kn->parent->priv;
+       bool enabled = resctrl_arch_mbm_cntr_assign_enabled(r);
 
         mutex_lock(&rdtgroup_mutex);
 
         if (r->mon.mbm_cntr_assignable) {
-               if (resctrl_arch_mbm_cntr_assign_enabled(r)) {
+               if (enabled)
                         seq_puts(s, "[mbm_cntr_assign]\n");
-                       seq_puts(s, "default\n");
-               } else {
-                       seq_puts(s, "mbm_cntr_assign\n");
+               else
                         seq_puts(s, "[default]\n");
+
+               if (!IS_ENABLED(CONFIG_RESCTRL_ASSIGN_FIXED) {
+                       if (enabled)
+                               seq_puts(s, "default\n");
+                       else
+                               seq_puts(s, "mbm_cntr_assign\n");
                 }
         } else {
                 seq_puts(s, "[default]\n");
Quoted 8 lines

----------%<----------

x86 wouldn't define CONFIG_RESCTRL_ASSIGN_FIXED, arm64 would, meaning for MPAM the file would be either:
| [default]
or
| [mbm_cntr_assign]

Looks good mostly.

resctrl_arch_mbm_cntr_assign_enabled(r) needs to be called with the lock.

Also, there is no reference of CONFIG_RESCTRL_ASSIGN_FIXED in this series. Hope that is not an issue.

arch/x86/kernel/cpu/resctrl/rdtgroup.c +10 -4
index 3880480a41d2..2907bb7bfa56 100644
@@ -858,16 +858,22 @@ static int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of,
                                        struct seq_file *s, void *v)
 {
        struct rdt_resource *r = of->kn->parent->priv;
+       bool enabled;
 
        mutex_lock(&rdtgroup_mutex);
+       enabled = resctrl_arch_mbm_cntr_assign_enabled(r);
 
        if (r->mon.mbm_cntr_assignable) {
-               if (resctrl_arch_mbm_cntr_assign_enabled(r)) {
+               if (enabled)
                        seq_puts(s, "[mbm_cntr_assign]\n");
-                       seq_puts(s, "default\n");
-               } else {
-                       seq_puts(s, "mbm_cntr_assign\n");
+               else
                        seq_puts(s, "[default]\n");
+
+               if (!IS_ENABLED(CONFIG_RESCTRL_ASSIGN_FIXED)) {
+                       if (enabled)
+                               seq_puts(s, "default\n");
+                       else
+                               seq_puts(s, "mbm_cntr_assign\n");
                }
        } else {
                seq_puts(s, "[default]\n");
Quoted 13 lines

arch/x86/kernel/cpu/resctrl/rdtgroup.c static int rdtgroup_rmid_show(struct kernfs_open_file *of, · line 879

Quoted 9 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +8 -0
+	} else {
+		seq_puts(s, "[default]\n");
+	}
+
+	mutex_unlock(&rdtgroup_mutex);
+
+	return 0;
+}

Thanks,

Quoted 2 lines

James

Thanks
Babu

#53 lore raw

Re: [PATCH v11 11/23] x86/resctrl: Introduce mbm_cntr_cfg to track assignable counters at domain

In reply to Reinette Chatre
Quoted 47 lines · Reinette Chatre

Hi James,

Quoted 44 lines · James Morse

Hi Babu,

Quoted 25 lines · Babu Moger

In mbm_cntr_assign mode hardware counters are assigned/unassigned to an MBM event of a monitor group. Hardware counters are assigned/unassigned at monitoring domain level.

Manage a monitoring domain's hardware counters using a per monitoring domain array of struct mbm_cntr_cfg that is indexed by the hardware
counter ID. A hardware counter's configuration contains the MBM event
ID and points to the monitoring group that it is assigned to, with a NULL pointer meaning that the hardware counter is available for assignment.

There is no direct way to determine which hardware counters are assigned
to a particular monitoring group. Check every entry of every hardware
counter configuration array in every monitoring domain to query which
MBM events of a monitoring group is tracked by hardware. Such queries are acceptable because of a very small number of assignable counters.

include/linux/resctrl.h +1 -0
index 511cfce8fc21..9a54e307d340 100644
@@ -94,6 +94,18 @@ struct rdt_ctrl_domain {
  	u32				*mbps_val;
  };
 
+/**

include/linux/resctrl.h struct rdt_ctrl_domain { · line 107

Quoted 10 lines
include/linux/resctrl.h +10 -0
+ * struct mbm_cntr_cfg - assignable counter configuration
+ * @evtid:		 MBM event to which the counter is assigned. Only valid
+ *			 if @rdtgroup is not NULL.
+ * @rdtgroup:		 resctrl group assigned to the counter. NULL if the
+ *			 counter is free.
+ */
+struct mbm_cntr_cfg {
+	enum resctrl_event_id	evtid;
+	struct rdtgroup		*rdtgrp;
+};

struct rdtgroup here suggests this shouldn't be something the arch code is touching.

If its not needed by any arch specific code, (I couldn't find a resctrl_arch helper that takes this) - could it be moved to resctrl's internal.h.

Quoted 9 lines
Quoted 3 lines

(If this does need to be visible to the arch code, one option would be to replace rdtgroup with the closid/rmid, and a valid flag so that memset() continues to reset these entries)

Thank you for catching this!

Reinette

Sure. Will move it to arch/x86/kernel/cpu/resctrl/internal.h.

thanks
Babu

maintainer
#107 lore raw

Re: [PATCH v11 22/23] x86/resctrl: Introduce interface to list assignment states of all the groups

In reply to Dave Martin

Hi Dave,

Quoted 49 lines · Dave Martin
Quoted 6 lines · Babu

Hi Dave,

Quoted 3 lines · Dave Martin

Hi,

On Wed, Feb 19, 2025 at 03:09:51PM -0600, Moger, Babu wrote:

[...]

Quoted 29 lines
Quoted 8 lines
Quoted 7 lines

Good catch.

I see similar buffer overflow is handled by calling seq_buf_clear() (look at process_durations() or in show_user_instructions()).

How about handling this by calling rdt_last_cmd_clear() before printing each group?

Quoted 7 lines

Does this work?

Once seq_buf_has_overflowed() returns nonzero, data has been lost, no? So far as I can see, show_user_instructions() just gives up on printing the affected line, while process_durations() tries to anticipate overflow and prints out the accumulated text to dmesg before clearing the buffer.

Yea. Agree,

Quoted 11 lines

In our case, we cannot send more data to userspace than was requested in the read() call, so we might have nowhere to drain the seq_buf contents to in order to free up space.

sysfs "expects" userspace to do a big enough read() that this problem doesn't happen. In practice this is OK because people usually read through a buffered I/O layer like stdio, and in realistic implementations the user-side I/O buffer is large enough to hide this issue.

Quoted 5 lines
Quoted 2 lines

But mbm_assign_control data is dynamically generated and potentially much bigger than a typical sysfs file.

I have no idea how to handle this case. We may have to live with this problem. Let us know if there are any ideas.

I think the current implication is that this will work for now provided that the generated text fits in a page.

Quoted 6 lines

Reinette, what's your view on accepting this limitation in the interest of stabilising this series, and tidying up this corner case later?

As for writes to this file, we're unlikely to hit the limit unless there are a lot of RMIDs available and many groups with excessively long names.

I am more concerned about reads to this file. If only 4K writes are supported then user space can reconfigure the system in page sized portions. It may not be efficient if the user wants to reconfigure the entire system but it will work. The problem with reads is that if larger than 4K reads are required but not supported then it will be impossible for user space to learn state of the system.

We may already be at that limit. Peter described [1] how AMD systems already have 32 L3 monitoring domains and 256 RMIDs. With conservative resource group names of 10 characters I see one line per monitoring group that could look like below and thus easily be above 200 characters:

resgroupAA/mongroupAA/0=tl;1=tl;2=tl;3=tl;4=tl;5=tl;6=tl;7=tl;8=tl;9=tl;10=tl;11=tl;12=tl;13=tl;14=tl;15=tl;16=tl;17=tl;18=tl;19=tl;20=tl;21=tl;22=tl;23=tl;24=tl;25=tl;26=tl;27=tl;28=tl;29=tl;30=tl;31=tl;32=tl

Multiplying that with the existing possible 256 monitor groups the limit is exceeded today.

I understand that all domains having "tl" flags are not possible today, but even if that is changed to "_" the resulting display still looks to easily exceed a page when many RMIDs are in use.

Quoted 3 lines

This looks perfectly fixable, but it might be better to settle the design of this series first before we worry too much about it.

I think it fair to delay support of writing more than a page of data but it looks to me like we need a solution to support displaying more than a page of data to user space.

Reinette

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

maintainer
#123 lore raw

Re: [PATCH v11 23/23] x86/resctrl: Introduce interface to modify assignment states of the groups

In reply to Dave Martin

Hi Dave,

Quoted 61 lines · Dave Martin

Hi,

Quoted 1 line · Babu

Hi Dave,

[...]

Quoted 26 lines

Created the problem using this code using a "test" group.

include <stdio.h>
#include <errno.h>
#include <string.h>

int main()

{
        FILE *file;
        int n;

        file = fopen("/sys/fs/resctrl/info/L3_MON/mbm_assign_control", "w");

        if (file == NULL) {
                printf("Error opening file!\n");
                return 1;
        }

        printf("File opened successfully.\n");

        for (n = 0; n < 100; n++)
                if

(fputs("test//0=tl;1=tl;2=tl;3=tl;4=tl;5=tl;9=tl;10=tl;11=tl\n", file) == EOF)
fprintf(stderr, "Failed on interation %d error
%s\n ", n, strerror(errno));

Quoted 6 lines
        if (fclose(file) == 0) {
                printf("File closed successfully.\n");
        } else {
                printf("Error closing file!\n");
        }
}

Right.

Quoted 19 lines

When the buffer overflow happens the newline will not be there. I have added this error via rdt_last_cmd_puts. At least user knows there is an error.

arch/x86/kernel/cpu/resctrl/rdtgroup.c +3 -1
index 484d6009869f..70a96976e3ab 100644
@@ -1250,8 +1252,10 @@ static ssize_t
 resctrl_mbm_assign_control_write(struct kernfs_open_file *of,
        int ret;
 
        /* Valid input requires a trailing newline */
-       if (nbytes == 0 || buf[nbytes - 1] != '\n')
+       if (nbytes == 0 || buf[nbytes - 1] != '\n') {
+               rdt_last_cmd_puts("mbm_cntr_assign: buffer invalid\n");
                return -EINVAL;
+       }
 
Quoted 7 lines
Quoted 5 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -0
        buf[nbytes - 1] = '\0';

I am open to other ideas to handle this case.

Reinette, what do you think about this as a stopgap approach?

This seems fair. I expect that we need to document somewhere that writes "may" (to leave wiggle room for improvements) require page sized writes.

Quoted 37 lines

The worst that happens is that userspace gets an unexpected failure in scenarios that seem unlikely in the near future (i.e., where there are a lot of RMIDs available, and at the same time groups have been given stupidly long names).

Since this is an implementation issue rather than an interface issue, we could fix it later on.

Longer term, we may want to define some stuff along the lines of

	struct rdtgroup_file {
		/* persistent data for an rdtgroup open file instance */
	};

	static int rdtgroup_file_open(struct kernfs_open_file *of)
	{
		struct rdtgroup_file *rf;

		rf = kzalloc(sizeof(*rf), GFP_KERNEL);
		if (!rf)
			return -ENOMEM;

		of->priv;
	}

	static void rdtgroup_file_release(struct kernfs_open_file *of)
	{
		/*
		 * Deal with dangling data and do cleanup appropriate
		 * for whatever kind of file this is, then:
		 */
		kfree(of->priv);
	}
Quoted 2 lines

Then we'd have somewhere to stash data that needs to be carried over from one read/write call to the next.

Something like this seems needed for reading from this file.

Quoted 8 lines

I tried to port my schemata buffering hack over, but the requirements are not exactly the same as for mbm_assign_control, so it wasn't trivial. It feels do-able, but it might be better to stabilise this series before going down that road.

(I'm happy to spend some time trying to wire this up if it would be useful, though.)

I was hoping that we would not need to re-invent something here. This does not seem like a new problem.

Reinette

#63 lore raw

Re: [PATCH v11 14/23] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC

In reply to James Morse

Hi James,

Quoted 18 lines · James Morse

Hi Babu,

Quoted 14 lines · Babu Moger

The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually.

Implement an architecture-specific handler to assign and unassign the counter. Configure counters by writing to the L3_QOS_ABMC_CFG MSR, specifying the counter ID, bandwidth source (RMID), and event configuration.

The feature details are documented in the APM listed below [1].
[1] AMD64 Architecture Programmer's Manual Volume 2: System Programming

     Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth
     Monitoring (ABMC).
Quoted 17 lines

arch/x86/kernel/cpu/resctrl/internal.h unsigned int mon_event_config_index_get(u32 evtid); · line 730

Quoted 12 lines
arch/x86/kernel/cpu/resctrl/internal.h +3 -0
index acac7972cea4..161d3feb567c 100644
@@ -724,4 +724,7 @@ unsigned int mon_event_config_index_get(u32 evtid);
  void resctrl_arch_mon_event_config_set(void *info);
  u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d,
  				      enum resctrl_event_id eventid);
+int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,
+			     enum resctrl_event_id evtid, u32 rmid, u32 closid,
+			     u32 cntr_id, bool assign);
  #endif /* _ASM_X86_RESCTRL_INTERNAL_H */

Could this be added to include/linux/resctrl.h instead? Its where it needs to end up eventually.

As Reinette already mentioned in [1], Boris wanted this moved when arch/fs code separation integrated. Lets keep it in resctrl/internal.h for now.

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

Thanks
Babu

Quoted 4 lines

Thanks,

James

maintainer
#160 lore raw
In reply to Peter Newman

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 46 lines · Reinette Chatre
Quoted 36 lines · Peter Newman
Quoted 26 lines · Reinette Chatre
Quoted 5 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Dave Martin
Quoted 2 lines · Reinette Chatre
Quoted 1 line · Dave Martin

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)

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

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>
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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.

Quoted 65 lines
Quoted 56 lines
Quoted 52 lines
Quoted 38 lines

Until now I viewed counter configuration separate from counter assignment, similar to how AMD's counters can be configured via mbm_total_bytes_config and mbm_local_bytes_config before they are assigned. That is still per-domain counter configuration though, not per-counter.

Quoted 13 lines

I assume packing all of this info for a group's desired counter configuration into a single line (with 32 domains per line on many dual-socket AMD configurations I see) would be difficult to look at, even if we could settle on a single letter to represent each universally.

Quoted 7 lines

My goal is for resctrl to have a user interface that can as much as possible be ready for whatever may be required from it years down the line. Of course, I may be wrong and resctrl would never need to support more than 26 events per resource (*). The risk is that resctrl *may* need to support more than 26 events and how could resctrl support that?

Quoted 8 lines
Quoted 5 lines

What is the risk of supporting more than 26 events? As I highlighted earlier the interface I used as demonstration may become unwieldy to parse on a system with many domains that supports many events. This is a concern for me. Any suggestions will be appreciated, especially from you since I know that you are very familiar with issues related to large scale use of resctrl interfaces.

It's mainly just the unwieldiness of all the information in one file. It's already at the limit of what I can visually look through.

I agree.

Quoted 7 lines

I believe that shared assignments will take care of all the high-frequency and performance-intensive batch configuration updates I was originally concerned about, so I no longer see much benefit in finding ways to textually encode all this information in a single file when it would be more manageable to distribute it around the filesystem hierarchy.

Quoted 6 lines

This is significant. The motivation for the single file was to support the "high-frequency and performance-intensive" usage. Would "shared assignments" not also depend on the same files that, if distributed, will require many filesystem operations?
Having the files distributed will be significantly simpler while also avoiding the file size issue that Dave Martin exposed.

The remaining filesystem operations will be assigning or removing shared counter assignments in the applicable domains, which would normally correspond to mkdir/rmdir of groups or changing their CPU affinity. The shared assignments are more "program and forget", while the exclusive assignment approach requires updates for every counter (in every domain) every few seconds to cover a large number of groups.

Quoted 3 lines

When they want to pay extra attention to a particular group, I expect they'll ask for exclusive counters and leave them assigned for a while as they collect extra data.

Quoted 8 lines

The single file approach is already unwieldy. The demands that will be placed on it to support the usages currently being discussed would make this interface even harder to use and manage. If the single file is not required then I think we should go back to smaller files distributed in resctrl. This may not even be an either/or argument. One way to view mbm_assign_control could be as a way for user to interact with the distributed counter related files with a single file system operation. Although, without knowing how counter configuration is expected to work this remains unclear.

Quoted 6 lines

If we do both interfaces and the multi-file model gives us more capability to express configurations, we could find situations where there are configurations we cannot represent when reading back from mbm_assign_control, or updates through mbm_assign_control have ambiguous effects on existing configurations which were created with other files.

Right. My assumption was that the syntax would be identical.

Quoted 3 lines

However, the example I gave above seems to be adequately represented by a minor extension to mbm_assign_control and we all seem to

To confirm what you mean with "minor extension to mbm_assign_control", is this where the flags are associated with counter configurations? At this time this is done separately from mbm_assign_control with the hardcoded "t" and "l" flags configured via mbm_total_bytes_config and mbm_local_bytes respectively. I think it would be simpler to keep these configurations separate from mbm_assign_control. How it would look without better understanding of MPAM is not clear to me at this time, unless if the requirement is to enhance support for ABMC and BMEC. I do see that this can be added later to build on what is supported by mbm_assign_control with the syntax in this version.

Quoted 3 lines

understand it now, so maybe it's not broken yet. It's unfortunate that work went into a requirement that's no longer relevant, but I don't think that on its own is a blocker.

I understand that requirements may change as we get new information. Digesting it now is significantly easier than trying to adapt after the user interface is merged and essentially set in stone.

Reinette

maintainer
#202 lore raw
In reply to Dave Martin

Hi Dave,

Quoted 95 lines · Dave Martin

Hi Reinette,

Quoted 6 lines · Reinette Chatre

Hi Dave,

Quoted 3 lines · Dave Martin

Hi again,

On Thu, Feb 20, 2025 at 04:46:40PM +0000, Dave Martin wrote:

[...]

Quoted 31 lines
Quoted 22 lines

Having taken a quick look at that now, this all seems to duplicate perf's design journey (again).

"rate" events make some sense. The perf equivalent is to keep an accumulated count of the amount of time a counter has been assigned to an event, and another accumulated count of the events counted by the counter during assignment. Only userspace knows what it wants to do with this information: perf exposes the raw accumulated counts.

Perf events can be also pinned so that they are prioritised for assignment to counters; that sounds a lot like the regular, non-shared resctrl counters.

Playing devil's advocate:

It does feel like we are doomed to reinvent perf if we go too far down this road...

Quoted 3 lines

If we split the file, it will be more closely aligned with the design of the rest of the resctrlfs interface.

Quoted 8 lines
Quoted 5 lines

OTOH, the current interface seems workable and I think the file size issue can be addressed without major re-engineering.

So, from my side, I would not consider the current interface design a blocker.

...so, drawing a hard line around the use cases that we intend to address with this interface and avoiding feature creep seems desirable.

Quoted 6 lines

This is exactly what I am trying to do ... to understand what use cases the interface is expected to support.

You have mentioned a couple of times now that this interface is sufficient but at the same time you hinted at some features from MPAM that I do not see possible to accommodate with this interface.

It's kind of both.

I think the interface is sufficient to be useful, and therefore has value.

The problem being addressed here (shortage of counters) is fully relevant to MPAM (at last on some hardware).

Any architecture may define new metrics and types of event that can be counted, and they're not going to match up exactly between arches -- so I don't think we can expect everything to fit perfectly within a generic interface. But having a generic interface is still useful for making common features convenient to use.

So the interface is useful but not universal, but that doesn't feel like a bug.

Hopefully that makes my position a bit clearer.

Quoted 11 lines
Quoted 7 lines

resctrlfs is already in the wild, so providing reasonable baseline compatiblity with that interface for ABMC hardware is a sensible goal. The current series does that.

But I wonder how much additional functionality we should really be adding via the mbm_assign_control interface, once this series is settled.

Are you speculating that MPAM counters may not make use of this interface?

Reinette

No, I think it makes sense for MPAM to follow this interface, as least as far as what has been proposed so far here.

I think James got his updated rebase working. [1]

perf support would be for the future if we do it, but the ABMC interface may be a useful starting point anyway, because it allows counters to be assigned explicitly -- that provides a natural way to hand over some counters to perf, either because that interface may be a more natural fit for what the user is trying to do, or perhaps to count weird, platform-specific event types that do not merit the effort of integration into resctrlfs proper.

Quoted 2 lines

Does that make sense?

This is reasonable. You did state earlier that we should aim to draw hard lines around the use cases we aim to address and I think one way this work is doing this is by being explicit in user interface that this is all about "memory bandwidth monitoring". This is not intended to be a fully generic interface for all possible counters for all possible resources.

Apart from that time will tell how many blind spots there were while creating this interface.

Thank you very much for all your very valuable insights.

Reinette

maintainer
#85 lore raw

Re: [PATCH v11 17/23] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled

In reply to Moger, Babu

Hi Babu,

Quoted 78 lines · Babu

Hi All,

Quoted 75 lines · Dave Martin

Hi,

Quoted 8 lines · Reinette Chatre

Hi Dave,

Quoted 5 lines · Dave Martin
Quoted 4 lines · Peter Newman

Hi Reinette,

On Wed, Feb 19, 2025 at 6:55 PM Reinette Chatre
<[email protected]> wrote:

[...]

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 1 line

Could you please remind me how a user will set this flag?

Quoting my original suggestion[1]:

  "info/L3_MON/mbm_assign_on_mkdir?

   boolean (parsed with kstrtobool()), defaulting to true?"

After mount, any groups that got counters on creation would have to be cleaned up, but at least that can be done with forward progress once the flag is cleared.

I was able to live with that as long as there aren't users polling for resctrl to be mounted and immediately creating groups. For us, a single container manager service manages resctrl.

[...]

Quoted 15 lines
Quoted 15 lines

+1

That's basically my position -- the auto-assignment feels like a _potential_ nuisance for ABMC-aware users, but it depends on what they are trying to do.  Migration of non-ABMC-aware users will be easier for basic use cases if auto-assignment occurs by default (as in this series).

Having an explicit way to turn this off seems perfectly reasonable (and could be added later on, if not provided in this series).

What about the question re whether turning mbm_cntr_assign mode on should trigger auto-assignment?

Quoted 6 lines
Quoted 3 lines

Currently turning this mode off and then on again has the effect of removing all automatic assignments for extant groups.  This feels surprising and/or unintentional (?)

Connecting to what you start off by saying I also see auto-assignment as the way to provide a smooth transition for "non-ABMC-aware" users.

I agree, and having this on by default also helps non-ABMC-aware users.

Quoted 9 lines

To me a user that turns this mode off and then on again can be considered as a user that is "ABMC-aware" and turning it "off and then on again" seems like an intuitive way to get to a "clean slate" wrt counter assignments. This may also be a convenient way for an "ABMC-aware" user space to unassign all counters and thus also helpful if resctrl supports the flag that Peter proposed. The flag seems to already keep something like this in its context with a name of "mbm_assign_on_mkdir" that could be interpreted as "only auto assign on mkdir"?

Yes, that's reasonable.  It could be a good idea to document this behaviour of switching the mbm_cntr_assign mode, if we think it is useful and people are likely to rely on it.

Since mkdir is an implementation detail of the resctrl interface, I'd be tempted to go for a more generic name, say, "mbm_assign_new_mon_groups".  But that's just bikeshedding. The proposed behaviour seems fine.

Quoted 4 lines
Quoted 2 lines

Either way, if this is not included in this series, it could be added later without breaking anything.

How about more generic "mbm_cntr_assign_auto" ?

I would like to be careful to not make it _too_ generic. Dave already pointed out that users may be surprised that counters are not auto-assigned when switching between the different modes so using the the name to help highlight when this auto-assignment can be expected to happen seems very useful.

Reinette

#86 lore raw

Re: [PATCH v11 17/23] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled

Hi Reinette,

Quoted 84 lines · Reinette Chatre

Hi Babu,

Quoted 81 lines · Babu

Hi All,

Quoted 77 lines · Dave Martin

Hi,

Quoted 8 lines · Reinette Chatre

Hi Dave,

Quoted 5 lines · Dave Martin
Quoted 4 lines · Peter Newman

Hi Reinette,

On Wed, Feb 19, 2025 at 6:55 PM Reinette Chatre
<[email protected]> wrote:

[...]

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 1 line

Could you please remind me how a user will set this flag?

Quoting my original suggestion[1]:

  "info/L3_MON/mbm_assign_on_mkdir?

   boolean (parsed with kstrtobool()), defaulting to true?"

After mount, any groups that got counters on creation would have to be cleaned up, but at least that can be done with forward progress once the flag is cleared.

I was able to live with that as long as there aren't users polling for resctrl to be mounted and immediately creating groups. For us, a single container manager service manages resctrl.

[...]

Quoted 15 lines
Quoted 15 lines

+1

That's basically my position -- the auto-assignment feels like a _potential_ nuisance for ABMC-aware users, but it depends on what they are trying to do.  Migration of non-ABMC-aware users will be easier for basic use cases if auto-assignment occurs by default (as in this series).

Having an explicit way to turn this off seems perfectly reasonable (and could be added later on, if not provided in this series).

What about the question re whether turning mbm_cntr_assign mode on should trigger auto-assignment?

Quoted 6 lines
Quoted 3 lines

Currently turning this mode off and then on again has the effect of removing all automatic assignments for extant groups.  This feels surprising and/or unintentional (?)

Connecting to what you start off by saying I also see auto-assignment as the way to provide a smooth transition for "non-ABMC-aware" users.

I agree, and having this on by default also helps non-ABMC-aware users.

Quoted 9 lines

To me a user that turns this mode off and then on again can be considered as a user that is "ABMC-aware" and turning it "off and then on again" seems like an intuitive way to get to a "clean slate" wrt counter assignments. This may also be a convenient way for an "ABMC-aware" user space to unassign all counters and thus also helpful if resctrl supports the flag that Peter proposed. The flag seems to already keep something like this in its context with a name of "mbm_assign_on_mkdir" that could be interpreted as "only auto assign on mkdir"?

Yes, that's reasonable.  It could be a good idea to document this behaviour of switching the mbm_cntr_assign mode, if we think it is useful and people are likely to rely on it.

Since mkdir is an implementation detail of the resctrl interface, I'd be tempted to go for a more generic name, say, "mbm_assign_new_mon_groups".  But that's just bikeshedding. The proposed behaviour seems fine.

Either way, if this is not included in this series, it could be added later without breaking anything.

Quoted 6 lines
Quoted 1 line

How about more generic "mbm_cntr_assign_auto" ?

I would like to be careful to not make it _too_ generic. Dave already pointed out that users may be surprised that counters are not auto-assigned when switching between the different modes so using the the name to help highlight when this auto-assignment can be expected to happen seems very useful.

In that case "mbm_assign_on_mkdir" seems on point and precise. Thanks
Babu

#72 lore raw

Re: [PATCH v11 16/23] x86/resctrl: Add the functionality to unassigm MBM events

In reply to Reinette Chatre

Hi Reinette,

Quoted 42 lines · Reinette Chatre

Hi Babu,

Quoted 10 lines · Babu

Hi Reinette,

Quoted 3 lines · Reinette Chatre

Hi Babu,

subject: unassigm -> unassign

Sure.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines · Babu Moger
Quoted 1 line

The mbm_cntr_assign mode provides a limited number of hardware counters

(now back to "limited number of hardware counters")

How about?

The mbm_cntr_assign mode provides "num_mbm_cntrs" number of hardware counters

ok.

Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

that can be assigned to an RMID, event pair to monitor bandwidth while assigned. If all counters are in use, the kernel will show an error
message: "Out of MBM assignable counters" when a new assignment is requested. To make space for a new assignment, users must unassign an

To me "kernel will show an error" implies the kernel ring buffer. Please make the message accurate and mention that it will be in last_cmd_status while also considering to use -ENOSPC to help user space.

Quoted 6 lines

If all the counters are in use, the kernel will log the error message "Unable to allocate counter in domain" in /sys/fs/resctrl/info/ last_cmd_status when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter and retry the assignment again.

Quoted 2 lines

This is better, but can user space receive -ENOSPC to avoid needing to check and parse last_cmd_status on every error?

Yes. There was a problem in passing the error in resctrl_process_flags(). Took care of it now.

Thanks
Babu

author reviewer
#96 lore raw

Re: [PATCH v11 20/23] x86/resctrl: Configure mbm_cntr_assign mode if supported

In reply to James Morse

Hi James,

Quoted 10 lines · James Morse

Hi Babu,

Quoted 4 lines · Babu Moger

Configure mbm_cntr_assign mode on AMD platforms. On AMD platforms, it is recommended to use mbm_cntr_assign mode if supported, because reading "mbm_total_bytes" or "mbm_local_bytes" will report 'Unavailable' if there is no counter associated with that event.

(If you agree with my comment on patch 7, it would be good to update this wording to match.)

Sure.

Quoted 6 lines
Quoted 6 lines

The mbm_cntr_assign mode, referred to as ABMC (Assignable Bandwidth Monitoring Counters) on AMD, is enabled by default when supported by the system.

Quoted 15 lines

arch/x86/kernel/cpu/resctrl/internal.h int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_domain *d · line 738

Quoted 12 lines

Update ABMC across all logical processors within the resctrl domain to ensure proper functionality.

arch/x86/kernel/cpu/resctrl/internal.h +1 -0
index c006c4d8d6ff..2480698b643d 100644
@@ -734,4 +734,5 @@ int resctrl_unassign_cntr_event(struct rdt_resource *r, struct rdt_mon_domain *d
 void mbm_cntr_reset(struct rdt_resource *r);
 int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d,
 		 struct rdtgroup *rdtgrp, enum resctrl_event_id evtid);
+void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r);
 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */

Could this be put in include/linux/resctrl.h, its where it needs to end up eventually.

As Reinette already mentioned in [1], Boris wanted this moved when arch/fs code separation integrated. Lets keep it in resctrl/internal.h for now.

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

Quoted 39 lines

This sequence has me confused:

arch/x86/kernel/cpu/resctrl/monitor.c int __init rdt_get_mon_l3_config(struct rdt_resource *r) · line 1237

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/monitor.c +1 -0
index 3d748fdbcb5f..a9a5dc626a1e 100644
@@ -1233,6 +1233,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
 			r->mon.mbm_cntr_assignable = true;
 			cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx);
 			r->mon.num_mbm_cntrs = (ebx & GENMASK(15, 0)) + 1;
 
+			hw_res->mbm_cntr_assign_enabled = true;

Here the arch code sets ABMC to be enabled by default at boot.

Quoted 7 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -0
index 6922173c4f8f..515969c5f64f 100644
@@ -4302,9 +4302,13 @@ int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d)
 
 void resctrl_online_cpu(unsigned int cpu)

arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d) · line 4313

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -0
 {
+	struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
+
 	mutex_lock(&rdtgroup_mutex);
 	/* The CPU is set in default rdtgroup after online. */
 	cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask);
+	if (r->mon_capable && r->mon.mbm_cntr_assignable)
+		resctrl_arch_mbm_cntr_assign_set_one(r);
 	mutex_unlock(&rdtgroup_mutex);
 }

But here, resctrl has to call back to the arch code to make sure the hardware is in the same state as hw_res->mbm_cntr_assign_enabled.

Quoted 3 lines

Could this be done in resctrl_arch_online_cpu() instead? That way resctrl doesn't get CPUs in an inconsistent state that it has to fix up...

Sure. Here is the diff.

(quoted diff) +0 -0

b/arch/x86/kernel/cpu/resctrl/core.c
index 22399f19810f..f48b298413bc 100644

arch/x86/kernel/cpu/resctrl/core.c +6 -0
@@ -771,6 +771,12 @@ static int resctrl_arch_online_cpu(unsigned int cpu)
                domain_add_cpu(cpu, r);
        mutex_unlock(&domain_list_lock);
 
+       r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
+       mutex_lock(&rdtgroup_mutex);
+       if (r->mon_capable && r->mon.mbm_cntr_assignable)
+               resctrl_arch_mbm_cntr_assign_set_one(r);
+       mutex_unlock(&rdtgroup_mutex);
+
        clear_closid_rmid(cpu);
        resctrl_online_cpu(cpu);
 
Signature · 2 lines
Thanks
Babu Moger
maintainer
#97 lore raw

Re: [PATCH v11 20/23] x86/resctrl: Configure mbm_cntr_assign mode if supported

Hi James and Babu,

Quoted 43 lines · Babu

Hi James,

Quoted 40 lines · James Morse

Hi Babu,

On 22/01/2025 20:20, Babu Moger wrote:

This sequence has me confused:

arch/x86/kernel/cpu/resctrl/monitor.c int __init rdt_get_mon_l3_config(struct rdt_resource *r) · line 1237

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/monitor.c +1 -0
index 3d748fdbcb5f..a9a5dc626a1e 100644
@@ -1233,6 +1233,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
 			r->mon.mbm_cntr_assignable = true;
 			cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx);
 			r->mon.num_mbm_cntrs = (ebx & GENMASK(15, 0)) + 1;
 
+			hw_res->mbm_cntr_assign_enabled = true;

Here the arch code sets ABMC to be enabled by default at boot.

Quoted 7 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -0
index 6922173c4f8f..515969c5f64f 100644
@@ -4302,9 +4302,13 @@ int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d)
 
 void resctrl_online_cpu(unsigned int cpu)

arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d) · line 4313

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -0
 {
+	struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
+
 	mutex_lock(&rdtgroup_mutex);
 	/* The CPU is set in default rdtgroup after online. */
 	cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask);
+	if (r->mon_capable && r->mon.mbm_cntr_assignable)
+		resctrl_arch_mbm_cntr_assign_set_one(r);
 	mutex_unlock(&rdtgroup_mutex);
 }

But here, resctrl has to call back to the arch code to make sure the hardware is in the same state as hw_res->mbm_cntr_assign_enabled.

Another scenario needing to be supported by this flow is when CPUs come online later ... after resctrl is mounted and potentially after the user modified the assignable counter mode.

Quoted 3 lines
Quoted 3 lines

Could this be done in resctrl_arch_online_cpu() instead? That way resctrl doesn't get CPUs in an inconsistent state that it has to fix up...

Could you please elaborate the inconsistent state that would need to be fixed up?

Quoted 11 lines
Quoted 1 line

Sure. Here is the diff.

arch/x86/kernel/cpu/resctrl/core.c +0 -0
index 22399f19810f..f48b298413bc 100644
@@ -771,6 +771,12 @@ static int resctrl_arch_online_cpu(unsigned int cpu)
                domain_add_cpu(cpu, r);

arch/x86/kernel/cpu/resctrl/core.c static int resctrl_arch_online_cpu(unsigned int cpu) · line 781

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/core.c +6 -0
        mutex_unlock(&domain_list_lock);
 
+       r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
+       mutex_lock(&rdtgroup_mutex);
+       if (r->mon_capable && r->mon.mbm_cntr_assignable)
+               resctrl_arch_mbm_cntr_assign_set_one(r);
+       mutex_unlock(&rdtgroup_mutex);
+
        clear_closid_rmid(cpu);
        resctrl_online_cpu(cpu);

This would require every architecture to duplicate the above, no?

Also, please note there is more appropriate domain_add_cpu_mon().

Reinette

reviewer
#108 lore raw

Re: [PATCH v11 22/23] x86/resctrl: Introduce interface to list assignment states of all the groups

In reply to Reinette Chatre
Quoted 7 lines · Reinette Chatre

Hi Dave,

Quoted 4 lines · Dave Martin
Quoted 3 lines · Babu

Hi Dave,

On 2/20/25 09:44, Dave Martin wrote:

[...]

Quoted 29 lines
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

But mbm_assign_control data is dynamically generated and potentially much bigger than a typical sysfs file.

I have no idea how to handle this case. We may have to live with this problem. Let us know if there are any ideas.

I think the current implication is that this will work for now provided that the generated text fits in a page.

Quoted 6 lines

Reinette, what's your view on accepting this limitation in the interest of stabilising this series, and tidying up this corner case later?

As for writes to this file, we're unlikely to hit the limit unless there are a lot of RMIDs available and many groups with excessively long names.

I am more concerned about reads to this file. If only 4K writes are supported then user space can reconfigure the system in page sized portions. It may not be efficient if the user wants to reconfigure the entire system but it will work. The problem with reads is that if larger than 4K reads are required but not supported then it will be impossible for user space to learn state of the system.

We may already be at that limit. Peter described [1] how AMD systems already have 32 L3 monitoring domains and 256 RMIDs. With conservative resource group names of 10 characters I see one line per monitoring group that could look like below and thus easily be above 200 characters:

Quoted 4 lines

resgroupAA/mongroupAA/0=tl;1=tl;2=tl;3=tl;4=tl;5=tl;6=tl;7=tl;8=tl;9=tl;10=tl;11=tl;12=tl;13=tl;14=tl;15=tl;16=tl;17=tl;18=tl;19=tl;20=tl;21=tl;22=tl;23=tl;24=tl;25=tl;26=tl;27=tl;28=tl;29=tl;30=tl;31=tl;32=tl

Multiplying that with the existing possible 256 monitor groups the limit is exceeded today.

That's useful to know. I guess we probably shouldn't just kick this issue down the road, then -- at least on the read side (as you say).

Quoted 8 lines

I understand that all domains having "tl" flags are not possible today, but even if that is changed to "_" the resulting display still looks to easily exceed a page when many RMIDs are in use.

Quoted 3 lines

This looks perfectly fixable, but it might be better to settle the design of this series first before we worry too much about it.

Quoted 7 lines

I think it fair to delay support of writing more than a page of data but it looks to me like we need a solution to support displaying more than a page of data to user space.

Reinette

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

Ack; if I can't find an off-the-shelf solution for this, I'll try to hack something as minimal as possible to provide the required behaviour, but I won't try to make it optimal or pretty for now.

It has just occurred to be that ftrace has large, multi-line text files in sysfs, so I'll try to find out how they handle that there. Maybe there is some infrastructure we can re-use.

Either way, hopefully that will move the discussion forward (unless someone else comes up with a better idea first!)

Cheers
---Dave

maintainer
#109 lore raw

RE: [PATCH v11 22/23] x86/resctrl: Introduce interface to list assignment states of all the groups

Quoted 3 lines

It has just occurred to be that ftrace has large, multi-line text files in sysfs, so I'll try to find out how they handle that there. Maybe there is some infrastructure we can re-use.

Resctrl was built on top of "kernfs" because that was a simple base that met needs at the time.

Do we need to look at either extending capabilities of kernfs? Or move to sysfs?

-Tony

author reviewer
#125 lore raw

Re: [PATCH v11 23/23] x86/resctrl: Introduce interface to modify assignment states of the groups

In reply to James Morse

Hi James,

Quoted 164 lines · James Morse

Hi Babu,

Quoted 161 lines · Babu Moger

When mbm_cntr_assign mode is enabled, users can designate which of the MBM events in the CTRL_MON or MON groups should have counters assigned.

Provide an interface for assigning MBM events by writing to the file:
/sys/fs/resctrl/info/L3_MON/mbm_assign_control. Using this interface, events can be assigned or unassigned as needed.

Format is similar to the list format with addition of opcode for the assignment operation.
"<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>"

Format for specific type of groups:

* Default CTRL_MON group:

         "//<domain_id><opcode><flags>"

* Non-default CTRL_MON group:

         "<CTRL_MON group>//<domain_id><opcode><flags>"

* Child MON group of default CTRL_MON group:

         "/<MON group>/<domain_id><opcode><flags>"

* Child MON group of non-default CTRL_MON group:

         "<CTRL_MON group>/<MON group>/<domain_id><opcode><flags>"

Domain_id '*' will apply the flags on all the domains.

Opcode can be one of the following:

= Update the assignment to match the flags
+ Assign a new MBM event without impacting existing assignments.
- Unassign a MBM event from currently assigned events.

Assignment flags can be one of the following:
t MBM total event
l MBM local event
tl Both total and local MBM events
_ None of the MBM events. Valid only with '=' opcode. This flag cannot
be combined with other flags.

arch/x86/kernel/cpu/resctrl/rdtgroup.c +113 -0
index 6e29827239e0..299839bcf23f 100644
@@ -1050,6 +1050,244 @@ static int resctrl_mbm_assign_control_show(struct kernfs_open_file *of,
 
+static int resctrl_process_flags(struct rdt_resource *r,
+				 enum rdt_group_type rtype,
+				 char *p_grp, char *c_grp, char *tok)
+{
+	unsigned int op, mon_state, assign_state, unassign_state;
+	char *dom_str, *id_str, *op_str;
+	struct rdt_mon_domain *d;
+	unsigned long dom_id = 0;
+	struct rdtgroup *rdtgrp;
+	char domain[10];
+	bool found;
+	int ret;
+
+	rdtgrp = rdtgroup_find_grp_by_name(rtype, p_grp, c_grp);
+
+	if (!rdtgrp) {
+		rdt_last_cmd_puts("Not a valid resctrl group\n");
+		return -EINVAL;
+	}
+
+next:
+	if (!tok || tok[0] == '\0')
+		return 0;
+
+	/* Start processing the strings for each domain */
+	dom_str = strim(strsep(&tok, ";"));
+
+	op_str = strpbrk(dom_str, "=+-");
+
+	if (op_str) {
+		op = *op_str;
+	} else {
+		rdt_last_cmd_puts("Missing operation =, +, - character\n");
+		return -EINVAL;
+	}
+
+	id_str = strsep(&dom_str, "=+-");
+
+	/* Check for domain id '*' which means all domains */
+	if (id_str && *id_str == '*') {
+		d = NULL;
+		goto check_state;
+	} else if (!id_str || kstrtoul(id_str, 10, &dom_id)) {
+		rdt_last_cmd_puts("Missing domain id\n");
+		return -EINVAL;
+	}
+
+	/* Verify if the dom_id is valid */
+	found = false;
+	list_for_each_entry(d, &r->mon_domains, hdr.list) {
+		if (d->hdr.id == dom_id) {
+			found = true;
+			break;
+		}
+	}
+
+	if (!found) {
+		rdt_last_cmd_printf("Invalid domain id %ld\n", dom_id);
+		return -EINVAL;
+	}
+
+check_state:
+	mon_state = resctrl_str_to_mon_state(dom_str);
+
+	if (mon_state == ASSIGN_INVALID) {
+		rdt_last_cmd_puts("Invalid assign flag\n");
+		goto out_fail;
+	}
+
+	assign_state = 0;
+	unassign_state = 0;
+
+	switch (op) {
+	case '+':
+		if (mon_state == ASSIGN_NONE) {
+			rdt_last_cmd_puts("Invalid assign opcode\n");
+			goto out_fail;
+		}
+		assign_state = mon_state;
+		break;
+	case '-':
+		if (mon_state == ASSIGN_NONE) {
+			rdt_last_cmd_puts("Invalid assign opcode\n");
+			goto out_fail;
+		}
+		unassign_state = mon_state;
+		break;
+	case '=':
+		assign_state = mon_state;
+		unassign_state = (ASSIGN_TOTAL | ASSIGN_LOCAL) & ~assign_state;
+		break;
+	default:
+		break;
+	}
 
 
+	if (unassign_state & ASSIGN_TOTAL) {
+		ret = resctrl_unassign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID);
+		if (ret)
+			goto out_fail;
+	}
+
+	if (unassign_state & ASSIGN_LOCAL) {
+		ret = resctrl_unassign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID);
+		if (ret)
+			goto out_fail;
+	}
+
+	if (assign_state & ASSIGN_TOTAL) {
+		ret = resctrl_assign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID);
+		if (ret)
+			goto out_fail;
+	}
+
+	if (assign_state & ASSIGN_LOCAL) {
Quoted 9 lines

arch/x86/kernel/cpu/resctrl/rdtgroup.c static int resctrl_mbm_assign_control_show(struct kernfs_open_file *of, · line 1221

Quoted 4 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -0
+		ret = resctrl_assign_cntr_event(r, d, rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID);
+		if (ret)
+			goto out_fail;
+	}

This sequence of if's allows the helpers to be called on platforms that doesn't support both local and total. Could we reject such misconfiguration here in the parsing code? You have these checks in rdtgroup_assign_cntrs() added in patch 17.

Yes. Added the check is_mbm_total_enabled() and is_mbm_local_enabled().

Quoted 4 lines

What do you think to trying to group these four by event type, and passing the event type in as an argument? ... it ends up with a helper that takes a large number of arguments, (both assign_state and unassign_state), but there is less repetition...

Added a new helper function resctrl_process_cntr_event(). I could not avoid the repetitions.

Quoted 18 lines

Thanks,

James

Quoted 11 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +11 -0
+	goto next;
+
+out_fail:
+	sprintf(domain, d ? "%ld" : "*", dom_id);
+
+	rdt_last_cmd_printf("Assign operation '%s%c%s' failed on the group %s/%s/\n",
+			    domain, op, dom_str, p_grp, c_grp);
+
+	return -EINVAL;
+}
+
Signature · 2 lines
Thanks
Babu Moger
author reviewer
#98 lore raw

Re: [PATCH v11 20/23] x86/resctrl: Configure mbm_cntr_assign mode if supported

In reply to Reinette Chatre

Hi Reinette,

Quoted 47 lines · Reinette Chatre

Hi James and Babu,

Quoted 43 lines · Babu

Hi James,

Quoted 40 lines · James Morse

Hi Babu,

On 22/01/2025 20:20, Babu Moger wrote:

This sequence has me confused:

arch/x86/kernel/cpu/resctrl/monitor.c int __init rdt_get_mon_l3_config(struct rdt_resource *r) · line 1237

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/monitor.c +1 -0
index 3d748fdbcb5f..a9a5dc626a1e 100644
@@ -1233,6 +1233,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
 			r->mon.mbm_cntr_assignable = true;
 			cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx);
 			r->mon.num_mbm_cntrs = (ebx & GENMASK(15, 0)) + 1;
 
+			hw_res->mbm_cntr_assign_enabled = true;

Here the arch code sets ABMC to be enabled by default at boot.

Quoted 7 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -0
index 6922173c4f8f..515969c5f64f 100644
@@ -4302,9 +4302,13 @@ int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d)
 
 void resctrl_online_cpu(unsigned int cpu)

arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d) · line 4313

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -0
 {
+	struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
+
 	mutex_lock(&rdtgroup_mutex);
 	/* The CPU is set in default rdtgroup after online. */
 	cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask);
+	if (r->mon_capable && r->mon.mbm_cntr_assignable)
+		resctrl_arch_mbm_cntr_assign_set_one(r);
 	mutex_unlock(&rdtgroup_mutex);
 }

But here, resctrl has to call back to the arch code to make sure the hardware is in the same state as hw_res->mbm_cntr_assign_enabled.

Quoted 3 lines

Another scenario needing to be supported by this flow is when CPUs come online later ... after resctrl is mounted and potentially after the user modified the assignable counter mode.

If the user modifies the assignable counter mode. It is recorded in mbm_cntr_assign_enabled already. When the new CPU comes online, the hotplug handler(resctrl_arch_online_cpu) is will update the CPU to the new mode after checking mbm_cntr_assign_enabled.

Are you talking about different case here? Please elaborate.

Quoted 31 lines
Quoted 4 lines
Quoted 4 lines

Could this be done in resctrl_arch_online_cpu() instead? That way resctrl doesn't get CPUs in an inconsistent state that it has to fix up...

Could you please elaborate the inconsistent state that would need to be fixed up?

Quoted 11 lines
Quoted 1 line

Sure. Here is the diff.

arch/x86/kernel/cpu/resctrl/core.c +0 -0
index 22399f19810f..f48b298413bc 100644
@@ -771,6 +771,12 @@ static int resctrl_arch_online_cpu(unsigned int cpu)
                domain_add_cpu(cpu, r);

arch/x86/kernel/cpu/resctrl/core.c static int resctrl_arch_online_cpu(unsigned int cpu) · line 781

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/core.c +6 -0
        mutex_unlock(&domain_list_lock);
 
+       r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
+       mutex_lock(&rdtgroup_mutex);
+       if (r->mon_capable && r->mon.mbm_cntr_assignable)
+               resctrl_arch_mbm_cntr_assign_set_one(r);
+       mutex_unlock(&rdtgroup_mutex);
+
        clear_closid_rmid(cpu);
        resctrl_online_cpu(cpu);

This would require every architecture to duplicate the above, no?

Quoted 1 line

Also, please note there is more appropriate domain_add_cpu_mon().

Yes. This may be better place to add this code. Will wait once James clarifies on "inconsistent state".

Signature · 2 lines
Thanks
Babu Moger
maintainer
#99 lore raw

Re: [PATCH v11 20/23] x86/resctrl: Configure mbm_cntr_assign mode if supported

Hi Babu,

Quoted 55 lines · Babu

Hi Reinette,

Quoted 47 lines · Reinette Chatre

Hi James and Babu,

Quoted 43 lines · Babu

Hi James,

Quoted 40 lines · James Morse

Hi Babu,

On 22/01/2025 20:20, Babu Moger wrote:

This sequence has me confused:

arch/x86/kernel/cpu/resctrl/monitor.c int __init rdt_get_mon_l3_config(struct rdt_resource *r) · line 1237

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/monitor.c +1 -0
index 3d748fdbcb5f..a9a5dc626a1e 100644
@@ -1233,6 +1233,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
 			r->mon.mbm_cntr_assignable = true;
 			cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx);
 			r->mon.num_mbm_cntrs = (ebx & GENMASK(15, 0)) + 1;
 
+			hw_res->mbm_cntr_assign_enabled = true;

Here the arch code sets ABMC to be enabled by default at boot.

Quoted 7 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -0
index 6922173c4f8f..515969c5f64f 100644
@@ -4302,9 +4302,13 @@ int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d)
 
 void resctrl_online_cpu(unsigned int cpu)

arch/x86/kernel/cpu/resctrl/rdtgroup.c int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d) · line 4313

Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -0
 {
+	struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
+
 	mutex_lock(&rdtgroup_mutex);
 	/* The CPU is set in default rdtgroup after online. */
 	cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask);
+	if (r->mon_capable && r->mon.mbm_cntr_assignable)
+		resctrl_arch_mbm_cntr_assign_set_one(r);
 	mutex_unlock(&rdtgroup_mutex);
 }

But here, resctrl has to call back to the arch code to make sure the hardware is in the same state as hw_res->mbm_cntr_assign_enabled.

Quoted 3 lines

Another scenario needing to be supported by this flow is when CPUs come online later ... after resctrl is mounted and potentially after the user modified the assignable counter mode.

Quoted 6 lines

If the user modifies the assignable counter mode. It is recorded in mbm_cntr_assign_enabled already. When the new CPU comes online, the hotplug handler(resctrl_arch_online_cpu) is will update the CPU to the new mode after checking mbm_cntr_assign_enabled.

Are you talking about different case here? Please elaborate.

I am talking about the same case. James started with "This sequence has me confused" with "Here the arch code sets ABMC to be enabled by default at boot." snippet not seemingly matching with later snippet where "resctrl has to call back to the arch code". My goal was to highlight why resctrl would need to call back into arch code even though arch code establishes the default.

Reinette

#161 lore raw
In reply to Reinette Chatre

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 46 lines · Reinette Chatre
Quoted 36 lines · Peter Newman
Quoted 26 lines · Reinette Chatre
Quoted 5 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Dave Martin
Quoted 2 lines · Reinette Chatre

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)

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

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>

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

(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'm worried about requiring support for domain-level mbm_total_bytes_config and mbm_local_bytes_config files to be carried forward, because this conflicts with the configuration being per group/domain. (i.e., what would be read back from the domain files if per-group customizations have already been applied?)

Quoted 79 lines
Quoted 66 lines
Quoted 57 lines
Quoted 53 lines
Quoted 39 lines

Until now I viewed counter configuration separate from counter assignment, similar to how AMD's counters can be configured via mbm_total_bytes_config and mbm_local_bytes_config before they are assigned. That is still per-domain counter configuration though, not per-counter.

Quoted 13 lines

I assume packing all of this info for a group's desired counter configuration into a single line (with 32 domains per line on many dual-socket AMD configurations I see) would be difficult to look at, even if we could settle on a single letter to represent each universally.

Quoted 7 lines

My goal is for resctrl to have a user interface that can as much as possible be ready for whatever may be required from it years down the line. Of course, I may be wrong and resctrl would never need to support more than 26 events per resource (*). The risk is that resctrl *may* need to support more than 26 events and how could resctrl support that?

Quoted 8 lines
Quoted 5 lines

What is the risk of supporting more than 26 events? As I highlighted earlier the interface I used as demonstration may become unwieldy to parse on a system with many domains that supports many events. This is a concern for me. Any suggestions will be appreciated, especially from you since I know that you are very familiar with issues related to large scale use of resctrl interfaces.

It's mainly just the unwieldiness of all the information in one file. It's already at the limit of what I can visually look through.

I agree.

Quoted 7 lines

I believe that shared assignments will take care of all the high-frequency and performance-intensive batch configuration updates I was originally concerned about, so I no longer see much benefit in finding ways to textually encode all this information in a single file when it would be more manageable to distribute it around the filesystem hierarchy.

Quoted 6 lines

This is significant. The motivation for the single file was to support the "high-frequency and performance-intensive" usage. Would "shared assignments" not also depend on the same files that, if distributed, will require many filesystem operations?
Having the files distributed will be significantly simpler while also avoiding the file size issue that Dave Martin exposed.

The remaining filesystem operations will be assigning or removing shared counter assignments in the applicable domains, which would normally correspond to mkdir/rmdir of groups or changing their CPU affinity. The shared assignments are more "program and forget", while the exclusive assignment approach requires updates for every counter (in every domain) every few seconds to cover a large number of groups.

Quoted 3 lines

When they want to pay extra attention to a particular group, I expect they'll ask for exclusive counters and leave them assigned for a while as they collect extra data.

Quoted 8 lines

The single file approach is already unwieldy. The demands that will be placed on it to support the usages currently being discussed would make this interface even harder to use and manage. If the single file is not required then I think we should go back to smaller files distributed in resctrl. This may not even be an either/or argument. One way to view mbm_assign_control could be as a way for user to interact with the distributed counter related files with a single file system operation. Although, without knowing how counter configuration is expected to work this remains unclear.

Quoted 6 lines

If we do both interfaces and the multi-file model gives us more capability to express configurations, we could find situations where there are configurations we cannot represent when reading back from mbm_assign_control, or updates through mbm_assign_control have ambiguous effects on existing configurations which were created with other files.

Right. My assumption was that the syntax would be identical.

Quoted 3 lines

However, the example I gave above seems to be adequately represented by a minor extension to mbm_assign_control and we all seem to

Quoted 10 lines

To confirm what you mean with "minor extension to mbm_assign_control", is this where the flags are associated with counter configurations? At this time this is done separately from mbm_assign_control with the hardcoded "t" and "l" flags configured via mbm_total_bytes_config and mbm_local_bytes respectively. I think it would be simpler to keep these configurations separate from mbm_assign_control. How it would look without better understanding of MPAM is not clear to me at this time, unless if the requirement is to enhance support for ABMC and BMEC. I do see that this can be added later to build on what is supported by mbm_assign_control with the syntax in this version.

As I explained above, I was looking at this from the perspective of the extended event assignment mode.

Thanks,
-Peter

author reviewer
#162 lore raw

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 46 lines · Reinette Chatre
Quoted 36 lines · Peter Newman
Quoted 26 lines · Reinette Chatre
Quoted 5 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Dave Martin

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)

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

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>

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

Quoted 10 lines

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.

Quoted 8 lines

(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.

Quoted 103 lines

I'm worried about requiring support for domain-level mbm_total_bytes_config and mbm_local_bytes_config files to be carried forward, because this conflicts with the configuration being per group/domain. (i.e., what would be read back from the domain files if per-group customizations have already been applied?)

Quoted 79 lines
Quoted 66 lines
Quoted 57 lines
Quoted 53 lines
Quoted 39 lines

Until now I viewed counter configuration separate from counter assignment, similar to how AMD's counters can be configured via mbm_total_bytes_config and mbm_local_bytes_config before they are assigned. That is still per-domain counter configuration though, not per-counter.

Quoted 13 lines

I assume packing all of this info for a group's desired counter configuration into a single line (with 32 domains per line on many dual-socket AMD configurations I see) would be difficult to look at, even if we could settle on a single letter to represent each universally.

Quoted 7 lines

My goal is for resctrl to have a user interface that can as much as possible be ready for whatever may be required from it years down the line. Of course, I may be wrong and resctrl would never need to support more than 26 events per resource (*). The risk is that resctrl *may* need to support more than 26 events and how could resctrl support that?

Quoted 8 lines
Quoted 5 lines

What is the risk of supporting more than 26 events? As I highlighted earlier the interface I used as demonstration may become unwieldy to parse on a system with many domains that supports many events. This is a concern for me. Any suggestions will be appreciated, especially from you since I know that you are very familiar with issues related to large scale use of resctrl interfaces.

It's mainly just the unwieldiness of all the information in one file. It's already at the limit of what I can visually look through.

I agree.

Quoted 7 lines

I believe that shared assignments will take care of all the high-frequency and performance-intensive batch configuration updates I was originally concerned about, so I no longer see much benefit in finding ways to textually encode all this information in a single file when it would be more manageable to distribute it around the filesystem hierarchy.

Quoted 6 lines

This is significant. The motivation for the single file was to support the "high-frequency and performance-intensive" usage. Would "shared assignments" not also depend on the same files that, if distributed, will require many filesystem operations?
Having the files distributed will be significantly simpler while also avoiding the file size issue that Dave Martin exposed.

The remaining filesystem operations will be assigning or removing shared counter assignments in the applicable domains, which would normally correspond to mkdir/rmdir of groups or changing their CPU affinity. The shared assignments are more "program and forget", while the exclusive assignment approach requires updates for every counter (in every domain) every few seconds to cover a large number of groups.

Quoted 3 lines

When they want to pay extra attention to a particular group, I expect they'll ask for exclusive counters and leave them assigned for a while as they collect extra data.

Quoted 8 lines

The single file approach is already unwieldy. The demands that will be placed on it to support the usages currently being discussed would make this interface even harder to use and manage. If the single file is not required then I think we should go back to smaller files distributed in resctrl. This may not even be an either/or argument. One way to view mbm_assign_control could be as a way for user to interact with the distributed counter related files with a single file system operation. Although, without knowing how counter configuration is expected to work this remains unclear.

Quoted 6 lines

If we do both interfaces and the multi-file model gives us more capability to express configurations, we could find situations where there are configurations we cannot represent when reading back from mbm_assign_control, or updates through mbm_assign_control have ambiguous effects on existing configurations which were created with other files.

Right. My assumption was that the syntax would be identical.

Quoted 3 lines

However, the example I gave above seems to be adequately represented by a minor extension to mbm_assign_control and we all seem to

Quoted 10 lines

To confirm what you mean with "minor extension to mbm_assign_control", is this where the flags are associated with counter configurations? At this time this is done separately from mbm_assign_control with the hardcoded "t" and "l" flags configured via mbm_total_bytes_config and mbm_local_bytes respectively. I think it would be simpler to keep these configurations separate from mbm_assign_control. How it would look without better understanding of MPAM is not clear to me at this time, unless if the requirement is to enhance support for ABMC and BMEC. I do see that this can be added later to build on what is supported by mbm_assign_control with the syntax in this version.

As I explained above, I was looking at this from the perspective of the extended event assignment mode.

Thanks,
-Peter

Signature · 2 lines
Thanks
Babu Moger
maintainer
#197 lore raw
In reply to Peter Newman

Hi Peter,

Quoted 251 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 46 lines · Reinette Chatre
Quoted 36 lines · Peter Newman
Quoted 26 lines · Reinette Chatre
Quoted 5 lines · Babu
Quoted 4 lines · Reinette Chatre
Quoted 3 lines · Dave Martin

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)

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

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>

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

Quoted 7 lines

(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 am surprised to hear this at this point of this work. Sounds like we need to go back a couple of steps to determine how to best support user requirements that now includes per-group counter assignment.

Have you perhaps looked into how users access the counter data as part of your prototyping?

Reinette

#163 lore raw
In reply to Moger, Babu

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 46 lines · Reinette Chatre
Quoted 36 lines · Peter Newman
Quoted 26 lines · Reinette Chatre
Quoted 5 lines · Babu
Quoted 4 lines · Reinette Chatre

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)

Quoted 17 lines
Quoted 17 lines

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>

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

-Peter

maintainer
#164 lore raw

Hi Peter,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 46 lines · Reinette Chatre
Quoted 36 lines · Peter Newman
Quoted 26 lines · Reinette Chatre
Quoted 5 lines · Babu

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)

Quoted 17 lines

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>

Quoted 7 lines
Quoted 3 lines

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 2 lines

On ABMC hardware that also supports BMEC, I'm concerned about enabling ABMC when only the BMEC-style event configuration interface exists.

ABMC currently depends on BMEC making the current implementation the one you are concerned about?
https://lore.kernel.org/lkml/e4111779ebb0e7004dbedc258eeae2677f578ab1.1737577229.git.babu.moger@amd.com/

Quoted 3 lines

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.

Reinette

author reviewer
#165 lore raw

Hi Peter/Reinette,

Quoted 304 lines · Reinette Chatre

Hi Peter,

Quoted 301 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 46 lines · Reinette Chatre
Quoted 36 lines · Peter Newman
Quoted 33 lines · Reinette Chatre

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

It's good that we at least know about this concern now. Let's take a step back and figure out how we can address it.

Quoted 7 lines
Quoted 3 lines

On ABMC hardware that also supports BMEC, I'm concerned about enabling ABMC when only the BMEC-style event configuration interface exists.

ABMC currently depends on BMEC making the current implementation the one you are concerned about?
https://lore.kernel.org/lkml/e4111779ebb0e7004dbedc258eeae2677f578ab1.1737577229.git.babu.moger@amd.com/

I think it is more than that.

The ABMC feature allows event configuration by writing to L3_QOS_ABMC_CFG, where we can set cntr_id, RMID, and event configuration. Currently, we derive event configuration from BMEC settings (either mbm_total_bytes_config or mbm_local_bytes_config).

If we don’t use BMEC values, we would need to require users to manually specify event configuration settings.

struct mbm_cntr_cfg {
        enum resctrl_event_id   evtid;
        struct rdtgroup         *rdtgrp;
};

Currently, we determine the RMID from the rdtgroup and the event type, while event configuration relies on BMEC:

To make event configuration independent of BMEC, we can include an explicit event configuration field:

struct mbm_cntr_cfg {
        enum resctrl_event_id   evtid;
        u32                     evt_cfg;  // User-provided config value
        struct rdtgroup         *rdtgrp;
};

Key Considerations

1. Counter Management: Managing counters globally (like CLOSID management) would be simpler than handling them at the domain level, though domain-level management is feasible.

2. User Input: Users will need to specify event configuration when assigning events.

Here is the quick example using our current interface:
a. List the group.

#cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control //0=t:0x1F,l:0x15;1=t:0x1F,l:0x15

b. Unassign an Event:

#echo "//0-l" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control

#cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control //0=t:0x1F;1=t:0x1F,l:0x15

c. Assign an Event:

#echo "//0+l:0x15" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control

Note that I dont want to rush here.

Peter, Can you please spend some time and propose the interface you are thinking of based on both ABMC and MPAM.

Quoted 9 lines
Quoted 4 lines

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.

Reinette

Signature · 2 lines
Thanks
Babu Moger
#87 lore raw

Re: [PATCH v11 17/23] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled

In reply to Moger, Babu

Hi Babu,

Quoted 90 lines · Babu

Hi Reinette,

Quoted 86 lines · Reinette Chatre

Hi Babu,

Quoted 82 lines · Babu

Hi All,

Quoted 70 lines · Dave Martin

Hi,

Quoted 8 lines · Reinette Chatre

Hi Dave,

Quoted 5 lines · Dave Martin
Quoted 4 lines · Peter Newman

Hi Reinette,

On Wed, Feb 19, 2025 at 6:55 PM Reinette Chatre
<[email protected]> wrote:

[...]

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 1 line

Could you please remind me how a user will set this flag?

Quoting my original suggestion[1]:

"info/L3_MON/mbm_assign_on_mkdir?

boolean (parsed with kstrtobool()), defaulting to true?"

After mount, any groups that got counters on creation would have to be cleaned up, but at least that can be done with forward progress once the flag is cleared.

I was able to live with that as long as there aren't users polling for resctrl to be mounted and immediately creating groups. For us, a single container manager service manages resctrl.

[...]

Quoted 15 lines
Quoted 15 lines

+1

That's basically my position -- the auto-assignment feels like a _potential_ nuisance for ABMC-aware users, but it depends on what they are trying to do. Migration of non-ABMC-aware users will be easier for basic use cases if auto-assignment occurs by default (as in this series).

Having an explicit way to turn this off seems perfectly reasonable (and could be added later on, if not provided in this series).

What about the question re whether turning mbm_cntr_assign mode on should trigger auto-assignment?

Quoted 6 lines
Quoted 3 lines

Currently turning this mode off and then on again has the effect of removing all automatic assignments for extant groups. This feels surprising and/or unintentional (?)

Connecting to what you start off by saying I also see auto-assignment as the way to provide a smooth transition for "non-ABMC-aware" users.

I agree, and having this on by default also helps non-ABMC-aware users.

Quoted 9 lines

To me a user that turns this mode off and then on again can be considered as a user that is "ABMC-aware" and turning it "off and then on again" seems like an intuitive way to get to a "clean slate" wrt counter assignments. This may also be a convenient way for an "ABMC-aware" user space to unassign all counters and thus also helpful if resctrl supports the flag that Peter proposed. The flag seems to already keep something like this in its context with a name of "mbm_assign_on_mkdir" that could be interpreted as "only auto assign on mkdir"?

Yes, that's reasonable. It could be a good idea to document this behaviour of switching the mbm_cntr_assign mode, if we think it is useful and people are likely to rely on it.

Quoted 7 lines

Since mkdir is an implementation detail of the resctrl interface, I'd be tempted to go for a more generic name, say, "mbm_assign_new_mon_groups". But that's just bikeshedding. The proposed behaviour seems fine.

Either way, if this is not included in this series, it could be added later without breaking anything.

How about more generic "mbm_cntr_assign_auto" ?

Quoted 7 lines
Quoted 4 lines

I would like to be careful to not make it _too_ generic. Dave already pointed out that users may be surprised that counters are not auto-assigned when switching between the different modes so using the the name to help highlight when this auto-assignment can be expected to happen seems very useful.

In that case "mbm_assign_on_mkdir" seems on point and precise. Thanks

It also looks like counters are not assigned when a domain is hotplugged, so explicitly stating that it's on mkdir gets us off the hook for that.

-Peter

reviewer
#110 lore raw

Re: [PATCH v11 22/23] x86/resctrl: Introduce interface to list assignment states of all the groups

In reply to Luck, Tony

Hi,

Quoted 15 lines · Dave Martin

Hi Tony,

Quoted 11 lines · Tony
Quoted 3 lines

It has just occurred to be that ftrace has large, multi-line text files in sysfs, so I'll try to find out how they handle that there. Maybe there is some infrastructure we can re-use.

Resctrl was built on top of "kernfs" because that was a simple base that met needs at the time.

Do we need to look at either extending capabilities of kernfs? Or move to sysfs?

-Tony

Quoted 8 lines

I took a look at what ftrace does: it basically rolls its own buffering implementation, sufficient for its needs.

The ftrace code is internal and not trivial to pick up and plonk into resctrl. We also have another possible requirement that ftrace doesn't have (whole-file atomicity). But ftrace's example at least confirms that there is probably no off-the-shelf implementation for this in the kernel.

[...]

After having spent a bit of time looking into this, I think we are probably OK, at least for reading these files.

seq_file will loop over the file's show() callback, growing the seq_file buffer until show() can run without overrunning the buffer.

This means that the show() callback receives a buffer that is magically big enough, but there may be some "speculative" calls whose output never goes to userspace. Once seq_file has the data, it deals with the userspace- facing I/O buffering internally, so we shouldn't have to worry about that.

I'll try to hack up a test next week to confirm that this works.

The seq_file approach appears sound, but may be inefficient if the initial guess at the buffer size (= PAGE_SIZE) is frequently too small. (There is single_open_size() though, which allows the buffer to be preallocated with a specified size and may be useful.)

seq_file doesn't help with the write side at all, but I think we agreed that handling large file writes properly is less urgent.

Cheers
---Dave

author reviewer
#166 lore raw
In reply to Peter Newman

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 46 lines · Reinette Chatre
Quoted 36 lines · Peter Newman
Quoted 26 lines · Reinette Chatre
Quoted 5 lines · Babu

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)

Quoted 17 lines

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>

Quoted 7 lines
Quoted 3 lines

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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=_

Interpretation:
/group0/0=t;1=t : Assign a counter with event configuration 't' to domain 0 and 1 on the resctrl group0.

This format does not indicate which index should be used for assignment. Based the index we can read the events from either mbm_total_bytes or mbm_local_bytes.

Currently, we can assign two counters to a group and events can be read from mon_data/mon_L3_00/mbm_total_bytes (index 0) and mon_data/mon_L3_00/mbm_local_bytes (index 1).

To address this, we need to include the index in some form. One approach is to incorporate this information into the group's name.

Like below:

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

Interpretation:
/group0:0/0=t;1=t : Assign a counter with event configuration 't' to domain 0 and 1 on the resctrl group0 and use the index 0. The events can be read in group0/mon_data/mon_L3_00/mbm_total_bytes and group0/mon_data/mon_L3_01/mbm_total_bytes

/group0:1/0=l;1=l : Assign a counter with event configuration 'l' to domain 0 and 1 on the resctrl group0 and use the index 1. The events can be read in group0/mon_data/mon_L3_00/mbm_local_bytes and group0/mon_data/mon_L3_01/mbm_local_bytes

What are your thoughts?

Signature · 2 lines
Thanks
Babu Moger
maintainer
#111 lore raw

RE: [PATCH v11 22/23] x86/resctrl: Introduce interface to list assignment states of all the groups

In reply to Dave Martin
Quoted 10 lines

After having spent a bit of time looking into this, I think we are probably OK, at least for reading these files.

seq_file will loop over the file's show() callback, growing the seq_file buffer until show() can run without overrunning the buffer.

This means that the show() callback receives a buffer that is magically big enough, but there may be some "speculative" calls whose output never goes to userspace. Once seq_file has the data, it deals with the userspace- facing I/O buffering internally, so we shouldn't have to worry about that.

Doesn't this depend on the size of the user read(2) syscall request?

If the total size of the resctrl file is very large, we have a potential issue:

1) User asks for 4KB, owns the resctrl mutex.

2) resctrl uses seq_file and fills with more than 4KB

3) User gets the first 4KB, releases the resctrl mutex

4) Some other pending resctrl operation now gets the mutex and makes changes that affect the contents of this file

5) User asks for next 4K (when it reaquires resctrl mutex)

6) resctrl uses seq_file() to construct new image of file incorporating changes because of step 4

7) User gets the second 4KB from the seq_file buffer (which doesn't fit cleanly next to data it got in step 3).

-Tony

#167 lore raw
In reply to Moger, Babu
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 46 lines · Reinette Chatre
Quoted 36 lines · Peter Newman
Quoted 33 lines · Reinette Chatre

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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.

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.

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

Note that we could also pre-populate info/L3_MON/counter_configs with the expected configuration for mbm_local_bytes and mbm_total_bytes for backwards compatibility.

To manually allocate counters for "mbm_local_bytes":

 # mkdir test
 # echo mbm_local_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_02/assign_exclusive
[..]

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

For unassignment, we can just make an "unassign" node alongside "assign_exclusive" and "assign_shared". These should provide enough context to form resctrl_arch_config_cntr() calls.

-Peter

[1] https://lore.kernel.org/lkml/CALPaoCj1TH+GN6+dFnt5xuN406u=tB-8mj+UuMRSm5KWPJW2wg@mail.gmail.com/

author reviewer
#168 lore raw

Hi Peter,

Quoted 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 46 lines · Reinette Chatre
Quoted 42 lines · Peter Newman

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.

Quoted 10 lines

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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.

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?

Quoted 8 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?

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.

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.

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

That was another problem we need to address.

Quoted 5 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.

Quoted 8 lines
 # 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

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

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

Quoted 15 lines

Note that we could also pre-populate info/L3_MON/counter_configs with the expected configuration for mbm_local_bytes and mbm_total_bytes for backwards compatibility.

To manually allocate counters for "mbm_local_bytes":

 # mkdir test
 # echo mbm_local_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_02/assign_exclusive
[..]

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

Quoted 8 lines

For unassignment, we can just make an "unassign" node alongside "assign_exclusive" and "assign_shared". These should provide enough context to form resctrl_arch_config_cntr() calls.

-Peter

[1] https://lore.kernel.org/lkml/CALPaoCj1TH+GN6+dFnt5xuN406u=tB-8mj+UuMRSm5KWPJW2wg@mail.gmail.com/

Lets keep discussing.

Signature · 2 lines
Thanks
Babu Moger
#169 lore raw

Hi Babu,

Quoted 383 lines · Babu

Hi Peter,

Quoted 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 59 lines · Peter Newman
Quoted 56 lines · Reinette Chatre

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.

Quoted 5 lines

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.

Quoted 13 lines

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)

Quoted 9 lines

(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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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.

Quoted 7 lines

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

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?

Quoted 11 lines
Quoted 9 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].

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.

Quoted 9 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.

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.

Quoted 4 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.

Quoted 16 lines
Quoted 7 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.

Quoted 8 lines
 # 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

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.

-Peter

reviewer
#112 lore raw

Re: [PATCH v11 22/23] x86/resctrl: Introduce interface to list assignment states of all the groups

In reply to Luck, Tony
Quoted 6 lines · Tony
Quoted 6 lines

After having spent a bit of time looking into this, I think we are probably OK, at least for reading these files.

seq_file will loop over the file's show() callback, growing the seq_file buffer until show() can run without overrunning the buffer.

Quoted 6 lines
Quoted 4 lines

This means that the show() callback receives a buffer that is magically big enough, but there may be some "speculative" calls whose output never goes to userspace. Once seq_file has the data, it deals with the userspace- facing I/O buffering internally, so we shouldn't have to worry about that.

Doesn't this depend on the size of the user read(2) syscall request?

Yes and no.

If I've understood correctly:

To service a given read() call, seq_file calls down into the backend to generate some whole record, then copies it out to userspace, then repeats this process so long as there is any space left in the user buffer.

For resctrl files, we don't implement a seq_file iterator: there is no .next(), no .llseek(), and we don't implement any notion of file position. So our _show() functions generate a single big record that contains the whole dump -- frequently multiple lines of text.

(This might or might not be desirable, but it is at least simple.)

If a _show() function in resctrl holds rdtgroup_mutex throughout, then whatever it dumps will be dumped atomically with respect to other resctrl operations that take this mutex.

So, to flesh out your scenario:

Quoted 2 lines

If the total size of the resctrl file is very large, we have a potential issue:

Let's say it's 5KB.

Quoted 1 line

1) User asks for 4KB, owns the resctrl mutex.

(Note, rdtgroup_mutex is only held temporarily inside the resctrlfs backend to these operations; at the start of the process, it is not held.)

Quoted 1 line

2) resctrl uses seq_file and fills with more than 4KB

(It's actually seq_file that uses resctrl here via callbacks: seq_file sits in between the VFS layer and resctrl.)

When a .show() callback is called, resctrl doesn't know how much data to generate; it just writes stuff out with seq_printf() etc.

If there's too much to fit in the default seq_file buffer, the data gets truncated and the seq_file will get internally marked as having overflowed. resctrl could check for this condition in order to avoid formatting text that will get thrown away due to truncation, but this is not required. When the .show() callback returns, the seq_file implementation will respond to the overflow by growing the buffer and retrying the whole thing until this doesn't occur (see the loop preceding the "Fill" label in seq_file.c:seq_read_iter().)

This terminates with a seq_file buffer that contains all the output (untruncated), or with an -ENOMEM failure (which would be punted to userspace).

So, assuming nothing went wrong, the seq_file buffer now has the 5KB of data. rdtgroup_mutex is not held (it was only held in the _show() callback).

Quoted 1 line

3) User gets the first 4KB, releases the resctrl mutex

Userspace gets the first 4KB, and seq_file's notion of the file position is advanced by this amount, and the generated text is kept in the seq_file's buffer.

Quoted 1 line

4) Some other pending resctrl operation now gets the mutex and makes changes that affect the contents of this file

The un-read data remains buffered in seq_file. Other resctrl operations can happen, so the buffered data may become stale, but it is still an atomic snapshot.

Quoted 1 line

5) User asks for next 4K (when it reaquires resctrl mutex)

If an iterator is implemented, seq_file might try to generate another record to fill the requested space. But we don't have an iterator, so the generated data remains as-is.

Quoted 1 line

6) resctrl uses seq_file() to construct new image of file incorporating changes because of step 4

I think this happens only if the file is reopened or lseek()'d, and only if .llseek() is wired up in struct file_operations. Resctrl doesn't seem to do this (whether by accident or by design).

So userspace just sees a non-seekable file.

Quoted 1 line

7) User gets the second 4KB from the seq_file buffer (which doesn't fit cleanly next to data it got in step 3).

Userspace gets the final 1K of the data that was generated in response to the original read() call.

If userspace tries to read again, it will get EOF (again, because we don't have an iterator -- meaning that no additional records can be generated).

I haven't traced in detail through the code, but that's my understanding.

Cheers
---Dave

author reviewer
#170 lore raw
In reply to Peter Newman

Hi Peter,

Quoted 388 lines · Peter Newman

Hi Babu,

Quoted 385 lines · Babu

Hi Peter,

Quoted 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 91 lines · Reinette Chatre
Quoted 64 lines · Peter Newman

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.

Quoted 22 lines

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
...

Quoted 4 lines

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
   /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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.

Quoted 19 lines
Quoted 11 lines
Quoted 10 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.

Quoted 1 line

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 7 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.

Quoted 8 lines
 # 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.

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

# #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

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

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>.

Signature · 2 lines
Thanks
Babu Moger
#171 lore raw

Hi All,

Quoted 575 lines · Babu

Hi Peter,

Quoted 388 lines · Peter Newman

Hi Babu,

Quoted 385 lines · Babu

Hi Peter,

Quoted 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 105 lines · Peter Newman
Quoted 95 lines · Reinette Chatre

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.

Quoted 4 lines

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:

Quoted 8 lines
Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
    /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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.

Quoted 19 lines
Quoted 11 lines
Quoted 10 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.

Quoted 1 line

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 7 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.

Quoted 8 lines
  # 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.

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

# #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

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 7 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>.

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

maintainer
#172 lore raw
Quoted 521 lines · Babu

Hi All,

Quoted 518 lines · Babu

Hi Peter,

Quoted 388 lines · Peter Newman

Hi Babu,

Quoted 385 lines · Babu

Hi Peter,

Quoted 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 178 lines · Reinette Chatre
Quoted 109 lines · Peter Newman

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:

Quoted 8 lines

(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

Quoted 6 lines

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=_

Quoted 7 lines

- 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

Quoted 8 lines
    /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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.

Quoted 19 lines
Quoted 11 lines
Quoted 10 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.

Quoted 1 line

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 7 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.

Quoted 8 lines
  # 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.

#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 57 lines
Quoted 57 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

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

-Tony

#173 lore raw

Hi Tony,

Quoted 520 lines · Tony
Quoted 519 lines · Babu

Hi All,

Quoted 516 lines · Babu

Hi Peter,

Quoted 388 lines · Peter Newman

Hi Babu,

Quoted 385 lines · Babu

Hi Peter,

Quoted 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 207 lines · Peter Newman
Quoted 184 lines · Reinette Chatre

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=_
Quoted 7 lines

- 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

Quoted 8 lines
     /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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.

Quoted 19 lines
Quoted 11 lines
Quoted 10 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.

Quoted 1 line

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 7 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.

Quoted 8 lines
   # 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.

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.

Quoted 81 lines
Quoted 58 lines
Quoted 58 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

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 2 lines
Quoted 1 line
Quoted 9 lines
Quoted 6 lines

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

-Tony

thanks
Babu

maintainer
#174 lore raw
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 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 227 lines · Reinette Chatre

Hi Peter,

Quoted 214 lines · Peter Newman

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

Quoted 8 lines

     /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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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 7 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.

Quoted 8 lines
   # 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/

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

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 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.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

     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

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.

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.

Quoted 59 lines
Quoted 59 lines
Quoted 29 lines
Quoted 29 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
#175 lore raw

Hi All,

Quoted 540 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 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 240 lines · Peter Newman

Hi Reinette,

Quoted 235 lines · Reinette Chatre

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.

Quoted 10 lines

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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 123 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 7 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.

Quoted 8 lines
   # 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.

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.

Quoted 7 lines
Quoted 1 line

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/

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 32 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 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.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

     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 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.

Quoted 7 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

Signature · 2 lines
Thanks
Babu Moger
maintainer
#176 lore raw
Quoted 624 lines · Babu

Hi All,

Quoted 540 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 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 250 lines · Peter Newman

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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 123 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 7 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.

Quoted 8 lines
   # 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.

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.

Quoted 7 lines
Quoted 1 line

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/

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 32 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 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.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

     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 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.

Quoted 7 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.

Quoted 6 lines

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.

How big of a problem is this in reality? I'd assume that users of this feature would only reassign counter attributes at some slow rate (set up counters, measure for at least a few seconds, then set up for next measurement). Cost to open/read/close a few hundred kernfs files isn't very high. Biggest cost might be hogging the resctrl mutex which would cause jitter in the tasks reading data from resctrl monitors.

Anyone doing this at scale should be able to keep track of what they set, so wouldn't need to read at all. I'm not a big believer in "multiple agents independently tweaking resctrl without knowledge of each other".

Quoted 101 lines

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 64 lines
Quoted 64 lines
Quoted 62 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

-Tony

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

thanks
Babu

Reinette

Signature · 2 lines
Thanks
Babu Moger

-Tony

maintainer
#179 lore raw
In reply to Moger, Babu

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 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 284 lines · Babu

Hi Peter,

Quoted 250 lines · Peter Newman

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.

Quoted 5 lines

(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.)

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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 7 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.

Quoted 8 lines
   # 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.

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.

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

Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 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?

Quoted 142 lines
Quoted 9 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
#177 lore raw
In reply to Luck, Tony

Hi Tony,

Quoted 632 lines · Tony
Quoted 624 lines · Babu

Hi All,

Quoted 540 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 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 291 lines · Babu

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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 123 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 7 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.

Quoted 8 lines
   # 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.

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.

Quoted 7 lines
Quoted 1 line

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/

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 32 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 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.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

     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 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.

Quoted 7 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.

Quoted 6 lines

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.

Quoted 6 lines

How big of a problem is this in reality? I'd assume that users of this feature would only reassign counter attributes at some slow rate (set up counters, measure for at least a few seconds, then set up for next measurement). Cost to open/read/close a few hundred kernfs files isn't very high. Biggest cost might be hogging the resctrl mutex which would cause jitter in the tasks reading data from resctrl monitors.

Yes. That is a good point. Dont know how big the problem it is.

But we all need to aggre that group listing is not requirement. We can go ahead that route.

Lets hear from all the parties.

Quoted 119 lines

Anyone doing this at scale should be able to keep track of what they set, so wouldn't need to read at all. I'm not a big believer in "multiple agents independently tweaking resctrl without knowledge of each other".

Quoted 101 lines

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 64 lines
Quoted 64 lines
Quoted 62 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

-Tony

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

thanks
Babu

Reinette

Signature · 2 lines
Thanks
Babu Moger

-Tony

Signature · 2 lines
Thanks
Babu Moger
maintainer
#178 lore raw
In reply to Luck, Tony

Hi Tony,

Quoted 632 lines · Tony
Quoted 624 lines · Babu

Hi All,

Quoted 540 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 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 291 lines · Babu

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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 123 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 7 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.

Quoted 8 lines
   # 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.

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.

Quoted 7 lines
Quoted 1 line

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/

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 32 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 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.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

     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 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.

Quoted 7 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.

Quoted 6 lines

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.

Quoted 6 lines

How big of a problem is this in reality? I'd assume that users of this feature would only reassign counter attributes at some slow rate (set up counters, measure for at least a few seconds, then set up for next measurement). Cost to open/read/close a few hundred kernfs files isn't very high. Biggest cost might be hogging the resctrl mutex which would cause jitter in the tasks reading data from resctrl monitors.

Good point. The length of holding the resctrl mutex should also be considered when exploring the mbm_assign_control file. If a user attempts to make many changes using a single file like that then holding the resctrl mutex during entire configuration may also have a big impact. This may be of more concern with the additional automation being added to resctrl, for example the upcoming "shared assignment" that does automatic assignment of counters.

Quoted 118 lines

Anyone doing this at scale should be able to keep track of what they set, so wouldn't need to read at all. I'm not a big believer in "multiple agents independently tweaking resctrl without knowledge of each other".

Quoted 101 lines

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 64 lines
Quoted 64 lines
Quoted 62 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

-Tony

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

thanks
Babu

Reinette

Signature · 2 lines
Thanks
Babu Moger

-Tony

author reviewer
#180 lore raw
In reply to Reinette Chatre

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 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 302 lines · Peter Newman

Hi Babu,

Quoted 291 lines · Babu

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.

Quoted 5 lines

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

Quoted 6 lines

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:

Quoted 8 lines

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 7 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.

Quoted 8 lines
   # 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?

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.

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 189 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?

Quoted 142 lines
Quoted 9 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

Signature · 2 lines
Thanks
Babu Moger
maintainer
#181 lore raw

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 369 lines · Peter Newman
Quoted 353 lines · Babu

Hi Peter/Reinette,

Quoted 307 lines · Peter Newman

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

Quoted 6 lines

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:

Quoted 8 lines

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 7 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.

Quoted 8 lines
   # 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

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

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

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 195 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 189 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?

Quoted 142 lines
Quoted 9 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
#182 lore raw

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 369 lines · Peter Newman
Quoted 359 lines · Babu

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:

Quoted 8 lines

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 7 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.

Quoted 8 lines
   # 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 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/

# 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

In the future, we can add mkdir support.

# mkdir info/L3_MON/counter_configs/mbm_read_only
# echo LclFill > info/L3_MON/counter_configs/mbm_read_only
# cat info/L3_MON/counter_configs/mbm_read_only
  LclFill

#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.

Quoted 7 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

Signature · 2 lines
Thanks
Babu Moger