Skip to content

[26.04_linux-nvidia-bos] MPAM update - #543

Open
ltrager wants to merge 82 commits into
NVIDIA:26.04_linux-nvidia-bosfrom
ltrager:7.0-mpam-update
Open

[26.04_linux-nvidia-bos] MPAM update#543
ltrager wants to merge 82 commits into
NVIDIA:26.04_linux-nvidia-bosfrom
ltrager:7.0-mpam-update

Conversation

@ltrager

@ltrager ltrager commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Overview

When backporting MPAM to the linux-nvidia-6.18 kernel I took the latest MPAM/resctrl patch series from LORE and Linus's tree. This left linux-nvidia-6.18-next with newer MPAM/resctrl support than 26.04_linux-nvidia-bos. This PR updates 26.04_linux-nvidia-bos MPAM/resctrl support to mirror what is in linux-nvidia-6.18-next, while retaining the required BOS-specific integration changes.

I have not yet created a bug on launchpad yet as I'd like to get feedback as to whether we want to proceed or not.

Updated Patch Series

Series Changes
arm_mpam: Add MPAM-Fb firmware support v9 Updates the MPAM-Fb support to the complete 12-patch v9 series. Nine patches match LORE directly. Three were adapted to preserve BOS MAX/HARDLIM probing, MBW_PBM/CMAX/CMIN programming, and downstream programming-error handling in the threaded IRQ conversion.
arm_mpam: resctrl: Counter Assignment (ABMC) v5 Replaces the older Arm ABMC implementation with the five-patch v5 series and refreshes the associated ABMC/CDP KUnit coverage. The obsolete free-running-monitor and RMID-hook implementations are absorbed by the v5 design.

New Patch Series

New patch series applied to resolve conflicts with updated series

Subject Source
x86,fs/resctrl: Pave the way for MPAM counter assignment v7 Adds all seven generic resctrl prerequisites using their final commits from Linus’s tree.
fs/resctrl: IOMMU group fixes for tasks interface and cleanup v2 Adds all three v2 fixes for PID parsing, helper cleanup, and IOMMU-group migration when resctrl groups are removed.
KVM: arm64: Force guest EL1 to use user-space's partid configuration 67faed4ccb4f
arm_mpam: Update architecture version check for MPAM MSC 50a42e03cdbd
arm_mpam: Fix MPAMCFG_MBW_PBM register setting 021118ce5ea9

Patches now sourced from Linus's tree

  • 7625632fed43 — fs/resctrl: Tidy up the error path in resctrl_mkdir_event_configs()
  • 94a1206522d1 — x86,fs/resctrl: Create 'event_filter' files read only if they're not configurable
  • f52abe650241 — fs/resctrl: Disallow the software controller when MBM counters are assignable
  • ee3d4c81d89c — fs/resctrl: Add monitor property 'mbm_cntr_assign_fixed'
  • 3aec86e4ea01 — fs/resctrl: Continue counter allocation after failure
  • 9a1646211f8c — fs/resctrl: Document that automatic counter assignment is best effort
  • 1cfa74c683ea — fs/resctrl: Document tasks file behaviour for task id 0 and idle tasks

Reverted and Reapplied Patches

The older versions were reverted before replaying their replacements in dependency order. This avoids layering the newer series over overlapping BOS SAUCE implementations and makes the required conflict resolutions explicit.

Reverted functionality Reverted commit Reapplied commit
Apply T241-MPAM-6 to 63-bit counters 0f0f62d1cd92 62b5c4d7ec21
Fix mbm_L3_assign and mon_local_bytes 9d97d90c12bc 9343a4d7c69a
Add MBA max_lim sysfs support eb2a397ffd99 0375f48339eb
Probe MBW MAX_LIM and hardlim_rw 3f89f038d12e 497927a4144f
Reset RIS using the explicit default configuration 39c973a9670a 2c2b0824b283
Include associated MSC components during domain setup 3ce46c56e790 40878d018a1f
Avoid MSC teardown for software programming errors 7abd6df46f5e 68f7f93b2b89
Determine whether exposed counters can overflow 280d19355685 a4bdf5756702
Assign IOMMU groups to resctrl groups 69037f273891 37844a5cdb78
Add IOMMU QoS state helpers 9f1da5623808 e87d5188d3bd
Add SMMUv3 MPAM query and set helpers f1c8da0cfad3 98377e75e771
Register SMMU capabilities with MPAM 4bfc66310af1 2647763ba37e
Add the this_is_not_abi mount option 1bf2d6c7b578 57dc56521ca0
Allow an MSC to be forced to have an unknown location 5ddc3a894634 a94bee05d160
Allow the maximum PARTID to be overridden 7a882f69a85b 0694f0e9b3af
Split locking around the mon_sel registers 0d9b271e9466 e5a6b275c27c
Expose NRDY retry counts in debugfs 154491fb0815 17c6383eb1fb
Add the MSC/RIS debugfs hierarchy 56836799ed9a b65066184f81
Avoid the dom_data_exit() and rmid_ptrs[] race 4dee6626ad77 9176563c832a
Add ABMC counter read and reset hooks a639261dd308 bf6dfdc6ce01
Add resctrl_arch_config_cntr() for ABMC 77c4e9f9d629 3dd88e6bf668
Add ABMC/CDP KUnit coverage a199cc64eb18 fe2c2b28b50f
Pre-allocate assignable monitors 2d109004824f 6550788495fe
Pick MPAM classes for use as MBM counters eaff6c2bde68 a466792cdf0f

Testing

Built and ran on a Vera system. Greenlit passes all MPAM tests

