Skip to contentSkip to conversation

Resctrl and I/O

DISCUSSION Luck, Tony 8 participants 10 messages Sep 22 – Oct 15 RISC-V

lore
Share & tools
lore

Luck, Tony

author
#0 lore raw

Patches for ARM[1] and RISC-V[2] are both at RFC status.

They appear to be based on similar h/w capabilities where architecture specific tags can be added to transactions from I/O devices by the IOMMU servicing the device. Device enumeration is handled outside of the resctrl file system.

ARM docs say "the device name is the one listed under /sys/kernel/iommu_groups/<id>/devices/"

RISC-V says architecture specific device tokens are "devices or device groups"

In both cases assignments are made with:

	# echo {device} > {group}/devices

So now I'm looking at the capabilities of Intel RDT hardware. I'm ignoring the implementation on the Granite Rapids CPU, and looking at what is described in the RDT Architecture Specification[3]. Here are the highlights:

1) Enumeration is split between two ACPI tables. IRDT enumerates device groups and provides MMIO addresses to assign CLOSID/RMID to each group. ERDT provides MMIO addresses to read event counts for RMIDs and to configure cache allocation bit masks and memory bandwidth limits.

2) All I/O monitoring and control is with respect to I/O caches, not to the L3 caches that legacy RDT features operate on.

3) The number of RMIDs supported for I/O is lower (maybe considearbly lower) than the number supported for CPU monitoring.

4) Monitoring events are I/O cache occupancy, total i/o bandwidth, and i/o miss bandwidth.

5) Current revision (1.4) of the specification doesn't include details of I/O memory bandwidth control (The "IBAD" subtable of ERDT is reserved for this).

Fitting this into resctrl
-------------------------

RISC-V description of "architecture specific device tokens" sounds great. I'll have to find some ares of /sys to provide the mapping of tokens to "device groups". There's no association with IOMMUs, so this will be some other path in /sys. Perhaps under /sys/firmware/acpi since the data comes from ACPI IRDT table.

Need an info file to tell users the format and source for device tokens.

I'd like to avoid limiting resctrl monitoring of CPU activity due to the small number of I/O RMIDs. Perhaps don't include a "devices" file or mon_data/{i/o events} files in resctrl group directories when rdtgroup::mon::rmid >= num_io_rmids? But that feels clumsy.

Domains are based on I/O L3 cache instances. So a new rdt_resource with new line in the schemata file for IOL3 cache masks per domain. In the future when there are I/O MBA controls, new line(s) for those too.

-Tony

[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] Linked from the bottom of https://www.intel.com/sdm under "Related Specifications", or direct link: https://cdrdv2.intel.com/v1/dl/getContent/789566?erpm_id=1158389_ts1790091453223

#1 lore raw
Quoted 6 lines · Tony

Patches for ARM[1] and RISC-V[2] are both at RFC status.

They appear to be based on similar h/w capabilities where architecture specific tags can be added to transactions from I/O devices by the IOMMU servicing the device. Device enumeration is handled outside of the resctrl file system.

Thanks for starting a discussion on this topic.

Quoted 5 lines

RISC-V description of "architecture specific device tokens" sounds great. I'll have to find some ares of /sys to provide the mapping of tokens to "device groups". There's no association with IOMMUs, so this will be some other path in /sys. Perhaps under /sys/firmware/acpi since the data comes from ACPI IRDT table.

resctrl could parse iommu_group:<id> itself which should cover the IOMMU case on ARM and RISC-V. Maybe other prefixes could be passed on to arch code?

Quoted 1 line

Need an info file to tell users the format and source for device tokens.

I agree and it could list which token namespaces the platform uses.

Quoted 4 lines

I'd like to avoid limiting resctrl monitoring of CPU activity due to the small number of I/O RMIDs. Perhaps don't include a "devices" file or mon_data/{i/o events} files in resctrl group directories when rdtgroup::mon::rmid >= num_io_rmids? But that feels clumsy.

There's no separate I/O ID space on RISC-V that could be smaller. The IDs a device carries are the same IDs the hart (e.g. cpu) carries. The number of RCIDs (e.g. CLOSID) and MCIDs (e.g. RMID) is a property of each capacity or bandwidth (CBQRI) controller. The RISC-V IOMMU spec also requires the IOMMU to support RCID and MCID at least as wide as any hart.

Thanks,
Drew

#2 lore raw
In reply to Luck, Tony

Hi Tony,

Quoted 8 lines · Tony

Patches for ARM[1] and RISC-V[2] are both at RFC status.

They appear to be based on similar h/w capabilities where architecture specific tags can be added to transactions from I/O devices by the IOMMU servicing the device. Device enumeration is handled outside of the resctrl file system.

ARM docs say "the device name is the one listed under /sys/kernel/iommu_groups/<id>/devices/"

I think using existing stuff in sysfs is a good idea. (Creating new things in sysfs fills me with dread!)

ARM/MPAM also has platform devices that can add the CLOSID/RMID metadata. e.g. the GIC ITS [4] - a kind of translator for MSIs.

For these we considered just using the device name as found in /sys/bus/platform/devices/, in the hope that can be tied back to a struct device - and we could add a callback for resctrl to configure the device with a CLOSID/RMID.
(but - I've not seen a use-case for this yet - those devices generate very little traffic)

Robin M set me straight on the iommu_group:
Strictly that is the wrong abstraction as devices are in the same group if the driver can't stop them communicating, e.g. PCIe peer2peer. This doesn't mean it can't tell the traffic apart for CLOSID/RMID labelling.
I picked this because its the device granularity VFIO works with.

Equally, a device may create multiple streams of traffic, where only the driver will know what each one corresponds to.

Using iommu_group like this may need a bit more thinking....
If we can fall back to using a device as seen by sysfs, then the arch differences here could be invisible to user-space.

Quoted 6 lines

RISC-V says architecture specific device tokens are "devices or device groups"

In both cases assignments are made with:

	# echo {device} > {group}/devices
Quoted 7 lines

So now I'm looking at the capabilities of Intel RDT hardware. I'm ignoring the implementation on the Granite Rapids CPU, and looking at what is described in the RDT Architecture Specification[3]. Here are the highlights:

1) Enumeration is split between two ACPI tables. IRDT enumerates device groups and provides MMIO addresses to assign CLOSID/RMID to each group.

