2 * Copyright 2014, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
14 * Test counting multiple events using EBBs.
16 int multi_counter(void)
18 struct event events[6];
21 event_init_named(&events[0], 0x1001C, "PM_CMPLU_STALL_THRD");
22 event_init_named(&events[1], 0x2D016, "PM_CMPLU_STALL_FXU");
23 event_init_named(&events[2], 0x30006, "PM_CMPLU_STALL_OTHER_CMPL");
24 event_init_named(&events[3], 0x4000A, "PM_CMPLU_STALL");
25 event_init_named(&events[4], 0x600f4, "PM_RUN_CYC");
26 event_init_named(&events[5], 0x500fa, "PM_RUN_INST_CMPL");
28 event_leader_ebb_init(&events[0]);
29 for (i = 1; i < 6; i++)
30 event_ebb_init(&events[i]);
33 for (i = 0; i < 6; i++) {
34 events[i].attr.exclude_kernel = 1;
35 events[i].attr.exclude_hv = 1;
36 events[i].attr.exclude_idle = 1;
38 FAIL_IF(event_open_with_group(&events[i], group_fd));
40 group_fd = events[0].fd;
43 ebb_enable_pmc_counting(1);
44 ebb_enable_pmc_counting(2);
45 ebb_enable_pmc_counting(3);
46 ebb_enable_pmc_counting(4);
47 ebb_enable_pmc_counting(5);
48 ebb_enable_pmc_counting(6);
49 setup_ebb_handler(standard_ebb_callee);
51 FAIL_IF(ioctl(events[0].fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP));
52 FAIL_IF(event_read(&events[0]));
56 mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
57 mtspr(SPRN_PMC2, pmc_sample_period(sample_period));
58 mtspr(SPRN_PMC3, pmc_sample_period(sample_period));
59 mtspr(SPRN_PMC4, pmc_sample_period(sample_period));
60 mtspr(SPRN_PMC5, pmc_sample_period(sample_period));
61 mtspr(SPRN_PMC6, pmc_sample_period(sample_period));
63 while (ebb_state.stats.ebb_count < 50) {
64 FAIL_IF(core_busy_loop());
65 FAIL_IF(ebb_check_mmcr0());
71 count_pmc(1, sample_period);
72 count_pmc(2, sample_period);
73 count_pmc(3, sample_period);
74 count_pmc(4, sample_period);
75 count_pmc(5, sample_period);
76 count_pmc(6, sample_period);
80 for (i = 0; i < 6; i++)
81 event_close(&events[i]);
83 FAIL_IF(ebb_state.stats.ebb_count == 0);
90 return test_harness(multi_counter, "multi_counter");