@@ -195,6 +195,7 @@ struct msr_counter bic[] = {
195
195
{ 0x0 , "APIC" , NULL , 0 , 0 , 0 , NULL , 0 },
196
196
{ 0x0 , "X2APIC" , NULL , 0 , 0 , 0 , NULL , 0 },
197
197
{ 0x0 , "Die" , NULL , 0 , 0 , 0 , NULL , 0 },
198
+ { 0x0 , "L3" , NULL , 0 , 0 , 0 , NULL , 0 },
198
199
{ 0x0 , "GFXAMHz" , NULL , 0 , 0 , 0 , NULL , 0 },
199
200
{ 0x0 , "IPC" , NULL , 0 , 0 , 0 , NULL , 0 },
200
201
{ 0x0 , "CoreThr" , NULL , 0 , 0 , 0 , NULL , 0 },
@@ -263,6 +264,7 @@ enum bic_names {
263
264
BIC_APIC ,
264
265
BIC_X2APIC ,
265
266
BIC_Die ,
267
+ BIC_L3 ,
266
268
BIC_GFXACTMHz ,
267
269
BIC_IPC ,
268
270
BIC_CORE_THROT_CNT ,
@@ -292,7 +294,7 @@ void print_bic_set(char *s, cpu_set_t *set)
292
294
if (CPU_ISSET (i , set )) {
293
295
assert (i < MAX_BIC );
294
296
printf (" %s" , bic [i ].name );
295
- }
297
+ }
296
298
}
297
299
putchar ('\n' );
298
300
}
@@ -357,6 +359,7 @@ static void bic_groups_init(void)
357
359
SET_BIC (BIC_Core , & bic_group_topology );
358
360
SET_BIC (BIC_CPU , & bic_group_topology );
359
361
SET_BIC (BIC_Die , & bic_group_topology );
362
+ SET_BIC (BIC_L3 , & bic_group_topology );
360
363
361
364
BIC_INIT (& bic_group_thermal_pwr );
362
365
SET_BIC (BIC_CoreTmp , & bic_group_thermal_pwr );
@@ -2273,6 +2276,7 @@ struct platform_counters {
2273
2276
struct cpu_topology {
2274
2277
int physical_package_id ;
2275
2278
int die_id ;
2279
+ int l3_id ;
2276
2280
int logical_cpu_id ;
2277
2281
int physical_node_id ;
2278
2282
int logical_node_id ; /* 0-based count within the package */
@@ -2294,6 +2298,7 @@ struct topo_params {
2294
2298
int max_core_id ;
2295
2299
int max_package_id ;
2296
2300
int max_die_id ;
2301
+ int max_l3_id ;
2297
2302
int max_node_num ;
2298
2303
int nodes_per_pkg ;
2299
2304
int cores_per_node ;
@@ -2712,6 +2717,8 @@ void print_header(char *delim)
2712
2717
outp += sprintf (outp , "%sPackage" , (printed ++ ? delim : "" ));
2713
2718
if (DO_BIC (BIC_Die ))
2714
2719
outp += sprintf (outp , "%sDie" , (printed ++ ? delim : "" ));
2720
+ if (DO_BIC (BIC_L3 ))
2721
+ outp += sprintf (outp , "%sL3" , (printed ++ ? delim : "" ));
2715
2722
if (DO_BIC (BIC_Node ))
2716
2723
outp += sprintf (outp , "%sNode" , (printed ++ ? delim : "" ));
2717
2724
if (DO_BIC (BIC_Core ))
@@ -3183,6 +3190,8 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
3183
3190
outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
3184
3191
if (DO_BIC (BIC_Die ))
3185
3192
outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
3193
+ if (DO_BIC (BIC_L3 ))
3194
+ outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
3186
3195
if (DO_BIC (BIC_Node ))
3187
3196
outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
3188
3197
if (DO_BIC (BIC_Core ))
@@ -3206,6 +3215,12 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
3206
3215
else
3207
3216
outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
3208
3217
}
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
+ }
3209
3224
if (DO_BIC (BIC_Node )) {
3210
3225
if (t )
3211
3226
outp += sprintf (outp , "%s%d" ,
@@ -5911,6 +5926,11 @@ int get_die_id(int cpu)
5911
5926
return parse_int_file ("/sys/devices/system/cpu/cpu%d/topology/die_id" , cpu );
5912
5927
}
5913
5928
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
+
5914
5934
int get_core_id (int cpu )
5915
5935
{
5916
5936
return parse_int_file ("/sys/devices/system/cpu/cpu%d/topology/core_id" , cpu );
@@ -9203,6 +9223,11 @@ void topology_probe(bool startup)
9203
9223
if (cpus [i ].die_id > topo .max_die_id )
9204
9224
topo .max_die_id = cpus [i ].die_id ;
9205
9225
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
+
9206
9231
/* get numa node information */
9207
9232
cpus [i ].physical_node_id = get_physical_node_id (& cpus [i ]);
9208
9233
if (cpus [i ].physical_node_id > topo .max_node_num )
@@ -9235,6 +9260,9 @@ void topology_probe(bool startup)
9235
9260
if (!summary_only && topo .num_die > 1 )
9236
9261
BIC_PRESENT (BIC_Die );
9237
9262
9263
+ if (!summary_only && topo .max_l3_id > 0 )
9264
+ BIC_PRESENT (BIC_L3 );
9265
+
9238
9266
topo .num_packages = max_package_id + 1 ;
9239
9267
if (debug > 1 )
9240
9268
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)
9258
9286
if (cpu_is_not_present (i ))
9259
9287
continue ;
9260
9288
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 ,
9263
9291
cpus [i ].physical_node_id , cpus [i ].logical_node_id , cpus [i ].physical_core_id , cpus [i ].thread_id );
9264
9292
}
9265
9293
0 commit comments