For ARM/MPAM - this would always be driver specific. The fields may be share a register with other things the driver needs to consider.
The IOMMU abstracts this for its devices, but this is still something the IOMMU driver needs to know about.

A driver hook, with a drivers/acpi fallback would be ideal.

Do you have arbitrary grouping of devices? e.g. a USB controller and the UART. Or would the grouping make some sense to the OS. e.g. all the USB devices behind this port.

Having the UART show up when you add a USB controller to a control group is a bit odd.

Quoted 3 lines

ERDT provides
MMIO addresses to read event counts for RMIDs and to configure cache allocation bit masks and memory bandwidth limits.

Arm's IOMMU does have controls/monitors that match the spec the MPAM driver needs, but we currently have no way to expose them through resctrl.
The caches on the IOMMU are also relatively small - I've not yet seen anyone show that setting the controls there makes a big difference.

Quoted 2 lines

2) All I/O monitoring and control is with respect to I/O caches, not to the L3 caches that legacy RDT features operate on.

Do you have I/O traffic that can turn up in the CPU L3 cache? I think PCIe calls this 'cache stashing'.

Arm's IOMMU is the same - but the traffic may also show up in the L3 depending on how the system is put together.

Quoted 2 lines

3) The number of RMIDs supported for I/O is lower (maybe considearbly lower) than the number supported for CPU monitoring.

MPAM can have this happen - and today it will sanitise the values to the lowest common value. Considerably lower becomes considerably upsetting!

I'd be interested if we have an approach for this - the IOMMU designers would argue they only need one RMID per device - but the system wide sanitised value means they have to match the rest of the system.

For MPAM systems this shape is a big headache because on the platforms we've seen, the monitoring is done at the memory-controllers - so any RMID spaces get joined up eventually.

Quoted 10 lines

4) Monitoring events are I/O cache occupancy, total i/o bandwidth, and i/o miss bandwidth.

5) Current revision (1.4) of the specification doesn't include details of I/O memory bandwidth control (The "IBAD" subtable of ERDT is reserved for this).

Fitting this into resctrl
-------------------------

Quoted 6 lines

RISC-V description of "architecture specific device tokens" sounds great. I'll have to find some ares of /sys to provide the mapping of tokens to "device groups".
There's no association with IOMMUs, so this will be some other path in /sys. Perhaps under /sys/firmware/acpi since the data comes from ACPI IRDT table.

What about using the device behind the IOMMU instead? Presumably the kernel could allocate ids that don't clash with those in the IRDT, and use those for the IOMMU.

Quoted 1 line

Need an info file to tell users the format and source for device tokens.

I'd prefer we have one consistent way of doing this across architectures. Especially if we're going to add something new to sysfs.

The sysfs path probably covers all bases - but I wouldn't want to parse that in the kernel.

Quoted 4 lines

I'd like to avoid limiting resctrl monitoring of CPU activity due to the small number of I/O RMIDs. Perhaps don't include a "devices" file or mon_data/{i/o events} files in resctrl group directories when rdtgroup::mon::rmid >= num_io_rmids? But that feels clumsy.

I had a half baked idea on how to do this. (which Ben has poked some holes in)

Assigning a device to a ctrl/mon group needs to be able to fail. We can use this to re-allocate the RMID into the range the new device can use. The CPU tasks can be repainted to use the new value - but the obvious problem is the old data in the caches that uses the old RMID.
As no new traffic will be generated for that RMID, it might be possible to keep it associated with the ctrl/mon group (which would now have two RMID) to keep the user-space view of the counters correct until the old RMID falls below the reallocation threshold, and it can be free'd.

It's worse if we ever needed/wanted to do this with CLOSID. Two CAT bitmaps can be configured the same - but MBA doesn't alias in the same way. Tasks would be able to burst higher than the configured limit - but the size is limited by the size of the caches. And if no new traffic can be generated with the old CLOSID/RMID, then the effect can't be made to last forever.

For a totally wild suggestion (that I don't think works here) - I had mooted having a second mount of resctrl for islands of the SoC where the properties are different. I don't think it works in this case as the IO-RMID presumably gets seen by some other monitors later.

Quoted 3 lines

Domains are based on I/O L3 cache instances. So a new rdt_resource with new line in the schemata file for IOL3 cache masks per domain. In the future when there are I/O MBA controls, new line(s) for those too.

Thanks,

James

[4] https://support.arm.com/documentation/ihi0069/hb/?lang=en search for "MPAM" in the pdf.

Quoted 5 lines

[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] Linked from the bottom of https://www.intel.com/sdm under "Related Specifications", or direct link: https://cdrdv2.intel.com/v1/dl/getContent/789566?erpm_id=1158389_ts1790091453223

#3 lore raw
Quoted 3 lines · James Morse

Using iommu_group like this may need a bit more thinking....
If we can fall back to using a device as seen by sysfs, then the arch differences here could be invisible to user-space.

Please don't codify iommu_groups in any new uAPI, that has proven to be a problematic choice for VFIO. We undid it.. Lets not repeat it.

Jason

#4 lore raw
In reply to James Morse

Hi James,

Quoted 92 lines · James Morse

Hi Tony,

Quoted 8 lines · Tony

Patches for ARM[1] and RISC-V[2] are both at RFC status.

They appear to be based on similar h/w capabilities where architecture specific tags can be added to transactions from I/O devices by the IOMMU servicing the device. Device enumeration is handled outside of the resctrl file system.

ARM docs say "the device name is the one listed under /sys/kernel/iommu_groups/<id>/devices/"

I think using existing stuff in sysfs is a good idea. (Creating new things in sysfs fills me with dread!)

ARM/MPAM also has platform devices that can add the CLOSID/RMID metadata. e.g. the GIC ITS [4] - a kind of translator for MSIs.

For these we considered just using the device name as found in /sys/bus/platform/devices/, in the hope that can be tied back to a struct device - and we could add a callback for resctrl to configure the device with a CLOSID/RMID.
(but - I've not seen a use-case for this yet - those devices generate very little traffic)

Robin M set me straight on the iommu_group:
Strictly that is the wrong abstraction as devices are in the same group if the driver can't stop them communicating, e.g. PCIe peer2peer. This doesn't mean it can't tell the traffic apart for CLOSID/RMID labelling.
I picked this because its the device granularity VFIO works with.

Equally, a device may create multiple streams of traffic, where only the driver will know what each one corresponds to.

Using iommu_group like this may need a bit more thinking....
If we can fall back to using a device as seen by sysfs, then the arch differences here could be invisible to user-space.

Quoted 6 lines

RISC-V says architecture specific device tokens are "devices or device groups"

In both cases assignments are made with:

      # echo {device} > {group}/devices
Quoted 7 lines

So now I'm looking at the capabilities of Intel RDT hardware. I'm ignoring the implementation on the Granite Rapids CPU, and looking at what is described in the RDT Architecture Specification[3]. Here are the highlights:

1) Enumeration is split between two ACPI tables. IRDT enumerates device groups and provides MMIO addresses to assign CLOSID/RMID to each group.

For ARM/MPAM - this would always be driver specific. The fields may be share a register with other things the driver needs to consider.
The IOMMU abstracts this for its devices, but this is still something the IOMMU driver needs to know about.

A driver hook, with a drivers/acpi fallback would be ideal.

Do you have arbitrary grouping of devices? e.g. a USB controller and the UART. Or would the grouping make some sense to the OS. e.g. all the USB devices behind this port.

Having the UART show up when you add a USB controller to a control group is a bit odd.

Quoted 3 lines

ERDT provides
MMIO addresses to read event counts for RMIDs and to configure cache allocation bit masks and memory bandwidth limits.

Arm's IOMMU does have controls/monitors that match the spec the MPAM driver needs, but we currently have no way to expose them through resctrl.
The caches on the IOMMU are also relatively small - I've not yet seen anyone show that setting the controls there makes a big difference.

Quoted 2 lines

2) All I/O monitoring and control is with respect to I/O caches, not to the L3 caches that legacy RDT features operate on.

