1 /***************************************************************************
2 HTinterrupt.c - description
4 email : sonic,zhang@intel.com
5 ***************************************************************************/
7 /***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 ***************************************************************************/
22 char *TCID
= "ht_interrupt";
25 #define INTERRUPT_NAME "/proc/interrupts"
27 int HT_InterruptDistribution()
34 tst_resm(TINFO
, "Get interrupts distribution with HT.");
36 if((cpucount
=get_cpu_count())<=0)
41 if((pFile
=fopen(INTERRUPT_NAME
, "r"))==NULL
)
46 fgets(buf
, 255, pFile
);
47 fscanf(pFile
, "%s %d %d %d %d %d %d %d %d \
48 %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \
49 %d %d %d %d %d %d %d %d", buf
, ci
, ci
+1, ci
+2, ci
+3,
50 ci
+4, ci
+5, ci
+6, ci
+7, ci
+8, ci
+9, ci
+10, ci
+11,
51 ci
+12, ci
+13, ci
+14, ci
+15, ci
+16, ci
+17, ci
+18, ci
+19,
52 ci
+20, ci
+21, ci
+22, ci
+23, ci
+24, ci
+25, ci
+26, ci
+27,
53 ci
+28, ci
+29, ci
+30, ci
+31);
63 if((pFile
=fopen(INTERRUPT_NAME
, "r"))==NULL
)
68 fgets(buf
, 255, pFile
);
69 fscanf(pFile
, "%s %d %d %d %d %d %d %d %d \
70 %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \
71 %d %d %d %d %d %d %d %d", buf
, cj
, cj
+1, cj
+2, cj
+3,
72 cj
+4, cj
+5, cj
+6, cj
+7, cj
+8, cj
+9, cj
+10, cj
+11,
73 cj
+12, cj
+13, cj
+14, cj
+15, cj
+16, cj
+17, cj
+18, cj
+19,
74 cj
+20, cj
+21, cj
+22, cj
+23, cj
+24, cj
+25, cj
+26, cj
+27,
75 cj
+28, cj
+29, cj
+30, cj
+31);
80 printf("Timer interrupt counts per CPU:\n");
84 for(i
=1;i
<cpucount
;i
++)
95 printf("max value: %d\n", cmax
);
96 printf("min value: %d\n", cmin
);
99 if(cmin
==0 || cmax
/cmin
>10)
109 // return 0 means Pass, return 1 means Fail.
110 int main(int argc
, char *argv
[])
112 tst_resm(TINFO
, "Begin: HyperThreading Interrupt");
115 tst_brkm(TCONF
, NULL
, "This test suite can only execute on i386 architecture.");
117 if (!check_ht_capability())
119 if(HT_InterruptDistribution())
120 tst_resm(TPASS
, "Interrupt distribution is balanceable.");
122 tst_resm(TFAIL
, "Interrupt distribution is not balanceable.");
126 tst_brkm(TCONF
, NULL
, "HT is not enabled or not supported.");
130 tst_resm(TINFO
, "End: HyperThreading Interrupt");