2 * Copyright 2014, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
10 #include <sys/types.h>
18 * Tests we can setup an EBB on our child. The child expects this and enables
19 * EBBs, which are then delivered to the child, even though the event is
20 * created by the parent.
23 static int victim_child(union pipe read_pipe, union pipe write_pipe)
25 FAIL_IF(wait_for_parent(read_pipe));
27 /* Setup our EBB handler, before the EBB event is created */
28 ebb_enable_pmc_counting(1);
29 setup_ebb_handler(standard_ebb_callee);
32 FAIL_IF(notify_parent(write_pipe));
34 while (ebb_state.stats.ebb_count < 20) {
35 FAIL_IF(core_busy_loop());
43 FAIL_IF(ebb_state.stats.ebb_count == 0);
48 /* Tests we can setup an EBB on our child - if it's expecting it */
49 int ebb_on_willing_child(void)
51 union pipe read_pipe, write_pipe;
55 SKIP_IF(!ebb_is_supported());
57 FAIL_IF(pipe(read_pipe.fds) == -1);
58 FAIL_IF(pipe(write_pipe.fds) == -1);
62 /* NB order of pipes looks reversed */
63 exit(victim_child(write_pipe, read_pipe));
66 /* Signal the child to setup its EBB handler */
67 FAIL_IF(sync_with_child(read_pipe, write_pipe));
69 /* Child is running now */
71 event_init_named(&event, 0x1001e, "cycles");
72 event_leader_ebb_init(&event);
74 event.attr.exclude_kernel = 1;
75 event.attr.exclude_hv = 1;
76 event.attr.exclude_idle = 1;
78 FAIL_IF(event_open_with_pid(&event, pid));
79 FAIL_IF(ebb_event_enable(&event));
81 /* Child show now take EBBs and then exit */
82 FAIL_IF(wait_for_child(pid));
91 return test_harness(ebb_on_willing_child, "ebb_on_willing_child");