~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/powerpc/pmu/ebb/cpu_event_vs_ebb_test.c

Version: ~ [ linux-5.13-rc5 ] ~ [ linux-5.12.9 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.42 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.124 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.193 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.235 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.271 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.271 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright 2014, Michael Ellerman, IBM Corp.
  4  */
  5 
  6 #include <signal.h>
  7 #include <stdio.h>
  8 #include <stdlib.h>
  9 #include <stdbool.h>
 10 #include <sys/types.h>
 11 #include <sys/wait.h>
 12 #include <unistd.h>
 13 
 14 #include "ebb.h"
 15 
 16 
 17 /*
 18  * Tests a cpu event vs an EBB - in that order. The EBB should force the cpu
 19  * event off the PMU.
 20  */
 21 
 22 static int setup_cpu_event(struct event *event, int cpu)
 23 {
 24         event_init_named(event, 0x400FA, "PM_RUN_INST_CMPL");
 25 
 26         event->attr.exclude_kernel = 1;
 27         event->attr.exclude_hv = 1;
 28         event->attr.exclude_idle = 1;
 29 
 30         SKIP_IF(require_paranoia_below(1));
 31         FAIL_IF(event_open_with_cpu(event, cpu));
 32         FAIL_IF(event_enable(event));
 33 
 34         return 0;
 35 }
 36 
 37 int cpu_event_vs_ebb(void)
 38 {
 39         union pipe read_pipe, write_pipe;
 40         struct event event;
 41         int cpu, rc;
 42         pid_t pid;
 43 
 44         SKIP_IF(!ebb_is_supported());
 45 
 46         cpu = pick_online_cpu();
 47         FAIL_IF(cpu < 0);
 48         FAIL_IF(bind_to_cpu(cpu));
 49 
 50         FAIL_IF(pipe(read_pipe.fds) == -1);
 51         FAIL_IF(pipe(write_pipe.fds) == -1);
 52 
 53         pid = fork();
 54         if (pid == 0) {
 55                 /* NB order of pipes looks reversed */
 56                 exit(ebb_child(write_pipe, read_pipe));
 57         }
 58 
 59         /* We setup the cpu event first */
 60         rc = setup_cpu_event(&event, cpu);
 61         if (rc) {
 62                 kill_child_and_wait(pid);
 63                 return rc;
 64         }
 65 
 66         /* Signal the child to install its EBB event and wait */
 67         if (sync_with_child(read_pipe, write_pipe))
 68                 /* If it fails, wait for it to exit */
 69                 goto wait;
 70 
 71         /* Signal the child to run */
 72         FAIL_IF(sync_with_child(read_pipe, write_pipe));
 73 
 74 wait:
 75         /* We expect the child to succeed */
 76         FAIL_IF(wait_for_child(pid));
 77 
 78         FAIL_IF(event_disable(&event));
 79         FAIL_IF(event_read(&event));
 80 
 81         event_report(&event);
 82 
 83         /* The cpu event may have run */
 84 
 85         return 0;
 86 }
 87 
 88 int main(void)
 89 {
 90         return test_harness(cpu_event_vs_ebb, "cpu_event_vs_ebb");
 91 }
 92 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp