2 * Copyright 2014, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
10 #include <sys/types.h>
18 * Tests a pinned cpu event vs an EBB - in that order. The pinned cpu event
19 * should remain and the EBB event should fail to enable.
22 static int setup_cpu_event(struct event *event, int cpu)
24 event_init_named(event, 0x400FA, "PM_RUN_INST_CMPL");
26 event->attr.pinned = 1;
28 event->attr.exclude_kernel = 1;
29 event->attr.exclude_hv = 1;
30 event->attr.exclude_idle = 1;
32 SKIP_IF(require_paranoia_below(1));
33 FAIL_IF(event_open_with_cpu(event, cpu));
34 FAIL_IF(event_enable(event));
39 int cpu_event_pinned_vs_ebb(void)
41 union pipe read_pipe, write_pipe;
46 SKIP_IF(!ebb_is_supported());
48 cpu = pick_online_cpu();
50 FAIL_IF(bind_to_cpu(cpu));
52 FAIL_IF(pipe(read_pipe.fds) == -1);
53 FAIL_IF(pipe(write_pipe.fds) == -1);
57 /* NB order of pipes looks reversed */
58 exit(ebb_child(write_pipe, read_pipe));
61 /* We setup the cpu event first */
62 rc = setup_cpu_event(&event, cpu);
64 kill_child_and_wait(pid);
68 /* Signal the child to install its EBB event and wait */
69 if (sync_with_child(read_pipe, write_pipe))
70 /* If it fails, wait for it to exit */
73 /* Signal the child to run */
74 FAIL_IF(sync_with_child(read_pipe, write_pipe));
77 /* We expect it to fail to read the event */
78 FAIL_IF(wait_for_child(pid) != 2);
80 FAIL_IF(event_disable(&event));
81 FAIL_IF(event_read(&event));
85 /* The cpu event should have run */
86 FAIL_IF(event.result.value == 0);
87 FAIL_IF(event.result.enabled != event.result.running);
94 return test_harness(cpu_event_pinned_vs_ebb, "cpu_event_pinned_vs_ebb");