@@ -92,7 +92,11 @@ int fill_string_with_spaces(char *s, int n)
92
92
return 0 ;
93
93
}
94
94
95
- #define MAX_COL_WIDTH 6
95
+ #define MAX_COL_WIDTH 6
96
+ #define TOPOLOGY_DEPTH_PKG 3
97
+ #define TOPOLOGY_DEPTH_CORE 2
98
+ #define TOPOLOGY_DEPTH_CPU 1
99
+
96
100
void print_header (int topology_depth )
97
101
{
98
102
int unsigned mon ;
@@ -114,12 +118,19 @@ void print_header(int topology_depth)
114
118
}
115
119
printf ("\n" );
116
120
117
- if (topology_depth > 2 )
121
+ switch (topology_depth ) {
122
+ case TOPOLOGY_DEPTH_PKG :
118
123
printf (" PKG|" );
119
- if (topology_depth > 1 )
124
+ break ;
125
+ case TOPOLOGY_DEPTH_CORE :
120
126
printf ("CORE|" );
121
- if (topology_depth > 0 )
127
+ break ;
128
+ case TOPOLOGY_DEPTH_CPU :
122
129
printf (" CPU|" );
130
+ break ;
131
+ default :
132
+ return ;
133
+ }
123
134
124
135
for (mon = 0 ; mon < avail_monitors ; mon ++ ) {
125
136
if (mon != 0 )
@@ -153,12 +164,19 @@ void print_results(int topology_depth, int cpu)
153
164
cpu_top .core_info [cpu ].pkg == -1 )
154
165
return ;
155
166
156
- if (topology_depth > 2 )
167
+ switch (topology_depth ) {
168
+ case TOPOLOGY_DEPTH_PKG :
157
169
printf ("%4d|" , cpu_top .core_info [cpu ].pkg );
158
- if (topology_depth > 1 )
170
+ break ;
171
+ case TOPOLOGY_DEPTH_CORE :
159
172
printf ("%4d|" , cpu_top .core_info [cpu ].core );
160
- if (topology_depth > 0 )
173
+ break ;
174
+ case TOPOLOGY_DEPTH_CPU :
161
175
printf ("%4d|" , cpu_top .core_info [cpu ].cpu );
176
+ break ;
177
+ default :
178
+ return ;
179
+ }
162
180
163
181
for (mon = 0 ; mon < avail_monitors ; mon ++ ) {
164
182
if (mon != 0 )
@@ -454,15 +472,15 @@ int cmd_monitor(int argc, char **argv)
454
472
/* ToDo: Topology parsing needs fixing first to do
455
473
this more generically */
456
474
if (cpu_top .pkgs > 1 )
457
- print_header (3 );
475
+ print_header (TOPOLOGY_DEPTH_PKG );
458
476
else
459
- print_header (1 );
477
+ print_header (TOPOLOGY_DEPTH_CPU );
460
478
461
479
for (cpu = 0 ; cpu < cpu_count ; cpu ++ ) {
462
480
if (cpu_top .pkgs > 1 )
463
- print_results (3 , cpu );
481
+ print_results (TOPOLOGY_DEPTH_PKG , cpu );
464
482
else
465
- print_results (1 , cpu );
483
+ print_results (TOPOLOGY_DEPTH_CPU , cpu );
466
484
}
467
485
468
486
for (num = 0 ; num < avail_monitors ; num ++ ) {
0 commit comments