nvidia@localhost:/home/nvidia/ltrager/greenlit$ sudo glt-test-suite --test-case arm64:test_mpam_resctrl_mount --test-case arm64:test_mpam_resctrl_schemata --test-case arm64:test_mpam_l3_occupancy --test-case arm64:test_mpam_mba_schemata --test-case arm64:test_mpam_resctrl_info
2026-08-11 19:09:32 - [INFO] glt-test-suite: ===== System Information =====
2026-08-11 19:09:32 - [INFO] glt-test-suite: Distribution: Ubuntu
2026-08-11 19:09:32 - [INFO] glt-test-suite: Release: 24.04
2026-08-11 19:09:32 - [INFO] glt-test-suite: Architecture: aarch64
2026-08-11 19:09:32 - [INFO] glt-test-suite: Kernel: 7.0.0-2017-nvidia-bos
2026-08-11 19:09:32 - [INFO] glt-test-suite: DMI:
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/bios_date:Sat May 30 10:47:02 AM UTC 2026
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/bios_vendor:NVIDIA
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/bios_version:NV_SBIOS: 06.01.00.00, OEM_SBIOS: 06.01.00.00
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/board_name:P3809-BMC
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/board_serial:1331026110247
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/board_vendor:NVIDIA
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/board_version:C01
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/chassis_serial:1942026270153
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/chassis_type:28
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/chassis_vendor:NVIDIA
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/chassis_version:A.0
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/ec_firmware_release:26.5
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/modalias:dmi:bvnNVIDIA:bvrNV_SBIOS06.01.00.00,OEM_SBIOS06.01.00.00:bdSatMay30104702AMUTC2026:efr26.5:svnNVIDIA:pnVRNVL72:pvrA.0:rvnNVIDIA:rnP3809-BMC:rvrC01:cvnNVIDIA:ct28:cvrA.0:sku965-XXXXX-XXXX-XXX:pfaMGX:
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/product_family:MGX
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/product_name:VR NVL72
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/product_serial:183XXXXXXXXXX
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/product_sku:965-XXXXX-XXXX-XXX
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/product_uuid:9385286f-53fa-9e88-475f-1a02676a0073
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/product_version:A.0
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/sys_vendor:NVIDIA
2026-08-11 19:09:32 - [INFO] glt-test-suite: /sys/class/dmi/id/uevent:MODALIAS=dmi:bvnNVIDIA:bvrNV_SBIOS06.01.00.00,OEM_SBIOS06.01.00.00:bdSatMay30104702AMUTC2026:efr26.5:svnNVIDIA:pnVRNVL72:pvrA.0:rvnNVIDIA:rnP3809-BMC:rvrC01:cvnNVIDIA:ct28:cvrA.0:sku965-XXXXX-XXXX-XXX:pfaMGX:
2026-08-11 19:09:32 - [INFO] glt-test-suite: ============================
2026-08-11 19:09:32 - [WARNING] glt-test-suite: Matching kernel perf binary is missing: /usr/lib/linux-tools/7.0.0-2017-nvidia-bos/perf; installed perf may not include events for the running kernel.
2026-08-11 19:09:32 - [WARNING] glt-test-suite: Linux source code is not in /usr/local/share/greenlit/linux.
2026-08-11 19:09:32 - [INFO] glt-test-suite: == Session /var/cache/greenlit/2026-08-11-19:09:32 started ==
2026-08-11 19:09:32 - [INFO] (arm64) test_mpam_resctrl_mount: resctrl already mounted at /sys/fs/resctrl; mount ability confirmed.
2026-08-11 19:14:02 - [INFO] glt-test-suite:
===========================================================

Summary:
  PASSED            : 5
  FAILED            : 0
  Allowed FAILURE   : 0
  SKIPPED           : 0
  WARNED            : 0

Details:
  [PASSED] arm64:test_mpam_resctrl_mount
  [PASSED] arm64:test_mpam_resctrl_schemata
  [PASSED] arm64:test_mpam_l3_occupancy
  [PASSED] arm64:test_mpam_mba_schemata
  [PASSED] arm64:test_mpam_resctrl_info

===========================================================
2026-08-11 19:14:02 - [INFO] glt-test-suite: == Session /var/cache/greenlit/2026-08-11-19:09:32 completed ==

@ltrager
ltrager requested a review from fyu1 August 12, 2026 01:08
@nirmoy nirmoy added the help wanted Extra attention is needed label Aug 12, 2026
@nirmoy

nirmoy commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Boro watcher review skipped

The PR watcher skips automatic boro reviews for changes with more than 50 commits. This change currently has 82 commits.

To run the review anyway, ask BaseOS_Kernel_Bot in #baseos-kernel:

review https://github.com/NVIDIA/NV-Kernels/pull/543

Head: 01cb4e9840ad

This comment is maintained by BaseOS Reviewer. It is updated when the watcher sees a newer head.

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

PR Validation Report

Patchscan ✅ No Missing Fixes

All cherry-picked commits checked — no missing upstream fixes found.

PR Lint ❌ Errors found

Details
Checking 82 commits...