Do you have I/O traffic that can turn up in the CPU L3 cache? I think PCIe calls this 'cache stashing'.

Arm's IOMMU is the same - but the traffic may also show up in the L3 depending on how the system is put together.

Quoted 2 lines

3) The number of RMIDs supported for I/O is lower (maybe considearbly lower) than the number supported for CPU monitoring.

Quoted 7 lines

MPAM can have this happen - and today it will sanitise the values to the lowest common value. Considerably lower becomes considerably upsetting!

I'd be interested if we have an approach for this - the IOMMU designers would argue they only need one RMID per device - but the system wide sanitised value means they have to match the rest of the system.

This lowest-common-denominator issue suggests that resctrl may need a logical CLOSID/RMID namespace that is independent of the ID space implemented by each hardware controller.

A resctrl group would retain a system-wide logical CLOSID/RMID, while each resource or architecture backend maps those logical IDs to its controller-local allocation entries and monitoring counters. This would avoid unconditionally limiting the number of resctrl groups to the minimum ID count across all enabled resources.

The current resctrl allocation model uses that minimum as the system-wide CLOSID limit, which is safe for direct indexing but leaves additional entries in larger controllers unused.

On the RISC-V CBQRI side, we are discussing a hardware mechanism that could provide such per-controller mapping while requests continue to carry the logical RCIDs/MCIDs:

https://lists.riscv.org/g/sig-datacenter/message/286

Thanks,
Yunhui

Quoted 85 lines

For MPAM systems this shape is a big headache because on the platforms we've seen, the monitoring is done at the memory-controllers - so any RMID spaces get joined up eventually.

Quoted 10 lines

4) Monitoring events are I/O cache occupancy, total i/o bandwidth, and i/o miss bandwidth.

5) Current revision (1.4) of the specification doesn't include details of I/O memory bandwidth control (The "IBAD" subtable of ERDT is reserved for this).

Fitting this into resctrl
-------------------------

Quoted 6 lines

RISC-V description of "architecture specific device tokens" sounds great. I'll have to find some ares of /sys to provide the mapping of tokens to "device groups".
There's no association with IOMMUs, so this will be some other path in /sys. Perhaps under /sys/firmware/acpi since the data comes from ACPI IRDT table.

What about using the device behind the IOMMU instead? Presumably the kernel could allocate ids that don't clash with those in the IRDT, and use those for the IOMMU.

Quoted 1 line

Need an info file to tell users the format and source for device tokens.

I'd prefer we have one consistent way of doing this across architectures. Especially if we're going to add something new to sysfs.

The sysfs path probably covers all bases - but I wouldn't want to parse that in the kernel.

Quoted 4 lines

I'd like to avoid limiting resctrl monitoring of CPU activity due to the small number of I/O RMIDs. Perhaps don't include a "devices" file or mon_data/{i/o events} files in resctrl group directories when rdtgroup::mon::rmid >= num_io_rmids? But that feels clumsy.

I had a half baked idea on how to do this. (which Ben has poked some holes in)

Assigning a device to a ctrl/mon group needs to be able to fail. We can use this to re-allocate the RMID into the range the new device can use. The CPU tasks can be repainted to use the new value - but the obvious problem is the old data in the caches that uses the old RMID.
As no new traffic will be generated for that RMID, it might be possible to keep it associated with the ctrl/mon group (which would now have two RMID) to keep the user-space view of the counters correct until the old RMID falls below the reallocation threshold, and it can be free'd.

It's worse if we ever needed/wanted to do this with CLOSID. Two CAT bitmaps can be configured the same - but MBA doesn't alias in the same way. Tasks would be able to burst higher than the configured limit - but the size is limited by the size of the caches. And if no new traffic can be generated with the old CLOSID/RMID, then the effect can't be made to last forever.

