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

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

Version: ~ [ linux-5.2-rc1 ] ~ [ linux-5.1.2 ] ~ [ linux-5.0.16 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.43 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.119 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.176 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.179 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.139 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.67 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ 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 /*
  2  * Copyright 2014, Michael Ellerman, IBM Corp.
  3  * Licensed under GPLv2.
  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 we can setup an EBB on our child. Nothing interesting happens, because
 19  * even though the event is enabled and running the child hasn't enabled the
 20  * actual delivery of the EBBs.
 21  */
 22 
 23 static int victim_child(union pipe read_pipe, union pipe write_pipe)
 24 {
 25         int i;
 26 
 27         FAIL_IF(wait_for_parent(read_pipe));
 28         FAIL_IF(notify_parent(write_pipe));
 29 
 30         /* Parent creates EBB event */
 31 
 32         FAIL_IF(wait_for_parent(read_pipe));
 33         FAIL_IF(notify_parent(write_pipe));
 34 
 35         /* Check the EBB is enabled by writing PMC1 */
 36         write_pmc1();
 37 
 38         /* EBB event is enabled here */
 39         for (i = 0; i < 1000000; i++) ;
 40 
 41         return 0;
 42 }
 43 
 44 int ebb_on_child(void)
 45 {
 46         union pipe read_pipe, write_pipe;
 47         struct event event;
 48         pid_t pid;
 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(victim_child(write_pipe, read_pipe));
 57         }
 58 
 59         FAIL_IF(sync_with_child(read_pipe, write_pipe));
 60 
 61         /* Child is running now */
 62 
 63         event_init_named(&event, 0x1001e, "cycles");
 64         event_leader_ebb_init(&event);
 65 
 66         event.attr.exclude_kernel = 1;
 67         event.attr.exclude_hv = 1;
 68         event.attr.exclude_idle = 1;
 69 
 70         FAIL_IF(event_open_with_pid(&event, pid));
 71         FAIL_IF(ebb_event_enable(&event));
 72 
 73         FAIL_IF(sync_with_child(read_pipe, write_pipe));
 74 
 75         /* Child should just exit happily */
 76         FAIL_IF(wait_for_child(pid));
 77 
 78         event_close(&event);
 79 
 80         return 0;
 81 }
 82 
 83 int main(void)
 84 {
 85         return test_harness(ebb_on_child, "ebb_on_child");
 86 }
 87 

~ [ 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