diff --git a/[refs] b/[refs] index 3acd1833717a..ed830b040752 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 84b13fd596522db47f9545d5124c30cc00dfdf5a +refs/heads/master: fcd1498405c2c88ac632e7c3c3fce3213d9196db diff --git a/trunk/kernel/perf_event.c b/trunk/kernel/perf_event.c index 07b7a435bf03..095101d685bc 100644 --- a/trunk/kernel/perf_event.c +++ b/trunk/kernel/perf_event.c @@ -4313,6 +4313,36 @@ static const struct pmu perf_ops_task_clock = { .read = task_clock_perf_event_read, }; +#ifdef CONFIG_EVENT_TRACING + +void perf_tp_event(int event_id, u64 addr, u64 count, void *record, + int entry_size, struct pt_regs *regs) +{ + struct perf_sample_data data; + struct perf_raw_record raw = { + .size = entry_size, + .data = record, + }; + + perf_sample_data_init(&data, addr); + data.raw = &raw; + + /* Trace events already protected against recursion */ + do_perf_sw_event(PERF_TYPE_TRACEPOINT, event_id, count, 1, + &data, regs); +} +EXPORT_SYMBOL_GPL(perf_tp_event); + +static int perf_tp_event_match(struct perf_event *event, + struct perf_sample_data *data) +{ + void *record = data->raw->data; + + if (likely(!event->filter) || filter_match_preds(event->filter, record)) + return 1; + return 0; +} + static void swevent_hlist_release_rcu(struct rcu_head *rcu_head) { struct swevent_hlist *hlist; @@ -4412,36 +4442,6 @@ static int swevent_hlist_get(struct perf_event *event) return err; } -#ifdef CONFIG_EVENT_TRACING - -void perf_tp_event(int event_id, u64 addr, u64 count, void *record, - int entry_size, struct pt_regs *regs) -{ - struct perf_sample_data data; - struct perf_raw_record raw = { - .size = entry_size, - .data = record, - }; - - perf_sample_data_init(&data, addr); - data.raw = &raw; - - /* Trace events already protected against recursion */ - do_perf_sw_event(PERF_TYPE_TRACEPOINT, event_id, count, 1, - &data, regs); -} -EXPORT_SYMBOL_GPL(perf_tp_event); - -static int perf_tp_event_match(struct perf_event *event, - struct perf_sample_data *data) -{ - void *record = data->raw->data; - - if (likely(!event->filter) || filter_match_preds(event->filter, record)) - return 1; - return 0; -} - static void tp_perf_event_destroy(struct perf_event *event) { perf_trace_disable(event->attr.config); diff --git a/trunk/tools/perf/Documentation/perf-record.txt b/trunk/tools/perf/Documentation/perf-record.txt index 020d871c7934..fc46c0b40f6e 100644 --- a/trunk/tools/perf/Documentation/perf-record.txt +++ b/trunk/tools/perf/Documentation/perf-record.txt @@ -58,7 +58,7 @@ OPTIONS -f:: --force:: - Overwrite existing data file. (deprecated) + Overwrite existing data file. -c:: --count=:: @@ -101,7 +101,7 @@ OPTIONS -R:: --raw-samples:: -Collect raw sample records from all opened counters (default for tracepoint counters). +Collect raw sample records from all opened counters (typically for tracepoint counters). SEE ALSO -------- diff --git a/trunk/tools/perf/builtin-record.c b/trunk/tools/perf/builtin-record.c index a1b99eeac3c0..9a9513687235 100644 --- a/trunk/tools/perf/builtin-record.c +++ b/trunk/tools/perf/builtin-record.c @@ -26,23 +26,15 @@ #include #include -enum write_mode_t { - WRITE_FORCE, - WRITE_APPEND -}; - static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; -static unsigned int user_interval = UINT_MAX; static long default_interval = 0; static int nr_cpus = 0; static unsigned int page_size; static unsigned int mmap_pages = 128; -static unsigned int user_freq = UINT_MAX; static int freq = 1000; static int output; -static int pipe_output = 0; static const char *output_name = "perf.data"; static int group = 0; static unsigned int realtime_prio = 0; @@ -55,7 +47,8 @@ static pid_t *all_tids = NULL; static int thread_num = 0; static pid_t child_pid = -1; static bool inherit = true; -static enum write_mode_t write_mode = WRITE_FORCE; +static bool force = false; +static bool append_file = false; static bool call_graph = false; static bool inherit_stat = false; static bool no_samples = false; @@ -110,11 +103,6 @@ static void mmap_write_tail(struct mmap_data *md, unsigned long tail) pc->data_tail = tail; } -static void advance_output(size_t size) -{ - bytes_written += size; -} - static void write_output(void *buf, size_t size) { while (size) { @@ -263,19 +251,10 @@ static void create_counter(int counter, int cpu) if (nr_counters > 1) attr->sample_type |= PERF_SAMPLE_ID; - /* - * We default some events to a 1 default interval. But keep - * it a weak assumption overridable by the user. - */ - if (!attr->sample_period || (user_freq != UINT_MAX && - user_interval != UINT_MAX)) { - if (freq) { - attr->sample_type |= PERF_SAMPLE_PERIOD; - attr->freq = 1; - attr->sample_freq = freq; - } else { - attr->sample_period = default_interval; - } + if (freq) { + attr->sample_type |= PERF_SAMPLE_PERIOD; + attr->freq = 1; + attr->sample_freq = freq; } if (no_samples) @@ -441,19 +420,10 @@ static int process_buildids(void) static void atexit_header(void) { - if (!pipe_output) { - session->header.data_size += bytes_written; - - process_buildids(); - perf_header__write(&session->header, output, true); - } else { - int err; + session->header.data_size += bytes_written; - err = event__synthesize_build_ids(process_synthesized_event, - session); - if (err < 0) - pr_err("Couldn't synthesize build ids.\n"); - } + process_buildids(); + perf_header__write(&session->header, output, true); } static int __cmd_record(int argc, const char **argv) @@ -479,44 +449,45 @@ static int __cmd_record(int argc, const char **argv) exit(-1); } - if (!strcmp(output_name, "-")) - pipe_output = 1; - else if (!stat(output_name, &st) && st.st_size) { - if (write_mode == WRITE_FORCE) { + if (!stat(output_name, &st) && st.st_size) { + if (!force) { + if (!append_file) { + pr_err("Error, output file %s exists, use -A " + "to append or -f to overwrite.\n", + output_name); + exit(-1); + } + } else { char oldname[PATH_MAX]; snprintf(oldname, sizeof(oldname), "%s.old", output_name); unlink(oldname); rename(output_name, oldname); } - } else if (write_mode == WRITE_APPEND) { - write_mode = WRITE_FORCE; + } else { + append_file = false; } flags = O_CREAT|O_RDWR; - if (write_mode == WRITE_APPEND) + if (append_file) file_new = 0; else flags |= O_TRUNC; - if (pipe_output) - output = STDOUT_FILENO; - else - output = open(output_name, flags, S_IRUSR | S_IWUSR); + output = open(output_name, flags, S_IRUSR|S_IWUSR); if (output < 0) { perror("failed to create output file"); exit(-1); } - session = perf_session__new(output_name, O_WRONLY, - write_mode == WRITE_FORCE); + session = perf_session__new(output_name, O_WRONLY, force); if (session == NULL) { pr_err("Not enough memory for reading perf file header\n"); return -1; } if (!file_new) { - err = perf_header__read(session, output); + err = perf_header__read(&session->header, output); if (err < 0) return err; } @@ -542,8 +513,6 @@ static int __cmd_record(int argc, const char **argv) } if (!child_pid) { - if (pipe_output) - dup2(2, 1); close(child_ready_pipe[0]); close(go_pipe[1]); fcntl(go_pipe[0], F_SETFD, FD_CLOEXEC); @@ -595,11 +564,7 @@ static int __cmd_record(int argc, const char **argv) open_counters(cpumap[i]); } - if (pipe_output) { - err = perf_header__write_pipe(output); - if (err < 0) - return err; - } else if (file_new) { + if (file_new) { err = perf_header__write(&session->header, output, false); if (err < 0) return err; @@ -607,34 +572,6 @@ static int __cmd_record(int argc, const char **argv) post_processing_offset = lseek(output, 0, SEEK_CUR); - if (pipe_output) { - err = event__synthesize_attrs(&session->header, - process_synthesized_event, - session); - if (err < 0) { - pr_err("Couldn't synthesize attrs.\n"); - return err; - } - - err = event__synthesize_event_types(process_synthesized_event, - session); - if (err < 0) { - pr_err("Couldn't synthesize event_types.\n"); - return err; - } - - err = event__synthesize_tracing_data(output, attrs, - nr_counters, - process_synthesized_event, - session); - if (err <= 0) { - pr_err("Couldn't record tracing data.\n"); - return err; - } - - advance_output(err); - } - err = event__synthesize_kernel_mmap(process_synthesized_event, session, "_text"); if (err < 0) @@ -730,8 +667,6 @@ static const char * const record_usage[] = { NULL }; -static bool force, append_file; - static const struct option options[] = { OPT_CALLBACK('e', "event", NULL, "event", "event selector. use 'perf list' to list available events", @@ -753,14 +688,14 @@ static const struct option options[] = { OPT_INTEGER('C', "profile_cpu", &profile_cpu, "CPU to profile on"), OPT_BOOLEAN('f', "force", &force, - "overwrite existing data file (deprecated)"), - OPT_LONG('c', "count", &user_interval, + "overwrite existing data file"), + OPT_LONG('c', "count", &default_interval, "event period to sample"), OPT_STRING('o', "output", &output_name, "file", "output file name"), OPT_BOOLEAN('i', "inherit", &inherit, "child tasks inherit counters"), - OPT_INTEGER('F', "freq", &user_freq, + OPT_INTEGER('F', "freq", &freq, "profile at this frequency"), OPT_INTEGER('m', "mmap-pages", &mmap_pages, "number of mmap data pages"), @@ -781,6 +716,7 @@ static const struct option options[] = { int cmd_record(int argc, const char **argv, const char *prefix __used) { + int counter; int i,j; argc = parse_options(argc, argv, options, record_usage, @@ -789,16 +725,6 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) !system_wide && profile_cpu == -1) usage_with_options(record_usage, options); - if (force && append_file) { - fprintf(stderr, "Can't overwrite and append at the same time." - " You need to choose between -f and -A"); - usage_with_options(record_usage, options); - } else if (append_file) { - write_mode = WRITE_APPEND; - } else { - write_mode = WRITE_FORCE; - } - symbol__init(); if (!nr_counters) { @@ -838,11 +764,6 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) if (!event_array) return -ENOMEM; - if (user_interval != UINT_MAX) - default_interval = user_interval; - if (user_freq != UINT_MAX) - freq = user_freq; - /* * User specified count overrides default frequency. */ @@ -855,5 +776,12 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) exit(EXIT_FAILURE); } + for (counter = 0; counter < nr_counters; counter++) { + if (attrs[counter].sample_period) + continue; + + attrs[counter].sample_period = default_interval; + } + return __cmd_record(argc, argv); } diff --git a/trunk/tools/perf/builtin-report.c b/trunk/tools/perf/builtin-report.c index 7da5fb365264..daee082ab42b 100644 --- a/trunk/tools/perf/builtin-report.c +++ b/trunk/tools/perf/builtin-report.c @@ -267,19 +267,8 @@ static struct perf_event_ops event_ops = { .fork = event__process_task, .lost = event__process_lost, .read = process_read_event, - .attr = event__process_attr, - .event_type = event__process_event_type, - .tracing_data = event__process_tracing_data, - .build_id = event__process_build_id, }; -extern volatile int session_done; - -static void sig_handler(int sig __attribute__((__unused__))) -{ - session_done = 1; -} - static int __cmd_report(void) { int ret = -EINVAL; @@ -287,8 +276,6 @@ static int __cmd_report(void) struct rb_node *next; const char *help = "For a higher level overview, try: perf report --sort comm,dso"; - signal(SIGINT, sig_handler); - session = perf_session__new(input_name, O_RDONLY, force); if (session == NULL) return -ENOMEM; @@ -478,8 +465,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used) { argc = parse_options(argc, argv, options, report_usage, 0); - if (strcmp(input_name, "-") != 0) - setup_browser(); + setup_browser(); if (symbol__init() < 0) return -1; diff --git a/trunk/tools/perf/builtin-trace.c b/trunk/tools/perf/builtin-trace.c index 2eefb33c9679..8fc50d831540 100644 --- a/trunk/tools/perf/builtin-trace.c +++ b/trunk/tools/perf/builtin-trace.c @@ -104,23 +104,10 @@ static int process_sample_event(event_t *event, struct perf_session *session) static struct perf_event_ops event_ops = { .sample = process_sample_event, .comm = event__process_comm, - .attr = event__process_attr, - .event_type = event__process_event_type, - .tracing_data = event__process_tracing_data, - .build_id = event__process_build_id, }; -extern volatile int session_done; - -static void sig_handler(int sig __unused) -{ - session_done = 1; -} - static int __cmd_trace(struct perf_session *session) { - signal(SIGINT, sig_handler); - return perf_session__process_events(session, &event_ops); } @@ -561,65 +548,6 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) suffix = REPORT_SUFFIX; } - if (!suffix && argc >= 2 && strncmp(argv[1], "-", strlen("-")) != 0) { - char *record_script_path, *report_script_path; - int live_pipe[2]; - pid_t pid; - - record_script_path = get_script_path(argv[1], RECORD_SUFFIX); - if (!record_script_path) { - fprintf(stderr, "record script not found\n"); - return -1; - } - - report_script_path = get_script_path(argv[1], REPORT_SUFFIX); - if (!report_script_path) { - fprintf(stderr, "report script not found\n"); - return -1; - } - - if (pipe(live_pipe) < 0) { - perror("failed to create pipe"); - exit(-1); - } - - pid = fork(); - if (pid < 0) { - perror("failed to fork"); - exit(-1); - } - - if (!pid) { - dup2(live_pipe[1], 1); - close(live_pipe[0]); - - __argv = malloc(5 * sizeof(const char *)); - __argv[0] = "/bin/sh"; - __argv[1] = record_script_path; - __argv[2] = "-o"; - __argv[3] = "-"; - __argv[4] = NULL; - - execvp("/bin/sh", (char **)__argv); - exit(-1); - } - - dup2(live_pipe[0], 0); - close(live_pipe[1]); - - __argv = malloc((argc + 3) * sizeof(const char *)); - __argv[0] = "/bin/sh"; - __argv[1] = report_script_path; - for (i = 2; i < argc; i++) - __argv[i] = argv[i]; - __argv[i++] = "-i"; - __argv[i++] = "-"; - __argv[i++] = NULL; - - execvp("/bin/sh", (char **)__argv); - exit(-1); - } - if (suffix) { script_path = get_script_path(argv[2], suffix); if (!script_path) { @@ -652,8 +580,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) if (session == NULL) return -ENOMEM; - if (strcmp(input_name, "-") && - !perf_session__has_traces(session, "record -R")) + if (!perf_session__has_traces(session, "record -R")) return -EINVAL; if (generate_script_lang) { diff --git a/trunk/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm b/trunk/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm index d94b40c8ac85..f869c48dc9b0 100644 --- a/trunk/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm +++ b/trunk/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm @@ -15,7 +15,6 @@ our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( avg nsecs nsecs_secs nsecs_nsecs nsecs_usecs print_nsecs -clear_term ); our $VERSION = '0.01'; @@ -56,11 +55,6 @@ sub nsecs_str { return $str; } -sub clear_term -{ - print "\x1b[H\x1b[2J"; -} - 1; __END__ =head1 NAME diff --git a/trunk/tools/perf/scripts/perl/bin/failed-syscalls-record b/trunk/tools/perf/scripts/perl/bin/failed-syscalls-record index 6ad9b8f5f009..f8885d389e6f 100644 --- a/trunk/tools/perf/scripts/perl/bin/failed-syscalls-record +++ b/trunk/tools/perf/scripts/perl/bin/failed-syscalls-record @@ -1,2 +1,2 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e raw_syscalls:sys_exit $@ +perf record -c 1 -f -a -M -R -e raw_syscalls:sys_exit diff --git a/trunk/tools/perf/scripts/perl/bin/failed-syscalls-report b/trunk/tools/perf/scripts/perl/bin/failed-syscalls-report index f6346082a8fc..8bfc660e5056 100644 --- a/trunk/tools/perf/scripts/perl/bin/failed-syscalls-report +++ b/trunk/tools/perf/scripts/perl/bin/failed-syscalls-report @@ -1,10 +1,4 @@ #!/bin/bash # description: system-wide failed syscalls # args: [comm] -if [ $# -gt 0 ] ; then - if ! expr match "$1" "-" ; then - comm=$1 - shift - fi -fi -perf trace $@ -s ~/libexec/perf-core/scripts/perl/failed-syscalls.pl $comm +perf trace -s ~/libexec/perf-core/scripts/perl/failed-syscalls.pl $1 diff --git a/trunk/tools/perf/scripts/perl/bin/rw-by-file-record b/trunk/tools/perf/scripts/perl/bin/rw-by-file-record index a828679837a8..b25056ebf963 100644 --- a/trunk/tools/perf/scripts/perl/bin/rw-by-file-record +++ b/trunk/tools/perf/scripts/perl/bin/rw-by-file-record @@ -1,3 +1,2 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e syscalls:sys_enter_read -e syscalls:sys_enter_write $@ - +perf record -c 1 -f -a -M -R -e syscalls:sys_enter_read -e syscalls:sys_enter_write diff --git a/trunk/tools/perf/scripts/perl/bin/rw-by-file-report b/trunk/tools/perf/scripts/perl/bin/rw-by-file-report index d83070b7eeb5..eddb9ccce6a5 100644 --- a/trunk/tools/perf/scripts/perl/bin/rw-by-file-report +++ b/trunk/tools/perf/scripts/perl/bin/rw-by-file-report @@ -1,13 +1,7 @@ #!/bin/bash # description: r/w activity for a program, by file # args: -if [ $# -lt 1 ] ; then - echo "usage: rw-by-file " - exit -fi -comm=$1 -shift -perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-file.pl $comm +perf trace -s ~/libexec/perf-core/scripts/perl/rw-by-file.pl $1 diff --git a/trunk/tools/perf/scripts/perl/bin/rw-by-pid-record b/trunk/tools/perf/scripts/perl/bin/rw-by-pid-record index 63976bf11e8b..8903979c5b6c 100644 --- a/trunk/tools/perf/scripts/perl/bin/rw-by-pid-record +++ b/trunk/tools/perf/scripts/perl/bin/rw-by-pid-record @@ -1,2 +1,2 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e syscalls:sys_enter_read -e syscalls:sys_exit_read -e syscalls:sys_enter_write -e syscalls:sys_exit_write $@ +perf record -c 1 -f -a -M -R -e syscalls:sys_enter_read -e syscalls:sys_exit_read -e syscalls:sys_enter_write -e syscalls:sys_exit_write diff --git a/trunk/tools/perf/scripts/perl/bin/rw-by-pid-report b/trunk/tools/perf/scripts/perl/bin/rw-by-pid-report index 7ef46983f62f..7f44c25cc857 100644 --- a/trunk/tools/perf/scripts/perl/bin/rw-by-pid-report +++ b/trunk/tools/perf/scripts/perl/bin/rw-by-pid-report @@ -1,6 +1,6 @@ #!/bin/bash # description: system-wide r/w activity -perf trace $@ -s ~/libexec/perf-core/scripts/perl/rw-by-pid.pl +perf trace -s ~/libexec/perf-core/scripts/perl/rw-by-pid.pl diff --git a/trunk/tools/perf/scripts/perl/bin/rwtop-record b/trunk/tools/perf/scripts/perl/bin/rwtop-record deleted file mode 100644 index 63976bf11e8b..000000000000 --- a/trunk/tools/perf/scripts/perl/bin/rwtop-record +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -perf record -c 1 -f -a -M -R -e syscalls:sys_enter_read -e syscalls:sys_exit_read -e syscalls:sys_enter_write -e syscalls:sys_exit_write $@ diff --git a/trunk/tools/perf/scripts/perl/bin/rwtop-report b/trunk/tools/perf/scripts/perl/bin/rwtop-report deleted file mode 100644 index 93e698cd3f38..000000000000 --- a/trunk/tools/perf/scripts/perl/bin/rwtop-report +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# description: system-wide r/w top -# args: [interval] -n_args=0 -for i in "$@" -do - if expr match "$i" "-" > /dev/null ; then - break - fi - n_args=$(( $n_args + 1 )) -done -if [ "$n_args" -gt 1 ] ; then - echo "usage: rwtop-report [interval]" - exit -fi -if [ "$n_args" -gt 0 ] ; then - interval=$1 - shift -fi -perf trace $@ -s ~/libexec/perf-core/scripts/perl/rwtop.pl $interval - - - diff --git a/trunk/tools/perf/scripts/perl/bin/wakeup-latency-record b/trunk/tools/perf/scripts/perl/bin/wakeup-latency-record index 9c0cf588ff8c..6abedda911a4 100644 --- a/trunk/tools/perf/scripts/perl/bin/wakeup-latency-record +++ b/trunk/tools/perf/scripts/perl/bin/wakeup-latency-record @@ -1,5 +1,5 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e sched:sched_switch -e sched:sched_wakeup $@ +perf record -c 1 -f -a -M -R -e sched:sched_switch -e sched:sched_wakeup diff --git a/trunk/tools/perf/scripts/perl/bin/wakeup-latency-report b/trunk/tools/perf/scripts/perl/bin/wakeup-latency-report index a0d898f9ca1d..fce3adcb3249 100644 --- a/trunk/tools/perf/scripts/perl/bin/wakeup-latency-report +++ b/trunk/tools/perf/scripts/perl/bin/wakeup-latency-report @@ -1,6 +1,6 @@ #!/bin/bash # description: system-wide min/max/avg wakeup latency -perf trace $@ -s ~/libexec/perf-core/scripts/perl/wakeup-latency.pl +perf trace -s ~/libexec/perf-core/scripts/perl/wakeup-latency.pl diff --git a/trunk/tools/perf/scripts/perl/bin/workqueue-stats-record b/trunk/tools/perf/scripts/perl/bin/workqueue-stats-record index c2a1a9421133..fce6637b19ba 100644 --- a/trunk/tools/perf/scripts/perl/bin/workqueue-stats-record +++ b/trunk/tools/perf/scripts/perl/bin/workqueue-stats-record @@ -1,2 +1,2 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e workqueue:workqueue_creation -e workqueue:workqueue_destruction -e workqueue:workqueue_execution -e workqueue:workqueue_insertion $@ +perf record -c 1 -f -a -M -R -e workqueue:workqueue_creation -e workqueue:workqueue_destruction -e workqueue:workqueue_execution -e workqueue:workqueue_insertion diff --git a/trunk/tools/perf/scripts/perl/bin/workqueue-stats-report b/trunk/tools/perf/scripts/perl/bin/workqueue-stats-report index 35081132ef97..71cfbd182fb9 100644 --- a/trunk/tools/perf/scripts/perl/bin/workqueue-stats-report +++ b/trunk/tools/perf/scripts/perl/bin/workqueue-stats-report @@ -1,6 +1,6 @@ #!/bin/bash # description: workqueue stats (ins/exe/create/destroy) -perf trace $@ -s ~/libexec/perf-core/scripts/perl/workqueue-stats.pl +perf trace -s ~/libexec/perf-core/scripts/perl/workqueue-stats.pl diff --git a/trunk/tools/perf/scripts/perl/rwtop.pl b/trunk/tools/perf/scripts/perl/rwtop.pl deleted file mode 100644 index ec2ab49a6f25..000000000000 --- a/trunk/tools/perf/scripts/perl/rwtop.pl +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/perl -w -# (c) 2010, Tom Zanussi -# Licensed under the terms of the GNU GPL License version 2 - -# read/write top -# -# Periodically displays system-wide r/w call activity, broken down by -# pid. If an [interval] arg is specified, the display will be -# refreshed every [interval] seconds. The default interval is 3 -# seconds. - -use 5.010000; -use strict; -use warnings; - -use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib"; -use lib "./Perf-Trace-Util/lib"; -use Perf::Trace::Core; -use Perf::Trace::Util; - -my $default_interval = 3; -my $nlines = 20; -my $print_thread; - -my %reads; -my %writes; - -my $interval = shift; -if (!$interval) { - $interval = $default_interval; -} - -sub syscalls::sys_exit_read -{ - my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, - $common_pid, $common_comm, - $nr, $ret) = @_; - - if ($ret > 0) { - $reads{$common_pid}{bytes_read} += $ret; - } else { - if (!defined ($reads{$common_pid}{bytes_read})) { - $reads{$common_pid}{bytes_read} = 0; - } - $reads{$common_pid}{errors}{$ret}++; - } -} - -sub syscalls::sys_enter_read -{ - my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, - $common_pid, $common_comm, - $nr, $fd, $buf, $count) = @_; - - $reads{$common_pid}{bytes_requested} += $count; - $reads{$common_pid}{total_reads}++; - $reads{$common_pid}{comm} = $common_comm; -} - -sub syscalls::sys_exit_write -{ - my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, - $common_pid, $common_comm, - $nr, $ret) = @_; - - if ($ret <= 0) { - $writes{$common_pid}{errors}{$ret}++; - } -} - -sub syscalls::sys_enter_write -{ - my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, - $common_pid, $common_comm, - $nr, $fd, $buf, $count) = @_; - - $writes{$common_pid}{bytes_written} += $count; - $writes{$common_pid}{total_writes}++; - $writes{$common_pid}{comm} = $common_comm; -} - -sub trace_begin -{ - $SIG{ALRM} = \&print_totals; - alarm 1; -} - -sub trace_end -{ - print_unhandled(); - print_totals(); -} - -sub print_totals -{ - my $count; - - $count = 0; - - clear_term(); - - printf("\nread counts by pid:\n\n"); - - printf("%6s %20s %10s %10s %10s\n", "pid", "comm", - "# reads", "bytes_req", "bytes_read"); - printf("%6s %-20s %10s %10s %10s\n", "------", "--------------------", - "----------", "----------", "----------"); - - foreach my $pid (sort {$reads{$b}{bytes_read} <=> - $reads{$a}{bytes_read}} keys %reads) { - my $comm = $reads{$pid}{comm}; - my $total_reads = $reads{$pid}{total_reads}; - my $bytes_requested = $reads{$pid}{bytes_requested}; - my $bytes_read = $reads{$pid}{bytes_read}; - - printf("%6s %-20s %10s %10s %10s\n", $pid, $comm, - $total_reads, $bytes_requested, $bytes_read); - - if (++$count == $nlines) { - last; - } - } - - $count = 0; - - printf("\nwrite counts by pid:\n\n"); - - printf("%6s %20s %10s %13s\n", "pid", "comm", - "# writes", "bytes_written"); - printf("%6s %-20s %10s %13s\n", "------", "--------------------", - "----------", "-------------"); - - foreach my $pid (sort {$writes{$b}{bytes_written} <=> - $writes{$a}{bytes_written}} keys %writes) { - my $comm = $writes{$pid}{comm}; - my $total_writes = $writes{$pid}{total_writes}; - my $bytes_written = $writes{$pid}{bytes_written}; - - printf("%6s %-20s %10s %13s\n", $pid, $comm, - $total_writes, $bytes_written); - - if (++$count == $nlines) { - last; - } - } - - %reads = (); - %writes = (); - alarm $interval; -} - -my %unhandled; - -sub print_unhandled -{ - if ((scalar keys %unhandled) == 0) { - return; - } - - print "\nunhandled events:\n\n"; - - printf("%-40s %10s\n", "event", "count"); - printf("%-40s %10s\n", "----------------------------------------", - "-----------"); - - foreach my $event_name (keys %unhandled) { - printf("%-40s %10d\n", $event_name, $unhandled{$event_name}); - } -} - -sub trace_unhandled -{ - my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, - $common_pid, $common_comm) = @_; - - $unhandled{$event_name}++; -} diff --git a/trunk/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py b/trunk/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py index 9689bc0acd9f..83e91435ed09 100644 --- a/trunk/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py +++ b/trunk/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py @@ -23,6 +23,3 @@ def nsecs_nsecs(nsecs): def nsecs_str(nsecs): str = "%5u.%09u" % (nsecs_secs(nsecs), nsecs_nsecs(nsecs)), return str - -def clear_term(): - print("\x1b[H\x1b[2J") diff --git a/trunk/tools/perf/scripts/python/bin/failed-syscalls-by-pid-record b/trunk/tools/perf/scripts/python/bin/failed-syscalls-by-pid-record index 6ad9b8f5f009..f8885d389e6f 100644 --- a/trunk/tools/perf/scripts/python/bin/failed-syscalls-by-pid-record +++ b/trunk/tools/perf/scripts/python/bin/failed-syscalls-by-pid-record @@ -1,2 +1,2 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e raw_syscalls:sys_exit $@ +perf record -c 1 -f -a -M -R -e raw_syscalls:sys_exit diff --git a/trunk/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report b/trunk/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report index 8c128eff9c0a..1e0c0a860c87 100644 --- a/trunk/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report +++ b/trunk/tools/perf/scripts/python/bin/failed-syscalls-by-pid-report @@ -1,10 +1,4 @@ #!/bin/bash # description: system-wide failed syscalls, by pid # args: [comm] -if [ $# -gt 0 ] ; then - if ! expr match "$1" "-" ; then - comm=$1 - shift - fi -fi -perf trace $@ -s ~/libexec/perf-core/scripts/python/failed-syscalls-by-pid.py $comm +perf trace -s ~/libexec/perf-core/scripts/python/failed-syscalls-by-pid.py $1 diff --git a/trunk/tools/perf/scripts/python/bin/sctop-record b/trunk/tools/perf/scripts/python/bin/sctop-record deleted file mode 100644 index 27ccffa26ab4..000000000000 --- a/trunk/tools/perf/scripts/python/bin/sctop-record +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -perf record -c 1 -f -a -M -R -e raw_syscalls:sys_enter $@ diff --git a/trunk/tools/perf/scripts/python/bin/sctop-report b/trunk/tools/perf/scripts/python/bin/sctop-report deleted file mode 100644 index b01c842ae7b4..000000000000 --- a/trunk/tools/perf/scripts/python/bin/sctop-report +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# description: syscall top -# args: [comm] [interval] -n_args=0 -for i in "$@" -do - if expr match "$i" "-" > /dev/null ; then - break - fi - n_args=$(( $n_args + 1 )) -done -if [ "$n_args" -gt 2 ] ; then - echo "usage: sctop-report [comm] [interval]" - exit -fi -if [ "$n_args" -gt 1 ] ; then - comm=$1 - interval=$2 - shift 2 -elif [ "$n_args" -gt 0 ] ; then - interval=$1 - shift -fi -perf trace $@ -s ~/libexec/perf-core/scripts/python/sctop.py $comm $interval diff --git a/trunk/tools/perf/scripts/python/bin/syscall-counts-by-pid-record b/trunk/tools/perf/scripts/python/bin/syscall-counts-by-pid-record index 27ccffa26ab4..45a8c50359da 100644 --- a/trunk/tools/perf/scripts/python/bin/syscall-counts-by-pid-record +++ b/trunk/tools/perf/scripts/python/bin/syscall-counts-by-pid-record @@ -1,2 +1,2 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e raw_syscalls:sys_enter $@ +perf record -c 1 -f -a -M -R -e raw_syscalls:sys_enter diff --git a/trunk/tools/perf/scripts/python/bin/syscall-counts-by-pid-report b/trunk/tools/perf/scripts/python/bin/syscall-counts-by-pid-report index c53362e48602..f8044d192271 100644 --- a/trunk/tools/perf/scripts/python/bin/syscall-counts-by-pid-report +++ b/trunk/tools/perf/scripts/python/bin/syscall-counts-by-pid-report @@ -1,10 +1,4 @@ #!/bin/bash # description: system-wide syscall counts, by pid # args: [comm] -if [ $# -gt 0 ] ; then - if ! expr match "$1" "-" ; then - comm=$1 - shift - fi -fi -perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts-by-pid.py $comm +perf trace -s ~/libexec/perf-core/scripts/python/syscall-counts-by-pid.py $1 diff --git a/trunk/tools/perf/scripts/python/bin/syscall-counts-record b/trunk/tools/perf/scripts/python/bin/syscall-counts-record index 27ccffa26ab4..45a8c50359da 100644 --- a/trunk/tools/perf/scripts/python/bin/syscall-counts-record +++ b/trunk/tools/perf/scripts/python/bin/syscall-counts-record @@ -1,2 +1,2 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e raw_syscalls:sys_enter $@ +perf record -c 1 -f -a -M -R -e raw_syscalls:sys_enter diff --git a/trunk/tools/perf/scripts/python/bin/syscall-counts-report b/trunk/tools/perf/scripts/python/bin/syscall-counts-report index 8c21552b3cdc..a366aa61612f 100644 --- a/trunk/tools/perf/scripts/python/bin/syscall-counts-report +++ b/trunk/tools/perf/scripts/python/bin/syscall-counts-report @@ -1,10 +1,4 @@ #!/bin/bash # description: system-wide syscall counts # args: [comm] -if [ $# -gt 0 ] ; then - if ! expr match "$1" "-" ; then - comm=$1 - shift - fi -fi -perf trace $@ -s ~/libexec/perf-core/scripts/python/syscall-counts.py $comm +perf trace -s ~/libexec/perf-core/scripts/python/syscall-counts.py $1 diff --git a/trunk/tools/perf/scripts/python/sctop.py b/trunk/tools/perf/scripts/python/sctop.py deleted file mode 100644 index 6cafad40c296..000000000000 --- a/trunk/tools/perf/scripts/python/sctop.py +++ /dev/null @@ -1,78 +0,0 @@ -# system call top -# (c) 2010, Tom Zanussi -# Licensed under the terms of the GNU GPL License version 2 -# -# Periodically displays system-wide system call totals, broken down by -# syscall. If a [comm] arg is specified, only syscalls called by -# [comm] are displayed. If an [interval] arg is specified, the display -# will be refreshed every [interval] seconds. The default interval is -# 3 seconds. - -import thread -import time -import os -import sys - -sys.path.append(os.environ['PERF_EXEC_PATH'] + \ - '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') - -from perf_trace_context import * -from Core import * -from Util import * - -usage = "perf trace -s syscall-counts.py [comm] [interval]\n"; - -for_comm = None -default_interval = 3 -interval = default_interval - -if len(sys.argv) > 3: - sys.exit(usage) - -if len(sys.argv) > 2: - for_comm = sys.argv[1] - interval = int(sys.argv[2]) -elif len(sys.argv) > 1: - try: - interval = int(sys.argv[1]) - except ValueError: - for_comm = sys.argv[1] - interval = default_interval - -syscalls = autodict() - -def trace_begin(): - thread.start_new_thread(print_syscall_totals, (interval,)) - pass - -def raw_syscalls__sys_enter(event_name, context, common_cpu, - common_secs, common_nsecs, common_pid, common_comm, - id, args): - if for_comm is not None: - if common_comm != for_comm: - return - try: - syscalls[id] += 1 - except TypeError: - syscalls[id] = 1 - -def print_syscall_totals(interval): - while 1: - clear_term() - if for_comm is not None: - print "\nsyscall events for %s:\n\n" % (for_comm), - else: - print "\nsyscall events:\n\n", - - print "%-40s %10s\n" % ("event", "count"), - print "%-40s %10s\n" % ("----------------------------------------", \ - "----------"), - - for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ - reverse = True): - try: - print "%-40d %10d\n" % (id, val), - except TypeError: - pass - syscalls.clear() - time.sleep(interval) diff --git a/trunk/tools/perf/util/event.h b/trunk/tools/perf/util/event.h index e5740ea140ab..7f7cf8539cfe 100644 --- a/trunk/tools/perf/util/event.h +++ b/trunk/tools/perf/util/event.h @@ -83,37 +83,6 @@ struct build_id_event { char filename[]; }; -enum perf_header_event_type { /* above any possible kernel type */ - PERF_RECORD_HEADER_ATTR = 64, - PERF_RECORD_HEADER_EVENT_TYPE = 65, - PERF_RECORD_HEADER_TRACING_DATA = 66, - PERF_RECORD_HEADER_BUILD_ID = 67, - PERF_RECORD_HEADER_MAX -}; - -struct attr_event { - struct perf_event_header header; - struct perf_event_attr attr; - u64 id[]; -}; - -#define MAX_EVENT_NAME 64 - -struct perf_trace_event_type { - u64 event_id; - char name[MAX_EVENT_NAME]; -}; - -struct event_type_event { - struct perf_event_header header; - struct perf_trace_event_type event_type; -}; - -struct tracing_data_event { - struct perf_event_header header; - u32 size; -}; - typedef union event_union { struct perf_event_header header; struct ip_event ip; @@ -123,10 +92,6 @@ typedef union event_union { struct lost_event lost; struct read_event read; struct sample_event sample; - struct attr_event attr; - struct event_type_event event_type; - struct tracing_data_event tracing_data; - struct build_id_event build_id; } event_t; struct events_stats { diff --git a/trunk/tools/perf/util/header.c b/trunk/tools/perf/util/header.c index 628173ba689e..6c9aa16ee51f 100644 --- a/trunk/tools/perf/util/header.c +++ b/trunk/tools/perf/util/header.c @@ -99,6 +99,13 @@ int perf_header__add_attr(struct perf_header *self, return 0; } +#define MAX_EVENT_NAME 64 + +struct perf_trace_event_type { + u64 event_id; + char name[MAX_EVENT_NAME]; +}; + static int event_count; static struct perf_trace_event_type *events; @@ -420,25 +427,6 @@ static int perf_header__adds_write(struct perf_header *self, int fd) return err; } -int perf_header__write_pipe(int fd) -{ - struct perf_pipe_file_header f_header; - int err; - - f_header = (struct perf_pipe_file_header){ - .magic = PERF_MAGIC, - .size = sizeof(f_header), - }; - - err = do_write(fd, &f_header, sizeof(f_header)); - if (err < 0) { - pr_debug("failed to write perf pipe header\n"); - return err; - } - - return 0; -} - int perf_header__write(struct perf_header *self, int fd, bool at_exit) { struct perf_file_header f_header; @@ -530,10 +518,25 @@ int perf_header__write(struct perf_header *self, int fd, bool at_exit) return 0; } +static int do_read(int fd, void *buf, size_t size) +{ + while (size) { + int ret = read(fd, buf, size); + + if (ret <= 0) + return -1; + + size -= ret; + buf += ret; + } + + return 0; +} + static int perf_header__getbuffer64(struct perf_header *self, int fd, void *buf, size_t size) { - if (do_read(fd, buf, size) <= 0) + if (do_read(fd, buf, size)) return -1; if (self->needs_swap) @@ -589,7 +592,7 @@ int perf_file_header__read(struct perf_file_header *self, { lseek(fd, 0, SEEK_SET); - if (do_read(fd, self, sizeof(*self)) <= 0 || + if (do_read(fd, self, sizeof(*self)) || memcmp(&self->magic, __perf_magic, sizeof(self->magic))) return -1; @@ -659,51 +662,13 @@ static int perf_file_section__process(struct perf_file_section *self, return 0; } -static int perf_file_header__read_pipe(struct perf_pipe_file_header *self, - struct perf_header *ph, int fd) -{ - if (do_read(fd, self, sizeof(*self)) <= 0 || - memcmp(&self->magic, __perf_magic, sizeof(self->magic))) - return -1; - - if (self->size != sizeof(*self)) { - u64 size = bswap_64(self->size); - - if (size != sizeof(*self)) - return -1; - - ph->needs_swap = true; - } - - return 0; -} - -static int perf_header__read_pipe(struct perf_session *session, int fd) -{ - struct perf_header *self = &session->header; - struct perf_pipe_file_header f_header; - - if (perf_file_header__read_pipe(&f_header, self, fd) < 0) { - pr_debug("incompatible file format\n"); - return -EINVAL; - } - - session->fd = fd; - - return 0; -} - -int perf_header__read(struct perf_session *session, int fd) +int perf_header__read(struct perf_header *self, int fd) { - struct perf_header *self = &session->header; struct perf_file_header f_header; struct perf_file_attr f_attr; u64 f_id; int nr_attrs, nr_ids, i, j; - if (session->fd_pipe) - return perf_header__read_pipe(session, fd); - if (perf_file_header__read(&f_header, self, fd) < 0) { pr_debug("incompatible file format\n"); return -EINVAL; @@ -800,279 +765,3 @@ perf_header__find_attr(u64 id, struct perf_header *header) return NULL; } - -int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, - event__handler_t process, - struct perf_session *session) -{ - event_t *ev; - size_t size; - int err; - - size = sizeof(struct perf_event_attr); - size = ALIGN(size, sizeof(u64)); - size += sizeof(struct perf_event_header); - size += ids * sizeof(u64); - - ev = malloc(size); - - ev->attr.attr = *attr; - memcpy(ev->attr.id, id, ids * sizeof(u64)); - - ev->attr.header.type = PERF_RECORD_HEADER_ATTR; - ev->attr.header.size = size; - - err = process(ev, session); - - free(ev); - - return err; -} - -int event__synthesize_attrs(struct perf_header *self, - event__handler_t process, - struct perf_session *session) -{ - struct perf_header_attr *attr; - int i, err = 0; - - for (i = 0; i < self->attrs; i++) { - attr = self->attr[i]; - - err = event__synthesize_attr(&attr->attr, attr->ids, attr->id, - process, session); - if (err) { - pr_debug("failed to create perf header attribute\n"); - return err; - } - } - - return err; -} - -int event__process_attr(event_t *self, struct perf_session *session) -{ - struct perf_header_attr *attr; - unsigned int i, ids, n_ids; - - attr = perf_header_attr__new(&self->attr.attr); - if (attr == NULL) - return -ENOMEM; - - ids = self->header.size; - ids -= (void *)&self->attr.id - (void *)self; - n_ids = ids / sizeof(u64); - - for (i = 0; i < n_ids; i++) { - if (perf_header_attr__add_id(attr, self->attr.id[i]) < 0) { - perf_header_attr__delete(attr); - return -ENOMEM; - } - } - - if (perf_header__add_attr(&session->header, attr) < 0) { - perf_header_attr__delete(attr); - return -ENOMEM; - } - - perf_session__update_sample_type(session); - - return 0; -} - -int event__synthesize_event_type(u64 event_id, char *name, - event__handler_t process, - struct perf_session *session) -{ - event_t ev; - size_t size = 0; - int err = 0; - - memset(&ev, 0, sizeof(ev)); - - ev.event_type.event_type.event_id = event_id; - memset(ev.event_type.event_type.name, 0, MAX_EVENT_NAME); - strncpy(ev.event_type.event_type.name, name, MAX_EVENT_NAME - 1); - - ev.event_type.header.type = PERF_RECORD_HEADER_EVENT_TYPE; - size = strlen(name); - size = ALIGN(size, sizeof(u64)); - ev.event_type.header.size = sizeof(ev.event_type) - - (sizeof(ev.event_type.event_type.name) - size); - - err = process(&ev, session); - - return err; -} - -int event__synthesize_event_types(event__handler_t process, - struct perf_session *session) -{ - struct perf_trace_event_type *type; - int i, err = 0; - - for (i = 0; i < event_count; i++) { - type = &events[i]; - - err = event__synthesize_event_type(type->event_id, type->name, - process, session); - if (err) { - pr_debug("failed to create perf header event type\n"); - return err; - } - } - - return err; -} - -int event__process_event_type(event_t *self, - struct perf_session *session __unused) -{ - if (perf_header__push_event(self->event_type.event_type.event_id, - self->event_type.event_type.name) < 0) - return -ENOMEM; - - return 0; -} - -int event__synthesize_tracing_data(int fd, struct perf_event_attr *pattrs, - int nb_events, - event__handler_t process, - struct perf_session *session __unused) -{ - event_t ev; - ssize_t size = 0, aligned_size = 0, padding; - int err = 0; - - memset(&ev, 0, sizeof(ev)); - - ev.tracing_data.header.type = PERF_RECORD_HEADER_TRACING_DATA; - size = read_tracing_data_size(fd, pattrs, nb_events); - if (size <= 0) - return size; - aligned_size = ALIGN(size, sizeof(u64)); - padding = aligned_size - size; - ev.tracing_data.header.size = sizeof(ev.tracing_data); - ev.tracing_data.size = aligned_size; - - process(&ev, session); - - err = read_tracing_data(fd, pattrs, nb_events); - write_padded(fd, NULL, 0, padding); - - return aligned_size; -} - -int event__process_tracing_data(event_t *self, - struct perf_session *session) -{ - ssize_t size_read, padding, size = self->tracing_data.size; - off_t offset = lseek(session->fd, 0, SEEK_CUR); - char buf[BUFSIZ]; - - /* setup for reading amidst mmap */ - lseek(session->fd, offset + sizeof(struct tracing_data_event), - SEEK_SET); - - size_read = trace_report(session->fd); - - padding = ALIGN(size_read, sizeof(u64)) - size_read; - - if (read(session->fd, buf, padding) < 0) - die("reading input file"); - - if (size_read + padding != size) - die("tracing data size mismatch"); - - return size_read + padding; -} - -int event__synthesize_build_id(struct dso *pos, u16 misc, - event__handler_t process, - struct perf_session *session) -{ - event_t ev; - size_t len; - int err = 0; - - if (!pos->hit) - return err; - - memset(&ev, 0, sizeof(ev)); - - len = pos->long_name_len + 1; - len = ALIGN(len, NAME_ALIGN); - memcpy(&ev.build_id.build_id, pos->build_id, sizeof(pos->build_id)); - ev.build_id.header.type = PERF_RECORD_HEADER_BUILD_ID; - ev.build_id.header.misc = misc; - ev.build_id.header.size = sizeof(ev.build_id) + len; - memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len); - - err = process(&ev, session); - - return err; -} - -static int __event_synthesize_build_ids(struct list_head *head, u16 misc, - event__handler_t process, - struct perf_session *session) -{ - struct dso *pos; - - dsos__for_each_with_build_id(pos, head) { - int err; - if (!pos->hit) - continue; - - err = event__synthesize_build_id(pos, misc, process, session); - if (err < 0) - return err; - } - - return 0; -} - -int event__synthesize_build_ids(event__handler_t process, - struct perf_session *session) -{ - int err; - - if (!dsos__read_build_ids(true)) - return 0; - - err = __event_synthesize_build_ids(&dsos__kernel, - PERF_RECORD_MISC_KERNEL, - process, session); - if (err == 0) - err = __event_synthesize_build_ids(&dsos__user, - PERF_RECORD_MISC_USER, - process, session); - - if (err < 0) { - pr_debug("failed to synthesize build ids\n"); - return err; - } - - dsos__cache_build_ids(); - - return 0; -} - -int event__process_build_id(event_t *self, - struct perf_session *session __unused) -{ - struct list_head *head = &dsos__user; - struct dso *dso; - - if (self->build_id.header.misc & PERF_RECORD_MISC_KERNEL) - head = &dsos__kernel; - - dso = __dsos__findnew(head, self->build_id.filename); - if (dso != NULL) { - dso__set_build_id(dso, &self->build_id.build_id); - if (head == &dsos__kernel && self->build_id.filename[0] == '[') - dso->kernel = 1; - } - - return 0; -} diff --git a/trunk/tools/perf/util/header.h b/trunk/tools/perf/util/header.h index 4214e2375650..c059f08cf877 100644 --- a/trunk/tools/perf/util/header.h +++ b/trunk/tools/perf/util/header.h @@ -39,11 +39,6 @@ struct perf_file_header { DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); }; -struct perf_pipe_file_header { - u64 magic; - u64 size; -}; - struct perf_header; int perf_file_header__read(struct perf_file_header *self, @@ -65,9 +60,8 @@ struct perf_header { int perf_header__init(struct perf_header *self); void perf_header__exit(struct perf_header *self); -int perf_header__read(struct perf_session *session, int fd); +int perf_header__read(struct perf_header *self, int fd); int perf_header__write(struct perf_header *self, int fd, bool at_exit); -int perf_header__write_pipe(int fd); int perf_header__add_attr(struct perf_header *self, struct perf_header_attr *attr); @@ -95,34 +89,4 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, const char *name, bool is_kallsyms); int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir); -int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, - event__handler_t process, - struct perf_session *session); -int event__synthesize_attrs(struct perf_header *self, - event__handler_t process, - struct perf_session *session); -int event__process_attr(event_t *self, struct perf_session *session); - -int event__synthesize_event_type(u64 event_id, char *name, - event__handler_t process, - struct perf_session *session); -int event__synthesize_event_types(event__handler_t process, - struct perf_session *session); -int event__process_event_type(event_t *self, - struct perf_session *session); - -int event__synthesize_tracing_data(int fd, struct perf_event_attr *pattrs, - int nb_events, - event__handler_t process, - struct perf_session *session); -int event__process_tracing_data(event_t *self, - struct perf_session *session); - -int event__synthesize_build_id(struct dso *pos, u16 misc, - event__handler_t process, - struct perf_session *session); -int event__synthesize_build_ids(event__handler_t process, - struct perf_session *session); -int event__process_build_id(event_t *self, struct perf_session *session); - #endif /* __PERF_HEADER_H */ diff --git a/trunk/tools/perf/util/hist.c b/trunk/tools/perf/util/hist.c index 18cf8b321608..9c2b8743cef6 100644 --- a/trunk/tools/perf/util/hist.c +++ b/trunk/tools/perf/util/hist.c @@ -68,7 +68,7 @@ hist_entry__cmp(struct hist_entry *left, struct hist_entry *right) int64_t cmp = 0; list_for_each_entry(se, &hist_entry__sort_list, list) { - cmp = se->cmp(left, right); + cmp = se->se_cmp(left, right); if (cmp) break; } @@ -85,7 +85,7 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right) list_for_each_entry(se, &hist_entry__sort_list, list) { int64_t (*f)(struct hist_entry *, struct hist_entry *); - f = se->collapse ?: se->cmp; + f = se->se_collapse ?: se->se_cmp; cmp = f(left, right); if (cmp) @@ -536,8 +536,8 @@ int hist_entry__snprintf(struct hist_entry *self, continue; ret += snprintf(s + ret, size - ret, "%s", sep ?: " "); - ret += se->snprintf(self, s + ret, size - ret, - se->width ? *se->width : 0); + ret += se->se_snprintf(self, s + ret, size - ret, + se->se_width ? *se->se_width : 0); } return ret; @@ -564,7 +564,7 @@ static size_t hist_entry__fprintf_callchain(struct hist_entry *self, FILE *fp, if (sort__first_dimension == SORT_COMM) { struct sort_entry *se = list_first_entry(&hist_entry__sort_list, typeof(*se), list); - left_margin = se->width ? *se->width : 0; + left_margin = se->se_width ? *se->se_width : 0; left_margin -= thread__comm_len(self->thread); } @@ -615,22 +615,22 @@ size_t perf_session__fprintf_hists(struct rb_root *hists, if (se->elide) continue; if (sep) { - fprintf(fp, "%c%s", *sep, se->header); + fprintf(fp, "%c%s", *sep, se->se_header); continue; } - width = strlen(se->header); - if (se->width) { + width = strlen(se->se_header); + if (se->se_width) { if (symbol_conf.col_width_list_str) { if (col_width) { - *se->width = atoi(col_width); + *se->se_width = atoi(col_width); col_width = strchr(col_width, ','); if (col_width) ++col_width; } } - width = *se->width = max(*se->width, width); + width = *se->se_width = max(*se->se_width, width); } - fprintf(fp, " %*s", width, se->header); + fprintf(fp, " %*s", width, se->se_header); } fprintf(fp, "\n"); @@ -652,10 +652,10 @@ size_t perf_session__fprintf_hists(struct rb_root *hists, continue; fprintf(fp, " "); - if (se->width) - width = *se->width; + if (se->se_width) + width = *se->se_width; else - width = strlen(se->header); + width = strlen(se->se_header); for (i = 0; i < width; i++) fprintf(fp, "."); } diff --git a/trunk/tools/perf/util/parse-events.c b/trunk/tools/perf/util/parse-events.c index 3b4ec6797565..435781e0c205 100644 --- a/trunk/tools/perf/util/parse-events.c +++ b/trunk/tools/perf/util/parse-events.c @@ -410,6 +410,7 @@ static enum event_result parse_single_tracepoint_event(char *sys_name, const char *evt_name, unsigned int evt_length, + char *flags, struct perf_event_attr *attr, const char **strp) { @@ -418,11 +419,13 @@ parse_single_tracepoint_event(char *sys_name, u64 id; int fd; - attr->sample_type |= PERF_SAMPLE_RAW; - attr->sample_type |= PERF_SAMPLE_TIME; - attr->sample_type |= PERF_SAMPLE_CPU; - - attr->sample_period = 1; + if (flags) { + if (!strncmp(flags, "record", strlen(flags))) { + attr->sample_type |= PERF_SAMPLE_RAW; + attr->sample_type |= PERF_SAMPLE_TIME; + attr->sample_type |= PERF_SAMPLE_CPU; + } + } snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", debugfs_path, sys_name, evt_name); @@ -530,7 +533,8 @@ static enum event_result parse_tracepoint_event(const char **strp, flags); } else return parse_single_tracepoint_event(sys_name, evt_name, - evt_length, attr, strp); + evt_length, flags, + attr, strp); } static enum event_result diff --git a/trunk/tools/perf/util/session.c b/trunk/tools/perf/util/session.c index 0fdf3ebef1e9..ddf288fca3eb 100644 --- a/trunk/tools/perf/util/session.c +++ b/trunk/tools/perf/util/session.c @@ -14,16 +14,6 @@ static int perf_session__open(struct perf_session *self, bool force) { struct stat input_stat; - if (!strcmp(self->filename, "-")) { - self->fd_pipe = true; - self->fd = STDIN_FILENO; - - if (perf_header__read(self, self->fd) < 0) - pr_err("incompatible file format"); - - return 0; - } - self->fd = open(self->filename, O_RDONLY); if (self->fd < 0) { pr_err("failed to open file: %s", self->filename); @@ -48,7 +38,7 @@ static int perf_session__open(struct perf_session *self, bool force) goto out_close; } - if (perf_header__read(self, self->fd) < 0) { + if (perf_header__read(&self->header, self->fd) < 0) { pr_err("incompatible file format"); goto out_close; } @@ -62,11 +52,6 @@ static int perf_session__open(struct perf_session *self, bool force) return -1; } -void perf_session__update_sample_type(struct perf_session *self) -{ - self->sample_type = perf_header__sample_type(&self->header); -} - struct perf_session *perf_session__new(const char *filename, int mode, bool force) { size_t len = filename ? strlen(filename) + 1 : 0; @@ -100,7 +85,7 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc goto out_delete; } - perf_session__update_sample_type(self); + self->sample_type = perf_header__sample_type(&self->header); out: return self; out_free: @@ -200,14 +185,6 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler) handler->throttle = process_event_stub; if (handler->unthrottle == NULL) handler->unthrottle = process_event_stub; - if (handler->attr == NULL) - handler->attr = process_event_stub; - if (handler->event_type == NULL) - handler->event_type = process_event_stub; - if (handler->tracing_data == NULL) - handler->tracing_data = process_event_stub; - if (handler->build_id == NULL) - handler->build_id = process_event_stub; } static const char *event__name[] = { @@ -221,23 +198,16 @@ static const char *event__name[] = { [PERF_RECORD_FORK] = "FORK", [PERF_RECORD_READ] = "READ", [PERF_RECORD_SAMPLE] = "SAMPLE", - [PERF_RECORD_HEADER_ATTR] = "ATTR", - [PERF_RECORD_HEADER_EVENT_TYPE] = "EVENT_TYPE", - [PERF_RECORD_HEADER_TRACING_DATA] = "TRACING_DATA", - [PERF_RECORD_HEADER_BUILD_ID] = "BUILD_ID", }; -unsigned long event__total[PERF_RECORD_HEADER_MAX]; +unsigned long event__total[PERF_RECORD_MAX]; void event__print_totals(void) { int i; - for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) { - if (!event__name[i]) - continue; + for (i = 0; i < PERF_RECORD_MAX; ++i) pr_info("%10s events: %10ld\n", event__name[i], event__total[i]); - } } void mem_bswap_64(void *src, int byte_size) @@ -291,37 +261,6 @@ static void event__read_swap(event_t *self) self->read.id = bswap_64(self->read.id); } -static void event__attr_swap(event_t *self) -{ - size_t size; - - self->attr.attr.type = bswap_32(self->attr.attr.type); - self->attr.attr.size = bswap_32(self->attr.attr.size); - self->attr.attr.config = bswap_64(self->attr.attr.config); - self->attr.attr.sample_period = bswap_64(self->attr.attr.sample_period); - self->attr.attr.sample_type = bswap_64(self->attr.attr.sample_type); - self->attr.attr.read_format = bswap_64(self->attr.attr.read_format); - self->attr.attr.wakeup_events = bswap_32(self->attr.attr.wakeup_events); - self->attr.attr.bp_type = bswap_32(self->attr.attr.bp_type); - self->attr.attr.bp_addr = bswap_64(self->attr.attr.bp_addr); - self->attr.attr.bp_len = bswap_64(self->attr.attr.bp_len); - - size = self->header.size; - size -= (void *)&self->attr.id - (void *)self; - mem_bswap_64(self->attr.id, size); -} - -static void event__event_type_swap(event_t *self) -{ - self->event_type.event_type.event_id = - bswap_64(self->event_type.event_type.event_id); -} - -static void event__tracing_data_swap(event_t *self) -{ - self->tracing_data.size = bswap_32(self->tracing_data.size); -} - typedef void (*event__swap_op)(event_t *self); static event__swap_op event__swap_ops[] = { @@ -332,11 +271,7 @@ static event__swap_op event__swap_ops[] = { [PERF_RECORD_LOST] = event__all64_swap, [PERF_RECORD_READ] = event__read_swap, [PERF_RECORD_SAMPLE] = event__all64_swap, - [PERF_RECORD_HEADER_ATTR] = event__attr_swap, - [PERF_RECORD_HEADER_EVENT_TYPE] = event__event_type_swap, - [PERF_RECORD_HEADER_TRACING_DATA] = event__tracing_data_swap, - [PERF_RECORD_HEADER_BUILD_ID] = NULL, - [PERF_RECORD_HEADER_MAX] = NULL, + [PERF_RECORD_MAX] = NULL, }; static int perf_session__process_event(struct perf_session *self, @@ -346,7 +281,7 @@ static int perf_session__process_event(struct perf_session *self, { trace_event(event); - if (event->header.type < PERF_RECORD_HEADER_MAX) { + if (event->header.type < PERF_RECORD_MAX) { dump_printf("%#Lx [%#x]: PERF_RECORD_%s", offset + head, event->header.size, event__name[event->header.type]); @@ -376,16 +311,6 @@ static int perf_session__process_event(struct perf_session *self, return ops->throttle(event, self); case PERF_RECORD_UNTHROTTLE: return ops->unthrottle(event, self); - case PERF_RECORD_HEADER_ATTR: - return ops->attr(event, self); - case PERF_RECORD_HEADER_EVENT_TYPE: - return ops->event_type(event, self); - case PERF_RECORD_HEADER_TRACING_DATA: - /* setup for reading amidst mmap */ - lseek(self->fd, offset + head, SEEK_SET); - return ops->tracing_data(event, self); - case PERF_RECORD_HEADER_BUILD_ID: - return ops->build_id(event, self); default: self->unknown_events++; return -1; @@ -451,101 +376,6 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se return thread; } -int do_read(int fd, void *buf, size_t size) -{ - void *buf_start = buf; - - while (size) { - int ret = read(fd, buf, size); - - if (ret <= 0) - return ret; - - size -= ret; - buf += ret; - } - - return buf - buf_start; -} - -#define session_done() (*(volatile int *)(&session_done)) -volatile int session_done; - -static int __perf_session__process_pipe_events(struct perf_session *self, - struct perf_event_ops *ops) -{ - event_t event; - uint32_t size; - int skip = 0; - u64 head; - int err; - void *p; - - perf_event_ops__fill_defaults(ops); - - head = 0; -more: - err = do_read(self->fd, &event, sizeof(struct perf_event_header)); - if (err <= 0) { - if (err == 0) - goto done; - - pr_err("failed to read event header\n"); - goto out_err; - } - - if (self->header.needs_swap) - perf_event_header__bswap(&event.header); - - size = event.header.size; - if (size == 0) - size = 8; - - p = &event; - p += sizeof(struct perf_event_header); - - err = do_read(self->fd, p, size - sizeof(struct perf_event_header)); - if (err <= 0) { - if (err == 0) { - pr_err("unexpected end of event stream\n"); - goto done; - } - - pr_err("failed to read event data\n"); - goto out_err; - } - - if (size == 0 || - (skip = perf_session__process_event(self, &event, ops, - 0, head)) < 0) { - dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n", - head, event.header.size, event.header.type); - /* - * assume we lost track of the stream, check alignment, and - * increment a single u64 in the hope to catch on again 'soon'. - */ - if (unlikely(head & 7)) - head &= ~7ULL; - - size = 8; - } - - head += size; - - dump_printf("\n%#Lx [%#x]: event: %d\n", - head, event.header.size, event.header.type); - - if (skip > 0) - head += skip; - - if (!session_done()) - goto more; -done: - err = 0; -out_err: - return err; -} - int __perf_session__process_events(struct perf_session *self, u64 data_offset, u64 data_size, u64 file_size, struct perf_event_ops *ops) @@ -669,13 +499,9 @@ int perf_session__process_events(struct perf_session *self, self->cwdlen = strlen(self->cwd); } - if (!self->fd_pipe) - err = __perf_session__process_events(self, - self->header.data_offset, - self->header.data_size, - self->size, ops); - else - err = __perf_session__process_pipe_events(self, ops); + err = __perf_session__process_events(self, self->header.data_offset, + self->header.data_size, + self->size, ops); out_err: return err; } diff --git a/trunk/tools/perf/util/session.h b/trunk/tools/perf/util/session.h index 0ac14d42dc28..27f4c2dc715b 100644 --- a/trunk/tools/perf/util/session.h +++ b/trunk/tools/perf/util/session.h @@ -27,7 +27,6 @@ struct perf_session { u64 sample_type; struct ref_reloc_sym ref_reloc_sym; int fd; - bool fd_pipe; int cwdlen; char *cwd; char filename[0]; @@ -44,11 +43,7 @@ struct perf_event_ops { lost, read, throttle, - unthrottle, - attr, - event_type, - tracing_data, - build_id; + unthrottle; }; struct perf_session *perf_session__new(const char *filename, int mode, bool force); @@ -97,9 +92,6 @@ static inline struct map * return map_groups__new_module(&self->kmaps, start, filename); } -int do_read(int fd, void *buf, size_t size); -void perf_session__update_sample_type(struct perf_session *self); - #ifdef NO_NEWT_SUPPORT static inline int perf_session__browse_hists(struct rb_root *hists __used, u64 nr_hists __used, diff --git a/trunk/tools/perf/util/sort.c b/trunk/tools/perf/util/sort.c index 9d24d4b2c8fb..da30b305fba0 100644 --- a/trunk/tools/perf/util/sort.c +++ b/trunk/tools/perf/util/sort.c @@ -30,38 +30,38 @@ static int hist_entry__parent_snprintf(struct hist_entry *self, char *bf, size_t size, unsigned int width); struct sort_entry sort_thread = { - .header = "Command: Pid", - .cmp = sort__thread_cmp, - .snprintf = hist_entry__thread_snprintf, - .width = &threads__col_width, + .se_header = "Command: Pid", + .se_cmp = sort__thread_cmp, + .se_snprintf = hist_entry__thread_snprintf, + .se_width = &threads__col_width, }; struct sort_entry sort_comm = { - .header = "Command", - .cmp = sort__comm_cmp, - .collapse = sort__comm_collapse, - .snprintf = hist_entry__comm_snprintf, - .width = &comms__col_width, + .se_header = "Command", + .se_cmp = sort__comm_cmp, + .se_collapse = sort__comm_collapse, + .se_snprintf = hist_entry__comm_snprintf, + .se_width = &comms__col_width, }; struct sort_entry sort_dso = { - .header = "Shared Object", - .cmp = sort__dso_cmp, - .snprintf = hist_entry__dso_snprintf, - .width = &dsos__col_width, + .se_header = "Shared Object", + .se_cmp = sort__dso_cmp, + .se_snprintf = hist_entry__dso_snprintf, + .se_width = &dsos__col_width, }; struct sort_entry sort_sym = { - .header = "Symbol", - .cmp = sort__sym_cmp, - .snprintf = hist_entry__sym_snprintf, + .se_header = "Symbol", + .se_cmp = sort__sym_cmp, + .se_snprintf = hist_entry__sym_snprintf, }; struct sort_entry sort_parent = { - .header = "Parent symbol", - .cmp = sort__parent_cmp, - .snprintf = hist_entry__parent_snprintf, - .width = &parent_symbol__col_width, + .se_header = "Parent symbol", + .se_cmp = sort__parent_cmp, + .se_snprintf = hist_entry__parent_snprintf, + .se_width = &parent_symbol__col_width, }; struct sort_dimension { @@ -255,7 +255,7 @@ int sort_dimension__add(const char *tok) if (strncasecmp(tok, sd->name, strlen(tok))) continue; - if (sd->entry->collapse) + if (sd->entry->se_collapse) sort__need_collapse = 1; if (sd->entry == &sort_parent) { diff --git a/trunk/tools/perf/util/sort.h b/trunk/tools/perf/util/sort.h index 6d7b4be70609..1d857aa2c01f 100644 --- a/trunk/tools/perf/util/sort.h +++ b/trunk/tools/perf/util/sort.h @@ -78,13 +78,13 @@ enum sort_type { struct sort_entry { struct list_head list; - const char *header; + const char *se_header; - int64_t (*cmp)(struct hist_entry *, struct hist_entry *); - int64_t (*collapse)(struct hist_entry *, struct hist_entry *); - int (*snprintf)(struct hist_entry *self, char *bf, size_t size, - unsigned int width); - unsigned int *width; + int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *); + int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); + int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size, + unsigned int width); + unsigned int *se_width; bool elide; }; diff --git a/trunk/tools/perf/util/trace-event-info.c b/trunk/tools/perf/util/trace-event-info.c index 30cd9b575953..5ea8973ad331 100644 --- a/trunk/tools/perf/util/trace-event-info.c +++ b/trunk/tools/perf/util/trace-event-info.c @@ -154,17 +154,10 @@ static void put_tracing_file(char *file) free(file); } -static ssize_t calc_data_size; - static ssize_t write_or_die(const void *buf, size_t len) { int ret; - if (calc_data_size) { - calc_data_size += len; - return len; - } - ret = write(output_fd, buf, len); if (ret < 0) die("writing to '%s'", output_file); @@ -533,20 +526,3 @@ int read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events) return 0; } - -ssize_t read_tracing_data_size(int fd, struct perf_event_attr *pattrs, - int nb_events) -{ - ssize_t size; - int err = 0; - - calc_data_size = 1; - err = read_tracing_data(fd, pattrs, nb_events); - size = calc_data_size - 1; - calc_data_size = 0; - - if (err < 0) - return err; - - return size; -} diff --git a/trunk/tools/perf/util/trace-event-parse.c b/trunk/tools/perf/util/trace-event-parse.c index d6ef414075a6..17d6d66ed766 100644 --- a/trunk/tools/perf/util/trace-event-parse.c +++ b/trunk/tools/perf/util/trace-event-parse.c @@ -761,7 +761,7 @@ static int field_is_string(struct format_field *field) static int field_is_dynamic(struct format_field *field) { - if (!strncmp(field->type, "__data_loc", 10)) + if (!strcmp(field->type, "__data_loc")) return 1; return 0; diff --git a/trunk/tools/perf/util/trace-event-read.c b/trunk/tools/perf/util/trace-event-read.c index 44889c9b5630..7cd1193918c7 100644 --- a/trunk/tools/perf/util/trace-event-read.c +++ b/trunk/tools/perf/util/trace-event-read.c @@ -50,37 +50,14 @@ static int long_size; static unsigned long page_size; -static ssize_t calc_data_size; - -static int do_read(int fd, void *buf, int size) -{ - int rsize = size; - - while (size) { - int ret = read(fd, buf, size); - - if (ret <= 0) - return -1; - - size -= ret; - buf += ret; - } - - return rsize; -} - static int read_or_die(void *data, int size) { int r; - r = do_read(input_fd, data, size); - if (r <= 0) + r = read(input_fd, data, size); + if (r != size) die("reading input file (size expected=%d received=%d)", size, r); - - if (calc_data_size) - calc_data_size += r; - return r; } @@ -105,28 +82,56 @@ static char *read_string(void) char buf[BUFSIZ]; char *str = NULL; int size = 0; + int i; off_t r; - char c; for (;;) { - r = read(input_fd, &c, 1); + r = read(input_fd, buf, BUFSIZ); if (r < 0) die("reading input file"); if (!r) die("no data"); - buf[size++] = c; - - if (!c) + for (i = 0; i < r; i++) { + if (!buf[i]) + break; + } + if (i < r) break; - } - if (calc_data_size) - calc_data_size += size; + if (str) { + size += BUFSIZ; + str = realloc(str, size); + if (!str) + die("malloc of size %d", size); + memcpy(str + (size - BUFSIZ), buf, BUFSIZ); + } else { + size = BUFSIZ; + str = malloc_or_die(size); + memcpy(str, buf, size); + } + } - str = malloc_or_die(size); - memcpy(str, buf, size); + /* trailing \0: */ + i++; + + /* move the file descriptor to the end of the string */ + r = lseek(input_fd, -(r - i), SEEK_CUR); + if (r == (off_t)-1) + die("lseek"); + + if (str) { + size += i; + str = realloc(str, size); + if (!str) + die("malloc of size %d", size); + memcpy(str + (size - i), buf, i); + } else { + size = i; + str = malloc_or_die(i); + memcpy(str, buf, i); + } return str; } @@ -454,7 +459,7 @@ struct record *trace_read_data(int cpu) return data; } -ssize_t trace_report(int fd) +void trace_report(int fd) { char buf[BUFSIZ]; char test[] = { 23, 8, 68 }; @@ -462,9 +467,6 @@ ssize_t trace_report(int fd) int show_version = 0; int show_funcs = 0; int show_printk = 0; - ssize_t size; - - calc_data_size = 1; input_fd = fd; @@ -497,17 +499,14 @@ ssize_t trace_report(int fd) read_proc_kallsyms(); read_ftrace_printk(); - size = calc_data_size - 1; - calc_data_size = 0; - if (show_funcs) { print_funcs(); - return size; + return; } if (show_printk) { print_printk(); - return size; + return; } - return size; + return; } diff --git a/trunk/tools/perf/util/trace-event.h b/trunk/tools/perf/util/trace-event.h index 1f45d468fd9a..81f2fd20a0ea 100644 --- a/trunk/tools/perf/util/trace-event.h +++ b/trunk/tools/perf/util/trace-event.h @@ -163,7 +163,7 @@ struct record *trace_read_data(int cpu); void parse_set_info(int nr_cpus, int long_sz); -ssize_t trace_report(int fd); +void trace_report(int fd); void *malloc_or_die(unsigned int size); @@ -259,8 +259,6 @@ void *raw_field_ptr(struct event *event, const char *name, void *data); unsigned long long eval_flag(const char *flag); int read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events); -ssize_t read_tracing_data_size(int fd, struct perf_event_attr *pattrs, - int nb_events); /* taken from kernel/trace/trace.h */ enum trace_flag_type {