0001
0002
0003
0004
0005
0006 #include <sched.h>
0007 #include <signal.h>
0008 #include <stdio.h>
0009 #include <stdlib.h>
0010 #include <sys/mman.h>
0011
0012 #include "ebb.h"
0013
0014
0015
0016
0017
0018
0019
0020
0021 static int test_body(void)
0022 {
0023 int i, orig_period, max_period;
0024 struct event event;
0025
0026 SKIP_IF(!ebb_is_supported());
0027
0028
0029 event_init_named(&event, 0x40002, "instructions");
0030 event_leader_ebb_init(&event);
0031
0032 event.attr.exclude_kernel = 1;
0033 event.attr.exclude_hv = 1;
0034 event.attr.exclude_idle = 1;
0035
0036 FAIL_IF(event_open(&event));
0037
0038 ebb_enable_pmc_counting(4);
0039 setup_ebb_handler(standard_ebb_callee);
0040 ebb_global_enable();
0041 FAIL_IF(ebb_event_enable(&event));
0042
0043
0044
0045
0046
0047
0048
0049 orig_period = max_period = sample_period = 400;
0050
0051 mtspr(SPRN_PMC4, pmc_sample_period(sample_period));
0052
0053 while (ebb_state.stats.ebb_count < 1000000) {
0054
0055
0056
0057
0058
0059
0060
0061
0062 for (i = 0; i < 100000; i++)
0063 sched_yield();
0064
0065
0066 if (sample_period >= (orig_period + 200))
0067 sample_period = orig_period;
0068 else
0069 sample_period++;
0070
0071 if (sample_period > max_period)
0072 max_period = sample_period;
0073 }
0074
0075 ebb_freeze_pmcs();
0076 ebb_global_disable();
0077
0078 mtspr(SPRN_PMC4, 0xdead);
0079
0080 dump_summary_ebb_state();
0081 dump_ebb_hw_state();
0082
0083 event_close(&event);
0084
0085 FAIL_IF(ebb_state.stats.ebb_count == 0);
0086
0087
0088 FAIL_IF(!ebb_check_count(4, orig_period, 2 * (max_period - orig_period)));
0089
0090 return 0;
0091 }
0092
0093 static int lost_exception(void)
0094 {
0095 return eat_cpu(test_body);
0096 }
0097
0098 int main(void)
0099 {
0100 test_harness_set_timeout(300);
0101 return test_harness(lost_exception, "lost_exception");
0102 }