For a totally wild suggestion (that I don't think works here) - I had mooted having a second mount of resctrl for islands of the SoC where the properties are different. I don't think it works in this case as the IO-RMID presumably gets seen by some other monitors later.

Quoted 3 lines

Domains are based on I/O L3 cache instances. So a new rdt_resource with new line in the schemata file for IOL3 cache masks per domain. In the future when there are I/O MBA controls, new line(s) for those too.

Thanks,

James

[4] https://support.arm.com/documentation/ihi0069/hb/?lang=en search for "MPAM" in the pdf.

Quoted 5 lines

[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] Linked from the bottom of https://www.intel.com/sdm under "Related Specifications", or direct link: https://cdrdv2.intel.com/v1/dl/getContent/789566?erpm_id=1158389_ts1790091453223

#5 lore raw
In reply to James Morse
Quoted 30 lines · James Morse

Hi Tony,

Quoted 8 lines · Tony

Patches for ARM[1] and RISC-V[2] are both at RFC status.

They appear to be based on similar h/w capabilities where architecture specific tags can be added to transactions from I/O devices by the IOMMU servicing the device. Device enumeration is handled outside of the resctrl file system.

ARM docs say "the device name is the one listed under /sys/kernel/iommu_groups/<id>/devices/"

I think using existing stuff in sysfs is a good idea. (Creating new things in sysfs fills me with dread!)

ARM/MPAM also has platform devices that can add the CLOSID/RMID metadata. e.g. the GIC ITS [4] - a kind of translator for MSIs.

For these we considered just using the device name as found in /sys/bus/platform/devices/, in the hope that can be tied back to a struct device - and we could add a callback for resctrl to configure the device with a CLOSID/RMID.
(but - I've not seen a use-case for this yet - those devices generate very little traffic)

Robin M set me straight on the iommu_group:
Strictly that is the wrong abstraction as devices are in the same group if the driver can't stop them communicating, e.g. PCIe peer2peer. This doesn't mean it can't tell the traffic apart for CLOSID/RMID labelling.
I picked this because its the device granularity VFIO works with.

Quoted 9 lines

Equally, a device may create multiple streams of traffic, where only the driver will know what each one corresponds to.

Using iommu_group like this may need a bit more thinking....
If we can fall back to using a device as seen by sysfs, then the arch differences here could be invisible to user-space.

Hi all,

Thanks for the feedback and the discussion. The device_name -> iommu_group -> sid mapping shown in the patch[1] is only one configuration example. It may not fully exploit MPAM capabilities, especially when multiple devices share the same iommu_group.

There are other possible configuration approaches, for example deriving the SID directly from the PCIe BDF. I prefer to use the device directly
rather than iommu_group, as that is more aligned with the MPAM
specification. I also agree that iommu_group is not ideal as a new uAPI, for the reasons Jason and others have pointed out.

However, there are two problems with using the device directly:

Not all devices can obtain their SID via a device name in the same way PCIe devices can.

MPAM actually supports SSID-granularity control and monitoring, but users currently cannot obtain the SSID.

Quoted 145 lines
Quoted 6 lines

RISC-V says architecture specific device tokens are "devices or device groups"

In both cases assignments are made with:

	# echo {device} > {group}/devices
Quoted 7 lines

So now I'm looking at the capabilities of Intel RDT hardware. I'm ignoring the implementation on the Granite Rapids CPU, and looking at what is described in the RDT Architecture Specification[3]. Here are the highlights:

1) Enumeration is split between two ACPI tables. IRDT enumerates device groups and provides MMIO addresses to assign CLOSID/RMID to each group.

For ARM/MPAM - this would always be driver specific. The fields may be share a register with other things the driver needs to consider.
The IOMMU abstracts this for its devices, but this is still something the IOMMU driver needs to know about.

A driver hook, with a drivers/acpi fallback would be ideal.

Do you have arbitrary grouping of devices? e.g. a USB controller and the UART. Or would the grouping make some sense to the OS. e.g. all the USB devices behind this port.

Having the UART show up when you add a USB controller to a control group is a bit odd.

Quoted 3 lines

ERDT provides
MMIO addresses to read event counts for RMIDs and to configure cache allocation bit masks and memory bandwidth limits.

Arm's IOMMU does have controls/monitors that match the spec the MPAM driver needs, but we currently have no way to expose them through resctrl.
The caches on the IOMMU are also relatively small - I've not yet seen anyone show that setting the controls there makes a big difference.

Quoted 2 lines

2) All I/O monitoring and control is with respect to I/O caches, not to the L3 caches that legacy RDT features operate on.

Do you have I/O traffic that can turn up in the CPU L3 cache? I think PCIe calls this 'cache stashing'.

Arm's IOMMU is the same - but the traffic may also show up in the L3 depending on how the system is put together.

Quoted 2 lines

3) The number of RMIDs supported for I/O is lower (maybe considearbly lower) than the number supported for CPU monitoring.

MPAM can have this happen - and today it will sanitise the values to the lowest common value. Considerably lower becomes considerably upsetting!

I'd be interested if we have an approach for this - the IOMMU designers would argue they only need one RMID per device - but the system wide sanitised value means they have to match the rest of the system.

For MPAM systems this shape is a big headache because on the platforms we've seen, the monitoring is done at the memory-controllers - so any RMID spaces get joined up eventually.

Quoted 10 lines

4) Monitoring events are I/O cache occupancy, total i/o bandwidth, and i/o miss bandwidth.

5) Current revision (1.4) of the specification doesn't include details of I/O memory bandwidth control (The "IBAD" subtable of ERDT is reserved for this).

Fitting this into resctrl
-------------------------

Quoted 6 lines

RISC-V description of "architecture specific device tokens" sounds great. I'll have to find some ares of /sys to provide the mapping of tokens to "device groups".
There's no association with IOMMUs, so this will be some other path in /sys. Perhaps under /sys/firmware/acpi since the data comes from ACPI IRDT table.

What about using the device behind the IOMMU instead? Presumably the kernel could allocate ids that don't clash with those in the IRDT, and use those for the IOMMU.

Quoted 1 line

Need an info file to tell users the format and source for device tokens.

I'd prefer we have one consistent way of doing this across architectures. Especially if we're going to add something new to sysfs.

The sysfs path probably covers all bases - but I wouldn't want to parse that in the kernel.

Quoted 4 lines

I'd like to avoid limiting resctrl monitoring of CPU activity due to the small number of I/O RMIDs. Perhaps don't include a "devices" file or mon_data/{i/o events} files in resctrl group directories when rdtgroup::mon::rmid >= num_io_rmids? But that feels clumsy.

