linux-stable/arch/x86/kernel/cpu
James Morse fb700810d3 x86/resctrl: Separate arch and fs resctrl locks
resctrl has one mutex that is taken by the architecture-specific code, and the
filesystem parts. The two interact via cpuhp, where the architecture code
updates the domain list. Filesystem handlers that walk the domains list should
not run concurrently with the cpuhp callback modifying the list.

Exposing a lock from the filesystem code means the interface is not cleanly
defined, and creates the possibility of cross-architecture lock ordering
headaches. The interaction only exists so that certain filesystem paths are
serialised against CPU hotplug. The CPU hotplug code already has a mechanism to
do this using cpus_read_lock().

MPAM's monitors have an overflow interrupt, so it needs to be possible to walk
the domains list in irq context. RCU is ideal for this, but some paths need to
be able to sleep to allocate memory.

Because resctrl_{on,off}line_cpu() take the rdtgroup_mutex as part of a cpuhp
callback, cpus_read_lock() must always be taken first.
rdtgroup_schemata_write() already does this.

Most of the filesystem code's domain list walkers are currently protected by
the rdtgroup_mutex taken in rdtgroup_kn_lock_live().  The exceptions are
rdt_bit_usage_show() and the mon_config helpers which take the lock directly.

Make the domain list protected by RCU. An architecture-specific lock prevents
concurrent writers. rdt_bit_usage_show() could walk the domain list using RCU,
but to keep all the filesystem operations the same, this is changed to call
cpus_read_lock().  The mon_config helpers send multiple IPIs, take the
cpus_read_lock() in these cases.

The other filesystem list walkers need to be able to sleep.  Add
cpus_read_lock() to rdtgroup_kn_lock_live() so that the cpuhp callbacks can't
be invoked when file system operations are occurring.

Add lockdep_assert_cpus_held() in the cases where the rdtgroup_kn_lock_live()
call isn't obvious.

Resctrl's domain online/offline calls now need to take the rdtgroup_mutex
themselves.

  [ bp: Fold in a build fix: https://lore.kernel.org/r/87zfvwieli.ffs@tglx ]

Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Shaopeng Tan <tan.shaopeng@fujitsu.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Babu Moger <babu.moger@amd.com>
Tested-by: Shaopeng Tan <tan.shaopeng@fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64
Link: https://lore.kernel.org/r/20240213184438.16675-25-james.morse@arm.com
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
2024-02-19 19:28:07 +01:00
..
mce - Add support managing TDX host hardware 2024-01-18 13:41:48 -08:00
microcode x86/microcode/intel: Set new revision only after a successful update 2023-12-03 11:49:53 +01:00
mtrr x86/mtrr: Document missing function parameters in kernel-doc 2023-11-20 10:19:27 +01:00
resctrl x86/resctrl: Separate arch and fs resctrl locks 2024-02-19 19:28:07 +01:00
sgx arch/x86: Fix typos 2024-01-03 11:46:22 +01:00
.gitignore
acrn.c x86/apic: Nuke ack_APIC_irq() 2023-08-09 11:58:34 -07:00
amd.c - Add synthetic X86_FEATURE flags for the different AMD Zen generations 2024-01-08 15:45:31 -08:00
aperfmperf.c x86/aperfmperf: Erase stale arch_freq_scale values when disabling frequency invariance readings 2023-01-16 10:19:15 +01:00
bugs.c x86/srso: Remove unnecessary semicolon 2023-10-20 12:50:35 +02:00
cacheinfo.c x86/cpu: Move cpu_l[l2]c_id into topology info 2023-10-10 14:38:18 +02:00
centaur.c
common.c - Add support managing TDX host hardware 2024-01-18 13:41:48 -08:00
cpu.h x86/cpu: Move cpu_l[l2]c_id into topology info 2023-10-10 14:38:18 +02:00
cpuid-deps.c x86/cpufeatures: Add CPU feature flags for shadow stacks 2023-07-11 14:12:18 -07:00
cyrix.c x86/cyrix: include header linux/isa-dma.h 2022-07-26 14:03:12 -05:00
debugfs.c x86/cpu: Provide debug interface 2023-10-10 14:38:19 +02:00
feat_ctl.c x86/cpu: Include the header of init_ia32_feat_ctl()'s prototype 2022-09-26 17:06:27 +02:00
hygon.c x86/barrier: Do not serialize MSR accesses on AMD 2023-11-13 10:09:45 +01:00
hypervisor.c
intel.c sysctl-6.7-rc1 2023-11-01 20:51:41 -10:00
intel_epb.c x86/cpu/intel_epb: Don't rely on link order 2023-11-24 13:54:31 +01:00
intel_pconfig.c
Makefile x86/cpu: Provide debug interface 2023-10-10 14:38:19 +02:00
match.c
mkcapflags.sh
mshyperv.c x86/hyperv: Use atomic_try_cmpxchg() to micro-optimize hv_nmi_unknown() 2023-11-22 03:47:44 +00:00
perfctr-watchdog.c
powerflags.c
proc.c x86/cpu: Move cpu_core_id into topology info 2023-10-10 14:38:17 +02:00
rdrand.c x86/rdrand: Remove "nordrand" flag in favor of "random.trust_cpu" 2022-07-18 15:04:04 +02:00
scattered.c x86/cpufeatures: Add Bandwidth Monitoring Event Configuration feature flag 2023-01-23 17:38:31 +01:00
topology.c x86/cpu: Move cpu_core_id into topology info 2023-10-10 14:38:17 +02:00
transmeta.c
tsx.c x86/cpu: Remove redundant extern x86_read_arch_cap_msr() 2023-01-10 12:40:24 +01:00
umc.c
umwait.c x86/umwait: move to use bus_get_dev_root() 2023-03-17 15:29:29 +01:00
vmware.c sched/clock/x86: Mark sched_clock() noinstr 2023-01-31 15:01:47 +01:00
vortex.c
zhaoxin.c x86/cpu: Remove pointless evaluation of x86_coreid_bits 2023-10-10 14:38:18 +02:00