@@ -191,6 +191,7 @@ struct msr_counter bic[] = {
191191 { 0x0 , "Any%C0" , NULL , 0 , 0 , 0 , NULL , 0 },
192192 { 0x0 , "GFX%C0" , NULL , 0 , 0 , 0 , NULL , 0 },
193193 { 0x0 , "CPUGFX%" , NULL , 0 , 0 , 0 , NULL , 0 },
194+ { 0x0 , "Module" , NULL , 0 , 0 , 0 , NULL , 0 },
194195 { 0x0 , "Core" , NULL , 0 , 0 , 0 , NULL , 0 },
195196 { 0x0 , "CPU" , NULL , 0 , 0 , 0 , NULL , 0 },
196197 { 0x0 , "APIC" , NULL , 0 , 0 , 0 , NULL , 0 },
@@ -264,6 +265,7 @@ enum bic_names {
264265 BIC_Any_c0 ,
265266 BIC_GFX_c0 ,
266267 BIC_CPUGFX ,
268+ BIC_Module ,
267269 BIC_Core ,
268270 BIC_CPU ,
269271 BIC_APIC ,
@@ -364,6 +366,7 @@ static void bic_groups_init(void)
364366 SET_BIC (BIC_Node , & bic_group_topology );
365367 SET_BIC (BIC_CoreCnt , & bic_group_topology );
366368 SET_BIC (BIC_PkgCnt , & bic_group_topology );
369+ SET_BIC (BIC_Module , & bic_group_topology );
367370 SET_BIC (BIC_Core , & bic_group_topology );
368371 SET_BIC (BIC_CPU , & bic_group_topology );
369372 SET_BIC (BIC_Die , & bic_group_topology );
@@ -2383,6 +2386,7 @@ struct platform_counters {
23832386struct cpu_topology {
23842387 int cpu_id ;
23852388 int core_id ; /* unique within a package */
2389+ int module_id ;
23862390 int package_id ;
23872391 int die_id ;
23882392 int l3_id ;
@@ -2404,6 +2408,8 @@ struct topo_params {
24042408 int allowed_cores ;
24052409 int max_cpu_num ;
24062410 int max_core_id ; /* within a package */
2411+ int min_module_id ; /* system wide */
2412+ int max_module_id ; /* system wide */
24072413 int max_package_id ;
24082414 int max_die_id ;
24092415 int max_l3_id ;
@@ -2919,6 +2925,8 @@ void print_header(char *delim)
29192925 outp += sprintf (outp , "%sL3" , (printed ++ ? delim : "" ));
29202926 if (DO_BIC (BIC_Node ))
29212927 outp += sprintf (outp , "%sNode" , (printed ++ ? delim : "" ));
2928+ if (DO_BIC (BIC_Module ))
2929+ outp += sprintf (outp , "%sModule" , (printed ++ ? delim : "" ));
29222930 if (DO_BIC (BIC_Core ))
29232931 outp += sprintf (outp , "%sCore" , (printed ++ ? delim : "" ));
29242932 if (DO_BIC (BIC_CPU ))
@@ -3388,6 +3396,8 @@ int format_counters(PER_THREAD_PARAMS)
33883396 outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
33893397 if (DO_BIC (BIC_Node ))
33903398 outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
3399+ if (DO_BIC (BIC_Module ))
3400+ outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
33913401 if (DO_BIC (BIC_Core ))
33923402 outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
33933403 if (DO_BIC (BIC_CPU ))
@@ -3421,6 +3431,12 @@ int format_counters(PER_THREAD_PARAMS)
34213431 else
34223432 outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
34233433 }
3434+ if (DO_BIC (BIC_Module )) {
3435+ if (c )
3436+ outp += sprintf (outp , "%s0x%x" , (printed ++ ? delim : "" ), cpus [t -> cpu_id ].module_id );
3437+ else
3438+ outp += sprintf (outp , "%s-" , (printed ++ ? delim : "" ));
3439+ }
34243440 if (DO_BIC (BIC_Core )) {
34253441 if (c )
34263442 outp += sprintf (outp , "%s0x%x" , (printed ++ ? delim : "" ), cpus [t -> cpu_id ].core_id );
@@ -6079,6 +6095,11 @@ int get_l3_id(int cpu)
60796095 return parse_int_file ("/sys/devices/system/cpu/cpu%d/cache/index3/id" , cpu );
60806096}
60816097
6098+ int get_module_id (int cpu )
6099+ {
6100+ return parse_int_file ("/sys/devices/system/cpu/cpu%d/topology/cluster_id" , cpu );
6101+ }
6102+
60826103int get_core_id (int cpu )
60836104{
60846105 return parse_int_file ("/sys/devices/system/cpu/cpu%d/topology/core_id" , cpu );
@@ -9641,6 +9662,7 @@ void topology_probe(bool startup)
96419662 * For online cpus
96429663 * find max_core_id, max_package_id, num_cores (per system)
96439664 */
9665+ topo .min_module_id = 0x7FFFFFFF ;
96449666 for (i = 0 ; i <= topo .max_cpu_num ; ++ i ) {
96459667 int siblings ;
96469668
@@ -9672,6 +9694,13 @@ void topology_probe(bool startup)
96729694 if (cpus [i ].physical_node_id > topo .max_node_num )
96739695 topo .max_node_num = cpus [i ].physical_node_id ;
96749696
9697+ /* get module information */
9698+ cpus [i ].module_id = get_module_id (i );
9699+ if (cpus [i ].module_id > topo .max_module_id )
9700+ topo .max_module_id = cpus [i ].module_id ;
9701+ if (cpus [i ].module_id < topo .min_module_id )
9702+ topo .min_module_id = cpus [i ].module_id ;
9703+
96759704 /* get core information */
96769705 cpus [i ].core_id = get_core_id (i );
96779706 if (cpus [i ].core_id > max_core_id )
@@ -9693,6 +9722,11 @@ void topology_probe(bool startup)
96939722 if (!summary_only )
96949723 BIC_PRESENT (BIC_Core );
96959724
9725+ if (debug > 1 )
9726+ fprintf (outf , "min_module_id %d max_module_id %d\n" , topo .min_module_id , topo .max_module_id );
9727+ if (!summary_only && (topo .min_module_id != topo .max_module_id ))
9728+ BIC_PRESENT (BIC_Module );
9729+
96969730 topo .num_die = topo .max_die_id + 1 ;
96979731 if (debug > 1 )
96989732 fprintf (outf , "max_die_id %d, sizing for %d die\n" , topo .max_die_id , topo .num_die );
@@ -9727,9 +9761,9 @@ void topology_probe(bool startup)
97279761 if (cpu_is_not_present (i ))
97289762 continue ;
97299763 fprintf (outf ,
9730- "cpu %d pkg %d die %d l3 %d node %d lnode %d core %d ht_id %d" ,
9764+ "cpu %d pkg %d die %d l3 %d node %d lnode %d module 0x%x core %d ht_id %d" ,
97319765 i , cpus [i ].package_id , cpus [i ].die_id , cpus [i ].l3_id ,
9732- cpus [i ].physical_node_id , cpus [i ].logical_node_id , cpus [i ].core_id , cpus [i ].ht_id );
9766+ cpus [i ].physical_node_id , cpus [i ].logical_node_id , cpus [i ].module_id , cpus [ i ]. core_id , cpus [i ].ht_id );
97339767 fprintf (outf , " siblings" );
97349768 for (ht_id = 0 ; ht_id <= MAX_HT_ID ; ++ ht_id )
97359769 fprintf (outf , " %d" , cpus [i ].ht_sibling_cpu_id [ht_id ]);
0 commit comments