Skip to content

ANDROID: MPAM policy and arch drivers

System requirements

For MPAM to be usable at EL1, the following requirements must be met:

EL3 needs to:

set MPAM3_EL3.MPAMEN to 1
set MPAM3_EL3.TRAPLOWER to 0

EL2 needs to:

set MPAM2_EL2.TRAPMPAM0EL1 to 0
set MPAM2_EL2.TRAPMPAM1EL1 to 0

Assuming Linux is booted at EL2, the patches take care of doing the EL2 setup. EL3 setup is the responsibility of whichever bootloader/firmware you are using (arm-trusted-firmware was used to test this).

Code layout

Architecture feature handling

With one exception in the EL2 setup code (cf. EL2 requirements: System requirements: EL2), all of the MPAM architecture feature handling lives in the mpam_arch.c module.

System validation

The module verifies whether all CPUs in the system support MPAM and have MPAM enabled, and aggregates the minimum usable PARTID count accross all CPUs.

MSC discovery

The MSC platform_driver matches against "arm,mpam-msc" DT entries.

Features are discovered at probe time, and are exposed through the platform_driver's sysfs interface in an "mpam" directory.

Limitations: System-wide cache MSC only. No support for multiple MSCs. (more info available at Limitations)

Devicetree (DT) bindings for MPAM MSC:

Required properties:

  • compatible : expected: "arm,mpam-msc"
  • reg : physical base address and length of the register set

Example:

msc@0 {
      compatible = "arm,mpam-msc";
      reg = <0x0 0x30000000 0x0 0x3000>;
};

MSC configuration

# Default setup with 64 partitions, 16 portions
/sys/devices/platform/30000000.msc/
└── mpam/
    ├── partitions/
    │   ├── 0/
    │   │   └── cpbm -> 0-15
    │   ├── 1/
    │   │   └── cpbm -> 0-15
    │   ...
    │   └── 63/
    │       └── cpbm -> 0-15
    └── cpbm_nbits -> 16

The interface for cache portion partitionning follow the bitmap list format. For instance, the default setup (with default PARTID) for a 16-portion cache is all portions enabled, which shows as:

cat mpam/partitions/0/cpbm
0-15

Configuring the portions for a partition follows the same format:

echo 0-7 > mpam/partitions/42/cpbm

echo 8-15 > mpam/partitions/43/cpbm

echo 6,9 > mpam/partitions/44/cpbm

Task : partition mapping

The assignment of a PARTID to a given PID is handled by the mpam_policy.c module.

It creates a mount point at /sys/fs/mpam, and the interface can be mounted via:

mount -t mpam mpam /sys/fs/mpam 
cat /sys/fs/mpam/partitions/0/tasks
1
2
3
...
echo 141 > /sys/fs/mpam/partitions/1/tasks

Forked tasks inherit their parents' partid, unless SCHED_RESET_ON_FORK is used.

Module dependency

mpam_arch must be loaded before mpam_policy (moddep will enforce this).

Limitations

  • Assumes MSC features do not change after being read (no locking around accessing MSC data, only accessing the MSC registers)
  • System-wide single MSC support only; no private L2 or multi-cluster (i.e. multiple DSUs) support.

Validation

Limited scope of functional validation for both modules have been performed based on a simulated environment setup. The implementation provided is a basic one though, enabling cache portion partitioning only and in no means does it explore full MPAM functionality.

Edited by Beata Michalska

Merge request reports