diff --git a/[refs] b/[refs] index 54e5de7eb087..b50f8c190fd1 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 090f7204dfdb5d7f18208ea81dfdba845897cedd +refs/heads/master: e5a5f1f015cf435eb3d2f5712ba51ffdbb92cbef diff --git a/trunk/tools/perf/Documentation/perf-trace-perl.txt b/trunk/tools/perf/Documentation/perf-trace-perl.txt index d729cee8d987..ee6525ee6d69 100644 --- a/trunk/tools/perf/Documentation/perf-trace-perl.txt +++ b/trunk/tools/perf/Documentation/perf-trace-perl.txt @@ -49,12 +49,10 @@ available as calls back into the perf executable (see below). As an example, the following perf record command can be used to record all sched_wakeup events in the system: - # perf record -c 1 -f -a -M -R -e sched:sched_wakeup + # perf record -a -e sched:sched_wakeup Traces meant to be processed using a script should be recorded with -the above options: -c 1 says to sample every event, -a to enable -system-wide collection, -M to multiplex the output, and -R to collect -raw samples. +the above option: -a to enable system-wide collection. The format file for the sched_wakep event defines the following fields (see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format): diff --git a/trunk/tools/perf/Documentation/perf-trace-python.txt b/trunk/tools/perf/Documentation/perf-trace-python.txt index a241aca77184..16a86500dcf1 100644 --- a/trunk/tools/perf/Documentation/perf-trace-python.txt +++ b/trunk/tools/perf/Documentation/perf-trace-python.txt @@ -93,7 +93,7 @@ don't care how it exited, so we'll use 'perf record' to record only the sys_enter events: ---- -# perf record -c 1 -f -a -M -R -e raw_syscalls:sys_enter +# perf record -a -e raw_syscalls:sys_enter ^C[ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 56.545 MB perf.data (~2470503 samples) ] @@ -359,7 +359,7 @@ your script: # cat kernel-source/tools/perf/scripts/python/bin/syscall-counts-record #!/bin/bash -perf record -c 1 -f -a -M -R -e raw_syscalls:sys_enter +perf record -a -e raw_syscalls:sys_enter ---- The 'report' script is also a shell script with the same base name as @@ -449,12 +449,10 @@ available as calls back into the perf executable (see below). As an example, the following perf record command can be used to record all sched_wakeup events in the system: - # perf record -c 1 -f -a -M -R -e sched:sched_wakeup + # perf record -a -e sched:sched_wakeup Traces meant to be processed using a script should be recorded with -the above options: -c 1 says to sample every event, -a to enable -system-wide collection, -M to multiplex the output, and -R to collect -raw samples. +the above option: -a to enable system-wide collection. The format file for the sched_wakep event defines the following fields (see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format): diff --git a/trunk/tools/perf/Makefile b/trunk/tools/perf/Makefile index 0ef5cfe52f2d..739c4412b183 100644 --- a/trunk/tools/perf/Makefile +++ b/trunk/tools/perf/Makefile @@ -377,9 +377,9 @@ LIB_H += util/include/linux/rbtree.h LIB_H += util/include/linux/string.h LIB_H += util/include/linux/types.h LIB_H += util/include/asm/asm-offsets.h +LIB_H += util/include/asm/bitops.h LIB_H += util/include/asm/bug.h LIB_H += util/include/asm/byteorder.h -LIB_H += util/include/asm/hweight.h LIB_H += util/include/asm/swab.h LIB_H += util/include/asm/system.h LIB_H += util/include/asm/uaccess.h @@ -435,6 +435,7 @@ LIB_OBJS += $(OUTPUT)util/path.o LIB_OBJS += $(OUTPUT)util/rbtree.o LIB_OBJS += $(OUTPUT)util/bitmap.o LIB_OBJS += $(OUTPUT)util/hweight.o +LIB_OBJS += $(OUTPUT)util/find_next_bit.o LIB_OBJS += $(OUTPUT)util/run-command.o LIB_OBJS += $(OUTPUT)util/quote.o LIB_OBJS += $(OUTPUT)util/strbuf.o @@ -490,7 +491,6 @@ BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o BUILTIN_OBJS += $(OUTPUT)builtin-lock.o BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o BUILTIN_OBJS += $(OUTPUT)builtin-test.o -BUILTIN_OBJS += $(OUTPUT)builtin-inject.o PERFLIBS = $(LIB_FILE) @@ -948,6 +948,19 @@ $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< +# some perf warning policies can't fit to lib/bitmap.c, eg: it warns about variable shadowing +# from that comes from kernel headers wrapping. +KBITMAP_FLAGS=`echo $(ALL_CFLAGS) | sed s/-Wshadow// | sed s/-Wswitch-default// | sed s/-Wextra//` + +$(OUTPUT)util/bitmap.o: ../../lib/bitmap.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(KBITMAP_FLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< + +$(OUTPUT)util/hweight.o: ../../lib/hweight.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< + +$(OUTPUT)util/find_next_bit.o: ../../lib/find_next_bit.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< + $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< diff --git a/trunk/tools/perf/builtin-annotate.c b/trunk/tools/perf/builtin-annotate.c index ee154b58772b..b57dbcf62af3 100644 --- a/trunk/tools/perf/builtin-annotate.c +++ b/trunk/tools/perf/builtin-annotate.c @@ -554,7 +554,7 @@ static int __cmd_annotate(void) int ret; struct perf_session *session; - session = perf_session__new(input_name, O_RDONLY, force, false); + session = perf_session__new(input_name, O_RDONLY, force); if (session == NULL) return -ENOMEM; diff --git a/trunk/tools/perf/builtin-buildid-list.c b/trunk/tools/perf/builtin-buildid-list.c index 44a47e13bd67..7dc3b2e7a5e4 100644 --- a/trunk/tools/perf/builtin-buildid-list.c +++ b/trunk/tools/perf/builtin-buildid-list.c @@ -39,7 +39,7 @@ static int __cmd_buildid_list(void) int err = -1; struct perf_session *session; - session = perf_session__new(input_name, O_RDONLY, force, false); + session = perf_session__new(input_name, O_RDONLY, force); if (session == NULL) return -1; diff --git a/trunk/tools/perf/builtin-diff.c b/trunk/tools/perf/builtin-diff.c index 4cce68f23686..207e860591e2 100644 --- a/trunk/tools/perf/builtin-diff.c +++ b/trunk/tools/perf/builtin-diff.c @@ -156,8 +156,8 @@ static int __cmd_diff(void) int ret, i; struct perf_session *session[2]; - session[0] = perf_session__new(input_old, O_RDONLY, force, false); - session[1] = perf_session__new(input_new, O_RDONLY, force, false); + session[0] = perf_session__new(input_old, O_RDONLY, force); + session[1] = perf_session__new(input_new, O_RDONLY, force); if (session[0] == NULL || session[1] == NULL) return -ENOMEM; diff --git a/trunk/tools/perf/builtin-inject.c b/trunk/tools/perf/builtin-inject.c deleted file mode 100644 index 59e981a88908..000000000000 --- a/trunk/tools/perf/builtin-inject.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * builtin-inject.c - * - * Builtin inject command: Examine the live mode (stdin) event stream - * and repipe it to stdout while optionally injecting additional - * events into it. - */ -#include "builtin.h" - -#include "perf.h" -#include "util/session.h" -#include "util/debug.h" - -#include "util/parse-options.h" - -static char const *input_name = "-"; -static bool inject_build_ids; - -static int event__repipe(event_t *event __used, - struct perf_session *session __used) -{ - uint32_t size; - void *buf = event; - - size = event->header.size; - - while (size) { - int ret = write(STDOUT_FILENO, buf, size); - if (ret < 0) - return -errno; - - size -= ret; - buf += ret; - } - - return 0; -} - -static int event__repipe_mmap(event_t *self, struct perf_session *session) -{ - int err; - - err = event__process_mmap(self, session); - event__repipe(self, session); - - return err; -} - -static int event__repipe_task(event_t *self, struct perf_session *session) -{ - int err; - - err = event__process_task(self, session); - event__repipe(self, session); - - return err; -} - -static int event__repipe_tracing_data(event_t *self, - struct perf_session *session) -{ - int err; - - event__repipe(self, session); - err = event__process_tracing_data(self, session); - - return err; -} - -static int dso__read_build_id(struct dso *self) -{ - if (self->has_build_id) - return 0; - - if (filename__read_build_id(self->long_name, self->build_id, - sizeof(self->build_id)) > 0) { - self->has_build_id = true; - return 0; - } - - return -1; -} - -static int dso__inject_build_id(struct dso *self, struct perf_session *session) -{ - u16 misc = PERF_RECORD_MISC_USER; - struct machine *machine; - int err; - - if (dso__read_build_id(self) < 0) { - pr_debug("no build_id found for %s\n", self->long_name); - return -1; - } - - machine = perf_session__find_host_machine(session); - if (machine == NULL) { - pr_err("Can't find machine for session\n"); - return -1; - } - - if (self->kernel) - misc = PERF_RECORD_MISC_KERNEL; - - err = event__synthesize_build_id(self, misc, event__repipe, - machine, session); - if (err) { - pr_err("Can't synthesize build_id event for %s\n", self->long_name); - return -1; - } - - return 0; -} - -static int event__inject_buildid(event_t *event, struct perf_session *session) -{ - struct addr_location al; - struct thread *thread; - u8 cpumode; - - cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; - - thread = perf_session__findnew(session, event->ip.pid); - if (thread == NULL) { - pr_err("problem processing %d event, skipping it.\n", - event->header.type); - goto repipe; - } - - thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, - event->ip.pid, event->ip.ip, &al); - - if (al.map != NULL) { - if (!al.map->dso->hit) { - al.map->dso->hit = 1; - if (map__load(al.map, NULL) >= 0) { - dso__inject_build_id(al.map->dso, session); - /* - * If this fails, too bad, let the other side - * account this as unresolved. - */ - } else - pr_warning("no symbols found in %s, maybe " - "install a debug package?\n", - al.map->dso->long_name); - } - } - -repipe: - event__repipe(event, session); - return 0; -} - -struct perf_event_ops inject_ops = { - .sample = event__repipe, - .mmap = event__repipe, - .comm = event__repipe, - .fork = event__repipe, - .exit = event__repipe, - .lost = event__repipe, - .read = event__repipe, - .throttle = event__repipe, - .unthrottle = event__repipe, - .attr = event__repipe, - .event_type = event__repipe, - .tracing_data = event__repipe, - .build_id = event__repipe, -}; - -extern volatile int session_done; - -static void sig_handler(int sig __attribute__((__unused__))) -{ - session_done = 1; -} - -static int __cmd_inject(void) -{ - struct perf_session *session; - int ret = -EINVAL; - - signal(SIGINT, sig_handler); - - if (inject_build_ids) { - inject_ops.sample = event__inject_buildid; - inject_ops.mmap = event__repipe_mmap; - inject_ops.fork = event__repipe_task; - inject_ops.tracing_data = event__repipe_tracing_data; - } - - session = perf_session__new(input_name, O_RDONLY, false, true); - if (session == NULL) - return -ENOMEM; - - ret = perf_session__process_events(session, &inject_ops); - - perf_session__delete(session); - - return ret; -} - -static const char * const report_usage[] = { - "perf inject []", - NULL -}; - -static const struct option options[] = { - OPT_BOOLEAN('b', "inject build-ids", &inject_build_ids, - "Inject build-ids into the output stream"), - OPT_INCR('v', "verbose", &verbose, - "be more verbose (show build ids, etc)"), - OPT_END() -}; - -int cmd_inject(int argc, const char **argv, const char *prefix __used) -{ - argc = parse_options(argc, argv, options, report_usage, 0); - - /* - * Any (unrecognized) arguments left? - */ - if (argc) - usage_with_options(report_usage, options); - - if (symbol__init() < 0) - return -1; - - return __cmd_inject(); -} diff --git a/trunk/tools/perf/builtin-kmem.c b/trunk/tools/perf/builtin-kmem.c index 31f60a2535e0..ee05dba9609a 100644 --- a/trunk/tools/perf/builtin-kmem.c +++ b/trunk/tools/perf/builtin-kmem.c @@ -492,7 +492,7 @@ static void sort_result(void) static int __cmd_kmem(void) { int err = -EINVAL; - struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0, false); + struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0); if (session == NULL) return -ENOMEM; diff --git a/trunk/tools/perf/builtin-lock.c b/trunk/tools/perf/builtin-lock.c index 6605000ed73d..ce276750b140 100644 --- a/trunk/tools/perf/builtin-lock.c +++ b/trunk/tools/perf/builtin-lock.c @@ -818,7 +818,7 @@ static struct perf_event_ops eops = { static int read_events(void) { - session = perf_session__new(input_name, O_RDONLY, 0, false); + session = perf_session__new(input_name, O_RDONLY, 0); if (!session) die("Initializing perf session failed\n"); diff --git a/trunk/tools/perf/builtin-record.c b/trunk/tools/perf/builtin-record.c index ac989e9ba8fe..83b308a035c2 100644 --- a/trunk/tools/perf/builtin-record.c +++ b/trunk/tools/perf/builtin-record.c @@ -446,6 +446,13 @@ static void atexit_header(void) process_buildids(); perf_header__write(&session->header, output, true); + } else { + int err; + + err = event__synthesize_build_ids(process_synthesized_event, + session); + if (err < 0) + pr_err("Couldn't synthesize build ids.\n"); } } @@ -548,7 +555,7 @@ static int __cmd_record(int argc, const char **argv) } session = perf_session__new(output_name, O_WRONLY, - write_mode == WRITE_FORCE, false); + write_mode == WRITE_FORCE); if (session == NULL) { pr_err("Not enough memory for reading perf file header\n"); return -1; @@ -666,15 +673,12 @@ static int __cmd_record(int argc, const char **argv) nr_counters, process_synthesized_event, session); - /* - * FIXME err <= 0 here actually means that there were no tracepoints - * so its not really an error, just that we don't need to synthesize - * anything. - * We really have to return this more properly and also propagate - * errors that now are calling die() - */ - if (err > 0) - advance_output(err); + if (err <= 0) { + pr_err("Couldn't record tracing data.\n"); + return err; + } + + advance_output(err); } machine = perf_session__find_host_machine(session); diff --git a/trunk/tools/perf/builtin-report.c b/trunk/tools/perf/builtin-report.c index 0152b5412cc3..f1b46eb7ef9a 100644 --- a/trunk/tools/perf/builtin-report.c +++ b/trunk/tools/perf/builtin-report.c @@ -289,7 +289,7 @@ static int __cmd_report(void) signal(SIGINT, sig_handler); - session = perf_session__new(input_name, O_RDONLY, force, false); + session = perf_session__new(input_name, O_RDONLY, force); if (session == NULL) return -ENOMEM; diff --git a/trunk/tools/perf/builtin-sched.c b/trunk/tools/perf/builtin-sched.c index aef6ed0e119c..94453f1e4e01 100644 --- a/trunk/tools/perf/builtin-sched.c +++ b/trunk/tools/perf/builtin-sched.c @@ -1660,7 +1660,7 @@ static struct perf_event_ops event_ops = { static int read_events(void) { int err = -EINVAL; - struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0, false); + struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0); if (session == NULL) return -ENOMEM; diff --git a/trunk/tools/perf/builtin-timechart.c b/trunk/tools/perf/builtin-timechart.c index 5a52ed9fc10b..c35aa44f82ba 100644 --- a/trunk/tools/perf/builtin-timechart.c +++ b/trunk/tools/perf/builtin-timechart.c @@ -936,7 +936,7 @@ static struct perf_event_ops event_ops = { static int __cmd_timechart(void) { - struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0, false); + struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0); int ret = -EINVAL; if (session == NULL) diff --git a/trunk/tools/perf/builtin-top.c b/trunk/tools/perf/builtin-top.c index 3de397764cb3..d95281f588d2 100644 --- a/trunk/tools/perf/builtin-top.c +++ b/trunk/tools/perf/builtin-top.c @@ -1287,7 +1287,7 @@ static int __cmd_top(void) * FIXME: perf_session__new should allow passing a O_MMAP, so that all this * mmap reading, etc is encapsulated in it. Use O_WRONLY for now. */ - struct perf_session *session = perf_session__new(NULL, O_WRONLY, false, false); + struct perf_session *session = perf_session__new(NULL, O_WRONLY, false); if (session == NULL) return -ENOMEM; diff --git a/trunk/tools/perf/builtin-trace.c b/trunk/tools/perf/builtin-trace.c index 9c483e92e8db..77f556f7604c 100644 --- a/trunk/tools/perf/builtin-trace.c +++ b/trunk/tools/perf/builtin-trace.c @@ -661,7 +661,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) if (!script_name) setup_pager(); - session = perf_session__new(input_name, O_RDONLY, 0, false); + session = perf_session__new(input_name, O_RDONLY, 0); if (session == NULL) return -ENOMEM; diff --git a/trunk/tools/perf/builtin.h b/trunk/tools/perf/builtin.h index 921245b28583..34a8a9ab9617 100644 --- a/trunk/tools/perf/builtin.h +++ b/trunk/tools/perf/builtin.h @@ -34,6 +34,5 @@ extern int cmd_kmem(int argc, const char **argv, const char *prefix); extern int cmd_lock(int argc, const char **argv, const char *prefix); extern int cmd_kvm(int argc, const char **argv, const char *prefix); extern int cmd_test(int argc, const char **argv, const char *prefix); -extern int cmd_inject(int argc, const char **argv, const char *prefix); #endif diff --git a/trunk/tools/perf/perf.c b/trunk/tools/perf/perf.c index 08e0e5d2b50e..5ff9b5b46970 100644 --- a/trunk/tools/perf/perf.c +++ b/trunk/tools/perf/perf.c @@ -309,7 +309,6 @@ static void handle_internal_command(int argc, const char **argv) { "lock", cmd_lock, 0 }, { "kvm", cmd_kvm, 0 }, { "test", cmd_test, 0 }, - { "inject", cmd_inject, 0 }, }; unsigned int i; static const char ext[] = STRIP_EXTENSION; diff --git a/trunk/tools/perf/scripts/perl/bin/check-perf-trace-record b/trunk/tools/perf/scripts/perl/bin/check-perf-trace-record index e6cb1474f8e8..423ad6aed056 100644 --- a/trunk/tools/perf/scripts/perl/bin/check-perf-trace-record +++ b/trunk/tools/perf/scripts/perl/bin/check-perf-trace-record @@ -1,2 +1,2 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e kmem:kmalloc -e irq:softirq_entry -e kmem:kfree +perf record -a -e kmem:kmalloc -e irq:softirq_entry -e kmem:kfree diff --git a/trunk/tools/perf/scripts/perl/bin/failed-syscalls-record b/trunk/tools/perf/scripts/perl/bin/failed-syscalls-record index 6ad9b8f5f009..eb5846bcb565 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 -a -e raw_syscalls:sys_exit $@ 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..5bfaae5a6cba 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,3 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e syscalls:sys_enter_read -e syscalls:sys_enter_write $@ +perf record -a -e syscalls:sys_enter_read -e syscalls:sys_enter_write $@ 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..6e0b2f7755ac 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 -a -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-record b/trunk/tools/perf/scripts/perl/bin/rwtop-record index 63976bf11e8b..6e0b2f7755ac 100644 --- a/trunk/tools/perf/scripts/perl/bin/rwtop-record +++ b/trunk/tools/perf/scripts/perl/bin/rwtop-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 -a -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/wakeup-latency-record b/trunk/tools/perf/scripts/perl/bin/wakeup-latency-record index 9c0cf588ff8c..9f2acaaae9f0 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 -a -e sched:sched_switch -e sched:sched_wakeup $@ diff --git a/trunk/tools/perf/scripts/perl/bin/workqueue-stats-record b/trunk/tools/perf/scripts/perl/bin/workqueue-stats-record index c2a1a9421133..85301f2471ff 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 -a -e workqueue:workqueue_creation -e workqueue:workqueue_destruction -e workqueue:workqueue_execution -e workqueue:workqueue_insertion $@ 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..eb5846bcb565 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 -a -e raw_syscalls:sys_exit $@ diff --git a/trunk/tools/perf/scripts/python/bin/sctop-record b/trunk/tools/perf/scripts/python/bin/sctop-record index 27ccffa26ab4..1fc5998b721d 100644 --- a/trunk/tools/perf/scripts/python/bin/sctop-record +++ b/trunk/tools/perf/scripts/python/bin/sctop-record @@ -1,2 +1,2 @@ #!/bin/bash -perf record -c 1 -f -a -M -R -e raw_syscalls:sys_enter $@ +perf record -a -e raw_syscalls:sys_enter $@ 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..1fc5998b721d 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 -a -e raw_syscalls:sys_enter $@ diff --git a/trunk/tools/perf/scripts/python/bin/syscall-counts-record b/trunk/tools/perf/scripts/python/bin/syscall-counts-record index 27ccffa26ab4..1fc5998b721d 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 -a -e raw_syscalls:sys_enter $@ diff --git a/trunk/tools/perf/util/bitmap.c b/trunk/tools/perf/util/bitmap.c deleted file mode 100644 index 5e230acae1e9..000000000000 --- a/trunk/tools/perf/util/bitmap.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * From lib/bitmap.c - * Helper functions for bitmap.h. - * - * This source code is licensed under the GNU General Public License, - * Version 2. See the file COPYING for more details. - */ -#include - -int __bitmap_weight(const unsigned long *bitmap, int bits) -{ - int k, w = 0, lim = bits/BITS_PER_LONG; - - for (k = 0; k < lim; k++) - w += hweight_long(bitmap[k]); - - if (bits % BITS_PER_LONG) - w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); - - return w; -} diff --git a/trunk/tools/perf/util/header.c b/trunk/tools/perf/util/header.c index 79da0e50ef8f..6227dc4cb2cf 100644 --- a/trunk/tools/perf/util/header.c +++ b/trunk/tools/perf/util/header.c @@ -713,18 +713,10 @@ static int __event_process_build_id(struct build_id_event *bev, dso = __dsos__findnew(head, filename); if (dso != NULL) { - char sbuild_id[BUILD_ID_SIZE * 2 + 1]; - dso__set_build_id(dso, &bev->build_id); - - if (filename[0] == '[') - dso->kernel = dso_type; - - build_id__sprintf(dso->build_id, sizeof(dso->build_id), - sbuild_id); - pr_debug("build id event received for %s: %s\n", - dso->long_name, sbuild_id); - } + if (filename[0] == '[') + dso->kernel = dso_type; + } err = 0; out: @@ -775,7 +767,7 @@ static int perf_file_section__process(struct perf_file_section *self, switch (feat) { case HEADER_TRACE_INFO: - trace_report(fd, false); + trace_report(fd); break; case HEADER_BUILD_ID: @@ -790,16 +782,12 @@ static int perf_file_section__process(struct perf_file_section *self, } static int perf_file_header__read_pipe(struct perf_pipe_file_header *self, - struct perf_header *ph, int fd, - bool repipe) + 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 (repipe && do_write(STDOUT_FILENO, self, sizeof(*self)) < 0) - return -1; - if (self->size != sizeof(*self)) { u64 size = bswap_64(self->size); @@ -817,8 +805,7 @@ 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, - session->repipe) < 0) { + if (perf_file_header__read_pipe(&f_header, self, fd) < 0) { pr_debug("incompatible file format\n"); return -EINVAL; } @@ -1109,17 +1096,12 @@ int event__process_tracing_data(event_t *self, lseek(session->fd, offset + sizeof(struct tracing_data_event), SEEK_SET); - size_read = trace_report(session->fd, session->repipe); + 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 (session->repipe) { - int retw = write(STDOUT_FILENO, buf, padding); - if (retw <= 0 || retw != padding) - die("repiping tracing data padding"); - } if (size_read + padding != size) die("tracing data size mismatch"); @@ -1128,8 +1110,7 @@ int event__process_tracing_data(event_t *self, } int event__synthesize_build_id(struct dso *pos, u16 misc, - event__handler_t process, - struct machine *machine, + event__handler_t process, struct machine *machine, struct perf_session *session) { event_t ev; @@ -1155,6 +1136,67 @@ int event__synthesize_build_id(struct dso *pos, u16 misc, return err; } +static int __event_synthesize_build_ids(struct list_head *head, u16 misc, + event__handler_t process, + struct machine *machine, + 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, + machine, session); + if (err < 0) + return err; + } + + return 0; +} + +int event__synthesize_build_ids(event__handler_t process, + struct perf_session *session) +{ + int err = 0; + u16 kmisc, umisc; + struct machine *pos; + struct rb_node *nd; + + if (!dsos__read_build_ids(&session->header, true)) + return 0; + + for (nd = rb_first(&session->machines); nd; nd = rb_next(nd)) { + pos = rb_entry(nd, struct machine, rb_node); + if (machine__is_host(pos)) { + kmisc = PERF_RECORD_MISC_KERNEL; + umisc = PERF_RECORD_MISC_USER; + } else { + kmisc = PERF_RECORD_MISC_GUEST_KERNEL; + umisc = PERF_RECORD_MISC_GUEST_USER; + } + + err = __event_synthesize_build_ids(&pos->kernel_dsos, kmisc, + process, pos, session); + if (err == 0) + err = __event_synthesize_build_ids(&pos->user_dsos, umisc, + process, pos, session); + if (err) + break; + } + + if (err < 0) { + pr_debug("failed to synthesize build ids\n"); + return err; + } + + dsos__cache_build_ids(&session->header); + + return 0; +} + int event__process_build_id(event_t *self, struct perf_session *session) { diff --git a/trunk/tools/perf/util/header.h b/trunk/tools/perf/util/header.h index 402ac2454cf8..f39443db0706 100644 --- a/trunk/tools/perf/util/header.h +++ b/trunk/tools/perf/util/header.h @@ -122,6 +122,8 @@ int event__synthesize_build_id(struct dso *pos, u16 misc, event__handler_t process, struct machine *machine, 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/hweight.c b/trunk/tools/perf/util/hweight.c deleted file mode 100644 index 5c1d0d099f0d..000000000000 --- a/trunk/tools/perf/util/hweight.c +++ /dev/null @@ -1,31 +0,0 @@ -#include - -/** - * hweightN - returns the hamming weight of a N-bit word - * @x: the word to weigh - * - * The Hamming Weight of a number is the total number of bits set in it. - */ - -unsigned int hweight32(unsigned int w) -{ - unsigned int res = w - ((w >> 1) & 0x55555555); - res = (res & 0x33333333) + ((res >> 2) & 0x33333333); - res = (res + (res >> 4)) & 0x0F0F0F0F; - res = res + (res >> 8); - return (res + (res >> 16)) & 0x000000FF; -} - -unsigned long hweight64(__u64 w) -{ -#if BITS_PER_LONG == 32 - return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w); -#elif BITS_PER_LONG == 64 - __u64 res = w - ((w >> 1) & 0x5555555555555555ul); - res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); - res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful; - res = res + (res >> 8); - res = res + (res >> 16); - return (res + (res >> 32)) & 0x00000000000000FFul; -#endif -} diff --git a/trunk/tools/perf/util/include/asm/bitops.h b/trunk/tools/perf/util/include/asm/bitops.h new file mode 100644 index 000000000000..58e9817ffae0 --- /dev/null +++ b/trunk/tools/perf/util/include/asm/bitops.h @@ -0,0 +1,18 @@ +#ifndef _PERF_ASM_BITOPS_H_ +#define _PERF_ASM_BITOPS_H_ + +#include +#include "../../types.h" +#include + +/* CHECKME: Not sure both always match */ +#define BITS_PER_LONG __WORDSIZE + +#include "../../../../include/asm-generic/bitops/__fls.h" +#include "../../../../include/asm-generic/bitops/fls.h" +#include "../../../../include/asm-generic/bitops/fls64.h" +#include "../../../../include/asm-generic/bitops/__ffs.h" +#include "../../../../include/asm-generic/bitops/ffz.h" +#include "../../../../include/asm-generic/bitops/hweight.h" + +#endif diff --git a/trunk/tools/perf/util/include/asm/hweight.h b/trunk/tools/perf/util/include/asm/hweight.h deleted file mode 100644 index 36cf26d434a5..000000000000 --- a/trunk/tools/perf/util/include/asm/hweight.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PERF_HWEIGHT_H -#define PERF_HWEIGHT_H - -#include -unsigned int hweight32(unsigned int w); -unsigned long hweight64(__u64 w); - -#endif /* PERF_HWEIGHT_H */ diff --git a/trunk/tools/perf/util/include/linux/bitmap.h b/trunk/tools/perf/util/include/linux/bitmap.h index eda4416efa0a..94507639a8c4 100644 --- a/trunk/tools/perf/util/include/linux/bitmap.h +++ b/trunk/tools/perf/util/include/linux/bitmap.h @@ -1,35 +1,3 @@ -#ifndef _PERF_BITOPS_H -#define _PERF_BITOPS_H - -#include -#include - -int __bitmap_weight(const unsigned long *bitmap, int bits); - -#define BITMAP_LAST_WORD_MASK(nbits) \ -( \ - ((nbits) % BITS_PER_LONG) ? \ - (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ -) - -#define small_const_nbits(nbits) \ - (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) - -static inline void bitmap_zero(unsigned long *dst, int nbits) -{ - if (small_const_nbits(nbits)) - *dst = 0UL; - else { - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memset(dst, 0, len); - } -} - -static inline int bitmap_weight(const unsigned long *src, int nbits) -{ - if (small_const_nbits(nbits)) - return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits)); - return __bitmap_weight(src, nbits); -} - -#endif /* _PERF_BITOPS_H */ +#include "../../../../include/linux/bitmap.h" +#include "../../../../include/asm-generic/bitops/find.h" +#include diff --git a/trunk/tools/perf/util/include/linux/bitops.h b/trunk/tools/perf/util/include/linux/bitops.h index bb4ac2e05385..8d63116e9435 100644 --- a/trunk/tools/perf/util/include/linux/bitops.h +++ b/trunk/tools/perf/util/include/linux/bitops.h @@ -1,12 +1,13 @@ #ifndef _PERF_LINUX_BITOPS_H_ #define _PERF_LINUX_BITOPS_H_ -#include -#include +#define __KERNEL__ -#define BITS_PER_LONG __WORDSIZE -#define BITS_PER_BYTE 8 -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define CONFIG_GENERIC_FIND_NEXT_BIT +#define CONFIG_GENERIC_FIND_FIRST_BIT +#include "../../../../include/linux/bitops.h" + +#undef __KERNEL__ static inline void set_bit(int nr, unsigned long *addr) { @@ -19,9 +20,10 @@ static __always_inline int test_bit(unsigned int nr, const unsigned long *addr) (((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0; } -static inline unsigned long hweight_long(unsigned long w) -{ - return sizeof(w) == 4 ? hweight32(w) : hweight64(w); -} +unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, unsigned + long size, unsigned long offset); + +unsigned long generic_find_next_le_bit(const unsigned long *addr, unsigned + long size, unsigned long offset); #endif diff --git a/trunk/tools/perf/util/session.c b/trunk/tools/perf/util/session.c index 5d353e70fe26..a8dd73ed1581 100644 --- a/trunk/tools/perf/util/session.c +++ b/trunk/tools/perf/util/session.c @@ -77,7 +77,7 @@ int perf_session__create_kernel_maps(struct perf_session *self) return ret; } -struct perf_session *perf_session__new(const char *filename, int mode, bool force, bool repipe) +struct perf_session *perf_session__new(const char *filename, int mode, bool force) { size_t len = filename ? strlen(filename) + 1 : 0; struct perf_session *self = zalloc(sizeof(*self) + len); @@ -97,7 +97,6 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc self->cwdlen = 0; self->unknown_events = 0; self->machines = RB_ROOT; - self->repipe = repipe; self->ordered_samples.flush_limit = ULLONG_MAX; INIT_LIST_HEAD(&self->ordered_samples.samples_head); diff --git a/trunk/tools/perf/util/session.h b/trunk/tools/perf/util/session.h index f2b2c6a3a49d..61ca92e58ad4 100644 --- a/trunk/tools/perf/util/session.h +++ b/trunk/tools/perf/util/session.h @@ -34,7 +34,6 @@ struct perf_session { u64 sample_type; int fd; bool fd_pipe; - bool repipe; int cwdlen; char *cwd; struct ordered_samples ordered_samples; @@ -60,7 +59,7 @@ struct perf_event_ops { bool ordered_samples; }; -struct perf_session *perf_session__new(const char *filename, int mode, bool force, bool repipe); +struct perf_session *perf_session__new(const char *filename, int mode, bool force); void perf_session__delete(struct perf_session *self); void perf_event_header__bswap(struct perf_event_header *self); diff --git a/trunk/tools/perf/util/trace-event-read.c b/trunk/tools/perf/util/trace-event-read.c index 43f19c1fed3a..44889c9b5630 100644 --- a/trunk/tools/perf/util/trace-event-read.c +++ b/trunk/tools/perf/util/trace-event-read.c @@ -51,7 +51,6 @@ static int long_size; static unsigned long page_size; static ssize_t calc_data_size; -static bool repipe; static int do_read(int fd, void *buf, int size) { @@ -63,13 +62,6 @@ static int do_read(int fd, void *buf, int size) if (ret <= 0) return -1; - if (repipe) { - int retw = write(STDOUT_FILENO, buf, ret); - - if (retw <= 0 || retw != ret) - die("repiping input file"); - } - size -= ret; buf += ret; } @@ -124,13 +116,6 @@ static char *read_string(void) if (!r) die("no data"); - if (repipe) { - int retw = write(STDOUT_FILENO, &c, 1); - - if (retw <= 0 || retw != r) - die("repiping input file string"); - } - buf[size++] = c; if (!c) @@ -469,7 +454,7 @@ struct record *trace_read_data(int cpu) return data; } -ssize_t trace_report(int fd, bool __repipe) +ssize_t trace_report(int fd) { char buf[BUFSIZ]; char test[] = { 23, 8, 68 }; @@ -480,7 +465,6 @@ ssize_t trace_report(int fd, bool __repipe) ssize_t size; calc_data_size = 1; - repipe = __repipe; input_fd = fd; @@ -515,7 +499,6 @@ ssize_t trace_report(int fd, bool __repipe) size = calc_data_size - 1; calc_data_size = 0; - repipe = false; if (show_funcs) { print_funcs(); diff --git a/trunk/tools/perf/util/trace-event.h b/trunk/tools/perf/util/trace-event.h index ebfee80e4a07..1f45d468fd9a 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, bool repipe); +ssize_t trace_report(int fd); void *malloc_or_die(unsigned int size);