@@ -202,6 +202,7 @@ struct msr_counter bic[] = {
202
202
{ 0x0 , "Die%c6" , NULL , 0 , 0 , 0 , NULL , 0 },
203
203
{ 0x0 , "SysWatt" , NULL , 0 , 0 , 0 , NULL , 0 },
204
204
{ 0x0 , "Sys_J" , NULL , 0 , 0 , 0 , NULL , 0 },
205
+ { 0x0 , "NMI" , NULL , 0 , 0 , 0 , NULL , 0 },
205
206
};
206
207
207
208
#define MAX_BIC (sizeof(bic) / sizeof(struct msr_counter))
@@ -266,12 +267,13 @@ struct msr_counter bic[] = {
266
267
#define BIC_Diec6 (1ULL << 58)
267
268
#define BIC_SysWatt (1ULL << 59)
268
269
#define BIC_Sys_J (1ULL << 60)
270
+ #define BIC_NMI (1ULL << 61)
269
271
270
272
#define BIC_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die )
271
273
#define BIC_THERMAL_PWR ( BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__)
272
274
#define BIC_FREQUENCY (BIC_Avg_MHz | BIC_Busy | BIC_Bzy_MHz | BIC_TSC_MHz | BIC_GFXMHz | BIC_GFXACTMHz | BIC_SAMMHz | BIC_SAMACTMHz | BIC_UNCORE_MHZ)
273
275
#define BIC_IDLE (BIC_Busy | BIC_sysfs | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc6 | BIC_Pkgpc2 | BIC_Pkgpc3 | BIC_Pkgpc6 | BIC_Pkgpc7 | BIC_Pkgpc8 | BIC_Pkgpc9 | BIC_Pkgpc10 | BIC_CPU_LPI | BIC_SYS_LPI | BIC_Mod_c6 | BIC_Totl_c0 | BIC_Any_c0 | BIC_GFX_c0 | BIC_CPUGFX | BIC_SAM_mc6 | BIC_Diec6)
274
- #define BIC_OTHER ( BIC_IRQ | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)
276
+ #define BIC_OTHER ( BIC_IRQ | BIC_NMI | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)
275
277
276
278
#define BIC_DISABLED_BY_DEFAULT (BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC | BIC_SysWatt | BIC_Sys_J)
277
279
@@ -1628,6 +1630,7 @@ struct thread_data {
1628
1630
unsigned long long c1 ;
1629
1631
unsigned long long instr_count ;
1630
1632
unsigned long long irq_count ;
1633
+ unsigned long long nmi_count ;
1631
1634
unsigned int smi_count ;
1632
1635
unsigned int cpu_id ;
1633
1636
unsigned int apic_id ;
@@ -1934,6 +1937,7 @@ struct timeval tv_even, tv_odd, tv_delta;
1934
1937
1935
1938
int * irq_column_2_cpu ; /* /proc/interrupts column numbers */
1936
1939
int * irqs_per_cpu ; /* indexed by cpu_num */
1940
+ int * nmi_per_cpu ; /* indexed by cpu_num */
1937
1941
1938
1942
void setup_all_buffers (bool startup );
1939
1943
@@ -2319,6 +2323,12 @@ void print_header(char *delim)
2319
2323
else
2320
2324
outp += sprintf (outp , "%sIRQ" , (printed ++ ? delim : "" ));
2321
2325
}
2326
+ if (DO_BIC (BIC_NMI )) {
2327
+ if (sums_need_wide_columns )
2328
+ outp += sprintf (outp , "%s NMI" , (printed ++ ? delim : "" ));
2329
+ else
2330
+ outp += sprintf (outp , "%sNMI" , (printed ++ ? delim : "" ));
2331
+ }
2322
2332
2323
2333
if (DO_BIC (BIC_SMI ))
2324
2334
outp += sprintf (outp , "%sSMI" , (printed ++ ? delim : "" ));
@@ -2605,6 +2615,8 @@ int dump_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p
2605
2615
2606
2616
if (DO_BIC (BIC_IRQ ))
2607
2617
outp += sprintf (outp , "IRQ: %lld\n" , t -> irq_count );
2618
+ if (DO_BIC (BIC_NMI ))
2619
+ outp += sprintf (outp , "IRQ: %lld\n" , t -> nmi_count );
2608
2620
if (DO_BIC (BIC_SMI ))
2609
2621
outp += sprintf (outp , "SMI: %d\n" , t -> smi_count );
2610
2622
@@ -2824,6 +2836,14 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
2824
2836
outp += sprintf (outp , "%s%lld" , (printed ++ ? delim : "" ), t -> irq_count );
2825
2837
}
2826
2838
2839
+ /* NMI */
2840
+ if (DO_BIC (BIC_NMI )) {
2841
+ if (sums_need_wide_columns )
2842
+ outp += sprintf (outp , "%s%8lld" , (printed ++ ? delim : "" ), t -> nmi_count );
2843
+ else
2844
+ outp += sprintf (outp , "%s%lld" , (printed ++ ? delim : "" ), t -> nmi_count );
2845
+ }
2846
+
2827
2847
/* SMI */
2828
2848
if (DO_BIC (BIC_SMI ))
2829
2849
outp += sprintf (outp , "%s%d" , (printed ++ ? delim : "" ), t -> smi_count );
@@ -3439,6 +3459,9 @@ int delta_thread(struct thread_data *new, struct thread_data *old, struct core_d
3439
3459
if (DO_BIC (BIC_IRQ ))
3440
3460
old -> irq_count = new -> irq_count - old -> irq_count ;
3441
3461
3462
+ if (DO_BIC (BIC_NMI ))
3463
+ old -> nmi_count = new -> nmi_count - old -> nmi_count ;
3464
+
3442
3465
if (DO_BIC (BIC_SMI ))
3443
3466
old -> smi_count = new -> smi_count - old -> smi_count ;
3444
3467
@@ -3519,6 +3542,7 @@ void clear_counters(struct thread_data *t, struct core_data *c, struct pkg_data
3519
3542
t -> instr_count = 0 ;
3520
3543
3521
3544
t -> irq_count = 0 ;
3545
+ t -> nmi_count = 0 ;
3522
3546
t -> smi_count = 0 ;
3523
3547
3524
3548
c -> c3 = 0 ;
@@ -3623,6 +3647,7 @@ int sum_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
3623
3647
average .threads .instr_count += t -> instr_count ;
3624
3648
3625
3649
average .threads .irq_count += t -> irq_count ;
3650
+ average .threads .nmi_count += t -> nmi_count ;
3626
3651
average .threads .smi_count += t -> smi_count ;
3627
3652
3628
3653
for (i = 0 , mp = sys .tp ; mp ; i ++ , mp = mp -> next ) {
@@ -3764,6 +3789,9 @@ void compute_average(struct thread_data *t, struct core_data *c, struct pkg_data
3764
3789
3765
3790
if (average .threads .irq_count > 9999999 )
3766
3791
sums_need_wide_columns = 1 ;
3792
+ if (average .threads .nmi_count > 9999999 )
3793
+ sums_need_wide_columns = 1 ;
3794
+
3767
3795
3768
3796
average .cores .c3 /= topo .allowed_cores ;
3769
3797
average .cores .c6 /= topo .allowed_cores ;
@@ -4620,6 +4648,8 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
4620
4648
4621
4649
if (DO_BIC (BIC_IRQ ))
4622
4650
t -> irq_count = irqs_per_cpu [cpu ];
4651
+ if (DO_BIC (BIC_NMI ))
4652
+ t -> nmi_count = nmi_per_cpu [cpu ];
4623
4653
4624
4654
get_cstate_counters (cpu , t , c , p );
4625
4655
@@ -5365,6 +5395,7 @@ void free_all_buffers(void)
5365
5395
5366
5396
free (irq_column_2_cpu );
5367
5397
free (irqs_per_cpu );
5398
+ free (nmi_per_cpu );
5368
5399
5369
5400
for (i = 0 ; i <= topo .max_cpu_num ; ++ i ) {
5370
5401
if (cpus [i ].put_ids )
@@ -5821,31 +5852,37 @@ int snapshot_proc_interrupts(void)
5821
5852
5822
5853
irq_column_2_cpu [column ] = cpu_number ;
5823
5854
irqs_per_cpu [cpu_number ] = 0 ;
5855
+ nmi_per_cpu [cpu_number ] = 0 ;
5824
5856
}
5825
5857
5826
5858
/* read /proc/interrupt count lines and sum up irqs per cpu */
5827
5859
while (1 ) {
5828
5860
int column ;
5829
5861
char buf [64 ];
5862
+ int this_row_is_nmi = 0 ;
5830
5863
5831
- retval = fscanf (fp , " %s:" , buf ); /* flush irq# "N:" */
5864
+ retval = fscanf (fp , " %s:" , buf ); /* irq# "N:" */
5832
5865
if (retval != 1 )
5833
5866
break ;
5834
5867
5868
+ if (strncmp (buf , "NMI" , strlen ("NMI" )) == 0 )
5869
+ this_row_is_nmi = 1 ;
5870
+
5835
5871
/* read the count per cpu */
5836
5872
for (column = 0 ; column < topo .num_cpus ; ++ column ) {
5837
5873
5838
5874
int cpu_number , irq_count ;
5839
5875
5840
5876
retval = fscanf (fp , " %d" , & irq_count );
5877
+
5841
5878
if (retval != 1 )
5842
5879
break ;
5843
5880
5844
5881
cpu_number = irq_column_2_cpu [column ];
5845
5882
irqs_per_cpu [cpu_number ] += irq_count ;
5846
-
5883
+ if (this_row_is_nmi )
5884
+ nmi_per_cpu [cpu_number ] += irq_count ;
5847
5885
}
5848
-
5849
5886
while (getc (fp ) != '\n' ) ; /* flush interrupt description */
5850
5887
5851
5888
}
@@ -5942,7 +5979,7 @@ int snapshot_sys_lpi_us(void)
5942
5979
*/
5943
5980
int snapshot_proc_sysfs_files (void )
5944
5981
{
5945
- if (DO_BIC (BIC_IRQ ))
5982
+ if (DO_BIC (BIC_IRQ ) || DO_BIC ( BIC_NMI ) )
5946
5983
if (snapshot_proc_interrupts ())
5947
5984
return 1 ;
5948
5985
@@ -8263,6 +8300,7 @@ void process_cpuid()
8263
8300
aperf_mperf_multiplier = platform -> need_perf_multiplier ? 1024 : 1 ;
8264
8301
8265
8302
BIC_PRESENT (BIC_IRQ );
8303
+ BIC_PRESENT (BIC_NMI );
8266
8304
BIC_PRESENT (BIC_TSC_MHz );
8267
8305
}
8268
8306
@@ -8613,7 +8651,11 @@ void allocate_irq_buffers(void)
8613
8651
8614
8652
irqs_per_cpu = calloc (topo .max_cpu_num + 1 , sizeof (int ));
8615
8653
if (irqs_per_cpu == NULL )
8616
- err (-1 , "calloc %d" , topo .max_cpu_num + 1 );
8654
+ err (-1 , "calloc %d IRQ" , topo .max_cpu_num + 1 );
8655
+
8656
+ nmi_per_cpu = calloc (topo .max_cpu_num + 1 , sizeof (int ));
8657
+ if (nmi_per_cpu == NULL )
8658
+ err (-1 , "calloc %d NMI" , topo .max_cpu_num + 1 );
8617
8659
}
8618
8660
8619
8661
int update_topo (struct thread_data * t , struct core_data * c , struct pkg_data * p )
0 commit comments