I had a half baked idea on how to do this. (which Ben has poked some holes in)

Assigning a device to a ctrl/mon group needs to be able to fail. We can use this to re-allocate the RMID into the range the new device can use. The CPU tasks can be repainted to use the new value - but the obvious problem is the old data in the caches that uses the old RMID.
As no new traffic will be generated for that RMID, it might be possible to keep it associated with the ctrl/mon group (which would now have two RMID) to keep the user-space view of the counters correct until the old RMID falls below the reallocation threshold, and it can be free'd.

It's worse if we ever needed/wanted to do this with CLOSID. Two CAT bitmaps can be configured the same - but MBA doesn't alias in the same way. Tasks would be able to burst higher than the configured limit - but the size is limited by the size of the caches. And if no new traffic can be generated with the old CLOSID/RMID, then the effect can't be made to last forever.

For a totally wild suggestion (that I don't think works here) - I had mooted having a second mount of resctrl for islands of the SoC where the properties are different. I don't think it works in this case as the IO-RMID presumably gets seen by some other monitors later.

Quoted 3 lines

Domains are based on I/O L3 cache instances. So a new rdt_resource with new line in the schemata file for IOL3 cache masks per domain. In the future when there are I/O MBA controls, new line(s) for those too.

Thanks,

James

[4] https://support.arm.com/documentation/ihi0069/hb/?lang=en search for "MPAM" in the pdf.

Quoted 5 lines

[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] Linked from the bottom of https://www.intel.com/sdm under "Related Specifications", or direct link: https://cdrdv2.intel.com/v1/dl/getContent/789566?erpm_id=1158389_ts1790091453223

Signature · 2 lines
Thanks,
Qinxin
#6 lore raw
In reply to James Morse

Hi James,

Quoted 9 lines · James Morse

Hi Tony,

Quoted 6 lines · Tony

Patches for ARM[1] and RISC-V[2] are both at RFC status.

They appear to be based on similar h/w capabilities where architecture specific tags can be added to transactions from I/O devices by the IOMMU servicing the device. Device enumeration is handled outside of the resctrl file system.

[...]

Quoted 33 lines
Quoted 10 lines

Fitting this into resctrl
-------------------------

RISC-V description of "architecture specific device tokens" sounds great. I'll have to find some ares of /sys to provide the mapping of tokens to "device groups".
There's no association with IOMMUs, so this will be some other path in /sys. Perhaps under /sys/firmware/acpi since the data comes from ACPI IRDT table.

What about using the device behind the IOMMU instead? Presumably the kernel could allocate ids that don't clash with those in the IRDT, and use those for the IOMMU.

Quoted 1 line

Need an info file to tell users the format and source for device tokens.

I'd prefer we have one consistent way of doing this across architectures. Especially if we're going to add something new to sysfs.

The sysfs path probably covers all bases - but I wouldn't want to parse that in the kernel.

Quoted 4 lines

I'd like to avoid limiting resctrl monitoring of CPU activity due to the small number of I/O RMIDs. Perhaps don't include a "devices" file or mon_data/{i/o events} files in resctrl group directories when rdtgroup::mon::rmid >= num_io_rmids? But that feels clumsy.

I had a half baked idea on how to do this. (which Ben has poked some holes in)

Quoted 8 lines

Assigning a device to a ctrl/mon group needs to be able to fail. We can use this to re-allocate the RMID into the range the new device can use. The CPU tasks can be repainted to use the new value - but the obvious problem is the old data in the caches that uses the old RMID.
As no new traffic will be generated for that RMID, it might be possible to keep it associated with the ctrl/mon group (which would now have two RMID) to keep the user-space view of the counters correct until the old RMID falls below the reallocation threshold, and it can be free'd.

One limitation, "hole", is that it relies on assigning your devices early. If you've used all your rmids and then want to assign a device then that will only succeed for a subset of the monitor groups but you don't know which ones. Then you are left with trying until you see what works, peering into the debug interface or just remounting.

Thanks,

Ben

Quoted 32 lines

It's worse if we ever needed/wanted to do this with CLOSID. Two CAT bitmaps can be configured the same - but MBA doesn't alias in the same way. Tasks would be able to burst higher than the configured limit - but the size is limited by the size of the caches. And if no new traffic can be generated with the old CLOSID/RMID, then the effect can't be made to last forever.

For a totally wild suggestion (that I don't think works here) - I had mooted having a second mount of resctrl for islands of the SoC where the properties are different. I don't think it works in this case as the IO-RMID presumably gets seen by some other monitors later.

Quoted 3 lines

Domains are based on I/O L3 cache instances. So a new rdt_resource with new line in the schemata file for IOL3 cache masks per domain. In the future when there are I/O MBA controls, new line(s) for those too.

Thanks,

James

[4] https://support.arm.com/documentation/ihi0069/hb/?lang=en search for "MPAM" in the pdf.

Quoted 5 lines

[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] Linked from the bottom of https://www.intel.com/sdm under "Related Specifications", or direct link: https://cdrdv2.intel.com/v1/dl/getContent/789566?erpm_id=1158389_ts1790091453223

#7 lore raw
In reply to James Morse

Hi all,

Thank you for the helpful discussion, and sorry for the late reply.

Quoted 29 lines · James Morse

Hi Tony,

Quoted 8 lines · Tony

Patches for ARM[1] and RISC-V[2] are both at RFC status.

They appear to be based on similar h/w capabilities where architecture specific tags can be added to transactions from I/O devices by the IOMMU servicing the device. Device enumeration is handled outside of the resctrl file system.

ARM docs say "the device name is the one listed under /sys/kernel/iommu_groups/<id>/devices/"

I think using existing stuff in sysfs is a good idea. (Creating new things in sysfs fills me with dread!)

ARM/MPAM also has platform devices that can add the CLOSID/RMID metadata. e.g. the GIC ITS [4] - a kind of translator for MSIs.

For these we considered just using the device name as found in /sys/bus/platform/devices/, in the hope that can be tied back to a struct device - and we could add a callback for resctrl to configure the device with a CLOSID/RMID.
(but - I've not seen a use-case for this yet - those devices generate very little traffic)

Quoted 1 line

Robin M set me straight on the iommu_group:
Strictly that is the wrong abstraction as devices are in the same group if the driver can't stop them communicating, e.g. PCIe peer2peer. This doesn't mean it can't tell the traffic apart for CLOSID/RMID labelling.
I picked this because its the device granularity VFIO works with.

Quoted 5 lines

Equally, a device may create multiple streams of traffic, where only the driver will know what each one corresponds to.

Using iommu_group like this may need a bit more thinking....

I agree. DMA isolation groups do not necessarily match the granularity at which QoS IDs can be assigned.

Quoted 18 lines

If we can fall back to using a device as seen by sysfs, then the arch differences here could be invisible to user-space.

Quoted 6 lines

RISC-V says architecture specific device tokens are "devices or device groups"

In both cases assignments are made with:

	# echo {device} > {group}/devices
Quoted 7 lines

So now I'm looking at the capabilities of Intel RDT hardware. I'm ignoring the implementation on the Granite Rapids CPU, and looking at what is described in the RDT Architecture Specification[3]. Here are the highlights:

1) Enumeration is split between two ACPI tables. IRDT enumerates device groups and provides MMIO addresses to assign CLOSID/RMID to each group.

Quoted 7 lines

For ARM/MPAM - this would always be driver specific. The fields may be share a register with other things the driver needs to consider.
The IOMMU abstracts this for its devices, but this is still something the IOMMU driver needs to know about.

A driver hook, with a drivers/acpi fallback would be ideal.

Building on James's callback suggestion, could the driver responsible for tagging register supported devices with resctrl? Common resctrl code could manage token lookup, group membership and assignment cleanup, while the driver supplies the ID-programming callback.

For illustration:

     static const struct resctrl_device_ops iommu_resctrl_ops = {
         .set_ids = iommu_set_qos_ids,
     };

     /* After the device's tagging state is ready. */
     resctrl_device_register(dev, &iommu_resctrl_ops);

     /* Before releasing that state. */
     resctrl_device_unregister(dev);

For IOMMU-managed devices, the IOMMU driver could handle registration and the callback, without changes to individual endpoint drivers. We have an early PoC along these lines, but it is not yet ready for an RFC.

A full sysfs path would identify the device unambiguously, but can be long and cumbersome to use. Perhaps a bus-qualified device name under devices/, such as pci/<BDF> or platform/<name>, could be an alternative?

The token format, sub-device contexts, hardware-defined groups, differing ID limits and detailed removal/error handling remain open. I would appreciate your thoughts on whether this could be a useful direction for a shared interface.

Quoted 110 lines

Do you have arbitrary grouping of devices? e.g. a USB controller and the UART. Or would the grouping make some sense to the OS. e.g. all the USB devices behind this port.

Having the UART show up when you add a USB controller to a control group is a bit odd.

Quoted 3 lines

ERDT provides
MMIO addresses to read event counts for RMIDs and to configure cache allocation bit masks and memory bandwidth limits.

Arm's IOMMU does have controls/monitors that match the spec the MPAM driver needs, but we currently have no way to expose them through resctrl.
The caches on the IOMMU are also relatively small - I've not yet seen anyone show that setting the controls there makes a big difference.

Quoted 2 lines

2) All I/O monitoring and control is with respect to I/O caches, not to the L3 caches that legacy RDT features operate on.

Do you have I/O traffic that can turn up in the CPU L3 cache? I think PCIe calls this 'cache stashing'.

Arm's IOMMU is the same - but the traffic may also show up in the L3 depending on how the system is put together.

Quoted 2 lines

3) The number of RMIDs supported for I/O is lower (maybe considearbly lower) than the number supported for CPU monitoring.

