Commit 5cd0dad6 authored by James Morse's avatar James Morse Committed by Zeng Heng
Browse files

arm64: mpam: Context switch the MPAM registers

maillist inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8T2RT

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git/log/?h=mpam/snapshot/v6.7-rc2



---------------------------

MPAM has a system register that is used to hold the partid and pmg values
that traffic generated by EL0 will use. This can be set per-task by the
resctrl file system.

Add a helper to switch this. resctrl expects a 'default' value to be
used in preference if the default partid and pmg are selected.

struct task_struct's separate closid and rmid fields are insufficient
to implement resctrl using MPAM, as resctrl can change the partid (closid)
and pmg (sort of like the rmid) separately. On x86, the rmid is an
independent number, so a race that writes a mismatched  closid and rmid
into hardware is benign. On arm64, the pmg bits extend the partid.
(i.e. partid-5 has a pmg-0 that is not the same as partid-6's pmg-0).
In this case, mismatching the values will 'dirty' a pmg value that
resctrl believes is clean, and is not tracking with its 'limbo' code.

To avoid this, the partid and pmg are always read and written as a pair.
Instead of making struct task_struct's closid and rmid fields an
endian-unsafe union, add the value to struct thread_info and always use
READ_ONCE()/WRITE_ONCE() when accessing this field.

CC: Amit Singh Tomar <amitsinght@marvell.com>
Signed-off-by: default avatarJames Morse <james.morse@arm.com>
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
parent 30fae95d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment