@@ -195,6 +195,7 @@ struct msr_counter bic[] = {
195195 { 0x0 , "APIC" , NULL , 0 , 0 , 0 , NULL , 0 },
196196 { 0x0 , "X2APIC" , NULL , 0 , 0 , 0 , NULL , 0 },
197197 { 0x0 , "Die" , NULL , 0 , 0 , 0 , NULL , 0 },
198+ { 0x0 , "L3" , NULL , 0 , 0 , 0 , NULL , 0 },
198199 { 0x0 , "GFXAMHz" , NULL , 0 , 0 , 0 , NULL , 0 },
199200 { 0x0 , "IPC" , NULL , 0 , 0 , 0 , NULL , 0 },
200201 { 0x0 , "CoreThr" , NULL , 0 , 0 , 0 , NULL , 0 },
@@ -263,6 +264,7 @@ enum bic_names {
263264 BIC_APIC ,
264265 BIC_X2APIC ,
265266 BIC_Die ,
267+ BIC_L3 ,
266268 BIC_GFXACTMHz ,
267269 BIC_IPC ,
268270 BIC_CORE_THROT_CNT ,
@@ -292,7 +294,7 @@ void print_bic_set(char *s, cpu_set_t *set)
292294 if (CPU_ISSET (i , set )) {
293295 assert (i < MAX_BIC );
294296 printf (" %s" , bic [i ].name );
295- }
297+ }
296298 }
297299 putchar ('\n' );
298300}
@@ -357,6 +359,7 @@ static void bic_groups_init(void)
357359 SET_BIC (BIC_Core , & bic_group_topology );
358360 SET_BIC (BIC_CPU , & bic_group_topology );
359361 SET_BIC (BIC_Die , & bic_group_topology );
362+ SET_BIC (BIC_L3 , & bic_group_topology );
360363
361364 BIC_INIT (& bic_group_thermal_pwr );
362365 SET_BIC (BIC_CoreTmp , & bic_group_thermal_pwr );
@@ -2273,6 +2276,7 @@ struct platform_counters {
22732276struct cpu_topology {
22742277 int physical_package_id ;
22752278 int die_id ;
2279+ int l3_id ;
22762280 int logical_cpu_id ;
22772281 int physical_node_id ;
22782282 int logical_node_id ; /* 0-based count within the package */
@@ -2294,6 +2298,7 @@ struct topo_params {
22942298 int max_core_id ;
22952299 int max_package_id ;
22962300 int max_die_id ;
2301+ int max_l3_id ;
22972302 int max_node_num ;
22982303 int nodes_per_pkg ;
22992304 int cores_per_node ;
@@ -2712,6 +2717,8 @@ void print_header(char *delim)
27122717 outp += sprintf (outp , "%sPackage" , (printed ++ ? delim : "" ));
27132718 if (DO_BIC (BIC_Die ))
27142719 outp += sprintf (outp , "%sDie" , (printed ++ ? delim : "" ));
2720+ if (DO_BIC (BIC_L3 ))
2721+ outp += sprintf (outp , "%sL3" , (printed ++ ? delim : "" ));
27152722 if (DO_BIC (BIC_Node ))
27162723 outp += sprintf (outp , "%sNode" , (printed ++ ? delim : "" ));
27172724 if (DO_BIC (BIC_Core ))
@@ -3183,6 +3190,8 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
31833190 outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
31843191 if (DO_BIC (BIC_Die ))
31853192 outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
3193+ if (DO_BIC (BIC_L3 ))
3194+ outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
31863195 if (DO_BIC (BIC_Node ))
31873196 outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
31883197 if (DO_BIC (BIC_Core ))
@@ -3206,6 +3215,12 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
32063215 else
32073216 outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
32083217 }
3218+ if (DO_BIC (BIC_L3 )) {
3219+ if (c )
3220+ outp += sprintf (outp , "%s%d" , (printed ++ ? delim : "" ), cpus [t -> cpu_id ].l3_id );
3221+ else
3222+ outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
3223+ }
32093224 if (DO_BIC (BIC_Node )) {
32103225 if (t )
32113226 outp += sprintf (outp , "%s%d" ,
@@ -5911,6 +5926,11 @@ int get_die_id(int cpu)
59115926 return parse_int_file ("/sys/devices/system/cpu/cpu%d/topology/die_id" , cpu );
59125927}
59135928
5929+ int get_l3_id (int cpu )
5930+ {
5931+ return parse_int_file ("/sys/devices/system/cpu/cpu%d/cache/index3/id" , cpu );
5932+ }
5933+
59145934int get_core_id (int cpu )
59155935{
59165936 return parse_int_file ("/sys/devices/system/cpu/cpu%d/topology/core_id" , cpu );
@@ -9203,6 +9223,11 @@ void topology_probe(bool startup)
92039223 if (cpus [i ].die_id > topo .max_die_id )
92049224 topo .max_die_id = cpus [i ].die_id ;
92059225
9226+ /* get l3 information */
9227+ cpus [i ].l3_id = get_l3_id (i );
9228+ if (cpus [i ].l3_id > topo .max_l3_id )
9229+ topo .max_l3_id = cpus [i ].l3_id ;
9230+
92069231 /* get numa node information */
92079232 cpus [i ].physical_node_id = get_physical_node_id (& cpus [i ]);
92089233 if (cpus [i ].physical_node_id > topo .max_node_num )
@@ -9235,6 +9260,9 @@ void topology_probe(bool startup)
92359260 if (!summary_only && topo .num_die > 1 )
92369261 BIC_PRESENT (BIC_Die );
92379262
9263+ if (!summary_only && topo .max_l3_id > 0 )
9264+ BIC_PRESENT (BIC_L3 );
9265+
92389266 topo .num_packages = max_package_id + 1 ;
92399267 if (debug > 1 )
92409268 fprintf (outf , "max_package_id %d, sizing for %d packages\n" , max_package_id , topo .num_packages );
@@ -9258,8 +9286,8 @@ void topology_probe(bool startup)
92589286 if (cpu_is_not_present (i ))
92599287 continue ;
92609288 fprintf (outf ,
9261- "cpu %d pkg %d die %d node %d lnode %d core %d thread %d\n" ,
9262- i , cpus [i ].physical_package_id , cpus [i ].die_id ,
9289+ "cpu %d pkg %d die %d l3 %d node %d lnode %d core %d thread %d\n" ,
9290+ i , cpus [i ].physical_package_id , cpus [i ].die_id , cpus [ i ]. l3_id ,
92639291 cpus [i ].physical_node_id , cpus [i ].logical_node_id , cpus [i ].physical_core_id , cpus [i ].thread_id );
92649292 }
92659293
0 commit comments