Cherry-pick digest:
┌──────────────┬──────────────────────────────────────────────────────────────────┬────────────┬─────────┬───────────────────────────┐
│ Local        │ Referenced upstream / Patch subject                              │ Patch-ID   │ Subject │ SoB chain                 │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 01cb4e9840ad │ [SAUCE] arm_mpam: fix pcc channel lifetime during msc removal    │ N/A        │ N/A     │ ltrager, ltrager          │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 4ca08edbe965 │ [SAUCE] arm_mpam: scale saved mbwu state for t241-mpam-6         │ N/A        │ N/A     │ ltrager, ltrager          │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 1e863fe085e8 │ [SAUCE] arm_mpam: apply t241-mpam-6 to 63-bit counters           │ N/A        │ N/A     │ sdonthin, horgan, ltrager │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 13ddf9f68db5 │ [SAUCE] arm_mpam: skip nrdy values when saving mbwu state        │ N/A        │ N/A     │ ltrager, ltrager          │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 7f092997da82 │ [SAUCE] fs/resctrl: fix iommu_group reference leaks when iterati │ N/A        │ N/A     │ ltrager, ltrager          │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ b6544b75037b │ [SAUCE] arm_mpam: initialize mbwu_state values to 0              │ N/A        │ N/A     │ ltrager, ltrager          │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ a1100cba38da │ [SAUCE] fs/resctrl: fix redefinition of iommu helpers with confi │ N/A        │ N/A     │ ltrager, ltrager          │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ e8f43c4fa58d │ [SAUCE] fs/resctrl: migrate iommu groups when removing resource  │ N/A        │ N/A     │ zengheng, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 805f2bb20ea4 │ [SAUCE] fs/resctrl: remove unused 'of' parameter from rdtgroup_m │ N/A        │ N/A     │ zengheng, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ f7fb8b950d29 │ [SAUCE] fs/resctrl: fix incorrect pid parsing after iommu group  │ N/A        │ N/A     │ zengheng, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 219aef73af34 │ [SAUCE] arm_mpam: fix monitor capability and mbm assign for mb e │ N/A        │ N/A     │ fenghuay, bfigg, ltrager, │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 96a12bd7ee78 │ [SAUCE] fix mbm_l3_assign and mon_local_bytes                    │ N/A        │ N/A     │ fenghuay, bfigg, ltrager, │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 1e4bb0bdcf46 │ [SAUCE] arm_mpam: include all msc components during domain setup │ N/A        │ N/A     │ sdonthin, fenghuay, ltrag │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ d26b8f6979cc │ [SAUCE] resctrl: add mba max_lim sysfs and visibility from init  │ N/A        │ N/A     │ fenghuay, ltrager, ltrage │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ ff3f3427452f │ [SAUCE] arm_mpam: resctrl: determine if any exposed counter can  │ N/A        │ N/A     │ morse, ltrager, ltrager   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ ad925b660e44 │ [SAUCE] arm_mpam: expose the number of nrdy retries in debugfs   │ N/A        │ N/A     │ morse, fenghuay, ltrager, │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ a6f922cd6648 │ [SAUCE] arm_mpam: add debugfs entries to show the msc/ris the dr │ N/A        │ N/A     │ morse, fenghuay, ltrager, │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 97c1bf33c2ab │ [SAUCE] fs/resctrl: add support for assigning iommu_groups to re │ N/A        │ N/A     │ morse, ltrager, ltrager   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 8c136a469370 │ [SAUCE] iommu: add helpers to get and set the qos state          │ N/A        │ N/A     │ morse, ltrager, ltrager   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ a3fb2f109b32 │ [SAUCE] iommu/arm-smmu-v3: add mpam helpers to query and set sta │ N/A        │ N/A     │ morse, ltrager, ltrager   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 940fb218c304 │ [SAUCE] iommu/arm-smmu-v3: register smmu capabilities with mpam  │ N/A        │ N/A     │ morse, fenghuay, ltrager, │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ e1f9ee5c822d │ [SAUCE] arm_mpam: allow msc to be forced to have an unknown loca │ N/A        │ N/A     │ morse, fenghuay, ltrager, │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 3199f1b55b01 │ [SAUCE] fs/resctrl: add this_is_not_abi mount option             │ N/A        │ N/A     │ morse, fenghuay, ltrager, │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 314838157efe │ [SAUCE] arm_mpam: allow the maximum partid to be overridden from │ N/A        │ N/A     │ morse, fenghuay, ltrager, │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 56ba3887987a │ [SAUCE] fs/resctrl: avoid a race with dom_data_exit() and rmid_p │ N/A        │ N/A     │ morse, fenghuay, ltrager, │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ a143e2d9f81b │ [SAUCE] arm_mpam: resctrl: add kunit test for abmc/cdp interacti │ N/A        │ N/A     │ morse, fenghuay, ltrager, │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ c53d22622965 │ [SAUCE] arm64: mpam: add memory bandwidth usage (mbwu) documenta │ N/A        │ N/A     │ morse, horgan, ltrager    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ de7e9c859e5a │ [SAUCE] arm_mpam: resctrl: add resctrl_arch_cntr_read() & resctr │ N/A        │ N/A     │ morse, horgan, ltrager    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ d6fe836e0374 │ [SAUCE] arm_mpam: resctrl: add resctrl_arch_config_cntr() for ab │ N/A        │ N/A     │ morse, horgan, ltrager    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 28c18a8ff084 │ [SAUCE] arm_mpam: resctrl: pre-allocate assignable monitors      │ N/A        │ N/A     │ morse, horgan, ltrager    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 7a7587de5b0e │ [SAUCE] arm_mpam: resctrl: pick classes for use as mbm counters  │ N/A        │ N/A     │ morse, horgan, ltrager    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 8ef04b979b93 │ 1cfa74c683ea fs/resctrl: Document tasks file behaviour for task  │ match      │ match   │ preserved + ltrager added │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 55a8f06d19fe │ 9a1646211f8c fs/resctrl: Document that automatic counter assignm │ match      │ match   │ preserved + ltrager added │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ e75f35a41c25 │ 3aec86e4ea01 fs/resctrl: Continue counter allocation after failu │ match      │ match   │ preserved + ltrager added │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 24a628f64aa3 │ ee3d4c81d89c fs/resctrl: Add monitor property 'mbm_cntr_assign_f │ match      │ match   │ preserved + ltrager added │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 558c84e35969 │ f52abe650241 fs/resctrl: Disallow the software controller when M │ match      │ match   │ preserved + ltrager added │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ f5472a0843a3 │ 94a1206522d1 x86,fs/resctrl: Create 'event_filter' files read on │ match      │ match   │ preserved + ltrager added │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ dcc333a714e2 │ 7625632fed43 fs/resctrl: Tidy up the error path in resctrl_mkdir │ match      │ match   │ preserved + ltrager added │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 66e804162c74 │ [SAUCE] arm_mpam: detect and enable mpam-fb pcc support          │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ cfdd5b7c748d │ [SAUCE] arm_mpam: change mpam-fb error irq to use a threaded irq │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ c55d66ef0ef3 │ [SAUCE] arm_mpam: avoid msc teardown for the sw programming erro │ N/A        │ N/A     │ sdonthin, fenghuay, ltrag │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 78cd82f7759f │ [SAUCE] arm_mpam: add mpam-fb msc firmware access support        │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 922cf3f13584 │ [SAUCE] arm_mpam: prepare mon_sel locking for mpam-fb            │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 0931e0dcc8ee │ [SAUCE] arm_mpam: propagate msc access errors for interrupt cont │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ fce72dbc48e9 │ [SAUCE] arm_mpam: propagate msc access errors for mpam_reprogram │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 0e441efd579c │ 021118ce5ea9 arm_mpam: Fix MPAMCFG_MBW_PBM register setting      │ match      │ match   │ preserved + ltrager added │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 6a927ecb038e │ [SAUCE] resctrl/mpam: reset ris by applying explicit default con │ N/A        │ N/A     │ sdonthin, fenghuay, ltrag │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 495047d403d2 │ [SAUCE] arm_mpam: propagate msc access errors for state saving f │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 09786fe0c199 │ [SAUCE] arm_mpam: propagate msc access errors for __ris_msmon_re │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ e5b9448f8c1e │ [SAUCE] arm_mpam: propagate msc access errors for msmon helpers  │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 7443bf8fa1e1 │ [SAUCE] arm_mpam: propagate msc access errors for mbwu counters  │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 9e0fd0afc87a │ [SAUCE] arm_mpam: propagate msc access errors for hw_probe funct │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 7e1ef6b68445 │ [SAUCE] resctrl/mpam: probe mpamf_mbw_idr max_lim and hardlim_rw │ N/A        │ N/A     │ fenghuay, ltrager, ltrage │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 67708c5ef499 │ [SAUCE] arm_mpam: let low level msc accessors return an error    │ N/A        │ N/A     │ przywara, ltrager         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ d39607f9e9e8 │ 50a42e03cdbd arm_mpam: Update architecture version check for MPA │ match      │ match   │ preserved + ltrager added │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 16f3fd4bbc5e │ 67faed4ccb4f KVM: arm64: Force guest EL1 to use user-space's par │ match      │ match   │ preserved + ltrager added │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 577c60216823 │ [Revert] untested: arm_mpam: resctrl: pick classes for use as mb │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ bc73fff27fc2 │ [Revert] arm_mpam: resctrl: pre-allocate free running monitors   │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ dd82919c2abf │ [Revert] arm_mpam: resctrl: pre-allocate assignable monitors     │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 76ae65b782c6 │ [Revert] arm_mpam: resctrl: add kunit test for abmc/cdp interact │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ e37378a7fa77 │ [Revert] arm_mpam: resctrl: add resctrl_arch_config_cntr() for a │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 14f92c37ce36 │ [Revert] arm_mpam: resctrl: add resctrl_arch_rmid_read() and res │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 35f423170d06 │ [Revert] arm_mpam: resctrl: add resctrl_arch_cntr_read() & resct │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 74f3c2952e23 │ [Revert] fs/resctrl: avoid a race with dom_data_exit() and rmid_ │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 6779cceaed4a │ [Revert] arm_mpam: add debugfs entries to show the msc/ris the d │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 51c6838fbeaf │ [Revert] arm_mpam: expose the number of nrdy retries in debugfs  │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ b920998e255f │ [Revert] arm_mpam: split the locking around the mon_sel register │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 7ee46e438545 │ [Revert] arm_mpam: allow the maximum partid to be overridden fro │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ ab1751f282a7 │ [Revert] arm_mpam: allow msc to be forced to have an unknown loc │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 6d100b5dc674 │ [Revert] fs/resctrl: add this_is_not_abi mount option            │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 64fa409cc8ba │ [Revert] iommu/arm-smmu-v3: register smmu capabilities with mpam │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 8fceac6b2d49 │ [Revert] iommu/arm-smmu-v3: add mpam helpers to query and set st │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ c46332d8ff50 │ [Revert] iommu: add helpers to get and set the qos state         │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 34a5067583a0 │ [Revert] fs/resctrl: add support for assigning iommu_groups to r │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 2affafdf2802 │ [Revert] arm_mpam: resctrl: determine if any exposed counter can │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 095e99b9f4cb │ [Revert] arm_mpam: avoid msc teardown for the sw programming err │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ f9e6a1036597 │ [Revert] arm_mpam: include all associated msc components during  │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ eae554acb51a │ [Revert] resctrl/mpam: reset ris by applying explicit default co │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 0525852ee281 │ [Revert] resctrl/mpam: probe mpamf_mbw_idr max_lim and hardlim_r │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ ce370813e735 │ [Revert] resctrl: add mba max_lim sysfs and visibility from init │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ b7c92cefa609 │ [Revert] fix mbm_l3_assign and mon_local_bytes                   │ N/A        │ N/A     │ ltrager                   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 09263f40ac7e │ [Revert] arm_mpam: apply t241-mpam-6 to 63-bit counters          │ N/A        │ N/A     │ ltrager                   │
└──────────────┴──────────────────────────────────────────────────────────────────┴────────────┴─────────┴───────────────────────────┘

Lint results:
W: 558c84e35969 ("fs/resctrl: Disallow the software controller when "): subject 77 chars (>72)
W: f5472a0843a3 ("x86,fs/resctrl: Create 'event_filter' files read o"): subject 81 chars (>72)

PR metadata:
E: PR targets 26.04_linux-nvidia-bos but body has no https://bugs.launchpad.net/... link

@fyu1

fyu1 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

@ltrager, Is it worth to revert a lot of patches which have been tested by various groups to keep pace to upstream?

  1. arm_mpam: Add MPAM-Fb firmware support v9 is not supported on Nvidia platform.
  2. PBM is not supported on Nvidia platform.
  3. control assignment update is mainly cosmetic.
  4. others are mainly cosmetic changes.

@jamieNguyenNVIDIA

Copy link
Copy Markdown
Collaborator

Reviewed all 82 commits with Claude, one deep-dive pass per commit plus a
whole-series integration pass.

Downstream-only — introduced by this PR

1. 57dc56521ca0e drops the mount error-path cleanup.

The reverted 1bf2d6c7b5780 had two disable_abi_playground() calls; the
re-applied version has one. Missing from rdt_get_tree():

	if (ret && ctx->enable_abi_playground)
		disable_abi_playground();

The key is enabled before the first goto out, static_key_enable() is not
refcounted, and only rdt_kill_sb() disables it. So a failed mount -o this_is_not_abi (-EBUSY against an existing mount) latches
resctrl_abi_playground on for the boot, and a mount that never asked for it
starts accepting iommu_group:N in tasks. Nothing later restores the hunk.
Deliberate?

2. 2c2b0824b2838 moves the RIS reset off the width-aware bitmap helper.

The new mpam_init_reset_cfg() sets the feature bit, not just the value:

		mpam_set_feature(mpam_feat_mbw_part, reset_cfg);
		reset_cfg->mbw_pbm = GENMASK(props->mbw_pbm_bits - 1, 0);

so mpam_reprogram_ris_partid() now takes the single-u32 arm instead of
mpam_reset_msc_bitmap(). Previously mpam_reset_ris() passed
struct mpam_config reset_cfg = {} with no feature bits, taking the width-aware
path.

cpbm/mbw_pbm are one u32 each, but cpbm_wd is a 16-bit MPAMF_CPOR_IDR
field and mbw_pbm_bits comes from GENMASK(28, 16); cache_has_usable_cpor()
tests cpbm_wd <= 32 explicitly. Above 32 portions, are the upper words still
reset? At 65+, is GENMASK(wd - 1, 0) an out-of-range shift?

Two side notes on the same commit: the fract16_to_percent/percent_to_fract16
hunks are unrelated to the subject and unmentioned (they drop r->membw.min_bw
to 0, so bw_validate() accepts MB:0=0), and the changelog lists mbw_prop
among the defaulted controls with no mpam_feat_mbw_prop case present.

3. daa0489dc80b5 — the NRDY continue also skips the config capture.

cur_flt/cur_ctl are not invalidated by NRDY but get skipped anyway.
mbwu_state->enabled is written nowhere else and starts false, so after an
NRDY-skipped first save it stays false with MSMON_CFG_MBWU_CTL already written
0 — does mpam_restore_mbwu_state() leave the monitor disabled? The counter is
also read and zeroed before the test, so the sample is discarded rather than
deferred and correction never advances. The base has no NRDY handling in
mpam_save_mbwu_state() at all, so this is all new.

4. 8d82e5debf22brdt_move_group_iommus() aborts on the first error.

It breaks on the first per-group failure and all three callers discard the
return. In rmdir_all_sub() (from == NULL) the iommu_matches_rdtgroup()
filter is bypassed, so a group behind an SMMU without ARM_SMMU_FEAT_MPAM
returns -EIO and every later group keeps the stale PARTID/PMG — the state the
changelog says this removes. rdt_move_group_tasks(), which it says it mirrors,
has no abort path. It also lacks the resctrl_abi_playground gate the other two
iommu entry points carry.

In the MPAM-Fb v9 series — not yet in linux-next

drivers/resctrl/ in linux-next has no mpam_fb.c; this series exists only as
the lore posting, so these could go to Andre before v10 rather than being carried
as downstream deltas.

5. 52d30f1bd138c — nothing selects MAILBOX.

mpam_fb.o is unconditional in mpam-y and calls mbox_send_message(), which
needs CONFIG_MAILBOX and has no stub; the chain is ARM64_MPAM_DRIVER
select ACPI_MPAM if ACPI, a bare bool. arm64 allnoconfig +
CONFIG_ARM64_MPAM=y fails to link. Shipped config is fine (MAILBOX=y) —
select MAILBOX would close it.

6. 4218063d71143 — the PCC channel is freed while the error IRQ is live.

mpam_unregister_irqs() has one caller, mpam_disable().
mpam_msc_drv_remove() calls mpam_msc_destroy() + mpam_free_garbage(), which
runs pcc_mbox_free_channel() and kfree(pcc_chan) while the devm threaded
error IRQ is still registered — devres frees it only after .remove() returns,
and no suppress_bind_attrs blocks sysfs unbind. Can
__mpam_irq_handler()mpam_msc_read_esr() still reach msc->pcc_chan there?

The unbind gap itself is not new — mpam_msc_drv_remove() is byte-identical in
linux-next, so struct mpam_msc has the same exposure upstream. What v9 adds is
a second object freed in that window.

In linux-next — mailing list rather than this PR

Both are reproduced faithfully, so they are not backport defects.

