perf/x86/amd/uncore: Add memory controller support
Unified Memory Controller (UMC) events were introduced with Zen 4 as a part of the Performance Monitoring Version 2 (PerfMonV2) enhancements. An event is specified using the EventSelect bits and the RdWrMask bits can be used for additional filtering of read and write requests. As of now, a maximum of 12 channels of DDR5 are available on each socket and each channel is controlled by a dedicated UMC. Each UMC, in turn, has its own set of performance monitoring counters. Since the MSR address space for the UMC PERF_CTL and PERF_CTR registers are reused across sockets, uncore groups are created on the basis of socket IDs. Hence, group exclusivity is mandatory while opening events so that events for an UMC can only be opened on CPUs which are on the same socket as the corresponding memory channel. For each socket, the total number of available UMC counters and active memory channels are determined from CPUID leaf 0x80000022 EBX and ECX respectively. Usually, on Zen 4, each UMC has four counters. MSR assignments are determined on the basis of active UMCs. E.g. if UMCs 1, 4 and 9 are active for a given socket, then * UMC 1 gets MSRs 0xc0010800 to 0xc0010807 as PERF_CTLs and PERF_CTRs * UMC 4 gets MSRs 0xc0010808 to 0xc001080f as PERF_CTLs and PERF_CTRs * UMC 9 gets MSRs 0xc0010810 to 0xc0010817 as PERF_CTLs and PERF_CTRs If there are sockets without any online CPUs when the amd_uncore driver is loaded, UMCs for such sockets will not be discoverable since the mechanism relies on executing the CPUID instruction on an online CPU from the socket. Signed-off-by: Sandipan Das <sandipan.das@amd.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/b25f391205c22733493abec1ed850b71784edc5f.1696425185.git.sandipan.das@amd.com
This commit is contained in:
		
				
					committed by
					
						 Peter Zijlstra
						Peter Zijlstra
					
				
			
			
				
	
			
			
			
						parent
						
							83a43c6221
						
					
				
				
					commit
					25e5684782
				
			| @@ -112,6 +112,13 @@ | ||||
| 	(AMD64_PERFMON_V2_EVENTSEL_EVENT_NB	|	\ | ||||
| 	 AMD64_PERFMON_V2_EVENTSEL_UMASK_NB) | ||||
| 
 | ||||
| #define AMD64_PERFMON_V2_ENABLE_UMC			BIT_ULL(31) | ||||
| #define AMD64_PERFMON_V2_EVENTSEL_EVENT_UMC		GENMASK_ULL(7, 0) | ||||
| #define AMD64_PERFMON_V2_EVENTSEL_RDWRMASK_UMC		GENMASK_ULL(9, 8) | ||||
| #define AMD64_PERFMON_V2_RAW_EVENT_MASK_UMC		\ | ||||
| 	(AMD64_PERFMON_V2_EVENTSEL_EVENT_UMC	|	\ | ||||
| 	 AMD64_PERFMON_V2_EVENTSEL_RDWRMASK_UMC) | ||||
| 
 | ||||
| #define AMD64_NUM_COUNTERS				4 | ||||
| #define AMD64_NUM_COUNTERS_CORE				6 | ||||
| #define AMD64_NUM_COUNTERS_NB				4 | ||||
| @@ -232,6 +239,8 @@ union cpuid_0x80000022_ebx { | ||||
| 		unsigned int	lbr_v2_stack_sz:6; | ||||
| 		/* Number of Data Fabric Counters */ | ||||
| 		unsigned int	num_df_pmc:6; | ||||
| 		/* Number of Unified Memory Controller Counters */ | ||||
| 		unsigned int	num_umc_pmc:6; | ||||
| 	} split; | ||||
| 	unsigned int		full; | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user