source
large_stringclasses
2 values
subject
large_stringclasses
112 values
code
large_stringclasses
112 values
critique
large_stringlengths
61
3.04M
metadata
dict
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On Mon, Jan 12, 2026 at 5:59 PM Ben Horgan <ben.horgan@arm.com> wrote: Like before, I applied the patches and successfully booted a kernel on a baremetal Google Cloud C4A instance. I was able to confirm that the resources we expect were present and I was able to successfully run the monitor assignment test cases I used to validate ABMC on AMD systems. (Though I had to hack the driver to pretend there were less MBWU monitors so that the counter assignment interfaces would become available.) My use cases only cover resctrl in the host, so I didn't try any of the KVM integration, but I can at least say there wasn't any evidence that it interfered with resctrl. Tested-by: Peter Newman <peternewman@google.com> Thanks, -Peter
{ "author": "Peter Newman <peternewman@google.com>", "date": "Thu, 15 Jan 2026 12:14:19 +0100", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Marc, On 1/15/26 09:05, Marc Zyngier wrote: The new MPAM arch code always configures kernel space MPAM configuration in tandem, same value to MPAM0_EL1 and MPAM1_EL1 (will access MPAM2_EL2 in vhe). For the cpu part see PATCH v3 07 arm64: mpam: Re-initialise MPAM regs when CPU comes online and for context switching part see PATCH v3 06 arm64: mpam: Context switch the MPAM registers There are no plans to give the VM it's own MPAM configuration. The intent of this patch is to give all the code running in the VM, whether or not it is at EL0 or EL1, uses the MPAM partid/pmg configuration of the userspace VMM that is running it. What I was alluding to here is that if a future host MPAM policy allows the partid/pmg to differ for the kernel and userspace then we won't be able rely on the EL1 configuration matching EL0 in the nvhe case and so would have to copy the host EL0 configuration to EL1 (and add a restore). The goal is that all times the VM runs with the same MPAM partid/pmg configuration as the userspace vmm running it. In VHE: Host kernel configuration is in MPAM2_EL2 Host userspace configuration is in MPAM0_EL1 Guest kernel configuration needs to be in MPAM1_EL1 and so we copy it there from MPAM0_EL1 when switching to the guest. On switching back to the host we can just leave it there as the host doesn't use it. Guest userspace configuration is in MPAM0_EL1, just keep that unchanged. In nVHE: Host kernel configuration is in MPAM1_EL1 Host userspace configuration is in MPAM0_EL1 Once again, guest userspace configuration is in MPAM0_EL1, just keep that unchanged. As host policy ensures MPAM0_EL1 == MPAM1_EL1 for pmg/partid we rely on this to skip changing MPAM1_EL1 on guest entry and to skip the restore on guest exit. I hope this makes the intent clearer. Would you prefer to decouple the kvm handling of the MPAM configuration from the host policy? If so, I expect the MPAM handling can be done together in __activate_traps_mpam(). Thoughts? Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Thu, 15 Jan 2026 11:14:36 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Peter, On 1/15/26 11:14, Peter Newman wrote: [...] Thanks for the testing! Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Thu, 15 Jan 2026 11:36:47 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Thu, 15 Jan 2026 14:47:28 +0800 Gavin Shan <gshan@redhat.com> wrote: I commented on the nitpick. That is a non obvious include chain that we should not rely on. Please keep the headers and continue to follow include what you use style (with exceptions when a given header is clearly documented as always including another like some of the bit map stuff.) It is more obviously correct and causes less grief if headers get refactored in future.
{ "author": "Jonathan Cameron <jonathan.cameron@huawei.com>", "date": "Thu, 15 Jan 2026 12:09:23 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Zeng, +CC Babu (Comments on PLZA) On 1/14/26 06:51, Zeng Heng wrote: Makes sense, thanks for these two observations. I wonder if this would be possible in AMD PLZA as well. Babu? Yes, I watched a recording of that. :) Will do. Apologies for not doing this earlier and thank you for the promise of testing and reviews :) There is a v3 which you have hopefully seen. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Thu, 15 Jan 2026 14:37:31 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Reinette, On 1/13/26 23:14, Reinette Chatre wrote: I'll test against this. [...] Thanks for bringing this to my attention. mpam_resctrl_monitor_init() won't be called for all events known to resctrl as mpam_resctrl_pick_counters() will only set a class for the 3 that MPAM knows about. Still, it is probably best to restrict the iterator to the relevant ones. I will update to use the new signature. As noted above, this only happens for the ones chosen mpam_resctrl_pick_counters(). Hmm, I see now that 'num_rmid' is documented as an upper bound and so neither 1 or mpam_pmg_max + 1 agree with the documentation. " "num_rmids": The number of RMIDs available. This is the upper bound for how many "CTRL_MON" + "MON" groups can be created. " So, if I understand correctly you're proposing setting num_rmids = num_pmg * num_partids on arm platforms and that in the interim this can then be used to calculate the num_pmg by calculating num_closid/num_rmid but that a per CTRL_MON num_mon_groups should be added to make this consistent across architectures? I appreciate that you have shared this resctrl knowledge with me. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Thu, 15 Jan 2026 15:43:54 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On Mon, Jan 12, 2026 at 6:02 PM Ben Horgan <ben.horgan@arm.com> wrote: Are remote memory accesses not cached? How do we know an MBWU monitor residing on a cache won't count remote traffic? Thanks, -Peter
{ "author": "Peter Newman <peternewman@google.com>", "date": "Thu, 15 Jan 2026 16:49:20 +0100", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Shaopeng, On 1/15/26 10:05, Shaopeng Tan (Fujitsu) wrote: The intent of returning 0 here is that if csu is not supported on this class then there is nothing to do and hence no error. Yes, the check is redundant and can be removed. (If it were to stay it should be moved to be before call get_cpu_cacheinfo_level() call so that wouldn't give spurious errors for non-cache cpus.) Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Thu, 15 Jan 2026 16:02:47 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Mon, Jan 12, 2026 at 04:58:33PM +0000, Ben Horgan wrote: Since we have an isb() already, does it make any difference if we write MPAM0 before the barrier? Similar question for other places where we write these two registers. At some point, we should go through __switch_to() and coalesce the isbs into fewer as we keep accumulating them (e.g. all those switch function setting some sync variable if needed). Is it too expensive to read the MPAM sysregs and avoid carrying around another per-CPU state? You use it for pm restoring but we could just save it in cpu_do_suspend() like other sysregs. Not a big issue, it just feels like this function got unnecessarily complicated (it took me a bit to figure out what it all does). A related question - is resctrl_arch_set_cdp_enabled() always called in non-preemptible contexts? We potentially have a race between setting current->mpam_partid_msg and arm64_mpam_global_default, so the check in mpam_thread_switch() can get confused. And I couldn't figure out where the MPAMx_EL1 registers are written. If any global/per-cpu/per-task value is changed, does the kernel wait until the next thread switch to write the sysreg? The only places I can found touching these sysregs are the thread switch, pm notifiers and KVM. -- Catalin
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Thu, 15 Jan 2026 17:58:15 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Mon, Jan 12, 2026 at 04:58:30PM +0000, Ben Horgan wrote: Acked-by: Catalin Marinas <catalin.marinas@arm.com>
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Thu, 15 Jan 2026 17:59:05 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Mon, Jan 12, 2026 at 04:58:34PM +0000, Ben Horgan wrote: Is this comment about priority inversion no longer valid? I see thread switching sets the same value for both MPAM0 and MPAM1 registers but I couldn't find an explanation why this is now better when it wasn't before. MPAM1 will also be inherited by IRQ handlers AFAICT. I mentioned before, is it worth waiting until ERET? Related to this, do LDTR/STTR use MPAM0 or MPAM1? I couldn't figure out from the Arm ARM. If they use MPAM0, then we need the ISB early for the uaccess routines, at least in the thread switching path (an earlier patch). -- Catalin
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Thu, 15 Jan 2026 18:14:09 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Mon, Jan 12, 2026 at 04:58:35PM +0000, Ben Horgan wrote: Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Thu, 15 Jan 2026 18:16:49 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Mon, Jan 12, 2026 at 04:58:36PM +0000, Ben Horgan wrote: This looks fine unless we decide to save/restore them in the low-level suspend/resume functions. -- Catalin
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Thu, 15 Jan 2026 18:20:02 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On 1/15/26 7:43 AM, Ben Horgan wrote: ... Please note that this documentation has been refactored (without changing its meaning). The above quoted text is specific to L3 monitoring and with the addition of telemetry monitoring the relevant text now reads: The upper bound for how many "CTRL_MON" + "MON" can be created is the smaller of the L3_MON and PERF_PKG_MON "num_rmids" values. Yes for num_rmids = num_pmg * num_partids. The motivation for this is that to me this looks like the value that best matches the num_rmids documentation. I understand the RMID vs PMG is difficult so my proposal is certainly not set in stone and I would like to hear motivation for different interpretations. "calculating num_pmg" is not obvious though. I interpret "num_pmg" here as number of monitor groups per control group and on an Arm system this is indeed num_closid/num_rmids (if num_rmids = num_pmg * num_partids) but on x86 it is just num_rmids. Having user space depend on such computation to determine how many monitor groups per control group would thus require that user space knows whether the underlying system is Arm or x86 and would go against goal of having resctrl as a generic interface. The way forward may be to deprecate (somehow) num_rmids and transition to something like "num_mon_groups" but it is currently vague how "num_mon_groups" may look like. That thread (https://lore.kernel.org/lkml/46767ca7-1f1b-48e8-8ce6-be4b00d129f9@intel.com/) fizzled out after raising a few options how it may look. Another proposal was to add a "mon_id_includes_control_id" to use as another "guide" to determine how many monitoring groups can be created but at the time it seemed an intermediary step for user to determine the number of monitor groups that resctrl can also provide. https://lore.kernel.org/lkml/CALPaoChad6=xqz+BQQd=dB915xhj1gusmcrS9ya+T2GyhTQc5Q@mail.gmail.com/ Making this consistent across architectures is the goal since resctrl aims to be a generic interface. Users should not need to do things like infer which system they are running on by looking at output of resctrl files as mentioned. fwiw ... there seems to be a usage by Google to compare num_rmids to num_closids to determine how to interact with resctrl: https://lore.kernel.org/lkml/CALPaoCgSO7HzK9BjyM8yL50oPyq9kBj64Nkgyo1WEJrWy5uHUg@mail.gmail.com/ Reinette
{ "author": "Reinette Chatre <reinette.chatre@intel.com>", "date": "Thu, 15 Jan 2026 10:54:45 -0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Mon, Jan 12, 2026 at 04:58:37PM +0000, Ben Horgan wrote: Do we know for sure that system_supports_sme() returns true at this point (if SME supported)? Digging into the code, system_supports_sme() uses alternative_has_cap_unlikely() which relies on instruction patching. setup_system_capabilities(), IIUC, patches the alternatives after enable_cpu_capabilities(). I think you better use cpus_have_cap(). -- Catalin
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Thu, 15 Jan 2026 19:08:47 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Mon, Jan 12, 2026 at 04:58:38PM +0000, Ben Horgan wrote: Isn't this function, together with mpam_thread_switch(), in an enclosing #ifdef already? -- Catalin
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Thu, 15 Jan 2026 19:13:45 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Mon, Jan 12, 2026 at 04:59:06PM +0000, Ben Horgan wrote: Acked-by: Catalin Marinas <catalin.marinas@arm.com>
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Thu, 15 Jan 2026 19:16:48 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi, Shanker and Ben, On 1/12/26 08:59, Ben Horgan wrote: When MBW_MIN=1, min mem bw can be very low when contention. This may drop mem access performance. Is it possible to set MBW_MIN bigger so that ensure the floor of mem access is high? Thanks. -Fenghua
{ "author": "Fenghua Yu <fenghuay@nvidia.com>", "date": "Thu, 15 Jan 2026 15:20:55 -0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Reinette, Peter, On 1/15/26 18:54, Reinette Chatre wrote: Ok, I don't really see another option. The motivation for this is that to me Just thinking about it now but the "mon_id_includes_control_id" option seems the best to me as it is a single bit option that along with "num_rmids" let's you know which monitor groups you can create and if it's sensible to move monitor groups between CTRL MON groups. The "num_mon_groups" per CTRL MON group would also need to be interpreted together with "num_rmid" to know if it is a global or per CTRL MON upper bound. This option also uses multiple files to give the same bit of information. Unfortunately, it looks like we're about to break this heuristic :( At least, until a way to get this information generically in resctrl is decided upon. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Fri, 16 Jan 2026 10:29:01 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hello Ben, $ echo "default" | sudo tee /sys/fs/resctrl/info/L3_MON/mbm_assign_mode default tee: /sys/fs/resctrl/info/L3_MON/mbm_assign_mode:Invalid argument "return -EOPNOTSUPP;" might be better. Best regards, Shaopeng TAN
{ "author": "\"Shaopeng Tan (Fujitsu)\" <tan.shaopeng@fujitsu.com>", "date": "Fri, 16 Jan 2026 10:34:27 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hello Ben, I ran the MPAM driver on NVIDIA's Grace machine, and it seems to be working fine. Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
{ "author": "\"Shaopeng Tan (Fujitsu)\" <tan.shaopeng@fujitsu.com>", "date": "Fri, 16 Jan 2026 10:47:40 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Shaopeng, On 1/16/26 10:34, Shaopeng Tan (Fujitsu) wrote: [...] I'll keep this as -EINVAL in the case when 'enable' matches the current mode and change it to return 0 when there is nothing to change. This will match the behaviour once this is handled in resctrl. See the outcome of the discussion on this resctrl patch [1] Note, that I haven't yet updated the patch to match the discussion. Any objection? [1] https://lore.kernel.org/lkml/bf8bb682-6a4d-4f39-916c-952719fcf48d@arm.com/ Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Fri, 16 Jan 2026 11:04:24 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Shaopeng, On 1/16/26 10:47, Shaopeng Tan (Fujitsu) wrote: Thanks for the testing! Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Fri, 16 Jan 2026 11:05:57 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Mon, Jan 12, 2026 at 04:58:29PM +0000, Ben Horgan wrote: After discussing privately, I can see how test__props_mismatch() can end up with unaligned atomics on the mmap_props::features array. Happy to pick it up for 6.19 (probably the first patch as well, though that's harmless). Is there a Fixes tag here for future reference? -- Catalin
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Fri, 16 Jan 2026 11:57:25 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Catalin, On 1/16/26 11:57, Catalin Marinas wrote: Yes please. Yes, the mpam_set/clear macros were introduced in Fixes: 8c90dc68a5de ("arm_mpam: Probe the hardware features resctrl supports") Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Fri, 16 Jan 2026 12:02:06 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On 1/16/26 12:02, Ben Horgan wrote: The mpam_set_clear() actually comes after in: c10ca83a7783 arm_mpam: Merge supported features during mpam_enable() into mpam_class but I think the fixes below is still the correct one as it is where we could first start seeing the problem. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Fri, 16 Jan 2026 12:12:53 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Mon, 12 Jan 2026 16:58:27 +0000, Ben Horgan wrote: Applied to arm64 (for-next/fixes), thanks! [01/47] arm_mpam: Remove duplicate linux/srcu.h header https://git.kernel.org/arm64/c/b5a69c486921 [02/47] arm_mpam: Use non-atomic bitops when modifying feature bitmap https://git.kernel.org/arm64/c/b9f5c38e4af1 -- Catalin
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Fri, 16 Jan 2026 15:47:15 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On Fri, Jan 16, 2026 at 12:12:53PM +0000, Ben Horgan wrote: Yes, I left the original as that's the one first introducing the atomic bitops on this structure. -- Catalin
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Fri, 16 Jan 2026 15:51:02 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On 1/13/26 12:58 AM, Ben Horgan wrote: The L3 cache partitioning and MBW (soft) limiting works fine on NVidia's grace-hopper machine. Tested-by: Gavin Shan <gshan@redhat.com> Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 09:30:32 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On 1/13/26 12:58 AM, Ben Horgan wrote: mpam_register_requestor() is exposed until CONFIG_ARM64_MPAM_DRIVER is set. CONFIG_ARM64_MPAM_DRIVER and CONFIG_ARM64_MPAM can be different until PATCH[39/47] is applied. So we need PATCH[39/47] to be applied prior to this patch so that mpam_register_requestor() is always existing and exposed. Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 14:37:46 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On 1/13/26 12:58 AM, Ben Horgan wrote: Reviewed-by: Gavin Shan <gshan@redhat.com>
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 14:40:59 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On 1/13/26 12:58 AM, Ben Horgan wrote: One question below... Need we ensure MPAM capability exists in the hardware before the notifier is registerred? Otherwise, mpam_pm_notifier() can accesses SYS_MPAM0_EL1 and SYS_MPAM1_EL1 system registers which may not supported by the hardware. Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 14:50:16 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On 1/13/26 12:58 AM, Ben Horgan wrote: One nitpick below... Reviewed-by: Gavin Shan <gshan@redhat.com> { } is missed here. Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 14:51:40 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On 1/16/26 3:13 AM, Catalin Marinas wrote: I think Catalin is correct that this ifdef inside mpam_set_task_partid_pmg() can be dropped. Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 14:56:46 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On 1/13/26 12:58 AM, Ben Horgan wrote: Nitpick: Alignment issues in the lines for 2nd/3rd/4th FIELD_PREP(). return FIELD_PREP(...) | FIELD_PREP(...) | FIELD_PREP(...) | FIELD_PREP(...); per_cpu(arm64_mpam_default) won't be reachable until CONFIG_ARM64_MPAM is set. So I think both mpam_set_cpu_defaults() and __mpam_regval() need to be protected by '#ifdef CONFIG_ARM64_MPAM ... #endif'. Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 15:01:41 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On 1/13/26 12:58 AM, Ben Horgan wrote: A warning reported by checkpatch.pl like below. WARNING: Missing a blank line after declarations #117: FILE: drivers/resctrl/mpam_resctrl.c:375: + struct mpam_component *victim_iter; + cpumask_var_t __free(free_cpumask_var) tmp_cpumask; Besides, it'd better to initialize @tmp_cpumask: cpumask_var_t __free(free_cpumask_var) tmp_cpumask = CPUMASK_VAR_NULL; Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 19:53:25 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On 1/13/26 12:58 AM, Ben Horgan wrote: A warning reported by checkpatch.pl as below. WARNING: Missing a blank line after declarations #84: FILE: drivers/resctrl/mpam_resctrl.c:607: + size_t array_size = num_mbwu_mon * sizeof(int); + int *array __free(kfree) = kmalloc(array_size, GFP_KERNEL); Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 19:57:38 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Peter, On 15/01/2026 15:49, Peter Newman wrote: It will, yes you get double counting. Is forbidding both mbm_total and mbm_local preferable? I think this comes from 'total' in mbm_total not really having the obvious meaning of the word: If I have CPUs in NUMA-A and no memory controllers, then NUMA-B has no CPUs, and all the memory-controllers. With MPAM: we've only got one bandwidth counter, it doesn't know where the traffic goes after the MSC. mbm-local on the L3 would reflect all the bandwidth, and mbm-total on the memory-controllers would have the same number. I think on x86 mbm_local on the CPUs would read zero as zero traffic went to the 'local' memory controller, and mbm_total would reflect all the memory bandwidth. (so 'total' really means 'other') I think what MPAM is doing here is still useful as a system normally has both CPUs and memory controllers in the NUMA nodes, and you can use this to spot a control/monitor group on a NUMA-node that is hammering all the memory (outlier mbm_local), or the same where a NUMA-node's memory controller is getting hammered by all the NUMA nodes (outlier mbm_total) I've not heard of a platform with both memory bandwidth monitors at L3 and the memory controller, so this may be a theoretical issue. Shall we only expose one of mbm-local/total to prevent this being seen by user-space? Thanks, James
{ "author": "James Morse <james.morse@arm.com>", "date": "Mon, 19 Jan 2026 12:04:10 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On 1/13/26 12:59 AM, Ben Horgan wrote: An error reported by checkpatch.pl as below. ERROR: Macros with complex values should be enclosed in parentheses #135: FILE: drivers/resctrl/mpam_internal.h:238: +#define MPAM_IIDR_MATCH_ONE FIELD_PREP_CONST(MPAMF_IIDR_PRODUCTID, 0xfff) | \ + FIELD_PREP_CONST(MPAMF_IIDR_VARIANT, 0xf) | \ + FIELD_PREP_CONST(MPAMF_IIDR_REVISION, 0xf) | \ + FIELD_PREP_CONST(MPAMF_IIDR_IMPLEMENTER, 0xfff) Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 20:14:44 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On 1/13/26 12:59 AM, Ben Horgan wrote: An error reported by checkpatch.pl as below. ERROR: Macros with complex values should be enclosed in parentheses #205: FILE: drivers/resctrl/mpam_internal.h:247: +#define MPAM_IIDR_NVIDIA_T241 FIELD_PREP_CONST(MPAMF_IIDR_PRODUCTID, 0x241) | \ + FIELD_PREP_CONST(MPAMF_IIDR_VARIANT, 0) | \ + FIELD_PREP_CONST(MPAMF_IIDR_REVISION, 0) | \ + FIELD_PREP_CONST(MPAMF_IIDR_IMPLEMENTER, 0x36b) Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 20:16:30 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On 1/13/26 12:59 AM, Ben Horgan wrote: An error reported by checkpatch.pl as below. ERROR: Macros with complex values should be enclosed in parentheses #105: FILE: drivers/resctrl/mpam_internal.h:255: +#define MPAM_IIDR_ARM_CMN_650 FIELD_PREP_CONST(MPAMF_IIDR_PRODUCTID, 0) | \ + FIELD_PREP_CONST(MPAMF_IIDR_VARIANT, 0) | \ + FIELD_PREP_CONST(MPAMF_IIDR_REVISION, 0) | \ + FIELD_PREP_CONST(MPAMF_IIDR_IMPLEMENTER, 0x43b) Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Mon, 19 Jan 2026 20:18:50 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Catalin, On 1/15/26 17:58, Catalin Marinas wrote: The reason for the isb() placement is to document that it's not required for the MPAM0_EL1. All instructions running at EL1take their MPAM configuration from MPAM1_EL1. This includes LDTR and STTR as you asked about in a different thread. It's done this way as it matches what's done in x86. I expect it would be cheap enough to read the register to check whether a write is required. The resctrl filesystem can only ever get mounted once and resctrl_arch_set_cdp_enabled() is always called in mount. In rdt_get_tree(), rdt_enable_ctx() calls resctrl_arch_set_cdp_enabled(). This is done while holding the rdtgroup_mutex and the user can't change the mpam configuration from the default until the mutex is released and it can claim it. If the task configuration is changed then the MPAM sysreg will only be updated the next time it goes into the kernel. So, just eventually consistent. For cpu configuration, update_closid_rmid() gets called which ipis the cpus and ends up calling mpam_thread_switch() from resctrl_arch_sched_in(). Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 12:23:13 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi James, On Mon, Jan 19, 2026 at 1:04 PM James Morse <james.morse@arm.com> wrote: Our software is going off the definition from the Intel SDM: "This event monitors the L3 external bandwidth satisfied by the local memory. In most platforms that support this event, L3 requests are likely serviced by a memory system with non-uniform memory architecture. This allows bandwidth to off-package memory resources to be tracked by subtracting local from total bandwidth (for instance, bandwidth over QPI to a memory controller on another physical processor could be tracked by subtraction). On NUMA-capable hardware that can support this event where all memory is local, mbm_local == mbm_total, but in practice you can't read them at the same time from userspace, so if you read mbm_total first, you'll probably get a small negative result for remote bandwidth. I believe in the current software design, MPAM is only able to support mbm_total, as an individual MSC (or class of MSCs with the same configuration) can't separate traffic by destination, so it must be the combined value. On a hardware design where MSCs were placed such that one only counts local traffic and another only counts remote, the resctrl MPAM driver would have to understand the hardware configuration well enough to be able to produce counts following Intel's definition of mbm_local and mbm_total. Thanks, -Peter
{ "author": "Peter Newman <peternewman@google.com>", "date": "Mon, 19 Jan 2026 13:47:52 +0100", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Catalin, On 1/15/26 18:14, Catalin Marinas wrote: Yes, will drop it. I see thread I touch on it in the cover letter. It is the way it is done for x86 and so sensible to make it the default. All partids are usable from user-space and user-space can't bypass MPAM controls by doing the work in the kernel. There is a proposal from Babu at AMD, PLZA, which he presented at LPC which would give a new interface to have different configuration, closid, for userspace and kernel space. We should be able to use this with MPAM too. Yes, this is a disadvantage of having MPAM1 and MPAM0 change together. Just for documentation. I can change it if you prefer. They use LDTR/STTR. MPAM doesn't care about which instruction is running. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 13:38:11 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Catalin, On 1/15/26 19:08, Catalin Marinas wrote: I'll switch to cpus_have_cap(). Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 13:40:18 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Gavin, On 1/19/26 11:53, Gavin Shan wrote: [...] I expect this is because __free() declarations don't need to be at the top of a scope and so checkpatch doesn't treat them as normal declarations. I don't think anything needs changing here. Yep, I'll update. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 13:53:23 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Gavin, Jonathan, On 1/15/26 12:09, Jonathan Cameron wrote: Keeping the includes here makes sense to me too. Gavin, are you ok with keeping this as is? Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 14:00:07 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Catalin, On 1/19/26 13:38, Ben Horgan wrote: Ah, that's done in the patch already. Also, we can't treat 0 as special without taking it away from userspace and then we're down a partid and there might be that many. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 14:22:13 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Gavin, On 1/19/26 06:37, Gavin Shan wrote: I've split out the part of PATCH[39/47] that removes the CONFIG_EXPERT restriction and put it before this patch. With that CONFIG_ARM64_MPAM will unconditionally select CONFIG_ARM64_MPAM_DRIVER. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 14:49:38 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Gavin, On 1/19/26 06:50, Gavin Shan wrote: Ah yes, I'll add a system_supports_mpam() check here. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 15:08:39 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Gavin, On 1/19/26 06:51, Gavin Shan wrote: Addded. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 15:31:34 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Catalin, On 1/15/26 19:13, Catalin Marinas wrote: Yes, I'll remove the inner #ifdef. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 15:47:07 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Gavin, On 1/19/26 07:01, Gavin Shan wrote: Sure, I'll align these. I'll move the #ifdef CONFIG_ARM64_MPAM up to cover these. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 15:49:05 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Reinette, On 1/13/26 16:49, Reinette Chatre wrote: Yeah, that leaks the memory and the offline call is unnecessary. Yes. Indeed. Yes, it's missing. I've reworked the code to move the resctrl_online_*() calls further up so there is less to do on error, added a kfree(dom) and made the ctrl_mon cleanup after the monitor domain failure to be conditional on exposed_alloc_capable. Yes, added. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 17:20:51 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Gavin, On 1/19/26 11:57, Gavin Shan wrote: Similarly to the other blank line checkpatch.pl warning I expect this is to do with how it handles the __free() annotation. I'm not intending to change this code unless there is some style guideline that I've missed or other reason to do so. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 20:27:48 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Shaopeng, On 1/16/26 11:04, Ben Horgan wrote: Actually, resctl_arch_cntr_assign_set() only gets called on an attempt to change the value so I'll keep it as is. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 20:34:06 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Gavin, On 1/19/26 12:14, Gavin Shan wrote: That's a real error. Fixed. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 20:48:45 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Gavin, On 1/19/26 12:16, Gavin Shan wrote: Fixed Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 20:54:19 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Fenghua, On 1/15/26 23:20, Fenghua Yu wrote: Isn't that a policy decision rather than something we should be putting in a quirk framework? Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 20:56:17 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Gavin, On 1/19/26 12:18, Gavin Shan wrote: Fixed Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 19 Jan 2026 20:58:02 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben and Jonathan, On 1/19/26 10:00 PM, Ben Horgan wrote: Yeah, I'm fine to keep it as of being :-) Thanks, Gavin
{ "author": "Gavin Shan <gshan@redhat.com>", "date": "Tue, 20 Jan 2026 09:42:09 +0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On Fri, Jan 16, 2026 at 11:29 AM Ben Horgan <ben.horgan@arm.com> wrote: We actually ended up going with the "mon_id_includes_control_id" approach. The property it represents is rather fundamental to what a monitoring group actually is and is a low-level implementation detail that is difficult to hide. Google generally needs support for as many monitoring IDs as jobs it expects to be able to run on a machine, so the number of monitoring groups will be routinely maxed out (and there will be some jobs that are forever stuck in the default group because no RMIDs were free at the time it started[1]) Thanks, -Peter [1] https://lore.kernel.org/lkml/CALPaoCjTwySGX9i7uAtCWLKQpmELKP55xDLJhHmUve8ptsfFTw@mail.gmail.com/
{ "author": "Peter Newman <peternewman@google.com>", "date": "Tue, 20 Jan 2026 16:28:01 +0100", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben and Peter, On 1/20/26 7:28 AM, Peter Newman wrote: Thank you for confirming. I was hoping we could deprecate num_rmids after introducing a per resource group file but this does not seem to support all the use cases as highlighted by Ben. As I see it, a name like "mon_id_includes_control_id" also implies that "num_rmids", perhaps linked to a new "num_mon_ids" as Peter suggested in [2], should contain num_pmg * num_partids. One concern from earlier was that "mon_id_includes_control_id" may be used as a heuristic for whether monitor groups can be moved or not. Instead I seem to remember that there was a plan for MPAM to support moving monitor groups, with the caveat that counters will reset for which resctrl may need another flag. Reinette [2] https://lore.kernel.org/lkml/CALPaoChad6=xqz+BQQd=dB915xhj1gusmcrS9ya+T2GyhTQc5Q@mail.gmail.com/
{ "author": "Reinette Chatre <reinette.chatre@intel.com>", "date": "Wed, 21 Jan 2026 09:58:45 -0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On Mon, Jan 19, 2026 at 12:23:13PM +0000, Ben Horgan wrote: It's fine to keep it this way if LDTR/STTR are not affected by the MPAM0 register. Since you use it for CPU suspend/resume, I guess it's fine, it saves us from having to preserve it in the low-level asm sleep code. I don't have a strong preference either way. What if resctrl_arch_set_cdp_enabled() gets preempted between updating current task partid and setting arm64_mpam_global_default? The mutex doesn't help. Is it updated when it goes into the kernel or when we have a context switch? If you have a long-running user thread that is never scheduled out, it may not notice the update even if it entered the kernel (but no context switch). I see, it should be fine. -- Catalin
{ "author": "Catalin Marinas <catalin.marinas@arm.com>", "date": "Fri, 23 Jan 2026 14:29:42 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Catalin, On 1/23/26 14:29, Catalin Marinas wrote: I see, I had misinterpreted your question. When looking into this I spotted that the per-cpu default, arm64_mpam_default, is not updated on the cdp enable and so the default tasks carry on running with the non-cdp default pmg/partid configuration. On the race itself, if current->mpam_partid_pmg is set but not arm64_mpam_global_default then if the current task is preempted at that point there is a discrepancy. When the task gets context switched back in then the comparison in mpam_thread_switch() will be false when true would be expected. In order to update arm64_mpam_default and make sure the mpam variables and registers for the online cpus are in the right state by the end of resctrl_arch_set_cdp_enabled() I'll add a per cpu call to resctrl_arch_sync_cpu_closid_rmid(). I'll also add something in the resume path so that arm64_mpam_default gets set correctly for the cpus that were offline. Yes, only on context switch. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 26 Jan 2026 14:30:14 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
On 1/26/26 14:30, Ben Horgan wrote: Rather than the resume path I'll just set all the arm64_mpam_default in resctrl_arch_set_cdp_enabled(). In code: --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -193,6 +193,7 @@ static void resctrl_reset_task_closids(void) int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool enable) { u32 partid_i = RESCTRL_RESERVED_CLOSID, partid_d = RESCTRL_RESERVED_CLOSID; + int cpu; cdp_enabled = enable; @@ -209,6 +210,10 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool enable) resctrl_reset_task_closids(); + for_each_possible_cpu(cpu) + mpam_set_cpu_defaults(cpu, partid_d, partid_i, 0, 0); + on_each_cpu(resctrl_arch_sync_cpu_closid_rmid, NULL, 1); + return 0; } Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 26 Jan 2026 14:50:12 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Peter, James, On 1/19/26 12:47, Peter Newman wrote: Indeed we should base our discussion on the event definition in the Intel SDM. For our reference, the description for the external bandwidth monitoring event (mbm_total) is: "This event monitors the L3 total external bandwidth to the next level of the cache hierarchy, including all demand and prefetch misses from the L3 to the next hierarchy of the memory system. In most platforms, this represents memory bandwidth." On a system with MSC measuring memory bandwidth on the L3 caches these MSC will measure all bandwidth to the next level of the memory hierarchy which matches the definition of mbm_total. (We assume any MSC on an L3 is at the egress even though acpi/dt doesn't distinguish ingress and egress.) For MSC on memory controllers then they don't distinguish which L3 cache the traffic came from and so unless there is a single L3 then we can't use these memory bandwidth monitors as they count neither mbm_local nor mbm_total. When there is a single L3 (and no higher level caches) then it would match both mbm_total and mbm_local. Hence, I agree we should just use mbm_total and update the heuristics such that if the MSC are at the memory only consider them if there are no higher caches and a single L3. The introduction of ABMC muddies the waters as the "event_filter" file defines the meaning of mbm_local and mbm_total. In order to handle this file properly with MPAM, fs/resctrl changes are needed. We could either make "event_filter" show the bits that correspond to the mbm counter and unchangeable or decouple the "event_filter" part of ABMC from the counter assignment part. As more work is needed to not break abi here I'll drop the ABMC patches from the next respin of this series. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 26 Jan 2026 16:00:04 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi, Ben, On 1/19/26 12:56, Ben Horgan wrote: MBW_MIN is 1% or 5% less than MBW_MAX. The lower MBW_MIN hints hardware to lower mem bandwidth when mem access contention. That causes memory performance degradation. Is it possible to do the following changes to fix the performance issue? 1. By default min mbw is equal to max mbw. So hardware won't lower performance unless it's needed. This can fix the current performance issue. 2. Add a new schemata line (e.g. MBI:<id>=x;<id>=y;...) to specify min mbw just like max mbw specified by schemata line "MB:...". User can use this line to change min mbw per partition per node. This could be added in the future. Thanks. -Fenghua
{ "author": "Fenghua Yu <fenghuay@nvidia.com>", "date": "Thu, 29 Jan 2026 14:14:45 -0800", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Reinette, Peter, On 1/21/26 17:58, Reinette Chatre wrote: I had a chat offline with James about this. Currently, userspace expects either the copy to succeed and the counters not to glitch or the move to fail. If we were going to support a monitor move in MPAM with counter reset (or a best effort counter value) we would have to make this opt-in for userspace. If userspace tries the monitor move while being unaware of the new flag it would unexpectedly lose counter data. To get this opt-in behaviour there could be a mount option, "destructive_monitor_move" or such like. Although this was considered in the past, we're not currently aware of any usecase for this desctructive monitor move and so are not proposing adding it or changing the existing behaviour around this. This doesn't mean that a flag for indicating whether monitor move is supported or not is not useful; a user may want to know if monitor move is supported but not to do a monitor move at the current time. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Fri, 30 Jan 2026 11:07:31 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Replying to myself... On 1/12/26 16:58, Ben Horgan wrote: As the counter is named llc_occupancy (llc = last level cache) and we are naming the resource L3 it would be surprising to have llc_occupancy on anything other than an L3. Also, that L3 should be a last level cache. I'll update this as part of a general push to tighten up the heuristics in this series to make sure that in the future when more fitting user visible interfaces are added in resctrl we are able to use them rather than being stuck with something that almost fits. [...] Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Fri, 30 Jan 2026 11:19:29 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Fenghua, On 1/29/26 22:14, Fenghua Yu wrote: Thanks for bringing this up. It raises some more general queries about the handling of mbw_min and so I'll move the discussion to [PATCH v3 41/47] arm_mpam: Generate a configuration for min controls as it isn't specific to the nvidia quirks. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Fri, 30 Jan 2026 12:21:42 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On Mon, Jan 26, 2026 at 5:00 PM Ben Horgan <ben.horgan@arm.com> wrote: The text you quoted from Intel was in the context of the L3. I assume if such an event were implemented at a different level of the memory system, it would continue to refer to downstream bandwidth. That should be ok for now. If I see a system where this makes MBWU counters inaccessible, we'll continue the discussion then. I would prefer if you can just leave out the event_filter or make it unconfigurable on MPAM. The rest of the counter assignment seems to work well. Longer term, the event_filter interface is supposed to give us the ability to define and name our own counter events, but we'll have to find a way past the decision to define the event filters in terms copy-pasted from an AMD manual. Thanks, -Peter
{ "author": "Peter Newman <peternewman@google.com>", "date": "Fri, 30 Jan 2026 14:04:29 +0100", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Fenghua, Jonathan, On 1/13/26 15:39, Jonathan Cameron wrote: I've realised it's not harmless :( In the discussion on a platform quirk, arm_mpam: Add workaround for T241-MPAM-4, Fenghua raised the following issues. " MBW_MIN is 1% or 5% less than MBW_MAX. The lower MBW_MIN hints hardware to lower mem bandwidth when mem access contention. That causes memory performance degradation. Is it possible to do the following changes to fix the performance issue? 1. By default min mbw is equal to max mbw. So hardware won't lower performance unless it's needed. This can fix the current performance issue. 2. Add a new schemata line (e.g. MBI:<id>=x;<id>=y;...) to specify min mbw just like max mbw specified by schemata line "MB:...". User can use this line to change min mbw per partition per node. This could be added in the future. " On 1. Thinking about this again, I think adding any heuristic tied to mbw_max to determine what mbw_min is undesirable. Loading the mpam driver or mounting resctrl shouldn't change the defaults away from the defaults for h/w partid 0 or performance characteristics may change unexpectedly. The spec only gives us suggestions for these but we should go with those. See table 3.8 in IH0099B.a Mpam System Component Specification. The MBW_MIN that is 0xFFFF. Also, having mbw_min doesn't necessarily mean that there is mbw_max. A system that doesn't advertise mbw_min support to the user should act as if there is no mbw_min support. On 2. Yes, adding a new user interface in resctrl is the way to deal with this. See [1] for a discussion on adding new schema. Hence, I'll drop this patch, and update the mbw_min default to be 0xFFFF and for the value not to change even if mbw_max changes. I think this leaves us in the best position going forward without any heuristics that may come back to bite us later when proper support for a schema supporting mbw_min is added to resctrl. [1] https://lore.kernel.org/lkml/aPtfMFfLV1l%2FRB0L@e133380.arm.com/ Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Fri, 30 Jan 2026 14:17:38 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Peter, On 1/30/26 13:04, Peter Newman wrote: Yes, that does seem reasonable. That cache level would have to match with what is reported in resctrl too. I expect that would involve adding a new entry in enum resctrl_scope. Good to know. I'm looking into tightening the heuristics in general. Please shout if any of the changes in heuristics mean that any hardware or features stop being usable. If there is an event_filter file it should show the "correct" values and so just leaving it out would be the way to go. However, unless I'm missing something even this requires changes in fs/resctrl. As such, I think it's expedient to defer adding ABMC to the series until we have decided what to do in fs/resctrl. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Fri, 30 Jan 2026 14:38:00 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On 1/30/2026 8:17 AM, Ben Horgan wrote: Background: I previouslyshared original fix(seecodesnippet below) with James Morse ~2 years ago to address the errata, which explicitly recommends usinga 5% gap for mitigation of the Hardware issue (the problem described in commit text of T241-MPAM-4) For some reason theoriginalimplementationwas splitinto two patches:   - Generic change applicable toall chips   - Specific fixfor Graceerrata T241-MPAM-4 Issue: Dropping this patch impacts[PATCH v3 45/47] forthe errata fix. If removalis necessary, please mergethis changeinto the T241-MPAM-4-specific patch. --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -1190,8 +1190,12 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, rprops->mbw_pbm_bits);          } -       if (mpam_has_feature(mpam_feat_mbw_min, rprops)) -               mpam_write_partsel_reg(msc, MBW_MIN, 0); +       if (mpam_has_feature(mpam_feat_mbw_min, rprops)) { +               if (mpam_has_feature(mpam_feat_mbw_max, cfg)) +                       mpam_write_partsel_reg(msc, MBW_MIN, cfg->mbw_min); +               else +                       mpam_write_partsel_reg(msc, MBW_MIN, 0); +       }         if (mpam_has_feature(mpam_feat_mbw_max, rprops)) {                 if (mpam_has_feature(mpam_feat_mbw_max, cfg)) @@ -2332,6 +2336,31 @@ static int __write_config(void *arg)          return 0;   } +static void mpam_extend_config(struct mpam_class *class, struct mpam_config *cfg) +{ +       struct mpam_props *cprops = &class->props; +       u32 min, delta; + +       /* +        * MAX and MIN should be set together. If only one is provided, +        * generate a configuration for the other. If only one control +        * type is supported, the other value will be ignored. +        * +        * Resctrl can only configure the MAX. +        * +        * Parts affected by Nvidia's T241-MPAM-4 depend on this occurring, +        * and recommend a 5% difference. +        */ +       if (mpam_has_feature(mpam_feat_mbw_max, cfg) && +           !mpam_has_feature(mpam_feat_mbw_min, cfg)){ +               delta = ((5 * MPAMCFG_MBW_MAX_MAX) / 100) - 1; +               min = max_t(s32, cfg->mbw_max - delta, BIT(cprops->bwa_wd)); + +               cfg->mbw_min = max_t(s32, cfg->mbw_max - delta, BIT(16 - cprops->bwa_wd)); +               mpam_set_feature(mpam_feat_mbw_min, cfg); +       } +} Shanker
{ "author": "Shanker Donthineni <sdonthineni@nvidia.com>", "date": "Fri, 30 Jan 2026 20:30:01 -0600", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Shanker, On 1/31/26 02:30, Shanker Donthineni wrote: What's the behaviour on T241 when MBW_MIN is always 0xFFFF? I'm worried if we make a policy decision of how to set MBW_MIN based on MBW_MAX for this platform then we won't be able to support a configurable MBW_MIN in the future for this platform. As when MBW_MIN support is added in resctrl the user's configuration for this platform would change meaning on kernel upgrade. Thanks, Ben
{ "author": "Ben Horgan <ben.horgan@arm.com>", "date": "Mon, 2 Feb 2026 10:21:28 +0000", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
This new version of the mpam missing pieces has no major rework from the previous version. It's mainly small corrections and code tidying based on review and things I spotted along the way. To be able to merge this we need review from more people and people to start testing on their platforms and giving some Tested-by tags. Change list in patches. As mentioned in the cover letter for v2, one major departure from the previous snapshot branches referenced in the base driver series is that the same MPAM setting are used for kernel-space and user-space. There are pros and cons of choosing this policy but I think it is the best thing to start with as there are AMD plans for adding a resctrl feature to allow a different closid/rmid configuration for user-space from kernel space. The AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This gives us a path forward to add support for having the EL1 and EL0 MPAM partid/pmg configuration differ from each other. >From James' cover letter: This is the missing piece to make MPAM usable resctrl in user-space. This has shed its debugfs code and the read/write 'event configuration' for the monitors to make the series smaller. This adds the arch code and KVM support first. I anticipate the whole thing going via arm64, but if goes via tip instead, the an immutable branch with those patches should be easy to do. Generally the resctrl glue code works by picking what MPAM features it can expose from the MPAM drive, then configuring the structs that back the resctrl helpers. If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU counters are considerably more hairy, and depend on hueristics around the topology, and a bunch of stuff trying to emulate ABMC. If it didn't pick what you wanted it to, please share the debug messages produced when enabling dynamic debug and booting with: | dyndbg="file mpam_resctrl.c +pl" I've not found a platform that can test all the behaviours around the monitors, so this is where I'd expect the most bugs. The MPAM spec that describes all the system and MMIO registers can be found here: https://developer.arm.com/documentation/ddi0598/db/?lang=en (Ignored the 'RETIRED' warning - that is just arm moving the documentation around. This document has the best overview) Based on v6.19-rc5 This series can be retrieved from: https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3 v2 can be found at: https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/ rfc can be found at: https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/ [1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf Ben Horgan (10): arm_mpam: Use non-atomic bitops when modifying feature bitmap arm64/sysreg: Add MPAMSM_EL1 register KVM: arm64: Preserve host MPAM configuration when changing traps KVM: arm64: Make MPAMSM_EL1 accesses UNDEF arm64: mpam: Initialise and context switch the MPAMSM_EL1 register KVM: arm64: Use kernel-space partid configuration for hypercalls arm_mpam: resctrl: Add rmid index helpers arm_mpam: resctrl: Add kunit test for rmid idx conversions arm_mpam: resctrl: Wait for cacheinfo to be ready arm_mpam: resctrl: Add kunit test for mbw min control generation Dave Martin (2): arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats arm_mpam: resctrl: Add kunit test for control format conversions James Morse (30): arm64: mpam: Context switch the MPAM registers arm64: mpam: Re-initialise MPAM regs when CPU comes online arm64: mpam: Advertise the CPUs MPAM limits to the driver arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG values KVM: arm64: Force guest EL1 to use user-space's partid configuration arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation arm_mpam: resctrl: Sort the order of the domain lists arm_mpam: resctrl: Pick the caches we will use as resctrl resources arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls() arm_mpam: resctrl: Add resctrl_arch_get_config() arm_mpam: resctrl: Implement helpers to update configuration arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks arm_mpam: resctrl: Add CDP emulation arm_mpam: resctrl: Add support for 'MB' resource arm_mpam: resctrl: Add support for csu counters arm_mpam: resctrl: Pick classes for use as mbm counters arm_mpam: resctrl: Pre-allocate free running monitors arm_mpam: resctrl: Pre-allocate assignable monitors arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use arm_mpam: resctrl: Allow resctrl to allocate monitors arm_mpam: resctrl: Add resctrl_arch_rmid_read() and resctrl_arch_reset_rmid() arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() arm_mpam: resctrl: Update the rmid reallocation limit arm_mpam: resctrl: Add empty definitions for assorted resctrl functions arm64: mpam: Select ARCH_HAS_CPU_RESCTRL arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl arm_mpam: Generate a configuration for min controls arm_mpam: Quirk CMN-650's CSU NRDY behaviour Jiapeng Chong (1): arm_mpam: Remove duplicate linux/srcu.h header Shanker Donthineni (4): arm_mpam: Add quirk framework arm_mpam: Add workaround for T241-MPAM-1 arm_mpam: Add workaround for T241-MPAM-4 arm_mpam: Add workaround for T241-MPAM-6 Documentation/arch/arm64/silicon-errata.rst | 9 + arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/el2_setup.h | 3 +- arch/arm64/include/asm/mpam.h | 98 + arch/arm64/include/asm/resctrl.h | 2 + arch/arm64/include/asm/thread_info.h | 3 + arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpufeature.c | 21 +- arch/arm64/kernel/mpam.c | 58 + arch/arm64/kernel/process.c | 7 + arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 + arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 + arch/arm64/kvm/sys_regs.c | 2 + arch/arm64/tools/sysreg | 8 + drivers/resctrl/Kconfig | 9 +- drivers/resctrl/Makefile | 1 + drivers/resctrl/mpam_devices.c | 306 ++- drivers/resctrl/mpam_internal.h | 131 +- drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++ drivers/resctrl/test_mpam_devices.c | 66 + drivers/resctrl/test_mpam_resctrl.c | 426 ++++ include/linux/arm_mpam.h | 32 + 23 files changed, 3119 insertions(+), 33 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/include/asm/resctrl.h create mode 100644 arch/arm64/kernel/mpam.c create mode 100644 drivers/resctrl/mpam_resctrl.c create mode 100644 drivers/resctrl/test_mpam_resctrl.c -- 2.43.0
Hi Ben, On 2/2/2026 4:21 AM, Ben Horgan wrote: Memory bandwidth throttling will not function correctly. The MPAM hardware monitors MIN and MAX values for each active partition to maintain memory bandwidth usage between MBW_MIN and MBW_MAX. Therefore, MBW_MIN must be less than MBW_MAX (IMO, setting MBW_MIN to always 0xFFFF is incorrect) Grace errata T241-MPAM-4 has two issues: - MBW_MIN must be greater than 0 (WAR set to one when when it's zero) - In the Grace implementation of memory-bandwidth partitioning (MPAM), in the absence of contention for bandwidth, the minimum bandwidth setting can affect the amount of achieved bandwidth. Specifically, the achieved bandwidth in the absence of contention can settle to any value between the values of MIN and MAX. This means if the gap between MIN and MAX is large then the BW can settle closer to MIN. To achieve BW closer to MAX in the absence of contention, software should configure a relatively narrow gap between MPAMCFG_MBW_MIN and MPAMCFG_MBW_MAX. The recommendation is to use a 5% gap, corresponding to an absolute difference of (0xFFFF * 0.05) = 0xCCC between MPAMCFG_MBW_MIN and MPAMCFG_MBW_MAX. Yes, we can't support generic programmable MBW_MIN for Grace chip. The currentresctrl interface doesnot exposeMBW_MIN, preventingusers from configuring the recommended5% gap. Without this interfacesupport, theonly wayto applytheworkaround is through driver-level changes. What is the timelineforaddingMBW_MIN support? We have two options. Option-A: Keep the current WAR 5% gap and don't allow users to program MBW_MIN. Option-B:Remove the5% gap workaround and relyon usersto program MBW_MIN             accordingto the Grace recommendations whentheinterfacebecomes available. We'll prefer option-B. Thanks, Shanker
{ "author": "Shanker Donthineni <sdonthineni@nvidia.com>", "date": "Mon, 2 Feb 2026 10:34:18 -0600", "thread_id": "ca45ea06-53fa-4010-86c6-66213243b636@nvidia.com.mbox.gz" }
lkml
[syzbot] [kvm?] WARNING in kvm_gmem_fault_user_mapping
Hello, syzbot found the following issue on: HEAD commit: 1f97d9dcf536 Merge tag 'vfio-v6.19-rc8' of https://github... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10b3e322580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15e5ebfa580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13eef85a580000 Downloadable assets: disk image: https://storage.googleapis.com/syzbot-assets/f898291c4b7b/disk-1f97d9dc.raw.xz vmlinux: https://storage.googleapis.com/syzbot-assets/cac48e20323c/vmlinux-1f97d9dc.xz kernel image: https://storage.googleapis.com/syzbot-assets/d2e60d34b7e7/bzImage-1f97d9dc.xz IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com ------------[ cut here ]------------ folio_test_large(folio) WARNING: arch/x86/kvm/../../../virt/kvm/guest_memfd.c:416 at kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416, CPU#1: syz.3.124/6406 Modules linked in: CPU: 1 UID: 0 PID: 6406 Comm: syz.3.124 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/13/2026 RIP: 0010:kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416 Code: 00 e9 a1 fe ff ff bd 00 04 00 00 eb d9 e8 43 b8 83 00 48 c7 c6 e0 9f 82 8b 48 89 df e8 d4 f8 ce 00 90 0f 0b e8 2c b8 83 00 90 <0f> 0b 90 48 8d 6b 34 48 89 df e8 ec f6 bb 00 be 04 00 00 00 48 89 RSP: 0018:ffffc90004ab7848 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffea00018a0000 RCX: ffffffff81834070 RDX: ffff888028b124c0 RSI: ffffffff81834334 RDI: ffff888028b124c0 RBP: ffffc90004ab79f8 R08: 0000000000000007 R09: 0000000000000000 R10: 0000000000000040 R11: 0000000000000000 R12: ffffea00018a0000 R13: ffffc90004ab7a08 R14: 0000000000000040 R15: ffffea00018a0008 FS: 00007fb8562ce6c0(0000) GS:ffff8881246db000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f89fb863d58 CR3: 000000006060a000 CR4: 00000000003526f0 Call Trace: <TASK> __do_fault+0x10d/0x550 mm/memory.c:5323 do_read_fault mm/memory.c:5758 [inline] do_fault+0xaf9/0x1990 mm/memory.c:5892 do_pte_missing mm/memory.c:4404 [inline] handle_pte_fault mm/memory.c:6276 [inline] __handle_mm_fault+0x1807/0x2b50 mm/memory.c:6414 handle_mm_fault+0x36d/0xa20 mm/memory.c:6583 faultin_page mm/gup.c:1126 [inline] __get_user_pages+0xf9c/0x34d0 mm/gup.c:1428 populate_vma_page_range+0x267/0x3f0 mm/gup.c:1860 __mm_populate+0x107/0x3a0 mm/gup.c:1963 do_mlock+0x3f0/0x7f0 mm/mlock.c:653 __do_sys_mlock mm/mlock.c:661 [inline] __se_sys_mlock mm/mlock.c:659 [inline] __x64_sys_mlock+0x59/0x80 mm/mlock.c:659 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc9/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fb85539aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fb8562ce028 EFLAGS: 00000246 ORIG_RAX: 0000000000000095 RAX: ffffffffffffffda RBX: 00007fb855615fa0 RCX: 00007fb85539aeb9 RDX: 0000000000000000 RSI: 0000000000800000 RDI: 0000200000000000 RBP: 00007fb855408c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fb855616038 R14: 00007fb855615fa0 R15: 00007ffcc1750088 </TASK> --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. If the report is already addressed, let syzbot know by replying with: #syz fix: exact-commit-title If you want syzbot to run the reproducer, reply with: #syz test: git://repo/address.git branch-or-commit-hash If you attach or paste a git patch, syzbot will apply it before testing. If you want to overwrite report's subsystems, reply with: #syz set subsystems: new-subsystem (See the list of subsystem names on the web dashboard) If the report is a duplicate of another one, reply with: #syz dup: exact-subject-of-another-report If you want to undo deduplication, reply with: #syz undup
Hello, syzbot has tested the proposed patch but the reproducer is still triggering an issue: WARNING in kvm_gmem_fault_user_mapping ------------[ cut here ]------------ folio_test_large(folio) WARNING: arch/x86/kvm/../../../virt/kvm/guest_memfd.c:416 at kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416, CPU#1: syz.3.91/7037 Modules linked in: CPU: 1 UID: 0 PID: 7037 Comm: syz.3.91 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/24/2026 RIP: 0010:kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416 Code: 00 e9 a1 fe ff ff bd 00 04 00 00 eb d9 e8 43 b8 83 00 48 c7 c6 e0 9f 82 8b 48 89 df e8 54 fb ce 00 90 0f 0b e8 2c b8 83 00 90 <0f> 0b 90 48 8d 6b 34 48 89 df e8 ec f6 bb 00 be 04 00 00 00 48 89 RSP: 0018:ffffc90004477848 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffea0001c10000 RCX: ffffffff81834070 RDX: ffff88802e784980 RSI: ffffffff81834334 RDI: ffff88802e784980 RBP: ffffc900044779f8 R08: 0000000000000007 R09: 0000000000000000 R10: 0000000000000040 R11: 0000000000000000 R12: ffffea0001c10000 R13: ffffc90004477a08 R14: 0000000000000040 R15: ffffea0001c10008 FS: 00007f25057f76c0(0000) GS:ffff8881246d9000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f6a111b7d58 CR3: 00000000310af000 CR4: 00000000003526f0 Call Trace: <TASK> __do_fault+0x10d/0x550 mm/memory.c:5323 do_read_fault mm/memory.c:5758 [inline] do_fault+0xaf9/0x1990 mm/memory.c:5892 do_pte_missing mm/memory.c:4404 [inline] handle_pte_fault mm/memory.c:6276 [inline] __handle_mm_fault+0x1807/0x2b50 mm/memory.c:6414 handle_mm_fault+0x36d/0xa20 mm/memory.c:6583 faultin_page mm/gup.c:1126 [inline] __get_user_pages+0xf9c/0x34d0 mm/gup.c:1428 populate_vma_page_range+0x267/0x3f0 mm/gup.c:1860 __mm_populate+0x107/0x3a0 mm/gup.c:1963 do_mlock+0x3f0/0x7f0 mm/mlock.c:653 __do_sys_mlock mm/mlock.c:661 [inline] __se_sys_mlock mm/mlock.c:659 [inline] __x64_sys_mlock+0x59/0x80 mm/mlock.c:659 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc9/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f250499aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f25057f7028 EFLAGS: 00000246 ORIG_RAX: 0000000000000095 RAX: ffffffffffffffda RBX: 00007f2504c15fa0 RCX: 00007f250499aeb9 RDX: 0000000000000000 RSI: 0000000000800000 RDI: 0000200000000000 RBP: 00007f2504a08c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f2504c16038 R14: 00007f2504c15fa0 R15: 00007ffc912316c8 </TASK> Tested on: commit: 162b4244 Merge tag 'iommu-fixes-v6.19-rc7' of git://gi.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=14d7053a580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 patch: https://syzkaller.appspot.com/x/patch.diff?x=1048d322580000
{ "author": "syzbot <syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com>", "date": "Sat, 31 Jan 2026 21:40:03 -0800", "thread_id": "6980d327.050a0220.1d0a41.002a.GAE@google.com.mbox.gz" }
lkml
[syzbot] [kvm?] WARNING in kvm_gmem_fault_user_mapping
Hello, syzbot found the following issue on: HEAD commit: 1f97d9dcf536 Merge tag 'vfio-v6.19-rc8' of https://github... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10b3e322580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15e5ebfa580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13eef85a580000 Downloadable assets: disk image: https://storage.googleapis.com/syzbot-assets/f898291c4b7b/disk-1f97d9dc.raw.xz vmlinux: https://storage.googleapis.com/syzbot-assets/cac48e20323c/vmlinux-1f97d9dc.xz kernel image: https://storage.googleapis.com/syzbot-assets/d2e60d34b7e7/bzImage-1f97d9dc.xz IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com ------------[ cut here ]------------ folio_test_large(folio) WARNING: arch/x86/kvm/../../../virt/kvm/guest_memfd.c:416 at kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416, CPU#1: syz.3.124/6406 Modules linked in: CPU: 1 UID: 0 PID: 6406 Comm: syz.3.124 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/13/2026 RIP: 0010:kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416 Code: 00 e9 a1 fe ff ff bd 00 04 00 00 eb d9 e8 43 b8 83 00 48 c7 c6 e0 9f 82 8b 48 89 df e8 d4 f8 ce 00 90 0f 0b e8 2c b8 83 00 90 <0f> 0b 90 48 8d 6b 34 48 89 df e8 ec f6 bb 00 be 04 00 00 00 48 89 RSP: 0018:ffffc90004ab7848 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffea00018a0000 RCX: ffffffff81834070 RDX: ffff888028b124c0 RSI: ffffffff81834334 RDI: ffff888028b124c0 RBP: ffffc90004ab79f8 R08: 0000000000000007 R09: 0000000000000000 R10: 0000000000000040 R11: 0000000000000000 R12: ffffea00018a0000 R13: ffffc90004ab7a08 R14: 0000000000000040 R15: ffffea00018a0008 FS: 00007fb8562ce6c0(0000) GS:ffff8881246db000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f89fb863d58 CR3: 000000006060a000 CR4: 00000000003526f0 Call Trace: <TASK> __do_fault+0x10d/0x550 mm/memory.c:5323 do_read_fault mm/memory.c:5758 [inline] do_fault+0xaf9/0x1990 mm/memory.c:5892 do_pte_missing mm/memory.c:4404 [inline] handle_pte_fault mm/memory.c:6276 [inline] __handle_mm_fault+0x1807/0x2b50 mm/memory.c:6414 handle_mm_fault+0x36d/0xa20 mm/memory.c:6583 faultin_page mm/gup.c:1126 [inline] __get_user_pages+0xf9c/0x34d0 mm/gup.c:1428 populate_vma_page_range+0x267/0x3f0 mm/gup.c:1860 __mm_populate+0x107/0x3a0 mm/gup.c:1963 do_mlock+0x3f0/0x7f0 mm/mlock.c:653 __do_sys_mlock mm/mlock.c:661 [inline] __se_sys_mlock mm/mlock.c:659 [inline] __x64_sys_mlock+0x59/0x80 mm/mlock.c:659 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc9/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fb85539aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fb8562ce028 EFLAGS: 00000246 ORIG_RAX: 0000000000000095 RAX: ffffffffffffffda RBX: 00007fb855615fa0 RCX: 00007fb85539aeb9 RDX: 0000000000000000 RSI: 0000000000800000 RDI: 0000200000000000 RBP: 00007fb855408c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fb855616038 R14: 00007fb855615fa0 R15: 00007ffcc1750088 </TASK> --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. If the report is already addressed, let syzbot know by replying with: #syz fix: exact-commit-title If you want syzbot to run the reproducer, reply with: #syz test: git://repo/address.git branch-or-commit-hash If you attach or paste a git patch, syzbot will apply it before testing. If you want to overwrite report's subsystems, reply with: #syz set subsystems: new-subsystem (See the list of subsystem names on the web dashboard) If the report is a duplicate of another one, reply with: #syz dup: exact-subject-of-another-report If you want to undo deduplication, reply with: #syz undup
Hello, syzbot has tested the proposed patch and the reproducer did not trigger any issue: Reported-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com Tested-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com Tested on: commit: 162b4244 Merge tag 'iommu-fixes-v6.19-rc7' of git://gi.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=14a0445a580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 patch: https://syzkaller.appspot.com/x/patch.diff?x=167abbfa580000 Note: testing is done by a robot and is best-effort only.
{ "author": "syzbot <syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com>", "date": "Sat, 31 Jan 2026 22:25:03 -0800", "thread_id": "6980d327.050a0220.1d0a41.002a.GAE@google.com.mbox.gz" }
lkml
[syzbot] [kvm?] WARNING in kvm_gmem_fault_user_mapping
Hello, syzbot found the following issue on: HEAD commit: 1f97d9dcf536 Merge tag 'vfio-v6.19-rc8' of https://github... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10b3e322580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15e5ebfa580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13eef85a580000 Downloadable assets: disk image: https://storage.googleapis.com/syzbot-assets/f898291c4b7b/disk-1f97d9dc.raw.xz vmlinux: https://storage.googleapis.com/syzbot-assets/cac48e20323c/vmlinux-1f97d9dc.xz kernel image: https://storage.googleapis.com/syzbot-assets/d2e60d34b7e7/bzImage-1f97d9dc.xz IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com ------------[ cut here ]------------ folio_test_large(folio) WARNING: arch/x86/kvm/../../../virt/kvm/guest_memfd.c:416 at kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416, CPU#1: syz.3.124/6406 Modules linked in: CPU: 1 UID: 0 PID: 6406 Comm: syz.3.124 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/13/2026 RIP: 0010:kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416 Code: 00 e9 a1 fe ff ff bd 00 04 00 00 eb d9 e8 43 b8 83 00 48 c7 c6 e0 9f 82 8b 48 89 df e8 d4 f8 ce 00 90 0f 0b e8 2c b8 83 00 90 <0f> 0b 90 48 8d 6b 34 48 89 df e8 ec f6 bb 00 be 04 00 00 00 48 89 RSP: 0018:ffffc90004ab7848 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffea00018a0000 RCX: ffffffff81834070 RDX: ffff888028b124c0 RSI: ffffffff81834334 RDI: ffff888028b124c0 RBP: ffffc90004ab79f8 R08: 0000000000000007 R09: 0000000000000000 R10: 0000000000000040 R11: 0000000000000000 R12: ffffea00018a0000 R13: ffffc90004ab7a08 R14: 0000000000000040 R15: ffffea00018a0008 FS: 00007fb8562ce6c0(0000) GS:ffff8881246db000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f89fb863d58 CR3: 000000006060a000 CR4: 00000000003526f0 Call Trace: <TASK> __do_fault+0x10d/0x550 mm/memory.c:5323 do_read_fault mm/memory.c:5758 [inline] do_fault+0xaf9/0x1990 mm/memory.c:5892 do_pte_missing mm/memory.c:4404 [inline] handle_pte_fault mm/memory.c:6276 [inline] __handle_mm_fault+0x1807/0x2b50 mm/memory.c:6414 handle_mm_fault+0x36d/0xa20 mm/memory.c:6583 faultin_page mm/gup.c:1126 [inline] __get_user_pages+0xf9c/0x34d0 mm/gup.c:1428 populate_vma_page_range+0x267/0x3f0 mm/gup.c:1860 __mm_populate+0x107/0x3a0 mm/gup.c:1963 do_mlock+0x3f0/0x7f0 mm/mlock.c:653 __do_sys_mlock mm/mlock.c:661 [inline] __se_sys_mlock mm/mlock.c:659 [inline] __x64_sys_mlock+0x59/0x80 mm/mlock.c:659 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc9/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fb85539aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fb8562ce028 EFLAGS: 00000246 ORIG_RAX: 0000000000000095 RAX: ffffffffffffffda RBX: 00007fb855615fa0 RCX: 00007fb85539aeb9 RDX: 0000000000000000 RSI: 0000000000800000 RDI: 0000200000000000 RBP: 00007fb855408c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fb855616038 R14: 00007fb855615fa0 R15: 00007ffcc1750088 </TASK> --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. If the report is already addressed, let syzbot know by replying with: #syz fix: exact-commit-title If you want syzbot to run the reproducer, reply with: #syz test: git://repo/address.git branch-or-commit-hash If you attach or paste a git patch, syzbot will apply it before testing. If you want to overwrite report's subsystems, reply with: #syz set subsystems: new-subsystem (See the list of subsystem names on the web dashboard) If the report is a duplicate of another one, reply with: #syz dup: exact-subject-of-another-report If you want to undo deduplication, reply with: #syz undup
Hello, syzbot has tested the proposed patch but the reproducer is still triggering an issue: WARNING in kvm_gmem_create ------------[ cut here ]------------ !mapping_unevictable(inode->i_mapping) WARNING: arch/x86/kvm/../../../virt/kvm/guest_memfd.c:601 at __kvm_gmem_create virt/kvm/guest_memfd.c:601 [inline], CPU#0: syz.0.17/6689 WARNING: arch/x86/kvm/../../../virt/kvm/guest_memfd.c:601 at kvm_gmem_create+0x389/0x780 virt/kvm/guest_memfd.c:644, CPU#0: syz.0.17/6689 Modules linked in: CPU: 0 UID: 0 PID: 6689 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/24/2026 RIP: 0010:__kvm_gmem_create virt/kvm/guest_memfd.c:601 [inline] RIP: 0010:kvm_gmem_create+0x389/0x780 virt/kvm/guest_memfd.c:644 Code: 0f 85 88 03 00 00 4d 8b ad 28 01 00 00 31 ff 49 c1 ed 03 41 83 e5 01 44 89 ee e8 c2 ac 83 00 45 84 ed 75 09 e8 68 b2 83 00 90 <0f> 0b 90 e8 5f b2 83 00 49 8d bf 78 04 00 00 48 b8 00 00 00 00 00 RSP: 0018:ffffc90003f97990 EFLAGS: 00010293 RAX: 0000000000000000 RBX: 0000000000000005 RCX: ffffffff818348ee RDX: ffff88801ebb24c0 RSI: ffffffff818348f8 RDI: ffff88801ebb24c0 RBP: ffff88805dae0000 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: ffffffff82711c34 R12: ffff88801ffd5d00 R13: 0000000000000000 R14: 0000000000000003 R15: ffff88806b738048 FS: 00007f124fe386c0(0000) GS:ffff8881245d9000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b34963fff CR3: 000000002a3f2000 CR4: 00000000003526f0 Call Trace: <TASK> kvm_vm_ioctl+0x1109/0x4020 virt/kvm/kvm_main.c:5397 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] __se_sys_ioctl fs/ioctl.c:583 [inline] __x64_sys_ioctl+0x18e/0x210 fs/ioctl.c:583 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc9/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f124ef9aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f124fe38028 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f124f215fa0 RCX: 00007f124ef9aeb9 RDX: 00002000000001c0 RSI: 00000000c040aed4 RDI: 0000000000000004 RBP: 00007f124f008c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f124f216038 R14: 00007f124f215fa0 R15: 00007ffc8cc39a38 </TASK> Tested on: commit: 162b4244 Merge tag 'iommu-fixes-v6.19-rc7' of git://gi.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1039bbfa580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 patch: https://syzkaller.appspot.com/x/patch.diff?x=161ebbfa580000
{ "author": "syzbot <syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com>", "date": "Sun, 01 Feb 2026 02:33:03 -0800", "thread_id": "6980d327.050a0220.1d0a41.002a.GAE@google.com.mbox.gz" }
lkml
[syzbot] [kvm?] WARNING in kvm_gmem_fault_user_mapping
Hello, syzbot found the following issue on: HEAD commit: 1f97d9dcf536 Merge tag 'vfio-v6.19-rc8' of https://github... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10b3e322580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15e5ebfa580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13eef85a580000 Downloadable assets: disk image: https://storage.googleapis.com/syzbot-assets/f898291c4b7b/disk-1f97d9dc.raw.xz vmlinux: https://storage.googleapis.com/syzbot-assets/cac48e20323c/vmlinux-1f97d9dc.xz kernel image: https://storage.googleapis.com/syzbot-assets/d2e60d34b7e7/bzImage-1f97d9dc.xz IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com ------------[ cut here ]------------ folio_test_large(folio) WARNING: arch/x86/kvm/../../../virt/kvm/guest_memfd.c:416 at kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416, CPU#1: syz.3.124/6406 Modules linked in: CPU: 1 UID: 0 PID: 6406 Comm: syz.3.124 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/13/2026 RIP: 0010:kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416 Code: 00 e9 a1 fe ff ff bd 00 04 00 00 eb d9 e8 43 b8 83 00 48 c7 c6 e0 9f 82 8b 48 89 df e8 d4 f8 ce 00 90 0f 0b e8 2c b8 83 00 90 <0f> 0b 90 48 8d 6b 34 48 89 df e8 ec f6 bb 00 be 04 00 00 00 48 89 RSP: 0018:ffffc90004ab7848 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffea00018a0000 RCX: ffffffff81834070 RDX: ffff888028b124c0 RSI: ffffffff81834334 RDI: ffff888028b124c0 RBP: ffffc90004ab79f8 R08: 0000000000000007 R09: 0000000000000000 R10: 0000000000000040 R11: 0000000000000000 R12: ffffea00018a0000 R13: ffffc90004ab7a08 R14: 0000000000000040 R15: ffffea00018a0008 FS: 00007fb8562ce6c0(0000) GS:ffff8881246db000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f89fb863d58 CR3: 000000006060a000 CR4: 00000000003526f0 Call Trace: <TASK> __do_fault+0x10d/0x550 mm/memory.c:5323 do_read_fault mm/memory.c:5758 [inline] do_fault+0xaf9/0x1990 mm/memory.c:5892 do_pte_missing mm/memory.c:4404 [inline] handle_pte_fault mm/memory.c:6276 [inline] __handle_mm_fault+0x1807/0x2b50 mm/memory.c:6414 handle_mm_fault+0x36d/0xa20 mm/memory.c:6583 faultin_page mm/gup.c:1126 [inline] __get_user_pages+0xf9c/0x34d0 mm/gup.c:1428 populate_vma_page_range+0x267/0x3f0 mm/gup.c:1860 __mm_populate+0x107/0x3a0 mm/gup.c:1963 do_mlock+0x3f0/0x7f0 mm/mlock.c:653 __do_sys_mlock mm/mlock.c:661 [inline] __se_sys_mlock mm/mlock.c:659 [inline] __x64_sys_mlock+0x59/0x80 mm/mlock.c:659 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc9/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fb85539aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fb8562ce028 EFLAGS: 00000246 ORIG_RAX: 0000000000000095 RAX: ffffffffffffffda RBX: 00007fb855615fa0 RCX: 00007fb85539aeb9 RDX: 0000000000000000 RSI: 0000000000800000 RDI: 0000200000000000 RBP: 00007fb855408c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fb855616038 R14: 00007fb855615fa0 R15: 00007ffcc1750088 </TASK> --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. If the report is already addressed, let syzbot know by replying with: #syz fix: exact-commit-title If you want syzbot to run the reproducer, reply with: #syz test: git://repo/address.git branch-or-commit-hash If you attach or paste a git patch, syzbot will apply it before testing. If you want to overwrite report's subsystems, reply with: #syz set subsystems: new-subsystem (See the list of subsystem names on the web dashboard) If the report is a duplicate of another one, reply with: #syz dup: exact-subject-of-another-report If you want to undo deduplication, reply with: #syz undup
Hello, syzbot has tested the proposed patch but the reproducer is still triggering an issue: WARNING in kvm_gmem_fault_user_mapping ------------[ cut here ]------------ folio_test_large(folio) WARNING: arch/x86/kvm/../../../virt/kvm/guest_memfd.c:416 at kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416, CPU#0: syz.1.84/6725 Modules linked in: CPU: 0 UID: 0 PID: 6725 Comm: syz.1.84 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/24/2026 RIP: 0010:kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416 Code: 00 e9 a1 fe ff ff bd 00 04 00 00 eb d9 e8 43 b8 83 00 48 c7 c6 e0 9f 82 8b 48 89 df e8 54 fb ce 00 90 0f 0b e8 2c b8 83 00 90 <0f> 0b 90 48 8d 6b 34 48 89 df e8 ec f6 bb 00 be 04 00 00 00 48 89 RSP: 0018:ffffc90004d4f848 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffea0001380000 RCX: ffffffff81834070 RDX: ffff88802f604980 RSI: ffffffff81834334 RDI: ffff88802f604980 RBP: ffffc90004d4f9f8 R08: 0000000000000007 R09: 0000000000000000 R10: 0000000000000040 R11: 0000000000000000 R12: ffffea0001380000 R13: ffffc90004d4fa08 R14: 0000000000000040 R15: ffffea0001380008 FS: 00007efea6edc6c0(0000) GS:ffff8881245d9000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f0db714da08 CR3: 000000005a1f9000 CR4: 00000000003526f0 Call Trace: <TASK> __do_fault+0x10d/0x550 mm/memory.c:5323 do_read_fault mm/memory.c:5758 [inline] do_fault+0xaf9/0x1990 mm/memory.c:5892 do_pte_missing mm/memory.c:4404 [inline] handle_pte_fault mm/memory.c:6276 [inline] __handle_mm_fault+0x1807/0x2b50 mm/memory.c:6414 handle_mm_fault+0x36d/0xa20 mm/memory.c:6583 faultin_page mm/gup.c:1126 [inline] __get_user_pages+0xf9c/0x34d0 mm/gup.c:1428 populate_vma_page_range+0x267/0x3f0 mm/gup.c:1860 __mm_populate+0x107/0x3a0 mm/gup.c:1963 do_mlock+0x3f0/0x7f0 mm/mlock.c:653 __do_sys_mlock mm/mlock.c:661 [inline] __se_sys_mlock mm/mlock.c:659 [inline] __x64_sys_mlock+0x59/0x80 mm/mlock.c:659 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc9/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7efea5f9aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007efea6edc028 EFLAGS: 00000246 ORIG_RAX: 0000000000000095 RAX: ffffffffffffffda RBX: 00007efea6215fa0 RCX: 00007efea5f9aeb9 RDX: 0000000000000000 RSI: 0000000000800000 RDI: 0000200000000000 RBP: 00007efea6008c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007efea6216038 R14: 00007efea6215fa0 R15: 00007ffd595ac0c8 </TASK> Tested on: commit: 162b4244 Merge tag 'iommu-fixes-v6.19-rc7' of git://gi.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10fde45a580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 patch: https://syzkaller.appspot.com/x/patch.diff?x=116de45a580000
{ "author": "syzbot <syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com>", "date": "Sun, 01 Feb 2026 03:39:04 -0800", "thread_id": "6980d327.050a0220.1d0a41.002a.GAE@google.com.mbox.gz" }
lkml
[syzbot] [kvm?] WARNING in kvm_gmem_fault_user_mapping
Hello, syzbot found the following issue on: HEAD commit: 1f97d9dcf536 Merge tag 'vfio-v6.19-rc8' of https://github... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10b3e322580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15e5ebfa580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13eef85a580000 Downloadable assets: disk image: https://storage.googleapis.com/syzbot-assets/f898291c4b7b/disk-1f97d9dc.raw.xz vmlinux: https://storage.googleapis.com/syzbot-assets/cac48e20323c/vmlinux-1f97d9dc.xz kernel image: https://storage.googleapis.com/syzbot-assets/d2e60d34b7e7/bzImage-1f97d9dc.xz IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com ------------[ cut here ]------------ folio_test_large(folio) WARNING: arch/x86/kvm/../../../virt/kvm/guest_memfd.c:416 at kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416, CPU#1: syz.3.124/6406 Modules linked in: CPU: 1 UID: 0 PID: 6406 Comm: syz.3.124 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/13/2026 RIP: 0010:kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416 Code: 00 e9 a1 fe ff ff bd 00 04 00 00 eb d9 e8 43 b8 83 00 48 c7 c6 e0 9f 82 8b 48 89 df e8 d4 f8 ce 00 90 0f 0b e8 2c b8 83 00 90 <0f> 0b 90 48 8d 6b 34 48 89 df e8 ec f6 bb 00 be 04 00 00 00 48 89 RSP: 0018:ffffc90004ab7848 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffea00018a0000 RCX: ffffffff81834070 RDX: ffff888028b124c0 RSI: ffffffff81834334 RDI: ffff888028b124c0 RBP: ffffc90004ab79f8 R08: 0000000000000007 R09: 0000000000000000 R10: 0000000000000040 R11: 0000000000000000 R12: ffffea00018a0000 R13: ffffc90004ab7a08 R14: 0000000000000040 R15: ffffea00018a0008 FS: 00007fb8562ce6c0(0000) GS:ffff8881246db000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f89fb863d58 CR3: 000000006060a000 CR4: 00000000003526f0 Call Trace: <TASK> __do_fault+0x10d/0x550 mm/memory.c:5323 do_read_fault mm/memory.c:5758 [inline] do_fault+0xaf9/0x1990 mm/memory.c:5892 do_pte_missing mm/memory.c:4404 [inline] handle_pte_fault mm/memory.c:6276 [inline] __handle_mm_fault+0x1807/0x2b50 mm/memory.c:6414 handle_mm_fault+0x36d/0xa20 mm/memory.c:6583 faultin_page mm/gup.c:1126 [inline] __get_user_pages+0xf9c/0x34d0 mm/gup.c:1428 populate_vma_page_range+0x267/0x3f0 mm/gup.c:1860 __mm_populate+0x107/0x3a0 mm/gup.c:1963 do_mlock+0x3f0/0x7f0 mm/mlock.c:653 __do_sys_mlock mm/mlock.c:661 [inline] __se_sys_mlock mm/mlock.c:659 [inline] __x64_sys_mlock+0x59/0x80 mm/mlock.c:659 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc9/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fb85539aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fb8562ce028 EFLAGS: 00000246 ORIG_RAX: 0000000000000095 RAX: ffffffffffffffda RBX: 00007fb855615fa0 RCX: 00007fb85539aeb9 RDX: 0000000000000000 RSI: 0000000000800000 RDI: 0000200000000000 RBP: 00007fb855408c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fb855616038 R14: 00007fb855615fa0 R15: 00007ffcc1750088 </TASK> --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. If the report is already addressed, let syzbot know by replying with: #syz fix: exact-commit-title If you want syzbot to run the reproducer, reply with: #syz test: git://repo/address.git branch-or-commit-hash If you attach or paste a git patch, syzbot will apply it before testing. If you want to overwrite report's subsystems, reply with: #syz set subsystems: new-subsystem (See the list of subsystem names on the web dashboard) If the report is a duplicate of another one, reply with: #syz dup: exact-subject-of-another-report If you want to undo deduplication, reply with: #syz undup
Hello, syzbot has tested the proposed patch but the reproducer is still triggering an issue: kernel BUG in filemap_remove_folio ------------[ cut here ]------------ kernel BUG at mm/filemap.c:254! Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 1 UID: 0 PID: 7475 Comm: syz.2.329 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/24/2026 RIP: 0010:filemap_remove_folio+0x20f/0x270 mm/filemap.c:254 Code: fc 00 10 00 00 0f 86 5f ff ff ff eb 9e e8 b9 e5 c6 ff 48 c7 c6 20 0d 9d 8b 48 89 df e8 6a 2a 12 00 90 0f 0b e8 a2 e5 c6 ff 90 <0f> 0b e8 9a 38 31 00 e9 39 fe ff ff e8 90 38 31 00 e9 0c fe ff ff RSP: 0018:ffffc9000caaf7f0 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffea0001400000 RCX: ffffffff8240149d RDX: ffff88802bcaa4c0 RSI: ffffffff824015fe RDI: ffff88802bcaa4c0 RBP: ffff88806b3047b0 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: ffff88806b3045c0 R14: 0000000000000000 R15: 1000200001ee0000 FS: 00007fa5c3e506c0(0000) GS:ffff8881246d9000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000000572cf000 CR4: 00000000003526f0 Call Trace: <TASK> kvm_gmem_get_folio+0x118/0x320 virt/kvm/guest_memfd.c:166 kvm_gmem_fault_user_mapping+0x151/0x6e0 virt/kvm/guest_memfd.c:425 __do_fault+0x10d/0x550 mm/memory.c:5323 do_read_fault mm/memory.c:5758 [inline] do_fault+0xaf9/0x1990 mm/memory.c:5892 do_pte_missing mm/memory.c:4404 [inline] handle_pte_fault mm/memory.c:6276 [inline] __handle_mm_fault+0x1807/0x2b50 mm/memory.c:6414 handle_mm_fault+0x36d/0xa20 mm/memory.c:6583 faultin_page mm/gup.c:1126 [inline] __get_user_pages+0xf9c/0x34d0 mm/gup.c:1428 populate_vma_page_range+0x267/0x3f0 mm/gup.c:1860 __mm_populate+0x107/0x3a0 mm/gup.c:1963 do_mlock+0x3f0/0x7f0 mm/mlock.c:653 __do_sys_mlock mm/mlock.c:661 [inline] __se_sys_mlock mm/mlock.c:659 [inline] __x64_sys_mlock+0x59/0x80 mm/mlock.c:659 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc9/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fa5c2f9aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fa5c3e50028 EFLAGS: 00000246 ORIG_RAX: 0000000000000095 RAX: ffffffffffffffda RBX: 00007fa5c3215fa0 RCX: 00007fa5c2f9aeb9 RDX: 0000000000000000 RSI: 0000000000800000 RDI: 0000200000000000 RBP: 00007fa5c3008c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fa5c3216038 R14: 00007fa5c3215fa0 R15: 00007fff2603f848 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:filemap_remove_folio+0x20f/0x270 mm/filemap.c:254 Code: fc 00 10 00 00 0f 86 5f ff ff ff eb 9e e8 b9 e5 c6 ff 48 c7 c6 20 0d 9d 8b 48 89 df e8 6a 2a 12 00 90 0f 0b e8 a2 e5 c6 ff 90 <0f> 0b e8 9a 38 31 00 e9 39 fe ff ff e8 90 38 31 00 e9 0c fe ff ff RSP: 0018:ffffc9000caaf7f0 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffea0001400000 RCX: ffffffff8240149d RDX: ffff88802bcaa4c0 RSI: ffffffff824015fe RDI: ffff88802bcaa4c0 RBP: ffff88806b3047b0 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: ffff88806b3045c0 R14: 0000000000000000 R15: 1000200001ee0000 FS: 00007fa5c3e506c0(0000) GS:ffff8881245d9000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000000572cf000 CR4: 00000000003526f0 Tested on: commit: 18f7fcd5 Linux 6.19-rc8 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=14e73322580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 patch: https://syzkaller.appspot.com/x/patch.diff?x=17ca453a580000
{ "author": "syzbot <syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com>", "date": "Mon, 02 Feb 2026 02:52:01 -0800", "thread_id": "6980d327.050a0220.1d0a41.002a.GAE@google.com.mbox.gz" }
lkml
[syzbot] [kvm?] WARNING in kvm_gmem_fault_user_mapping
Hello, syzbot found the following issue on: HEAD commit: 1f97d9dcf536 Merge tag 'vfio-v6.19-rc8' of https://github... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10b3e322580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15e5ebfa580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13eef85a580000 Downloadable assets: disk image: https://storage.googleapis.com/syzbot-assets/f898291c4b7b/disk-1f97d9dc.raw.xz vmlinux: https://storage.googleapis.com/syzbot-assets/cac48e20323c/vmlinux-1f97d9dc.xz kernel image: https://storage.googleapis.com/syzbot-assets/d2e60d34b7e7/bzImage-1f97d9dc.xz IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com ------------[ cut here ]------------ folio_test_large(folio) WARNING: arch/x86/kvm/../../../virt/kvm/guest_memfd.c:416 at kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416, CPU#1: syz.3.124/6406 Modules linked in: CPU: 1 UID: 0 PID: 6406 Comm: syz.3.124 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/13/2026 RIP: 0010:kvm_gmem_fault_user_mapping+0x4b5/0x6e0 virt/kvm/guest_memfd.c:416 Code: 00 e9 a1 fe ff ff bd 00 04 00 00 eb d9 e8 43 b8 83 00 48 c7 c6 e0 9f 82 8b 48 89 df e8 d4 f8 ce 00 90 0f 0b e8 2c b8 83 00 90 <0f> 0b 90 48 8d 6b 34 48 89 df e8 ec f6 bb 00 be 04 00 00 00 48 89 RSP: 0018:ffffc90004ab7848 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffea00018a0000 RCX: ffffffff81834070 RDX: ffff888028b124c0 RSI: ffffffff81834334 RDI: ffff888028b124c0 RBP: ffffc90004ab79f8 R08: 0000000000000007 R09: 0000000000000000 R10: 0000000000000040 R11: 0000000000000000 R12: ffffea00018a0000 R13: ffffc90004ab7a08 R14: 0000000000000040 R15: ffffea00018a0008 FS: 00007fb8562ce6c0(0000) GS:ffff8881246db000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f89fb863d58 CR3: 000000006060a000 CR4: 00000000003526f0 Call Trace: <TASK> __do_fault+0x10d/0x550 mm/memory.c:5323 do_read_fault mm/memory.c:5758 [inline] do_fault+0xaf9/0x1990 mm/memory.c:5892 do_pte_missing mm/memory.c:4404 [inline] handle_pte_fault mm/memory.c:6276 [inline] __handle_mm_fault+0x1807/0x2b50 mm/memory.c:6414 handle_mm_fault+0x36d/0xa20 mm/memory.c:6583 faultin_page mm/gup.c:1126 [inline] __get_user_pages+0xf9c/0x34d0 mm/gup.c:1428 populate_vma_page_range+0x267/0x3f0 mm/gup.c:1860 __mm_populate+0x107/0x3a0 mm/gup.c:1963 do_mlock+0x3f0/0x7f0 mm/mlock.c:653 __do_sys_mlock mm/mlock.c:661 [inline] __se_sys_mlock mm/mlock.c:659 [inline] __x64_sys_mlock+0x59/0x80 mm/mlock.c:659 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc9/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fb85539aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fb8562ce028 EFLAGS: 00000246 ORIG_RAX: 0000000000000095 RAX: ffffffffffffffda RBX: 00007fb855615fa0 RCX: 00007fb85539aeb9 RDX: 0000000000000000 RSI: 0000000000800000 RDI: 0000200000000000 RBP: 00007fb855408c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fb855616038 R14: 00007fb855615fa0 R15: 00007ffcc1750088 </TASK> --- This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkaller@googlegroups.com. syzbot will keep track of this issue. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. If the report is already addressed, let syzbot know by replying with: #syz fix: exact-commit-title If you want syzbot to run the reproducer, reply with: #syz test: git://repo/address.git branch-or-commit-hash If you attach or paste a git patch, syzbot will apply it before testing. If you want to overwrite report's subsystems, reply with: #syz set subsystems: new-subsystem (See the list of subsystem names on the web dashboard) If the report is a duplicate of another one, reply with: #syz dup: exact-subject-of-another-report If you want to undo deduplication, reply with: #syz undup
Hello, syzbot has tested the proposed patch and the reproducer did not trigger any issue: Reported-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com Tested-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com Tested on: commit: 18f7fcd5 Linux 6.19-rc8 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=14ced644580000 kernel config: https://syzkaller.appspot.com/x/.config?x=f1fac0919970b671 dashboard link: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44 compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 patch: https://syzkaller.appspot.com/x/patch.diff?x=10b5c45a580000 Note: testing is done by a robot and is best-effort only.
{ "author": "syzbot <syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com>", "date": "Mon, 02 Feb 2026 08:39:03 -0800", "thread_id": "6980d327.050a0220.1d0a41.002a.GAE@google.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Currently, ops.dequeue() is only invoked when the sched_ext core knows that a task resides in BPF-managed data structures, which causes it to miss scheduling property change scenarios. As a result, BPF schedulers cannot reliably track task state. In addition, some ops.dequeue() callbacks can be skipped (e.g., during direct dispatch), so ops.enqueue() calls are not always paired with a corresponding ops.dequeue(), potentially breaking accounting logic. Fix this by guaranteeing that every ops.enqueue() is matched with a corresponding ops.dequeue(), and introduce the %SCX_DEQ_SCHED_CHANGE flag to distinguish dequeues triggered by scheduling property changes from those occurring in the normal dispatch/execution workflow. New semantics: 1. ops.enqueue() is called when a task enters the BPF scheduler 2. ops.dequeue() is called when the task leaves the BPF scheduler in the following cases: a) regular dispatch workflow: task dispatched to a DSQ, b) core scheduling pick: core-sched picks task before dispatch, c) property change: task properties modified. A new %SCX_DEQ_SCHED_CHANGE flag is also introduced, allowing BPF schedulers to distinguish between: - normal dispatch/execution workflow (dispatch, core-sched pick), - property changes that require state updates (e.g., sched_setaffinity(), sched_setscheduler(), set_user_nice(), NUMA balancing, CPU migrations, etc.). With this, BPF schedulers can: - reliably track task ownership and lifecycle, - maintain accurate accounting of enqueue/dequeue pairs, - distinguish between execution events and property changes, - update internal state appropriately for each dequeue type. Cc: Tejun Heo <tj@kernel.org> Cc: Emil Tsalapatis <emil@etsalapatis.com> Cc: Kuba Piecuch <jpiecuch@google.com> Signed-off-by: Andrea Righi <arighi@nvidia.com> --- Documentation/scheduler/sched-ext.rst | 33 +++++++ include/linux/sched/ext.h | 11 +++ kernel/sched/ext.c | 89 ++++++++++++++++++- kernel/sched/ext_internal.h | 7 ++ .../sched_ext/include/scx/enum_defs.autogen.h | 2 + .../sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + 7 files changed, 142 insertions(+), 3 deletions(-) diff --git a/Documentation/scheduler/sched-ext.rst b/Documentation/scheduler/sched-ext.rst index 404fe6126a769..ed6bf7d9e6e8c 100644 --- a/Documentation/scheduler/sched-ext.rst +++ b/Documentation/scheduler/sched-ext.rst @@ -252,6 +252,37 @@ The following briefly shows how a waking task is scheduled and executed. * Queue the task on the BPF side. + Once ``ops.enqueue()`` is called, the task enters the "enqueued state". + The task remains in this state until ``ops.dequeue()`` is called, which + happens in the following cases: + + 1. **Regular dispatch workflow**: when the task is successfully + dispatched to a DSQ (local, global, or user DSQ), ``ops.dequeue()`` + is triggered immediately to notify the BPF scheduler. + + 2. **Core scheduling pick**: when ``CONFIG_SCHED_CORE`` is enabled and + core scheduling picks a task for execution before it has been + dispatched, ``ops.dequeue()`` is called with the + ``SCX_DEQ_CORE_SCHED_EXEC`` flag. + + 3. **Scheduling property change**: when a task property changes (via + operations like ``sched_setaffinity()``, ``sched_setscheduler()``, + priority changes, CPU migrations, etc.), ``ops.dequeue()`` is called + with the ``SCX_DEQ_SCHED_CHANGE`` flag set in ``deq_flags``. + + **Important**: ``ops.dequeue()`` is called for *any* enqueued task, + regardless of whether the task is still on a BPF data structure, or it + has already been dispatched to a DSQ. This guarantees that every + ``ops.enqueue()`` will eventually be followed by a corresponding + ``ops.dequeue()``. + + This makes it reliable for BPF schedulers to track the enqueued state + and maintain accurate accounting. + + BPF schedulers can choose not to implement ``ops.dequeue()`` if they + don't need to track these transitions. The sched_ext core will safely + handle all dequeue operations regardless. + 3. When a CPU is ready to schedule, it first looks at its local DSQ. If empty, it then looks at the global DSQ. If there still isn't a task to run, ``ops.dispatch()`` is invoked which can use the following two @@ -319,6 +350,8 @@ by a sched_ext scheduler: /* Any usable CPU becomes available */ ops.dispatch(); /* Task is moved to a local DSQ */ + + ops.dequeue(); /* Exiting BPF scheduler */ } ops.running(); /* Task starts running on its assigned CPU */ while (task->scx.slice > 0 && task is runnable) diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h index bcb962d5ee7d8..59446cd0373fa 100644 --- a/include/linux/sched/ext.h +++ b/include/linux/sched/ext.h @@ -84,8 +84,19 @@ struct scx_dispatch_q { /* scx_entity.flags */ enum scx_ent_flags { SCX_TASK_QUEUED = 1 << 0, /* on ext runqueue */ + /* + * Set when ops.enqueue() is called; used to determine if ops.dequeue() + * should be invoked when transitioning out of SCX_OPSS_NONE state. + */ + SCX_TASK_OPS_ENQUEUED = 1 << 1, SCX_TASK_RESET_RUNNABLE_AT = 1 << 2, /* runnable_at should be reset */ SCX_TASK_DEQD_FOR_SLEEP = 1 << 3, /* last dequeue was for SLEEP */ + /* + * Set when ops.dequeue() is called after successful dispatch; used to + * distinguish dispatch dequeues from property change dequeues and + * prevent duplicate dequeue calls. + */ + SCX_TASK_DISPATCH_DEQUEUED = 1 << 4, SCX_TASK_STATE_SHIFT = 8, /* bit 8 and 9 are used to carry scx_task_state */ SCX_TASK_STATE_BITS = 2, diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index afe28c04d5aa7..18bca2b83f5c5 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -1287,6 +1287,20 @@ static void direct_dispatch(struct scx_sched *sch, struct task_struct *p, p->scx.ddsp_enq_flags |= enq_flags; + /* + * The task is about to be dispatched. If ops.enqueue() was called, + * notify the BPF scheduler by calling ops.dequeue(). + * + * Keep %SCX_TASK_OPS_ENQUEUED set so that subsequent property + * changes can trigger ops.dequeue() with %SCX_DEQ_SCHED_CHANGE. + * Mark that the dispatch dequeue has been called to distinguish + * from property change dequeues. + */ + if (SCX_HAS_OP(sch, dequeue) && (p->scx.flags & SCX_TASK_OPS_ENQUEUED)) { + SCX_CALL_OP_TASK(sch, SCX_KF_REST, dequeue, rq, p, 0); + p->scx.flags |= SCX_TASK_DISPATCH_DEQUEUED; + } + /* * We are in the enqueue path with @rq locked and pinned, and thus can't * double lock a remote rq and enqueue to its local DSQ. For @@ -1391,6 +1405,16 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags, WARN_ON_ONCE(atomic_long_read(&p->scx.ops_state) != SCX_OPSS_NONE); atomic_long_set(&p->scx.ops_state, SCX_OPSS_QUEUEING | qseq); + /* + * Mark that ops.enqueue() is being called for this task. + * Clear the dispatch dequeue flag for the new enqueue cycle. + * Only track these flags if ops.dequeue() is implemented. + */ + if (SCX_HAS_OP(sch, dequeue)) { + p->scx.flags |= SCX_TASK_OPS_ENQUEUED; + p->scx.flags &= ~SCX_TASK_DISPATCH_DEQUEUED; + } + ddsp_taskp = this_cpu_ptr(&direct_dispatch_task); WARN_ON_ONCE(*ddsp_taskp); *ddsp_taskp = p; @@ -1523,6 +1547,34 @@ static void ops_dequeue(struct rq *rq, struct task_struct *p, u64 deq_flags) switch (opss & SCX_OPSS_STATE_MASK) { case SCX_OPSS_NONE: + if (SCX_HAS_OP(sch, dequeue) && + p->scx.flags & SCX_TASK_OPS_ENQUEUED) { + /* + * Task was already dispatched. Only call ops.dequeue() + * if it hasn't been called yet (check DISPATCH_DEQUEUED). + * This can happen when: + * 1. Core-sched picks a task that was dispatched + * 2. Property changes occur after dispatch + */ + if (!(p->scx.flags & SCX_TASK_DISPATCH_DEQUEUED)) { + /* + * ops.dequeue() wasn't called during dispatch. + * This shouldn't normally happen, but call it now. + */ + SCX_CALL_OP_TASK(sch, SCX_KF_REST, dequeue, rq, + p, deq_flags); + } else if (!(deq_flags & (DEQUEUE_SLEEP | SCX_DEQ_CORE_SCHED_EXEC))) { + /* + * This is a property change after + * dispatch. Call ops.dequeue() again with + * %SCX_DEQ_SCHED_CHANGE. + */ + SCX_CALL_OP_TASK(sch, SCX_KF_REST, dequeue, rq, + p, deq_flags | SCX_DEQ_SCHED_CHANGE); + } + p->scx.flags &= ~(SCX_TASK_OPS_ENQUEUED | + SCX_TASK_DISPATCH_DEQUEUED); + } break; case SCX_OPSS_QUEUEING: /* @@ -1531,9 +1583,24 @@ static void ops_dequeue(struct rq *rq, struct task_struct *p, u64 deq_flags) */ BUG(); case SCX_OPSS_QUEUED: - if (SCX_HAS_OP(sch, dequeue)) - SCX_CALL_OP_TASK(sch, SCX_KF_REST, dequeue, rq, - p, deq_flags); + /* + * Task is still on the BPF scheduler (not dispatched yet). + * Call ops.dequeue() to notify. Add %SCX_DEQ_SCHED_CHANGE + * only for property changes, not for core-sched picks. + */ + if (SCX_HAS_OP(sch, dequeue)) { + u64 flags = deq_flags; + /* + * Add %SCX_DEQ_SCHED_CHANGE for property changes, + * but not for core-sched picks or sleep. + */ + if (!(deq_flags & (DEQUEUE_SLEEP | SCX_DEQ_CORE_SCHED_EXEC))) + flags |= SCX_DEQ_SCHED_CHANGE; + + SCX_CALL_OP_TASK(sch, SCX_KF_REST, dequeue, rq, p, flags); + p->scx.flags &= ~(SCX_TASK_OPS_ENQUEUED | + SCX_TASK_DISPATCH_DEQUEUED); + } if (atomic_long_try_cmpxchg(&p->scx.ops_state, &opss, SCX_OPSS_NONE)) @@ -2107,6 +2174,22 @@ static void finish_dispatch(struct scx_sched *sch, struct rq *rq, BUG_ON(!(p->scx.flags & SCX_TASK_QUEUED)); + /* + * The task is about to be dispatched. If ops.enqueue() was called, + * notify the BPF scheduler by calling ops.dequeue(). + * + * Keep %SCX_TASK_OPS_ENQUEUED set so that subsequent property + * changes can trigger ops.dequeue() with %SCX_DEQ_SCHED_CHANGE. + * Mark that the dispatch dequeue has been called to distinguish + * from property change dequeues. + */ + if (SCX_HAS_OP(sch, dequeue) && (p->scx.flags & SCX_TASK_OPS_ENQUEUED)) { + struct rq *task_rq = task_rq(p); + + SCX_CALL_OP_TASK(sch, SCX_KF_REST, dequeue, task_rq, p, 0); + p->scx.flags |= SCX_TASK_DISPATCH_DEQUEUED; + } + dsq = find_dsq_for_dispatch(sch, this_rq(), dsq_id, p); if (dsq->id == SCX_DSQ_LOCAL) diff --git a/kernel/sched/ext_internal.h b/kernel/sched/ext_internal.h index 386c677e4c9a0..befa9a5d6e53f 100644 --- a/kernel/sched/ext_internal.h +++ b/kernel/sched/ext_internal.h @@ -982,6 +982,13 @@ enum scx_deq_flags { * it hasn't been dispatched yet. Dequeue from the BPF side. */ SCX_DEQ_CORE_SCHED_EXEC = 1LLU << 32, + + /* + * The task is being dequeued due to a property change (e.g., + * sched_setaffinity(), sched_setscheduler(), set_user_nice(), + * etc.). + */ + SCX_DEQ_SCHED_CHANGE = 1LLU << 33, }; enum scx_pick_idle_cpu_flags { diff --git a/tools/sched_ext/include/scx/enum_defs.autogen.h b/tools/sched_ext/include/scx/enum_defs.autogen.h index c2c33df9292c2..8284f717ff05e 100644 --- a/tools/sched_ext/include/scx/enum_defs.autogen.h +++ b/tools/sched_ext/include/scx/enum_defs.autogen.h @@ -21,6 +21,7 @@ #define HAVE_SCX_CPU_PREEMPT_UNKNOWN #define HAVE_SCX_DEQ_SLEEP #define HAVE_SCX_DEQ_CORE_SCHED_EXEC +#define HAVE_SCX_DEQ_SCHED_CHANGE #define HAVE_SCX_DSQ_FLAG_BUILTIN #define HAVE_SCX_DSQ_FLAG_LOCAL_ON #define HAVE_SCX_DSQ_INVALID @@ -48,6 +49,7 @@ #define HAVE_SCX_TASK_QUEUED #define HAVE_SCX_TASK_RESET_RUNNABLE_AT #define HAVE_SCX_TASK_DEQD_FOR_SLEEP +#define HAVE_SCX_TASK_DISPATCH_DEQUEUED #define HAVE_SCX_TASK_STATE_SHIFT #define HAVE_SCX_TASK_STATE_BITS #define HAVE_SCX_TASK_STATE_MASK diff --git a/tools/sched_ext/include/scx/enums.autogen.bpf.h b/tools/sched_ext/include/scx/enums.autogen.bpf.h index 2f8002bcc19ad..5da50f9376844 100644 --- a/tools/sched_ext/include/scx/enums.autogen.bpf.h +++ b/tools/sched_ext/include/scx/enums.autogen.bpf.h @@ -127,3 +127,5 @@ const volatile u64 __SCX_ENQ_CLEAR_OPSS __weak; const volatile u64 __SCX_ENQ_DSQ_PRIQ __weak; #define SCX_ENQ_DSQ_PRIQ __SCX_ENQ_DSQ_PRIQ +const volatile u64 __SCX_DEQ_SCHED_CHANGE __weak; +#define SCX_DEQ_SCHED_CHANGE __SCX_DEQ_SCHED_CHANGE diff --git a/tools/sched_ext/include/scx/enums.autogen.h b/tools/sched_ext/include/scx/enums.autogen.h index fedec938584be..fc9a7a4d9dea5 100644 --- a/tools/sched_ext/include/scx/enums.autogen.h +++ b/tools/sched_ext/include/scx/enums.autogen.h @@ -46,4 +46,5 @@ SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_LAST); \ SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_CLEAR_OPSS); \ SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_DSQ_PRIQ); \ + SCX_ENUM_SET(skel, scx_deq_flags, SCX_DEQ_SCHED_CHANGE); \ } while (0) -- 2.52.0
{ "author": "Andrea Righi <arighi@nvidia.com>", "date": "Mon, 26 Jan 2026 09:41:49 +0100", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Add a new kselftest to validate that: - every enqueue is followed by proper dequeue, - dispatch dequeues happen exactly once per enqueue, - property change dequeues (%SCX_DEQ_SCHED_CHANGE) only happen for property changes, - no duplicate enqueues without proper dequeue. Test scenarios: - direct dispatch to local DSQ (%SCX_DSQ_LOCAL), - dispatch to user DSQ, - explicit property changes via sched_setaffinity(). This validates that the new ops.dequeue() semantics work correctly for all task lifecycle scenarios. Cc: Tejun Heo <tj@kernel.org> Cc: Emil Tsalapatis <emil@etsalapatis.com> Cc: Kuba Piecuch <jpiecuch@google.com> Signed-off-by: Andrea Righi <arighi@nvidia.com> --- tools/testing/selftests/sched_ext/Makefile | 1 + .../testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++ 3 files changed, 392 insertions(+) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c diff --git a/tools/testing/selftests/sched_ext/Makefile b/tools/testing/selftests/sched_ext/Makefile index 5fe45f9c5f8fd..764e91edabf93 100644 --- a/tools/testing/selftests/sched_ext/Makefile +++ b/tools/testing/selftests/sched_ext/Makefile @@ -161,6 +161,7 @@ all_test_bpfprogs := $(foreach prog,$(wildcard *.bpf.c),$(INCLUDE_DIR)/$(patsubs auto-test-targets := \ create_dsq \ + dequeue \ enq_last_no_enq_fails \ ddsp_bogus_dsq_fail \ ddsp_vtimelocal_fail \ diff --git a/tools/testing/selftests/sched_ext/dequeue.bpf.c b/tools/testing/selftests/sched_ext/dequeue.bpf.c new file mode 100644 index 0000000000000..8b2f792cf7d8b --- /dev/null +++ b/tools/testing/selftests/sched_ext/dequeue.bpf.c @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * A scheduler that validates ops.dequeue() is called correctly: + * - For tasks on BPF data structures (not yet dispatched) + * - For tasks already on DSQs (local or shared) + * - That every ops.enqueue() is followed by ops.dequeue() + * + * Copyright (c) 2025 NVIDIA Corporation. + */ + +#include <scx/common.bpf.h> + +#define SHARED_DSQ 0 + +char _license[] SEC("license") = "GPL"; + +UEI_DEFINE(uei); + +/* + * Counters to track the lifecycle of tasks: + * - enqueue_cnt: Number of times ops.enqueue() was called + * - dequeue_cnt: Number of times ops.dequeue() was called (any type) + * - dispatch_dequeue_cnt: Number of regular dispatch dequeues (no flag) + * - change_dequeue_cnt: Number of property change dequeues (%SCX_DEQ_SCHED_CHANGE) + */ +u64 enqueue_cnt, dequeue_cnt, dispatch_dequeue_cnt, change_dequeue_cnt; + +/* + * Test scenarios: + * - 0: Dispatch to local DSQ + * - 1: Dispatch to shared DSQ + */ +u32 test_scenario; + +/* + * Per-task state to track lifecycle and validate workflow semantics. + * State transitions: + * NONE -> ENQUEUED (on enqueue) + * ENQUEUED -> DISPATCHED (on dispatch dequeue) + * DISPATCHED -> NONE (on property change dequeue or re-enqueue) + * ENQUEUED -> NONE (on property change dequeue before dispatch) + */ +enum task_state { + TASK_NONE = 0, /* Task is outside scheduler control */ + TASK_ENQUEUED, /* ops.enqueue() called, waiting for dequeue */ + TASK_DISPATCHED, /* Dispatch dequeue received, can get property change or re-enqueue */ +}; + +struct task_ctx { + enum task_state state; /* Current state in the workflow */ + u64 enqueue_seq; /* Sequence number for debugging */ +}; + +struct { + __uint(type, BPF_MAP_TYPE_TASK_STORAGE); + __uint(map_flags, BPF_F_NO_PREALLOC); + __type(key, int); + __type(value, struct task_ctx); +} task_ctx_stor SEC(".maps"); + +static struct task_ctx *try_lookup_task_ctx(struct task_struct *p) +{ + return bpf_task_storage_get(&task_ctx_stor, p, 0, 0); +} + +s32 BPF_STRUCT_OPS(dequeue_select_cpu, struct task_struct *p, + s32 prev_cpu, u64 wake_flags) +{ + /* Always bounce to ops.enqueue() */ + return prev_cpu; +} + +void BPF_STRUCT_OPS(dequeue_enqueue, struct task_struct *p, u64 enq_flags) +{ + struct task_ctx *tctx; + + __sync_fetch_and_add(&enqueue_cnt, 1); + + tctx = try_lookup_task_ctx(p); + if (!tctx) + return; + + /* + * Validate state transition: enqueue is only valid from NONE or + * DISPATCHED states. Getting enqueue while in ENQUEUED state + * indicates a missing dequeue. + */ + if (tctx->state == TASK_ENQUEUED) + scx_bpf_error("%d (%s): enqueue while in ENQUEUED state (seq %llu)", + p->pid, p->comm, tctx->enqueue_seq); + + /* Transition to ENQUEUED state */ + tctx->state = TASK_ENQUEUED; + tctx->enqueue_seq++; + + switch (test_scenario) { + case 0: + /* Scenario 0: Direct dispatch to the local DSQ */ + scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, enq_flags); + break; + + case 1: + /* Scenario 1: Dispatch to shared DSQ */ + scx_bpf_dsq_insert(p, SHARED_DSQ, SCX_SLICE_DFL, enq_flags); + break; + } +} + +void BPF_STRUCT_OPS(dequeue_dequeue, struct task_struct *p, u64 deq_flags) +{ + struct task_ctx *tctx; + + __sync_fetch_and_add(&dequeue_cnt, 1); + + tctx = try_lookup_task_ctx(p); + if (!tctx) + return; + + /* + * Validate state: dequeue should only happen from ENQUEUED or + * DISPATCHED states. Getting dequeue from NONE indicates a bug. + */ + if (tctx->state == TASK_NONE) + scx_bpf_error("%d (%s): dequeue from NONE state (seq %llu)", + p->pid, p->comm, tctx->enqueue_seq); + + if (deq_flags & SCX_DEQ_SCHED_CHANGE) { + /* + * Async dequeue: property change interrupting the workflow. + * Valid from both ENQUEUED and DISPATCHED states. + * Transitions task back to NONE state. + */ + __sync_fetch_and_add(&change_dequeue_cnt, 1); + + /* Validate state transition */ + if (tctx->state != TASK_ENQUEUED && tctx->state != TASK_DISPATCHED) + scx_bpf_error("%d (%s): property change dequeue from invalid state %d (seq %llu)", + p->pid, p->comm, tctx->state, tctx->enqueue_seq); + + /* Transition back to NONE - task outside scheduler control */ + tctx->state = TASK_NONE; + } else { + /* + * Regular dispatch dequeue: normal workflow step. + * Valid only from ENQUEUED state (after enqueue, before dispatch dequeue). + * Transitions to DISPATCHED state. + */ + __sync_fetch_and_add(&dispatch_dequeue_cnt, 1); + + /* Validate: dispatch dequeue should NOT have %SCX_DEQ_SCHED_CHANGE flag */ + if (deq_flags & SCX_DEQ_SCHED_CHANGE) + scx_bpf_error("%d (%s): SCX_DEQ_SCHED_CHANGE in dispatch dequeue (seq %llu)", + p->pid, p->comm, tctx->enqueue_seq); + + /* Must be in ENQUEUED state */ + if (tctx->state != TASK_ENQUEUED) + scx_bpf_error("%d (%s): dispatch dequeue from state %d (seq %llu)", + p->pid, p->comm, tctx->state, tctx->enqueue_seq); + + /* Transition to DISPATCHED - normal cycle completed dispatch */ + tctx->state = TASK_DISPATCHED; + } +} + +void BPF_STRUCT_OPS(dequeue_dispatch, s32 cpu, struct task_struct *prev) +{ + scx_bpf_dsq_move_to_local(SHARED_DSQ); +} + +s32 BPF_STRUCT_OPS(dequeue_init_task, struct task_struct *p, + struct scx_init_task_args *args) +{ + struct task_ctx *tctx; + + tctx = bpf_task_storage_get(&task_ctx_stor, p, 0, + BPF_LOCAL_STORAGE_GET_F_CREATE); + if (!tctx) + return -ENOMEM; + + return 0; +} + +s32 BPF_STRUCT_OPS_SLEEPABLE(dequeue_init) +{ + s32 ret; + + ret = scx_bpf_create_dsq(SHARED_DSQ, -1); + if (ret) + return ret; + + return 0; +} + +void BPF_STRUCT_OPS(dequeue_exit, struct scx_exit_info *ei) +{ + UEI_RECORD(uei, ei); +} + +SEC(".struct_ops.link") +struct sched_ext_ops dequeue_ops = { + .select_cpu = (void *)dequeue_select_cpu, + .enqueue = (void *)dequeue_enqueue, + .dequeue = (void *)dequeue_dequeue, + .dispatch = (void *)dequeue_dispatch, + .init_task = (void *)dequeue_init_task, + .init = (void *)dequeue_init, + .exit = (void *)dequeue_exit, + .name = "dequeue_test", +}; diff --git a/tools/testing/selftests/sched_ext/dequeue.c b/tools/testing/selftests/sched_ext/dequeue.c new file mode 100644 index 0000000000000..6861257d79b47 --- /dev/null +++ b/tools/testing/selftests/sched_ext/dequeue.c @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2025 NVIDIA Corporation. + */ +#define _GNU_SOURCE +#include <stdio.h> +#include <unistd.h> +#include <signal.h> +#include <bpf/bpf.h> +#include <scx/common.h> +#include <sys/wait.h> +#include <sched.h> +#include <pthread.h> +#include "scx_test.h" +#include "dequeue.bpf.skel.h" + +#define NUM_WORKERS 8 + +/* + * Worker function that creates enqueue/dequeue events. It alternates + * between CPU work, sleeping, and affinity changes to trigger dequeues. + */ +static void worker_fn(int id) +{ + cpu_set_t cpuset; + int i; + volatile int sum = 0; + + for (i = 0; i < 1000; i++) { + int j; + + /* Do some work to trigger scheduling events */ + for (j = 0; j < 10000; j++) + sum += j; + + /* Change affinity to trigger dequeue */ + if (i % 10 == 0) { + CPU_ZERO(&cpuset); + /* Rotate through the first 4 CPUs */ + CPU_SET(i % 4, &cpuset); + sched_setaffinity(0, sizeof(cpuset), &cpuset); + } + + /* Do additional work */ + for (j = 0; j < 10000; j++) + sum += j; + + /* Sleep to trigger dequeue */ + usleep(1000 + (id * 100)); + } + + exit(0); +} + +static enum scx_test_status run_scenario(struct dequeue *skel, u32 scenario, + const char *scenario_name) +{ + struct bpf_link *link; + pid_t pids[NUM_WORKERS]; + int i, status; + u64 enq_start, deq_start, dispatch_deq_start, change_deq_start; + u64 enq_delta, deq_delta, dispatch_deq_delta, change_deq_delta; + + /* Set the test scenario */ + skel->bss->test_scenario = scenario; + + /* Record starting counts */ + enq_start = skel->bss->enqueue_cnt; + deq_start = skel->bss->dequeue_cnt; + dispatch_deq_start = skel->bss->dispatch_dequeue_cnt; + change_deq_start = skel->bss->change_dequeue_cnt; + + link = bpf_map__attach_struct_ops(skel->maps.dequeue_ops); + SCX_FAIL_IF(!link, "Failed to attach struct_ops for scenario %s", scenario_name); + + /* Fork worker processes to generate enqueue/dequeue events */ + for (i = 0; i < NUM_WORKERS; i++) { + pids[i] = fork(); + SCX_FAIL_IF(pids[i] < 0, "Failed to fork worker %d", i); + + if (pids[i] == 0) { + worker_fn(i); + /* Should not reach here */ + exit(1); + } + } + + /* Wait for all workers to complete */ + for (i = 0; i < NUM_WORKERS; i++) { + SCX_FAIL_IF(waitpid(pids[i], &status, 0) != pids[i], + "Failed to wait for worker %d", i); + SCX_FAIL_IF(status != 0, "Worker %d exited with status %d", i, status); + } + + bpf_link__destroy(link); + + SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_UNREG)); + + /* Calculate deltas */ + enq_delta = skel->bss->enqueue_cnt - enq_start; + deq_delta = skel->bss->dequeue_cnt - deq_start; + dispatch_deq_delta = skel->bss->dispatch_dequeue_cnt - dispatch_deq_start; + change_deq_delta = skel->bss->change_dequeue_cnt - change_deq_start; + + printf("%s:\n", scenario_name); + printf(" enqueues: %lu\n", (unsigned long)enq_delta); + printf(" dequeues: %lu (dispatch: %lu, property_change: %lu)\n", + (unsigned long)deq_delta, + (unsigned long)dispatch_deq_delta, + (unsigned long)change_deq_delta); + + /* + * Validate that we got enqueue and dequeue events. + * The BPF code does strict state machine validation with scx_bpf_error() + * to ensure the workflow semantics are correct. If we reach here without + * errors, the semantics are validated correctly. + */ + SCX_GT(enq_delta, 0); + SCX_GT(deq_delta, 0); + + return SCX_TEST_PASS; +} + +static enum scx_test_status setup(void **ctx) +{ + struct dequeue *skel; + + skel = dequeue__open(); + SCX_FAIL_IF(!skel, "Failed to open skel"); + SCX_ENUM_INIT(skel); + SCX_FAIL_IF(dequeue__load(skel), "Failed to load skel"); + + *ctx = skel; + + return SCX_TEST_PASS; +} + +static enum scx_test_status run(void *ctx) +{ + struct dequeue *skel = ctx; + enum scx_test_status status; + + status = run_scenario(skel, 0, "Local DSQ"); + if (status != SCX_TEST_PASS) + return status; + + status = run_scenario(skel, 1, "User DSQ"); + if (status != SCX_TEST_PASS) + return status; + + printf("\n=== Summary ===\n"); + printf("Total enqueues: %lu\n", (unsigned long)skel->bss->enqueue_cnt); + printf("Total dequeues: %lu\n", (unsigned long)skel->bss->dequeue_cnt); + printf(" Dispatch dequeues: %lu (no flag, normal workflow)\n", + (unsigned long)skel->bss->dispatch_dequeue_cnt); + printf(" Property change dequeues: %lu (SCX_DEQ_SCHED_CHANGE flag)\n", + (unsigned long)skel->bss->change_dequeue_cnt); + printf("\nAll scenarios passed - no state machine violations detected\n"); + printf("-> Validated: Correct state transitions (NONE -> ENQUEUED -> DISPATCHED)\n"); + printf("-> Validated: Dispatch dequeues have no flags (normal workflow)\n"); + printf("-> Validated: Async dequeues have SCX_DEQ_SCHED_CHANGE flag (interruptions)\n"); + printf("-> Validated: No duplicate enqueues or invalid state transitions\n"); + + return SCX_TEST_PASS; +} + +static void cleanup(void *ctx) +{ + struct dequeue *skel = ctx; + + dequeue__destroy(skel); +} + +struct scx_test dequeue_test = { + .name = "dequeue", + .description = "Verify that ops.enqueue() is balanced with ops.dequeue()", + .setup = setup, + .run = run, + .cleanup = cleanup, +}; + +REGISTER_SCX_TEST(&dequeue_test) -- 2.52.0
{ "author": "Andrea Righi <arighi@nvidia.com>", "date": "Mon, 26 Jan 2026 09:41:50 +0100", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
On Mon Jan 26, 2026 at 3:41 AM EST, Andrea Righi wrote: Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Looks great overall. Following up on our off-list chat about whether SCX_TASK_DISPATCH_DEQUEUED is necessary: We need it for the new DEQ_STATE change flag so no need to consider removing it imo.
{ "author": "\"Emil Tsalapatis\" <emil@etsalapatis.com>", "date": "Tue, 27 Jan 2026 11:38:45 -0500", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Hi Andrea, On Mon Jan 26, 2026 at 8:41 AM UTC, Andrea Righi wrote: Not sure I follow this paragraph, specifically the first sentence (starting with ``ops.dequeue()`` is called ...). It seems to imply that a task that has already been dispatched to a DSQ still counts as enqueued, but the preceding text contradicts that by saying that a task is in an "enqueued state" from the time ops.enqueue() is called until (among other things) it's successfully dispatched to a DSQ. This would make sense if this paragraph used "enqueued" in the SCX_TASK_QUEUED sense, while the first paragraph used the SCX_OPSS_QUEUED sense, but if that's the case, it's quite confusing and should be clarified IMO. What counts as a duplicate dequeue call? Looking at the code, we can clearly have ops.dequeue(SCHED_CHANGE) called after ops.dequeue(0) without an intervening call to ops.enqueue(). Should we add a warning here? If I understand the logic correctly, ops.dequeue(SCHED_CHANGE) will be called for a task at most once between it being dispatched and taken off the CPU, even if its properties are changed multiple times while it's on CPU. Is that intentional? I don't see it documented. To illustrate, assume we have a task p that has been enqueued, dispatched, and is currently running on the CPU, so we have both SCX_TASK_OPS_ENQUEUE and SCX_TASK_DISPATCH_DEQUEUED set in p->scx.flags. When a property of p is changed while it runs on the CPU, the sequence of calls is: dequeue_task_scx(p, DEQUEUE_SAVE) => put_prev_task_scx(p) => (change property) => enqueue_task_scx(p, ENQUEUE_RESTORE) => set_next_task_scx(p). dequeue_task_scx(p, DEQUEUE_SAVE) calls ops_dequeue() which calls ops.dequeue(p, ... | SCHED_CHANGE) and clears SCX_TASK_{OPS_ENQUEUED,DISPATCH_DEQUEUED} from p->scx.flags. put_prev_task_scx(p) doesn't do much because SCX_TASK_QUEUED was cleared by dequeue_task_scx(). enqueue_task_scx(p, ENQUEUE_RESTORE) sets sticky_cpu because the task is currently running and ENQUEUE_RESTORE is set. This causes do_enqueue_task() to jump straight to local_norefill, skipping the call to ops.enqueue(), leaving SCX_TASK_OPS_ENQUEUED unset, and then enqueueing the task on the local DSQ. set_next_task_scx(p) calls ops_dequeue(p, SCX_DEQ_CORE_SCHED_EXEC) even though this is not a core-sched pick, but it won't do much because the ops_state is SCX_OPSS_NONE and SCX_TASK_OPS_ENQUEUED is unset. It also calls dispatch_dequeue(p) which the removes the task from the local DSQ it was just inserted into. So, we end up in a state where any subsequent property change while the task is still on CPU will not result in ops.dequeue(p, ... | SCHED_CHANGE) being called, because both SCX_TASK_OPS_ENQUEUED and SCX_TASK_DISPATCH_DEQUEUED are unset in p->scx.flags. I really hope I didn't mess anything up when tracing the code, but of course I'm happy to be corrected. Thanks, Kuba
{ "author": "Kuba Piecuch <jpiecuch@google.com>", "date": "Tue, 27 Jan 2026 16:41:43 +0000", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
On Mon Jan 26, 2026 at 3:41 AM EST, Andrea Righi wrote: Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
{ "author": "\"Emil Tsalapatis\" <emil@etsalapatis.com>", "date": "Tue, 27 Jan 2026 11:53:57 -0500", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Hello, On Mon, Jan 26, 2026 at 09:41:49AM +0100, Andrea Righi wrote: 1. When to call ops.dequeue()? I'm not sure whether deciding whether to call ops.dequeue() solely onwhether ops.enqueue() was called. Direct dispatch has been expanded to include other DSQs but was originally added as a way to shortcut the dispatch path and "dispatch directly" for execution from ops.select_cpu/enqueue() paths. ie. When a task is dispatched directly to a local DSQ, the BPF scheduler is done with that task - the task is now in the same state with tasks that get dispatched to a local DSQ from ops.dispatch(). ie. What effectively decides whether a task left the BPF scheduler is whether the task reached a local DSQ or not, and direct dispatching into a local DSQ shouldn't trigger ops.dequeue() - the task never really "queues" on the BPF scheduler. This creates another discrepancy - From ops.enqueue(), direct dispatching into a non-local DSQ clearly makes the task enter the BPF scheduler and thus its departure should trigger ops.dequeue(). What about a task which is direct dispatched to a non-local DSQ from ops.select_cpu()? Superficially, the right thing to do seems to skip ops.dequeue(). After all, the task has never been ops.enqueue()'d. However, I think this is another case where what's obvious doesn't agree with what's happening underneath. ops.select_cpu() cannot actually queue anything. It's too early. Direct dispatch from ops.select_cpu() is a shortcut to schedule direct dispatch once the enqueue path is invoked so that the BPF scheudler can avoid invocation of ops.enqueue() when the decision has already been made. While this shortcut was added for convenience (so that e.g. the BPF scheduler doesn't have to pass a note from ops.select_cpu() to ops.enqueue()), it has real performance implications as it does save a roundtrip through ops.enqueue() and we know that such overheads do matter for some use cases (e.g. maximizing FPS on certain games). So, while more subtle on the surface, I think the right thing to do is basing the decision to call ops.dequeue() on the task's actual state - ops.dequeue() should be called if the task is "on" the BPF scheduler - ie. if the task ran ops.select_cpu/enqueue() paths and ended up in a non-local DSQ or on the BPF side. The subtlety would need clear documentation and we probably want to allow ops.dequeue() to distinguish different cases. If you boil it down to the actual task state, I don't think it's that subtle - if a task is in the custody of the BPF scheduler, ops.dequeue() will be called. Otherwise, not. Note that, this way, whether ops.dequeue() needs to be called agrees with whether the task needs to be dispatched to run. 2. Why keep %SCX_TASK_OPS_ENQUEUED for %SCX_DEQ_SCHED_CHANGE? Wouldn't that lead to calling ops.dequeue() more than once for the same enqueue event? If the BPF scheduler is told that the task has left it already, why does it matter whether the task gets dequeued for sched change afterwards? e.g. from the BPF sched's POV, it shouldn't matter whether the task is still on the local DSQ or already running, in which case the sched class's dequeue() wouldn't be called in the first place, no? Thanks. -- tejun
{ "author": "Tejun Heo <tj@kernel.org>", "date": "Wed, 28 Jan 2026 11:21:09 -1000", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Hi Kuba, On Tue, Jan 27, 2026 at 04:41:43PM +0000, Kuba Piecuch wrote: ... Good point, the confusion is on my side, the documentation overloads the term "enqueued" and doesn't clearly distinguish the different contexts. In that paragraph, "enqueued" refers to the ops lifecycle (i.e., a task for which ops.enqueue() has been called and whose scheduler-visible state is being tracked), not to the task being queued on a DSQ or having SCX_TASK_QUEUED set. The intent is to treat ops.enqueue() and ops.dequeue() as the boundaries of a scheduler-visible lifecycle, regardless of whether the task is eventually queued on a DSQ or dispatched directly. And as noted by Tejun in his last email, skipping ops.dequeue() for direct dispatches also makes sense, since in that case no new ops lifecycle is established (direct dispatch in ops.select_cpu() or ops.enqueue() can be seen as a shortcut to bypass the scheduler). I'll update the patch and documentation accordingly to make this distinction more explicit. Yeah SCHED_CHANGE dequeues are the exception, and it's acceptable to have ops.dequeue(0) + ops.dequeue(SCHED_CHANGE). The idea is to catch potential duplicate dispatch dequeues. I'll clarify this. Good idea, I'll add a WARN_ON_ONCE(). Correct. And the enqueue/dequeue balancing is preserved here. In the scenario you describe, subsequent property changes while the task remains running go through ENQUEUE_RESTORE, which intentionally skips ops.enqueue(). Since no new enqueue cycle is started, there is no corresponding ops.dequeue() to deliver either. In other words, SCX_DEQ_SCHED_CHANGE is associated with invalidating the scheduler state established by the last ops.enqueue(), not with every individual property change. Multiple property changes while the task stays on CPU are coalesced and the enqueue/dequeue pairing remains balanced. I agree this distinction isn't obvious from the current documentation, I'll clarify that SCX_DEQ_SCHED_CHANGE is edge-triggered per enqueue/run cycle, not per property change. Do you see any practical use case where it'd be beneficial to tie individual ops.dequeue() calls to every property change, as opposed to the current coalesced behavior?? Thanks, -Andrea
{ "author": "Andrea Righi <arighi@nvidia.com>", "date": "Fri, 30 Jan 2026 08:34:30 +0100", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Hi Tejun, On Wed Jan 28, 2026 at 9:21 PM UTC, Tejun Heo wrote: ... Is "local" short for "local or global", i.e. not user-created? Direct dispatching into the global DSQ also shouldn't trigger ops.dequeue(), since dispatch isn't necessary for the task to run. This follows from the last paragraph: Note that, this way, whether ops.dequeue() needs to be called agrees with whether the task needs to be dispatched to run. I agree with your points, just wanted to clarify this one thing. Here's my attempt at documenting this behavior: After ops.enqueue() is called on a task, the task is owned by the BPF scheduler, provided the task wasn't direct-dispatched to a local/global DSQ. When a task is owned by the BPF scheduler, the scheduler needs to dispatch the task to a local/global DSQ in order for it to run. When the BPF scheduler loses ownership of the task, either due to dispatching it to a local/global DSQ or due to external events (core-sched pick, CPU migration, scheduling property changes), the BPF scheduler is notified through ops.dequeue() with appropriate flags (TBD). Thanks, Kuba
{ "author": "Kuba Piecuch <jpiecuch@google.com>", "date": "Fri, 30 Jan 2026 11:54:00 +0000", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Hi Andrea, On Fri Jan 30, 2026 at 7:34 AM UTC, Andrea Righi wrote: ... Right, skipping ops.dequeue() for direct dispatches makes sense, provided the task is being dispatched to a local/global DSQ. Or at least that's my takeaway after reading Tejun's email. ... Ok, I think I understand the logic behind this, here's how I understand it: The BPF scheduler is naturally going to have some internal per-task state. That state may be expensive to compute from scratch, so we don't want to completely discard it when the BPF scheduler loses ownership of the task. ops.dequeue(SCHED_CHANGE) serves as a notification to the BPF scheduler: "Hey, some scheduling properties of the task are about to change, so you probably should invalidate whatever state you have for that task which depends on these properties." That way, the BPF scheduler will know to recompute the invalidated state on the next ops.enqueue(). If there was no call to ops.dequeue(SCHED_CHANGE), the BPF scheduler knows that none of the task's fundamental scheduling properties (priority, cpu, cpumask, etc.) changed, so it can potentially skip recomputing the state. Of course, the potential for savings depends on the particular scheduler's policy. This also explains why we only get one call to ops.dequeue(SCHED_CHANGE) while a task is running: for subsequent calls, the BPF scheduler had already been notified to invalidate its state, so there's no use in notifying it again. However, I feel like there's a hidden assumption here that the BPF scheduler doesn't recompute its state for the task before the next ops.enqueue(). What if the scheduler wanted to immediately react to the priority of a task being decreased by preempting it? You might say "hook into ops.set_weight()", but then doesn't that obviate the need for ops.dequeue(SCHED_CHANGE)? I guess it could be argued that ops.dequeue(SCHED_CHANGE) covers property changes that happen under ``scoped_guard (sched_change, ...)`` which don't have a dedicated ops callback, but I wasn't able to find any such properties which would be relevant to SCX. Another thought on the design: currently, the exact meaning of ops.dequeue(SCHED_CHANGE) depends on whether the task is owned by the BPF scheduler: * When it's owned, it combines two notifications: BPF scheduler losing ownership AND that it should invalidate task state. * When it's not owned, it only serves as an "invalidate" notification, the ownership status doesn't change. Wouldn't it be more elegant to have another callback, say ops.property_change(), which would only serve as the "invalidate" notification, and leave ops.dequeue() only for tracking ownership? That would mean calling ops.dequeue() followed by ops.property_change() when changing properties of a task owned by the BPF scheduler, as opposed to a single call to ops.dequeue(SCHED_CHANGE). But honestly, when I put it like this, it gets harder to justify having this callback over just using ops.set_weight() etc. I don't know how practical it is, but in my comment above I mention a BPF scheduler wanting to immediately preempt a running task on priority decrease, but in that case we need to hook into ops.set_weight() anyway to find out whether the priority was decreased. Thanks, Kuba
{ "author": "Kuba Piecuch <jpiecuch@google.com>", "date": "Fri, 30 Jan 2026 13:14:23 +0000", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Hi Kuba, On Fri, Jan 30, 2026 at 01:14:23PM +0000, Kuba Piecuch wrote: ... Correct. And it's also a way to notify that the task has left the BPF scheduler, so if the task is stored in any internal queue it can/should be removed. Actually I think the proper behavior would be to trigger ops.dequeue(SCHED_CHANGE) only when the task is "owned" by the BPF scheduler. While running, tasks are outside the BPF scheduler ownership, so ops.dequeue() shouldn't be triggered at all. And that should be the proper behavior. BPF scheduler should recompute a task state only when the task is re-enqueued after a property change. If a scheduler wants to implement preemption on property change, it can do so in ops.enqueue(): after a property change, the task is re-enqueued, triggering ops.enqueue(), at which point the BPF scheduler can decide whether and how to preempt currently running tasks. If a property change does not result in an ops.enqueue() call, it means the task is not runnable yet (or does not intend to run), so attempting to trigger a preemption at that point would be pointless. When it's not owned I think ops.dequeue() shouldn't be triggered at all. We could provide an ops.property_change(), but honestly I don't see any practical usage of this callback. Thanks, -Andrea
{ "author": "Andrea Righi <arighi@nvidia.com>", "date": "Sat, 31 Jan 2026 07:54:13 +0100", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
On Fri, Jan 30, 2026 at 11:54:00AM +0000, Kuba Piecuch wrote: I think this should be interpreted as local DSQs only (SCX_DSQ_LOCAL / SCX_DSQ_LOCAL_ON), not any built-in DSQ. SCX_DSQ_GLOBAL is essentially a built-in user DSQ, provided for convenience, it's not really a "direct dispatch" DSQ. This looks good overall, except for the global DSQ part. Also, it might be better to avoid the term “owned”, internally the kernel already uses the concept of "task ownership" with a different meaning (see https://lore.kernel.org/all/aVHAZNbIJLLBHEXY@slm.duckdns.org), and reusing it here could be misleading. With that in mind, I'd probably rephrase your documentation along these lines: After ops.enqueue() is called, the task is considered *enqueued* by the BPF scheduler, unless it is directly dispatched to a local DSQ (via SCX_DSQ_LOCAL or SCX_DSQ_LOCAL_ON). While a task is enqueued, the BPF scheduler must explicitly dispatch it to a DSQ in order for it to run. When a task leaves the enqueued state (either because it is dispatched to a non-local DSQ, or due to external events such as a core-sched pick, CPU migration, or scheduling property changes), ops.dequeue() is invoked to notify the BPF scheduler, with flags indicating the reason for the dequeue: regular dispatch dequeues have no flags set, whereas dequeues triggered by scheduling property changes are reported with SCX_DEQ_SCHED_CHANGE. What do you think? Thanks, -Andrea
{ "author": "Andrea Righi <arighi@nvidia.com>", "date": "Sat, 31 Jan 2026 10:02:19 +0100", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Hi Andrea, On Sat Jan 31, 2026 at 6:54 AM UTC, Andrea Righi wrote: Right, unless the task has already been dispatched, in which case it's just an invalidation notification. I don't think this is what the current implementation does, right? That would make sense if ops.enqueue() was called immediately after a property change when a task is running, but I believe that's currently not the case, see my attempt at tracing the enqueue-dequeue cycle on property change in my first reply. IIUC a dequeue-enqueue cycle on a running task during property change doesn't result in a call to ops.enqueue(), so if the BPF scheduler recomputed its state only in ops.enqueue(), then it wouldn't be able to react immediately. Neither do I, I just made it up for the sake of argument :-) Thanks, Kuba
{ "author": "Kuba Piecuch <jpiecuch@google.com>", "date": "Sat, 31 Jan 2026 16:45:59 +0000", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Hi Kuba, On Sat, Jan 31, 2026 at 04:45:59PM +0000, Kuba Piecuch wrote: ... Right, but if the task has already been dispatched I don't think we should trigger ops.dequeue(SCHED_CHANGE), because it's not anymore under the BPF scheduler's custody (not the way it's implemented right now, I'm just trying to define the proper semantics based on the latest disussions). Right, sorry, I wasn't clear. I'm just trying to define the behavior that makes more sense (see below). Yeah, that's right. I have a new patch set where I've implemented the following semantics (that should match also Tejun's requirements). With the new semantics: - for running tasks: property changes do NOT trigger ops.dequeue(SCHED_CHANGE) - once a task leaves BPF custody (dispatched to local DSQ), the BPF scheduler no longer manages it - property changes on running tasks don't affect the BPF scheduler Key principle: ops.dequeue() is only called when a task leaves BPF scheduler's custody. A running task has already left BPF custody, so property changes don't trigger ops.dequeue(). Therefore, `ops.dequeue(SCHED_CHANGE)` gets called only when: - task is in BPF data structures (QUEUED state), or - task is on a non-local DSQ (still in BPF custody) In this case (BPF scheduler custody), if a property change happens, ops.dequeue(SCHED_CHANGE) is called to notify the BPF scheduler. Then if you want to react immediately on priority changes for running tasks we have: - ops.set_cpumask(): CPU affinity changes - ops.set_weight(): priority/nice changes - ops.cgroup_*(): cgroup changes In conclusion, we don't need ops.dequeue(SCHED_CHANGE) for running tasks, the dedicated callbacks (ops.set_cpumask(), ops.set_weight(), ...) already provide comprehensive coverage for property changes on all tasks, regardless of whether they're running or in BPF custody. And the new ops.dequeue(SCHED_CHANGE) semantics only notifies for property changes when tasks are actively managed by the BPF scheduler (in QUEUED state or on non-local DSQs). Do you think it's reasonable enough / do you see any flaws? Thanks, -Andrea
{ "author": "Andrea Righi <arighi@nvidia.com>", "date": "Sat, 31 Jan 2026 18:24:06 +0100", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
On Sat Jan 31, 2026 at 9:02 AM UTC, Andrea Righi wrote: SCX_DSQ_GLOBAL is significantly different from user DSQs, because balance_one() can pull tasks directly from SCX_DSQ_GLOBAL, while it cannot pull tasks from user-created DSQs. If a BPF scheduler puts a task onto SCX_DSQ_GLOBAL, then it _must_ be ok with balance_one() coming along and pulling that task without the BPF scheduler's intervention, so in that way I believe SCX_DSQ_GLOBAL is semantically quite similar to local DSQs. Shouldn't it be "dispatched to a local DSQ"? Core-sched dequeues also have a dedicated flag, it should probably be included here. I think using the term "enqueued" isn't very good either since it results in two ways in which a task can be considered enqueued: 1. Between ops.enqueue() and ops.dequeue() 2. Between enqueue_task_scx() and dequeue_task_scx() The two are not equivalent, since a task that's running is not enqueued according to 1. but is enqueued according to 2. I would be ok with it if we change it to something unambiguous, e.g. "BPF-enqueued", although that poses a risk of people getting lazy and using "enqueued" anyway. Some potential alternative terms: "resident"/"BPF-resident", "managed"/"BPF-managed", "dispatchable", "pending dispatch", or simply "pending". Thanks, Kuba
{ "author": "Kuba Piecuch <jpiecuch@google.com>", "date": "Sat, 31 Jan 2026 17:53:27 +0000", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
On Sat, Jan 31, 2026 at 05:53:27PM +0000, Kuba Piecuch wrote: I agree that SCX_DSQ_GLOBAL behaves differently from user-created DSQs at the implementation level, but I think that difference shouldn't leak into the logical model. not mean that the task leaves the "enqueued by BPF" state. The task is still under the BPF scheduler's custody, not directly dispatched to a specific CPU, and remains sched_ext-managed. The scheduler has queued the task and it hasn't relinquished control over it. That said, I don't have a strong opinion here. If we prefer to treat SCX_DSQ_GLOBAL as a "direct dispatch" DSQ for the purposes of ops.dequeue() semantics, then I'm fine with adjusting the logic accordingly (with proper documentation). Tejun, thoughts? Oh yes, sorry, it should be "dispatched to a local DSQ, ...". Right, core-sched dequeues should be mentioned as well. I agree that enqueued is a very ambiguous term and we probably need something more BPF-specific. How about a task "under BPF custody"? Thanks, -Andrea
{ "author": "Andrea Righi <arighi@nvidia.com>", "date": "Sat, 31 Jan 2026 21:26:56 +0100", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Hello, Sorry about tardiness. On Fri, Jan 30, 2026 at 11:54:00AM +0000, Kuba Piecuch wrote: Yes, maybe it'd be useful to come up with a terminology for them. e.g. terminal - once a task reaches a terminal DSQ, the only way that the BPF scheduler can affect the task is by triggering re-enqueue (although we don't yet support reenqueueing global DSQs). Thanks. -- tejun
{ "author": "Tejun Heo <tj@kernel.org>", "date": "Sun, 1 Feb 2026 07:43:33 -1000", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }
lkml
[PATCHSET v3 sched_ext/for-6.20] sched_ext: Fix ops.dequeue() semantics
The callback ops.dequeue() is provided to let BPF schedulers observe when a task leaves the scheduler, either because it is dispatched or due to a task property change. However, this callback is currently unreliable and not invoked systematically, which can result in missed ops.dequeue() events. In particular, once a task is removed from the scheduler (whether for dispatch or due to a property change) the BPF scheduler loses visibility of the task and the sched_ext core may not always trigger ops.dequeue(). This breaks accurate accounting (i.e., per-DSQ queued runtime sums) and prevents reliable tracking of task lifecycle transitions. This patch set fixes the semantics of ops.dequeue(), ensuring that every ops.enqueue() is balanced by a corresponding ops.dequeue() invocation. In addition, ops.dequeue() is now properly invoked when tasks are removed from the sched_ext class, such as on task property changes. To distinguish between a "regular" dequeue and a property change dequeue a new dequeue flag is introduced: %SCX_DEQ_SCHED_CHANGE. BPF schedulers can use this flag to distinguish between regular dispatch dequeues (%SCX_DEQ_SCHED_CHANGE unset) and property change dequeues (%SCX_DEQ_SCHED_CHANGE set). Together, these changes allow BPF schedulers to reliably track task ownership and maintain accurate accounting. Changes in v3: - Rename SCX_DEQ_ASYNC to SCX_DEQ_SCHED_CHANGE - Handle core-sched dequeues (Kuba) - Link to v2: https://lore.kernel.org/all/20260121123118.964704-1-arighi@nvidia.com/ Changes in v2: - Distinguish between "dispatch" dequeues and "property change" dequeues (flag SCX_DEQ_ASYNC) - Link to v1: https://lore.kernel.org/all/20251219224450.2537941-1-arighi@nvidia.com Andrea Righi (2): sched_ext: Fix ops.dequeue() semantics selftests/sched_ext: Add test to validate ops.dequeue() semantics Documentation/scheduler/sched-ext.rst | 33 ++++ include/linux/sched/ext.h | 11 ++ kernel/sched/ext.c | 89 +++++++++- kernel/sched/ext_internal.h | 7 + tools/sched_ext/include/scx/enum_defs.autogen.h | 2 + tools/sched_ext/include/scx/enums.autogen.bpf.h | 2 + tools/sched_ext/include/scx/enums.autogen.h | 1 + tools/testing/selftests/sched_ext/Makefile | 1 + tools/testing/selftests/sched_ext/dequeue.bpf.c | 209 ++++++++++++++++++++++++ tools/testing/selftests/sched_ext/dequeue.c | 182 +++++++++++++++++++++ 10 files changed, 534 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
Hello, On Sat, Jan 31, 2026 at 09:26:56PM +0100, Andrea Righi wrote: I think putting a task into GLOBAL means that the BPF scheduler is done with it. Another data point in this direction is that when insertion into a local DSQ can't be done, the task falls back to the global DSQ although all the current ones also trigger error. Thanks. -- tejun
{ "author": "Tejun Heo <tj@kernel.org>", "date": "Mon, 2 Feb 2026 05:19:51 -1000", "thread_id": "20260126084258.3798129-1-arighi@nvidia.com.mbox.gz" }