This source file includes following definitions.
- test_body
- lost_exception
- main
1
2
3
4
5
6 #include <sched.h>
7 #include <signal.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <sys/mman.h>
11
12 #include "ebb.h"
13
14
15
16
17
18
19
20
21 static int test_body(void)
22 {
23 int i, orig_period, max_period;
24 struct event event;
25
26 SKIP_IF(!ebb_is_supported());
27
28
29 event_init_named(&event, 0x40002, "instructions");
30 event_leader_ebb_init(&event);
31
32 event.attr.exclude_kernel = 1;
33 event.attr.exclude_hv = 1;
34 event.attr.exclude_idle = 1;
35
36 FAIL_IF(event_open(&event));
37
38 ebb_enable_pmc_counting(4);
39 setup_ebb_handler(standard_ebb_callee);
40 ebb_global_enable();
41 FAIL_IF(ebb_event_enable(&event));
42
43
44
45
46
47
48
49 orig_period = max_period = sample_period = 400;
50
51 mtspr(SPRN_PMC4, pmc_sample_period(sample_period));
52
53 while (ebb_state.stats.ebb_count < 1000000) {
54
55
56
57
58
59
60
61
62 for (i = 0; i < 100000; i++)
63 sched_yield();
64
65
66 if (sample_period >= (orig_period + 200))
67 sample_period = orig_period;
68 else
69 sample_period++;
70
71 if (sample_period > max_period)
72 max_period = sample_period;
73 }
74
75 ebb_freeze_pmcs();
76 ebb_global_disable();
77
78 count_pmc(4, sample_period);
79 mtspr(SPRN_PMC4, 0xdead);
80
81 dump_summary_ebb_state();
82 dump_ebb_hw_state();
83
84 event_close(&event);
85
86 FAIL_IF(ebb_state.stats.ebb_count == 0);
87
88
89 FAIL_IF(!ebb_check_count(4, orig_period, 2 * (max_period - orig_period)));
90
91 return 0;
92 }
93
94 static int lost_exception(void)
95 {
96 return eat_cpu(test_body);
97 }
98
99 int main(void)
100 {
101 test_harness_set_timeout(300);
102 return test_harness(lost_exception, "lost_exception");
103 }