2 * Copyright 2014, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
15 * Test running multiple EBB using processes at once on a single CPU. They
16 * should all run happily without interfering with each other.
19 static bool child_should_exit;
21 static void sigint_handler(int signal)
23 child_should_exit = true;
26 struct sigaction sigint_action = {
27 .sa_handler = sigint_handler,
30 static int cycles_child(void)
34 if (sigaction(SIGINT, &sigint_action, NULL)) {
39 event_init_named(&event, 0x1001e, "cycles");
40 event_leader_ebb_init(&event);
42 event.attr.exclude_kernel = 1;
43 event.attr.exclude_hv = 1;
44 event.attr.exclude_idle = 1;
46 FAIL_IF(event_open(&event));
48 ebb_enable_pmc_counting(1);
49 setup_ebb_handler(standard_ebb_callee);
52 FAIL_IF(ebb_event_enable(&event));
54 mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
56 while (!child_should_exit) {
57 FAIL_IF(core_busy_loop());
58 FAIL_IF(ebb_check_mmcr0());
64 dump_summary_ebb_state();
68 FAIL_IF(ebb_state.stats.ebb_count == 0);
75 int multi_ebb_procs(void)
77 pid_t pids[NR_CHILDREN];
80 SKIP_IF(!ebb_is_supported());
82 cpu = pick_online_cpu();
84 FAIL_IF(bind_to_cpu(cpu));
86 for (i = 0; i < NR_CHILDREN; i++) {
92 /* Have them all run for "a while" */
96 for (i = 0; i < NR_CHILDREN; i++) {
97 /* Tell them to stop */
98 kill(pids[i], SIGINT);
100 rc |= wait_for_child(pids[i]);
108 return test_harness(multi_ebb_procs, "multi_ebb_procs");