MPAM can have this happen - and today it will sanitise the values to the lowest common value. Considerably lower becomes considerably upsetting!

I'd be interested if we have an approach for this - the IOMMU designers would argue they only need one RMID per device - but the system wide sanitised value means they have to match the rest of the system.

For MPAM systems this shape is a big headache because on the platforms we've seen, the monitoring is done at the memory-controllers - so any RMID spaces get joined up eventually.

Quoted 10 lines

4) Monitoring events are I/O cache occupancy, total i/o bandwidth, and i/o miss bandwidth.

5) Current revision (1.4) of the specification doesn't include details of I/O memory bandwidth control (The "IBAD" subtable of ERDT is reserved for this).

Fitting this into resctrl
-------------------------

Quoted 6 lines

RISC-V description of "architecture specific device tokens" sounds great. I'll have to find some ares of /sys to provide the mapping of tokens to "device groups".
There's no association with IOMMUs, so this will be some other path in /sys. Perhaps under /sys/firmware/acpi since the data comes from ACPI IRDT table.

What about using the device behind the IOMMU instead? Presumably the kernel could allocate ids that don't clash with those in the IRDT, and use those for the IOMMU.

Quoted 1 line

Need an info file to tell users the format and source for device tokens.

I'd prefer we have one consistent way of doing this across architectures. Especially if we're going to add something new to sysfs.

The sysfs path probably covers all bases - but I wouldn't want to parse that in the kernel.

Quoted 4 lines

I'd like to avoid limiting resctrl monitoring of CPU activity due to the small number of I/O RMIDs. Perhaps don't include a "devices" file or mon_data/{i/o events} files in resctrl group directories when rdtgroup::mon::rmid >= num_io_rmids? But that feels clumsy.

I had a half baked idea on how to do this. (which Ben has poked some holes in)

Assigning a device to a ctrl/mon group needs to be able to fail. We can use this to re-allocate the RMID into the range the new device can use. The CPU tasks can be repainted to use the new value - but the obvious problem is the old data in the caches that uses the old RMID.
As no new traffic will be generated for that RMID, it might be possible to keep it associated with the ctrl/mon group (which would now have two RMID) to keep the user-space view of the counters correct until the old RMID falls below the reallocation threshold, and it can be free'd.

It's worse if we ever needed/wanted to do this with CLOSID. Two CAT bitmaps can be configured the same - but MBA doesn't alias in the same way. Tasks would be able to burst higher than the configured limit - but the size is limited by the size of the caches. And if no new traffic can be generated with the old CLOSID/RMID, then the effect can't be made to last forever.