7. a466792cdf0f2counter_update_class() tests the candidate, not the incumbent.

	if (existing_class) {
		if (class->level == 3) {
			pr_debug("Existing class is L3 - L3 wins\n");
			return;

The first test reads class while the debug string and the existing_class->level < class->level test below both mean the incumbent. An L3 candidate against a
level-255 memory incumbent keeps the memory class; reverse the order and L3 wins.
Which class backs mbm_total_bytes therefore follows firmware MPAM table order.
Identical in linux-next (436d111d918ae).

8. 3dd88e6bf6681mbwu_idx_to_mon[] is not keyed by domain.

Indexed by CDP-shifted closid and rmid only, ignoring @d, while resctrl
allocates counter ids per domain and exposes per-domain assignment via
mbm_L3_assignments. Unassigning in one domain reports "Unassigned" in all of
them, and a diverging counter id lets two groups share one hardware monitor.
Also in linux-next

@jamieNguyenNVIDIA

Copy link
Copy Markdown
Collaborator

@ltrager, Is it worth to revert a lot of patches which have been tested by various groups to keep pace to upstream?

  1. arm_mpam: Add MPAM-Fb firmware support v9 is not supported on Nvidia platform.
  2. PBM is not supported on Nvidia platform.
  3. control assignment update is mainly cosmetic.
  4. others are mainly cosmetic changes.

Yes, this does seem a bit risky -- and we're trading SAUCE for a-little-bit-newer SAUCE in many cases.

@ltrager

ltrager commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. The purpose of this PR is to bring the MPAM/resctrl patch stack in 26.04_linux-nvidia-bos into alignment with linux-nvidia-6.18-next. I noticed some discrepancy when I started to update the nvidia-kernel-patches-verification tool for the patches I added to linux-nvidia-6.18-next. I audited the differences between linux-nvidia-6.18-next, 26.04_linux-nvidia-bos, and this PR. Maintaining newer MPAM/resctrl support in the 6.18 reference kernel than in 26.04_linux-nvidia-bos, our preferred kernel, creates an avoidable difference between the two patch stacks.

Some apparently unrelated patches are source prerequisites for a conflict-free replay of the aligned stack:

  • Omitting MPAM-Fb entirely causes b65066184f81 ("arm_mpam: Add debugfs entries to show the MSC/RIS the driver discovered") to conflict because it expects the error-returning MSC accessor API introduced by the MPAM-Fb series. This source dependency exists even if MPAM-Fb is not used at runtime on NVIDIA hardware.
  • The PBM fix is required in the source stack. Omitting it causes the following error-propagation patch to conflict in mpam_reprogram_ris_partid() because that patch expects the corrected PBM branch orientation. It is also already in Linus's tree as 021118ce5ea9 and has the same patch ID as the copy in linux-nvidia-6.18-next. The path remains feature-gated, so this does not enable PBM on hardware that does not advertise it.
  • The counter-assignment update is also more than cosmetic: v5 changes the allocation model to per-MPAM-class counters and depends on the seven generic resctrl prerequisite commits now in Linus's tree. The remaining additions include functional KVM PARTID handling, architecture-version validation, IOMMU-group cleanup, reference-leak fixes, and MBWU state fixes.

I am fine dropping this PR but it will mean the linux-nvidia-6.18 reference kernel and patching guide will differ from 26.04_linux-nvidia-bos.

@nvidia-bfigg
nvidia-bfigg force-pushed the 26.04_linux-nvidia-bos branch from 9ef5052 to ab2723a Compare August 14, 2026 12:11
ltrager added 20 commits August 20, 2026 17:20
This reverts commit 0f0f62d.

This commit is being reverted as part of the process in updating "T241-MPAM-6 fixes"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
This reverts commit 9d97d90.

This commit is being reverted as part of the process in updating "ABMC v5 integration adjustments"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…ity from init"

This reverts commit eb2a397.

This commit is being reverted as part of the process in updating "MPAM MBA MAX/HARDLIM support"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…and hardlim_rw"

This reverts commit 3f89f03.

This commit is being reverted as part of the process in updating "MPAM MBA MAX/HARDLIM support"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…efault config"

This reverts commit 39c973a.

This commit is being reverted as part of the process in updating "MPAM MBA MAX/HARDLIM support"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…s during domain setup"

This reverts commit 3ce46c5.

This commit is being reverted as part of the process in updating "ABMC v5 integration adjustments"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…ogramming errors"

This reverts commit 7abd6df.

This commit is being reverted as part of the process in updating "MPAM-Fb integration adjustments"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…unter can overflow"

This reverts commit 280d193.

This commit is being reverted as part of the process in updating "MPAM monitoring integration refresh"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…u_groups to resctrl groups"

This reverts commit 69037f2.

This commit is being reverted as part of the process in updating "MPAM IOMMU integration refresh"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…state"

This reverts commit 9f1da56.

This commit is being reverted as part of the process in updating "MPAM IOMMU integration refresh"; it is reapplied.

[ltrager: Resolved the drivers/iommu/iommu.c conflict by removing the
current QoS helper implementation while preserving later IOMMU changes.]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…ry and set state"

This reverts commit f1c8da0.

This commit is being reverted as part of the process in updating "MPAM IOMMU integration refresh"; it is reapplied.

[ltrager: Resolved conflicts against the device-based and kdump-aware SMMU
implementation by removing the current MPAM helpers while preserving later
unrelated SMMU and IOMMU changes.]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…ies with MPAM"

This reverts commit 4bfc663.

This commit is being reverted as part of the process in updating "MPAM IOMMU integration refresh"; it is reapplied.

[ltrager: Resolved the SMMU probe conflict by removing only MPAM capability
registration and preserving the later kdump hardware-probe path.]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
This reverts commit 1bf2d6c.

This commit is being reverted as part of the process in updating "Legacy resctrl integration refresh"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…n unknown location"

This reverts commit 5ddc3a8.

This commit is being reverted as part of the process in updating "Legacy MPAM integration refresh"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…verridden from the command line"

This reverts commit 7a882f6.

This commit is being reverted as part of the process in updating "Legacy MPAM integration refresh"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…_sel registers"

This reverts commit 0d9b271.

This commit is being reverted as part of the process in updating "arm_mpam: Add MPAM-Fb firmware support (v9)"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…s in debugfs"

This reverts commit 154491f.

This commit is being reverted as part of the process in updating "MPAM debugfs integration refresh"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…MSC/RIS the driver discovered"

This reverts commit 5683679.

This commit is being reverted as part of the process in updating "MPAM-Fb integration adjustments"; it is reapplied.

[ltrager: Resolved the debugfs conflict by removing the original discovery
tree while preserving the later force-disable debugfs feature.]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…t() and rmid_ptrs[]"

This reverts commit 4dee662.

This commit is being reverted as part of the process in updating "Legacy resctrl integration refresh"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
…) & resctrl_arch_reset_cntr()"

This reverts commit a639261.

This commit is being reverted as part of the process in updating "arm_mpam: resctrl: Counter Assignment (ABMC) (v5)"; it is reapplied.

Signed-off-by: Lee Trager <ltrager@nvidia.com>
James Morse and others added 29 commits August 20, 2026 23:17
…ABMC use

ABMC, mbm_event mode, has a helper resctrl_arch_config_cntr() for changing
the mapping between 'cntr_id' and a CLOSID/RMID pair.

Add the helper.

For MPAM this is done by updating the mon->mbwu_idx_to_mon[] array, and as
usual CDP means it needs doing in three different ways.

Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Fenghua Yu <fenghuay@nvidia.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
(cherry picked from https://lore.kernel.org/r/20260707162440.12132-4-ben.horgan@arm.com)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…trl_arch_reset_cntr()

When used in 'mbm_event' mode, ABMC emulation, resctrl uses arch hooks to
read and reset the memory bandwidth utilization (MBWU) counters.

Add these.

Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Fenghua Yu <fenghuay@nvidia.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
(cherry picked from https://lore.kernel.org/r/20260707162440.12132-5-ben.horgan@arm.com)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…tation

Memory bandwidth monitoring make uses of MBWU monitors and is now exposed
to the user via resctrl. Add some documentation so the user knows what to
expect.

Co-developed-by: James Morse <james.morse@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
(cherry picked from https://lore.kernel.org/r/20260707162440.12132-6-ben.horgan@arm.com)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…tions

ABMC v5 always uses mbm_event mode. Test that the assignable counter
count comes from the selected MPAM class, that CDP splits those counters,
that mbm_event remains enabled when the split leaves zero counters, and
that synchronization is deferred until counters are allocated.

Signed-off-by: James Morse <james.morse@arm.com>
(backported from commit a861a0f https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next)
[fenghuay:
  - Resolve minor conflicts in drivers/resctrl/test_mpam_resctrl.c;
]
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
[ltrager:
 - Rewrite the ABMC/CDP test for v5 class-based counter counts and
   always-on mbm_event mode.
]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Acked-by: Nirmoy Das <nirmoyd@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…_ptrs[]

On MPAM systems if an error occurs the arhictecture code will call
resctrl_exit(). This calls dom_data_exit() which takes the
rdrgroup_mutex and kfree()s rmid_ptrs[].
It is possible that another syscall tries to access that same array in
the meantime, but is blocked on the mutex. Once dom_data_exit()
completes, that syscall will see a NULL pointer.
Make __rmid_entry() return NULL in this case. Neither __check_limbo()
nor free_rmid() return an error, and can silently stop their work
if this occurs. dom_data_init() has only just allocated the array and
still holds the lock, so __rmid_entry() should never return NULL here.

Signed-off-by: James Morse <james.morse@arm.com>
(cherry picked from commit c1ac3a4 https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next)
[fenghuay:
  - Resolve minor conflicts in `fs/resctrl/monitor.c`;
 ltrager:
  - re-resolved against the __check_limbo() refactor from
    fc16126 ("x86,fs/resctrl: Prevent out-of-bounds access while
    offlining CPU when SNC enabled") from v6.18.39
]
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
[ltrager: Kept the target __check_limbo() flow and applied only the rmid_ptrs lifetime checks.]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…om the command line

MPAMs bandwidth monitors are only available via resctrl if there are
enough monitors for each combination of partid and pmg to have one.
As it is unlikely anyone built that many monitors, allow the
maximum partid the system will use to be set from the kernel
command-line.
With this, it should be possible for bandwidth monitors to be
enabled by reducing the number of partid in use.

Signed-off-by: James Morse <james.morse@arm.com>
(cherry picked from commit f12f00e https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next)
[fenghuay:
  - Resolve minor conflicts in `drivers/resctrl/mpam_devices.c`;
]
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Some later things in the MPAM tree enable behaviour that resctrl doesn't
have upstream. To make it clear to people using the out-of-tree code that
they shouldn't be relying on this in user-space, add a mount option to
enable this stuff.

Signed-off-by: James Morse <james.morse@arm.com>
(cherry picked from commit 8bd0025 https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next)
[fenghuay:
  - Resolve minor conflicts in `fs/resctrl/rdtgroup.c`;
]
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…cation

The MPAM driver discovers which MSC control which system resources from
firmware tables. The MPAM resctrl picking code then attempts to export
platforms that are Xeon shaped via resctrl.
Occasionally, the presence of one or more MSC prevents the platform
being described as Xeon shaped, and exposed via resctrl. For example
with CPU-less NUMA nodes. The additional node doensn't have an L3,
so can't have domain-ids exposed for the 'MB' memory bandwidth controls.
In this example, some users would prefer to control bandwidth on just
the CPU nodes, instead of having nothing at all.
Allow users an amount of wiggle room by allowing MSC to be forced to
be treated as unknown. This effectively disables parts of the MPAM
functionality.
Unknown MSC are not disabled, They are still probed and contribute to
the system wide properties.
Suggested-by: Dave Martin <dave.martin@arm.com>

Signed-off-by: James Morse <james.morse@arm.com>
(cherry picked from commit 542e79e https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next)
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Traffic in the system can be tagged with a PARTID and PMG. Different
requestors can support a different number of bits for these fields.
Before MPAM can be used, the MPAM driver has to discover the minimum
number of bits supported by any requestor, which affects the range
of PARTID and PMG that can be used.
Detect whether the SMMU supports MPAM, if it does provide the MPAM
driver with the maximum PARTID and PMG values.
Tested-by: Amit Singh Tomar <amitsinght@marvell.com>

Signed-off-by: James Morse <james.morse@arm.com>
(cherry picked from commit 254691a https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next)
[fenghuay:
  - Resolve minor conflicts in `drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c`;
]
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…tate

To allow an iommu_group to be moved between resctrl groups as if it
were a CPU thread, the mpam driver needs to be able to set the partid
and pmg for the iommu_group.

Use the properties in the STE, as these only apply to one stream.

The MPAM driver also needs to know the maximum partid and pmg
values that the SMMU can generate. This allows it to determine
the system-wide common supported range of values. Add a helper
to return this id register.

Tested-by: Amit Singh Tomar <amitsinght@marvell.com>
Signed-off-by: James Morse <james.morse@arm.com>
(cherry picked from commit 46a241f45ca9b71abf900f31a0c89fcbf24c44c4 https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
[ltrager: Fixed the conflict by keeping iommu_driver_get_domain_for_dev(),
the device-based MPAM callbacks for identity mappings from commit
23bcbda
https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next, and the
kdump MPAM guard from commit 156c23e
https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia-bos.]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
To allow an iommu_group to be moved between resctrl groups as if it
were a CPU thread, the mpam driver needs to be able to set the partid
and pmg for the iommu_group.

Add helpers that call the iommu driver's get/set methods for these
parameters.

Signed-off-by: James Morse <james.morse@arm.com>
(cherry picked from commit 5ee2d478b62586acf816699e3cc479f49b682a58 https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
[ltrager: Fixed the conflict by keeping the later PCI reset declarations and
stubs and the device-by-device QoS dispatch for identity mappings from commit
23bcbda
https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next.]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…resctrl groups

Arm's MPAM has support for assigning devices behind an IOMMU to a
control or monitor group. This can be used for device-passthrough
for a VM, or user-space drivers using VFIO to ensure the device
is either in the same control group as the CPU threads.
Alternatively, the iommu_group may be assigned to a different
control group with preferential schema values.

Extend the resctrl tasks file to include iommu_groups. These
appear as 'iommu_group:0', where 0 is the group number that
can be found from /sys/kernel/iommu_groups/. iommu_groups
can be moved between resctrl groups by writing this string
in the same way as tasks are moved.
No state is preserved by resctrl, an iommu_group that disappears
will no longer be listed as being part of a resctrl group. A new
iommu_group will appear in the default group.

Add helpers to list and move iommu_groups. Architecture specific
helpers are used to apply the closid/rmid to the iommu_group due
to the way MPAM emulates CDP.

Tested-by: Amit Singh Tomar <amitsinght@marvell.com>
Signed-off-by: James Morse <james.morse@arm.com>
(cherry picked from commit 98b622c413ee64b8e05f93f0ff5f8cf85776afba https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git)
[ltrager:
 - Resolved merge conflict relating to magic numbers now defined as macros, additional log output in drivers/acpi/arm64/mpam.c
 - Drop drivers/acpi/arm64/mpam.c hunks — the locator parsing they amended was removed along with the dropped "arm_mpam: Parse the rest of the ACPI table"
]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…driver discovered

Not all of MPAM is visible through the resctrl user-space interface.
To make it easy to debug why certain devices were not exposed through
resctrl, allow the properties of the devices to be read through debugfs.
This adds an mpam directory to debugfs, and exposes the devices as well
as the hierarchy that was built.

Signed-off-by: James Morse <james.morse@arm.com>
(backported from commit e8f0f21 https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next)
[fenghuay:
  - Resolve minor conflicts in `drivers/resctrl/mpam_devices.c`;
 ltrager:
  - Resolve minor conflicts in `drivers/resctrl/mpam_devices.c`;
]
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Acked-by: Nirmoy Das <nirmoyd@nvidia.com>
[ltrager: Kept the later force-disable debugfs node while restoring the updated MSC and RIS discovery hierarchy.]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
It's really popular to tie NRDY high, and then act surprised when the OS
never reads the counters, because they aren't ready. The spec obliges
hardware to clear this bit automatically before the firmware advertised
timeout.
To make it easier to find errant hardware, count the number of retries
and expose that number in debugfs.

Signed-off-by: James Morse <james.morse@arm.com>
(backported from commit 4fa427c https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next)
[fenghuay:
  - Resolve minor conflicts in `drivers/resctrl/mpam_devices.c`;
]
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
[ltrager: Refresh NRDY counting for the v5 propagated-error read paths.]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Acked-by: Nirmoy Das <nirmoyd@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…n overflow

Resctrl has an overflow handler that runs on each domain every second
to ensure that any overflow of the hardware counter is accounted for.

MPAM can have counters as large as 63 bits, in which case there is no
need to check for overflow.

To allow the overflow handler to be disabled, determine if an overflow
can happen. If a class is not implemented, or has the 63bit counter,
it can't overflow.

Signed-off-by: James Morse <james.morse@arm.com>
(backported from commit 5cbe15bd6c1d393cf1ffe2b259a3be54a5345e1e https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git)
[ltrager: Minor merge conflict]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Add rdt_mb_max_lim_show() and the max_lim entry in res_common_files[].
Add mb_max_lim_init() to call resctrl_file_fflags_init("max_lim", ...)
when arch_has_mb_max_lim, and invoke it from resctrl_init() after
io_alloc_init().

(forward ported from commit be13cad https://github.com/NVIDIA/NV-Kernels 24.04_linux-nvidia-6.17-next)
[fenghuay:
  - Resolve minor conflicts in `fs/resctrl/rdtgroup.c`;
 ltrager:
  - Call mb_max_lim_init() before resctrl_mon_init(), which 'Include all MSC
    components' renamed from resctrl_l3_mon_resource_init().
]
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
A single MPAM class can contain multiple MSC components, and a CPU may
be associated with more than one of them. Domain create/destroy only
walked the first matching component, so controls and monitors were not
installed for the rest. Traffic through those omitted components then
had no resctrl domain and bandwidth accounting or schemata did not
apply where expected.

Iterate every component associated with a CPU on online/offline and key
domain lookup and allocation by component so each MSC instance gets its
own resctrl domain.

Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
(backported from commit 46160db https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia-bos)
[ltrager:
 - Refresh the multi-MSC and MBA-backed monitor changes for ABMC v5.
 - Preserve v5 per-counter assignments and targeted counter reset.
 - Derive num_mbm_cntrs from the monitoring class selected for each resource.
 - Retain downstream MB_HLIM initialization in resctrl_init().
]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Acked-by: Nirmoy Das <nirmoyd@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
BugLink: https://bugs.launchpad.net/bugs/2154527

Add local bytes counter in mpam_resctrl_counters[] to fix missing
mbm_local_bytes monitoring on Grace.

Add mon->assigned_counters check to enable mbm_L3_assignments config
file on Grace.

Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Signed-off-by: Brad Figg <bfigg@nvidia.com>
(backported from commit 059412d https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia-bos)
[ltrager: Keep ABMC v5 resource synchronization keyed to assigned MBM counters.]
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Acked-by: Nirmoy Das <nirmoyd@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
… events

BugLink: https://bugs.launchpad.net/bugs/2157922

When mbm_total_bytes is exposed on MBA for memory-level MSC monitors,
resctrl_arch_mon_capable() must reflect mon_capable on the backing
resource, not only L3. Also gate MBM counter auto-assign and unassign
on each enabled event's resource so MBA-backed mbm_total_bytes gets
ABMC setup on group create and cleanup on group delete.

Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
Acked-by: Matthew R. Ochs <mochs@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Signed-off-by: Brad Figg <bfigg@nvidia.com>
(cherry picked from commit 568443a https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-6.17-next)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…p token

When the tasks interface receives an "iommu_group:id" configuration,
the original code fails to skip the PID parsing logic after processing
the IOMMU group. This causes the same token to be incorrectly passed
to kstrtoint() as a PID, resulting in -EINVAL.

Restructure the conditional logic to use explicit if-else branches,
ensuring that IOMMU group tokens are processed by rdtgroup_move_iommu()
and then skipped.

This fix also enables proper handling of mixed configurations with
multiple consecutive iommu_group:id and pid entries (e.g.,
echo "iommu_group:1,1234,iommu_group:2,5678" > tasks).

Fixes: 98b622c413ee ("fs/resctrl: Add support for assigning iommu_groups to resctrl groups")
Signed-off-by: Zeng Heng <zengheng4@huawei.com>
(cherry picked from https://lore.kernel.org/r/20260414032610.1523958-2-zengheng4@huawei.com)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…_move_iommu()

The 'of' (kernfs_open_file) parameter in rdtgroup_move_iommu() is
not used within the function body. Remove it to simplify the
interface and eliminate the unnecessary argument passing.

Signed-off-by: Zeng Heng <zengheng4@huawei.com>
(cherry picked from https://lore.kernel.org/r/20260414032610.1523958-3-zengheng4@huawei.com)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…e groups

When deleting a control group, monitor group, or unmounting the resctrl
filesystem, migrate all associated IOMMU groups to the appropriate
destination:
  * Control group deletion: move IOMMU groups to the default group
  * Monitor group deletion: move IOMMU groups to the parent control group
  * Filesystem unmount: move all IOMMU groups to the default group

Without this migration, IOMMU groups remain bound to stale PARTID/PMG
values of the destroyed group, causing them to "disappear" from the
resctrl interface.

Add rdt_move_group_iommus() to handle this migration, mirroring the
existing rdt_move_group_tasks() pattern for task migration.

When deleting a control group or unmounting the resctrl file system, it
is necessary to move its all iommu_groups back to the default group. When
removing a monitor group, need to move its iommu_groups back to the parent
control group.

Otherwise, these iommu_groups remain bound to the old PARTID and PMG, and
they will appear to "disappear" from the resctrl fs.

Signed-off-by: Zeng Heng <zengheng4@huawei.com>
(cherry picked from https://lore.kernel.org/r/20260414032610.1523958-4-zengheng4@huawei.com)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…FIG_RESCTRL_IOMMU=n

resctrl.h declares resctrl_arch_set_iommu_closid_rmid() and the two
match helpers under #ifdef CONFIG_RESCTRL_IOMMU, with static inline
stubs in the #else branch. mpam_resctrl.c defines the same functions
unconditionally, handling CONFIG_RESCTRL_IOMMU=n inside the function
bodies with IS_ENABLED() checks.

RESCTRL_IOMMU is only selected when ARM_SMMU_V3 is enabled, so building
with ARM64_MPAM_RESCTRL_FS=y and ARM_SMMU_V3=n pulls the static inline
stubs into mpam_resctrl.c alongside its out-of-line definitions:

  drivers/resctrl/mpam_resctrl.c:388:5: error: redefinition of 'resctrl_arch_set_iommu_closid_rmid'
  drivers/resctrl/mpam_resctrl.c:404:6: error: redefinition of 'resctrl_arch_match_iommu_closid'
  drivers/resctrl/mpam_resctrl.c:421:6: error: redefinition of 'resctrl_arch_match_iommu_closid_rmid'

Drop the stubs and declare the prototypes unconditionally. The
definitions already handle the disabled case internally, and on
architectures that never implement them every caller is behind an
IS_ENABLED(CONFIG_RESCTRL_IOMMU) check, so the calls are removed as
dead code.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
(cherry picked from commit 6024242 https://github.com/NVIDIA/NV-Kernels/tree/linux-nvidia-6.18-next)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Initialize mwbu_arg and val in mpam_restore_mbwu_state() to zero.
This ensures stack garbage is not used when checking mwbu_arg.err.
While val is not currently used, __ris_msmon_read() does *m->val += now,
so initialize it to ensure KMSAN does not flag it.

Reported in upstream review:
https://lore.kernel.org/all/673b79c0-d2e6-44a6-a1a8-a2ff92f2ff53@trager.us/

This downstream fix can be dropped once Ben Horgan's proposed change to
initialize struct mon_read in mpam_restore_mbwu_state() also initializes
val and is applied. See
https://lore.kernel.org/r/20260710115546.29644-8-ben.horgan@arm.com

Fixes: 38ca089 ("NVIDIA: SAUCE: arm_mpam: propagate MSC access errors for __ris_msmon_read()")
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
Acked-by: Nirmoy Das <nirmoyd@nvidia.com>
(cherry picked from commit 72474d0 https://github.com/NVIDIA/NV-Kernels/tree/linux-nvidia-6.18-next)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
…ting groups

iommu_group_get_from_kobj() returns with a reference held on
group->devices_kobj, which the caller must release with
iommu_group_put(). The explicit kobject_get() taken before the call
only compensates for the kobject_put(&group->kobj) that
iommu_group_get_from_kobj() performs internally.

Neither show_rdt_iommu() nor rdt_move_group_iommus() ever calls
iommu_group_put(), so each leaks one iommu_group reference per group
in the kset on every invocation: every read of a tasks file for the
former, and every ctrl/mon group rmdir or resctrl unmount for the
latter. Since devices_kobj pins the group's kobject, leaked groups
can never be freed.

rdt_move_group_iommus() additionally leaks the iterator's reference
on group_kobj on its error paths: kset_get_next_obj() only drops the
reference on the current kobject when it is passed back as @Prev on
the next call, so breaking out of the loop early leaks it.

Drop the iommu_group reference at the end of each loop iteration, and
drop the group_kobj reference before breaking out of the loop on
error.

Reported in upstream review - https://lore.kernel.org/all/c53d8057-d3c3-4000-8ce2-876385ca3f25@trager.us/

Fixes: 7b8c62d ("NVIDIA: SAUCE: fs/resctrl: Add support for assigning iommu_groups to resctrl groups")
Fixes: a110864 ("NVIDIA: SAUCE: fs/resctrl: Migrate IOMMU groups when removing resource groups")
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Jamie Nguyen <jamien@nvidia.com>
Acked-by: Carol L Soto <csoto@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
Acked-by: Fenghua Yu <fenghuay@nvidia.com>
(cherry picked from commit a4d885b https://github.com/NVIDIA/NV-Kernels/tree/linux-nvidia-6.18-next)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
mpam_msc_read_mbwu_l() reports an unstable read by returning zero
with MSMON___L_NRDY set in the output value. Hardware may also set the
NRDY bit.

mpam_save_mbwu_state() otherwise adds the invalid value to the saved
correction. Skip updating the saved monitor state whenever NRDY is set.

Reported in upstream review:
https://lore.kernel.org/all/2228a2be-96b1-4c8a-9786-6ba07fd302c0@trager.us/

This downstream fix can be dropped once Ben Horgan's proposed change to
use __ris_msmon_read() when saving MBWU state is applied. See
https://lore.kernel.org/r/20260710115546.29644-7-ben.horgan@arm.com

Fixes: ba83ae8 ("NVIDIA: SAUCE: arm_mpam: propagate MSC access errors for MBWU counters")
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Nirmoy Das <nirmoyd@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
(cherry picked from commit fb73228 https://github.com/ltrager/NV-Kernels/tree/linux-nvidia-6.18-next)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
T241-MPAM-6 causes all MBWU counter formats to count 64-byte
requests instead of bytes. Commit dc48eb1 excluded the 63-bit
MSMON_MBWU_LWD format while scaling the shorter counters. Systems
selecting the preferred 63-bit counter consequently report bandwidth
values that are 64 times too small.

Apply the scale to both the sampled value and overflow correction for
the 63-bit format. Unsigned arithmetic retains modulo-u64 behavior
when the scaled counter range exceeds u64.

Fixes: dc48eb1 ("arm_mpam: Add workaround for T241-MPAM-6")
(cherry picked from https://lore.kernel.org/lkml/20240816131432.993859-1-sdonthineni@nvidia.com/)
Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>
Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
Tested-by: Fenghua Yu <fenghuay@nvidia.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
(cherry picked from https://lore.kernel.org/r/20260727191326.2202616-1-sdonthineni@nvidia.com)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
__ris_msmon_read() scales T241 MBWU counter values from 64-byte
requests to bytes before adding mbwu_state->correction. The power
management save path adds its raw counter value to the same correction
without scaling it, mixing requests and bytes after state restoration.

Apply the T241 scale after rejecting NRDY so the saved correction uses
the same units as normal reads.

This downstream fix can be dropped once Ben Horgan's proposed change to
use __ris_msmon_read() when saving MBWU state is applied. See
https://lore.kernel.org/r/20260710115546.29644-7-ben.horgan@arm.com

Fixes: c31ebea ("arm_mpam: Add workaround for T241-MPAM-6")
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Nirmoy Das <nirmoyd@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
(cherry picked from commit cff1a2e https://github.com/ltrager/NV-Kernels/tree/linux-nvidia-6.18-next)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
mpam_msc_drv_remove() releases the PCC channel before unlinking the
MSC from the SRCU-protected lists. If this drops the final channel
reference, an existing reader can dereference the freed channel through
its retained MSC.

Simply moving the release after mpam_free_garbage() is insufficient. A
concurrent garbage collector can claim the queued MSC and wait for the
grace period while the remove caller finds an empty garbage list and
releases the channel immediately.

Add an optional garbage release callback and use it to drop each MSC
PCC reference after the collector completes synchronize_srcu(). This
also releases PCC references when mpam_disable() destroys the MSCs.

Fixes: 41e7e7d ("NVIDIA: SAUCE: arm_mpam: detect and enable MPAM-Fb PCC support")
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Acked-by: Nirmoy Das <nirmoyd@nvidia.com>
Acked-by: Seth Forshee <sforshee@nvidia.com>
(cherry picked from commit b7436bb https://github.com/ltrager/NV-Kernels/tree/linux-nvidia-6.18-next)
Signed-off-by: Lee Trager <ltrager@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed pending_review_comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants