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

TOMOYO Linux Cross Reference
Linux/tools/perf/builtin-kvm.c

Version: ~ [ linux-5.5-rc7 ] ~ [ linux-5.4.13 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.97 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.166 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.210 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.210 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ 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.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 #include "builtin.h"
  2 #include "perf.h"
  3 
  4 #include "util/util.h"
  5 #include "util/cache.h"
  6 #include "util/symbol.h"
  7 #include "util/thread.h"
  8 #include "util/header.h"
  9 #include "util/session.h"
 10 
 11 #include "util/parse-options.h"
 12 #include "util/trace-event.h"
 13 
 14 #include "util/debug.h"
 15 
 16 #include <sys/prctl.h>
 17 
 18 #include <semaphore.h>
 19 #include <pthread.h>
 20 #include <math.h>
 21 
 22 static const char               *file_name;
 23 static char                     name_buffer[256];
 24 
 25 bool                            perf_host = 1;
 26 bool                            perf_guest;
 27 
 28 static const char * const kvm_usage[] = {
 29         "perf kvm [<options>] {top|record|report|diff|buildid-list}",
 30         NULL
 31 };
 32 
 33 static const struct option kvm_options[] = {
 34         OPT_STRING('i', "input", &file_name, "file",
 35                    "Input file name"),
 36         OPT_STRING('o', "output", &file_name, "file",
 37                    "Output file name"),
 38         OPT_BOOLEAN(0, "guest", &perf_guest,
 39                     "Collect guest os data"),
 40         OPT_BOOLEAN(0, "host", &perf_host,
 41                     "Collect guest os data"),
 42         OPT_STRING(0, "guestmount", &symbol_conf.guestmount, "directory",
 43                    "guest mount directory under which every guest os"
 44                    " instance has a subdir"),
 45         OPT_STRING(0, "guestvmlinux", &symbol_conf.default_guest_vmlinux_name,
 46                    "file", "file saving guest os vmlinux"),
 47         OPT_STRING(0, "guestkallsyms", &symbol_conf.default_guest_kallsyms,
 48                    "file", "file saving guest os /proc/kallsyms"),
 49         OPT_STRING(0, "guestmodules", &symbol_conf.default_guest_modules,
 50                    "file", "file saving guest os /proc/modules"),
 51         OPT_END()
 52 };
 53 
 54 static int __cmd_record(int argc, const char **argv)
 55 {
 56         int rec_argc, i = 0, j;
 57         const char **rec_argv;
 58 
 59         rec_argc = argc + 2;
 60         rec_argv = calloc(rec_argc + 1, sizeof(char *));
 61         rec_argv[i++] = strdup("record");
 62         rec_argv[i++] = strdup("-o");
 63         rec_argv[i++] = strdup(file_name);
 64         for (j = 1; j < argc; j++, i++)
 65                 rec_argv[i] = argv[j];
 66 
 67         BUG_ON(i != rec_argc);
 68 
 69         return cmd_record(i, rec_argv, NULL);
 70 }
 71 
 72 static int __cmd_report(int argc, const char **argv)
 73 {
 74         int rec_argc, i = 0, j;
 75         const char **rec_argv;
 76 
 77         rec_argc = argc + 2;
 78         rec_argv = calloc(rec_argc + 1, sizeof(char *));
 79         rec_argv[i++] = strdup("report");
 80         rec_argv[i++] = strdup("-i");
 81         rec_argv[i++] = strdup(file_name);
 82         for (j = 1; j < argc; j++, i++)
 83                 rec_argv[i] = argv[j];
 84 
 85         BUG_ON(i != rec_argc);
 86 
 87         return cmd_report(i, rec_argv, NULL);
 88 }
 89 
 90 static int __cmd_buildid_list(int argc, const char **argv)
 91 {
 92         int rec_argc, i = 0, j;
 93         const char **rec_argv;
 94 
 95         rec_argc = argc + 2;
 96         rec_argv = calloc(rec_argc + 1, sizeof(char *));
 97         rec_argv[i++] = strdup("buildid-list");
 98         rec_argv[i++] = strdup("-i");
 99         rec_argv[i++] = strdup(file_name);
100         for (j = 1; j < argc; j++, i++)
101                 rec_argv[i] = argv[j];
102 
103         BUG_ON(i != rec_argc);
104 
105         return cmd_buildid_list(i, rec_argv, NULL);
106 }
107 
108 int cmd_kvm(int argc, const char **argv, const char *prefix __used)
109 {
110         perf_host = perf_guest = 0;
111 
112         argc = parse_options(argc, argv, kvm_options, kvm_usage,
113                         PARSE_OPT_STOP_AT_NON_OPTION);
114         if (!argc)
115                 usage_with_options(kvm_usage, kvm_options);
116 
117         if (!perf_host)
118                 perf_guest = 1;
119 
120         if (!file_name) {
121                 if (perf_host && !perf_guest)
122                         sprintf(name_buffer, "perf.data.host");
123                 else if (!perf_host && perf_guest)
124                         sprintf(name_buffer, "perf.data.guest");
125                 else
126                         sprintf(name_buffer, "perf.data.kvm");
127                 file_name = name_buffer;
128         }
129 
130         if (!strncmp(argv[0], "rec", 3))
131                 return __cmd_record(argc, argv);
132         else if (!strncmp(argv[0], "rep", 3))
133                 return __cmd_report(argc, argv);
134         else if (!strncmp(argv[0], "diff", 4))
135                 return cmd_diff(argc, argv, NULL);
136         else if (!strncmp(argv[0], "top", 3))
137                 return cmd_top(argc, argv, NULL);
138         else if (!strncmp(argv[0], "buildid-list", 12))
139                 return __cmd_buildid_list(argc, argv);
140         else
141                 usage_with_options(kvm_usage, kvm_options);
142 
143         return 0;
144 }
145 

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