For a totally wild suggestion (that I don't think works here) - I had mooted having a second mount of resctrl for islands of the SoC where the properties are different. I don't think it works in this case as the IO-RMID presumably gets seen by some other monitors later.

Quoted 3 lines

Domains are based on I/O L3 cache instances. So a new rdt_resource with new line in the schemata file for IOL3 cache masks per domain. In the future when there are I/O MBA controls, new line(s) for those too.

Quoted 13 lines

Thanks,

James

[4] https://support.arm.com/documentation/ihi0069/hb/?lang=en search for "MPAM" in the pdf.

Quoted 5 lines

[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] Linked from the bottom of https://www.intel.com/sdm under "Related Specifications", or direct link: https://cdrdv2.intel.com/v1/dl/getContent/789566?erpm_id=1158389_ts1790091453223

Regards,

Zhanpeng

#8 lore raw
Quoted 76 lines · Zhanpeng Zhang

Hi all,

Thank you for the helpful discussion, and sorry for the late reply.

Quoted 29 lines · James Morse

Hi Tony,

Quoted 8 lines · Tony

Patches for ARM[1] and RISC-V[2] are both at RFC status.

They appear to be based on similar h/w capabilities where architecture specific tags can be added to transactions from I/O devices by the IOMMU servicing the device. Device enumeration is handled outside of the resctrl file system.

ARM docs say "the device name is the one listed under /sys/kernel/iommu_groups/<id>/devices/"

I think using existing stuff in sysfs is a good idea. (Creating new things in sysfs fills me with dread!)

ARM/MPAM also has platform devices that can add the CLOSID/RMID metadata. e.g. the GIC ITS [4] - a kind of translator for MSIs.

For these we considered just using the device name as found in /sys/bus/platform/devices/, in the hope that can be tied back to a struct device - and we could add a callback for resctrl to configure the device with a CLOSID/RMID.
(but - I've not seen a use-case for this yet - those devices generate very little traffic)

Quoted 1 line

Robin M set me straight on the iommu_group:
Strictly that is the wrong abstraction as devices are in the same group if the driver can't stop them communicating, e.g. PCIe peer2peer. This doesn't mean it can't tell the traffic apart for CLOSID/RMID labelling.
I picked this because its the device granularity VFIO works with.

Quoted 5 lines

Equally, a device may create multiple streams of traffic, where only the driver will know what each one corresponds to.

Using iommu_group like this may need a bit more thinking....

I agree. DMA isolation groups do not necessarily match the granularity at which QoS IDs can be assigned.

Quoted 18 lines

If we can fall back to using a device as seen by sysfs, then the arch differences here could be invisible to user-space.

Quoted 6 lines

RISC-V says architecture specific device tokens are "devices or device groups"

In both cases assignments are made with:

	# echo {device} > {group}/devices
Quoted 7 lines

So now I'm looking at the capabilities of Intel RDT hardware. I'm ignoring the implementation on the Granite Rapids CPU, and looking at what is described in the RDT Architecture Specification[3]. Here are the highlights:

1) Enumeration is split between two ACPI tables. IRDT enumerates device groups and provides MMIO addresses to assign CLOSID/RMID to each group.

Quoted 7 lines

For ARM/MPAM - this would always be driver specific. The fields may be share a register with other things the driver needs to consider.
The IOMMU abstracts this for its devices, but this is still something the IOMMU driver needs to know about.

A driver hook, with a drivers/acpi fallback would be ideal.

Building on James's callback suggestion, could the driver responsible for tagging register supported devices with resctrl? Common resctrl code could manage token lookup, group membership and assignment cleanup, while the driver supplies the ID-programming callback.

For illustration:

Quoted 10 lines
      static const struct resctrl_device_ops iommu_resctrl_ops = {
          .set_ids = iommu_set_qos_ids,
      };

      /* After the device's tagging state is ready. */
      resctrl_device_register(dev, &iommu_resctrl_ops);

      /* Before releasing that state. */
      resctrl_device_unregister(dev);

There is a scenario where some devices simultaneously support configuring the QOS ID on both the device side and the iommu side. Therefore, we may need to maintain the ops as a linked list or manage iommu_ops separately. :-)

Quoted 142 lines

For IOMMU-managed devices, the IOMMU driver could handle registration and the callback, without changes to individual endpoint drivers. We have an early PoC along these lines, but it is not yet ready for an RFC.

A full sysfs path would identify the device unambiguously, but can be long and cumbersome to use. Perhaps a bus-qualified device name under devices/, such as pci/<BDF> or platform/<name>, could be an alternative?

The token format, sub-device contexts, hardware-defined groups, differing ID limits and detailed removal/error handling remain open. I would appreciate your thoughts on whether this could be a useful direction for a shared interface.

Quoted 110 lines

Do you have arbitrary grouping of devices? e.g. a USB controller and the UART. Or would the grouping make some sense to the OS. e.g. all the USB devices behind this port.

Having the UART show up when you add a USB controller to a control group is a bit odd.

Quoted 3 lines

ERDT provides
MMIO addresses to read event counts for RMIDs and to configure cache allocation bit masks and memory bandwidth limits.

Arm's IOMMU does have controls/monitors that match the spec the MPAM driver needs, but we currently have no way to expose them through resctrl.
The caches on the IOMMU are also relatively small - I've not yet seen anyone show that setting the controls there makes a big difference.

Quoted 2 lines

2) All I/O monitoring and control is with respect to I/O caches, not to the L3 caches that legacy RDT features operate on.

Do you have I/O traffic that can turn up in the CPU L3 cache? I think PCIe calls this 'cache stashing'.

Arm's IOMMU is the same - but the traffic may also show up in the L3 depending on how the system is put together.

Quoted 2 lines

3) The number of RMIDs supported for I/O is lower (maybe considearbly lower) than the number supported for CPU monitoring.

MPAM can have this happen - and today it will sanitise the values to the lowest common value. Considerably lower becomes considerably upsetting!

I'd be interested if we have an approach for this - the IOMMU designers would argue they only need one RMID per device - but the system wide sanitised value means they have to match the rest of the system.

For MPAM systems this shape is a big headache because on the platforms we've seen, the monitoring is done at the memory-controllers - so any RMID spaces get joined up eventually.

Quoted 10 lines

4) Monitoring events are I/O cache occupancy, total i/o bandwidth, and i/o miss bandwidth.

5) Current revision (1.4) of the specification doesn't include details of I/O memory bandwidth control (The "IBAD" subtable of ERDT is reserved for this).

Fitting this into resctrl
-------------------------

Quoted 6 lines

RISC-V description of "architecture specific device tokens" sounds great. I'll have to find some ares of /sys to provide the mapping of tokens to "device groups".
There's no association with IOMMUs, so this will be some other path in /sys. Perhaps under /sys/firmware/acpi since the data comes from ACPI IRDT table.

What about using the device behind the IOMMU instead? Presumably the kernel could allocate ids that don't clash with those in the IRDT, and use those for the IOMMU.

Quoted 1 line

Need an info file to tell users the format and source for device tokens.

I'd prefer we have one consistent way of doing this across architectures. Especially if we're going to add something new to sysfs.

The sysfs path probably covers all bases - but I wouldn't want to parse that in the kernel.

Quoted 4 lines

I'd like to avoid limiting resctrl monitoring of CPU activity due to the small number of I/O RMIDs. Perhaps don't include a "devices" file or mon_data/{i/o events} files in resctrl group directories when rdtgroup::mon::rmid >= num_io_rmids? But that feels clumsy.

I had a half baked idea on how to do this. (which Ben has poked some holes in)

Assigning a device to a ctrl/mon group needs to be able to fail. We can use this to re-allocate the RMID into the range the new device can use. The CPU tasks can be repainted to use the new value - but the obvious problem is the old data in the caches that uses the old RMID.
As no new traffic will be generated for that RMID, it might be possible to keep it associated with the ctrl/mon group (which would now have two RMID) to keep the user-space view of the counters correct until the old RMID falls below the reallocation threshold, and it can be free'd.

It's worse if we ever needed/wanted to do this with CLOSID. Two CAT bitmaps can be configured the same - but MBA doesn't alias in the same way. Tasks would be able to burst higher than the configured limit - but the size is limited by the size of the caches. And if no new traffic can be generated with the old CLOSID/RMID, then the effect can't be made to last forever.

For a totally wild suggestion (that I don't think works here) - I had mooted having a second mount of resctrl for islands of the SoC where the properties are different. I don't think it works in this case as the IO-RMID presumably gets seen by some other monitors later.

Quoted 3 lines

Domains are based on I/O L3 cache instances. So a new rdt_resource with new line in the schemata file for IOL3 cache masks per domain. In the future when there are I/O MBA controls, new line(s) for those too.

Quoted 13 lines

Thanks,

James

[4] https://support.arm.com/documentation/ihi0069/hb/?lang=en search for "MPAM" in the pdf.

Quoted 5 lines

[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] Linked from the bottom of https://www.intel.com/sdm under "Related Specifications", or direct link: https://cdrdv2.intel.com/v1/dl/getContent/789566?erpm_id=1158389_ts1790091453223

Regards,

Zhanpeng

Signature · 2 lines
Thanks,
Qinxin
#9 lore raw
In reply to Luck, Tony

Hi all,

Quoted 48 lines · Tony

Patches for ARM[1] and RISC-V[2] are both at RFC status.

They appear to be based on similar h/w capabilities where architecture specific tags can be added to transactions from I/O devices by the IOMMU servicing the device. Device enumeration is handled outside of the resctrl file system.

ARM docs say "the device name is the one listed under /sys/kernel/iommu_groups/<id>/devices/"

RISC-V says architecture specific device tokens are "devices or device groups"

In both cases assignments are made with:

	# echo {device} > {group}/devices

So now I'm looking at the capabilities of Intel RDT hardware. I'm ignoring the implementation on the Granite Rapids CPU, and looking at what is described in the RDT Architecture Specification[3]. Here are the highlights:

1) Enumeration is split between two ACPI tables. IRDT enumerates device groups and provides MMIO addresses to assign CLOSID/RMID to each group. ERDT provides MMIO addresses to read event counts for RMIDs and to configure cache allocation bit masks and memory bandwidth limits.

2) All I/O monitoring and control is with respect to I/O caches, not to the L3 caches that legacy RDT features operate on.

3) The number of RMIDs supported for I/O is lower (maybe considearbly lower) than the number supported for CPU monitoring.

4) Monitoring events are I/O cache occupancy, total i/o bandwidth, and i/o miss bandwidth.

5) Current revision (1.4) of the specification doesn't include details of I/O memory bandwidth control (The "IBAD" subtable of ERDT is reserved for this).

Fitting this into resctrl
-------------------------

RISC-V description of "architecture specific device tokens" sounds great. I'll have to find some ares of /sys to provide the mapping of tokens to "device groups". There's no association with IOMMUs, so this will be some other path in /sys. Perhaps under /sys/firmware/acpi since the data comes from ACPI IRDT table.

Need an info file to tell users the format and source for device tokens.

Quoted 8 lines

I'd like to avoid limiting resctrl monitoring of CPU activity due to the small number of I/O RMIDs. Perhaps don't include a "devices" file or mon_data/{i/o events} files in resctrl group directories when rdtgroup::mon::rmid >= num_io_rmids? But that feels clumsy.

Domains are based on I/O L3 cache instances. So a new rdt_resource with new line in the schemata file for IOL3 cache masks per domain. In the future when there are I/O MBA controls, new line(s) for those too.

Thanks for the feedback and the detailed discussion.

I have been occupied with some other work recently and have not had enough time to follow all the replies closely. I will catch up on the discussion and take the feedback into account before posting the next version of the RISC-V patchset.

Thanks again for all the comments and suggestions.

Quoted 8 lines

-Tony

[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] Linked from the bottom of https://www.intel.com/sdm under "Related Specifications", or direct link: https://cdrdv2.intel.com/v1/dl/getContent/789566?erpm_id=1158389_ts1790091453223

Best regards,
Zhanpeng