diff --git a/[refs] b/[refs] index 85d4fccf7131..39df8b9514c7 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3a9a0beba2913edaae39ff8b4645fee10c3acf37 +refs/heads/master: ed872d09effd54aa8ecb4ceedbc4dbab9592f337 diff --git a/trunk/include/linux/hw_breakpoint.h b/trunk/include/linux/hw_breakpoint.h index 4d14a384a01e..42da1ce19ec0 100644 --- a/trunk/include/linux/hw_breakpoint.h +++ b/trunk/include/linux/hw_breakpoint.h @@ -22,6 +22,8 @@ enum { static inline void hw_breakpoint_init(struct perf_event_attr *attr) { + memset(attr, 0, sizeof(*attr)); + attr->type = PERF_TYPE_BREAKPOINT; attr->size = sizeof(*attr); /* diff --git a/trunk/tools/perf/builtin-kmem.c b/trunk/tools/perf/builtin-kmem.c index 7551a5f834b8..f218990de0cd 100644 --- a/trunk/tools/perf/builtin-kmem.c +++ b/trunk/tools/perf/builtin-kmem.c @@ -57,6 +57,11 @@ static struct rb_root root_caller_sorted; static unsigned long total_requested, total_allocated; static unsigned long nr_allocs, nr_cross_allocs; +struct raw_event_sample { + u32 size; + char data[0]; +}; + #define PATH_SYS_NODE "/sys/devices/system/node" static void init_cpunode_map(void) @@ -196,7 +201,7 @@ static void insert_caller_stat(unsigned long call_site, } } -static void process_alloc_event(void *data, +static void process_alloc_event(struct raw_event_sample *raw, struct event *event, int cpu, u64 timestamp __used, @@ -209,10 +214,10 @@ static void process_alloc_event(void *data, int bytes_alloc; int node1, node2; - ptr = raw_field_value(event, "ptr", data); - call_site = raw_field_value(event, "call_site", data); - bytes_req = raw_field_value(event, "bytes_req", data); - bytes_alloc = raw_field_value(event, "bytes_alloc", data); + ptr = raw_field_value(event, "ptr", raw->data); + call_site = raw_field_value(event, "call_site", raw->data); + bytes_req = raw_field_value(event, "bytes_req", raw->data); + bytes_alloc = raw_field_value(event, "bytes_alloc", raw->data); insert_alloc_stat(call_site, ptr, bytes_req, bytes_alloc, cpu); insert_caller_stat(call_site, bytes_req, bytes_alloc); @@ -222,7 +227,7 @@ static void process_alloc_event(void *data, if (node) { node1 = cpunode_map[cpu]; - node2 = raw_field_value(event, "node", data); + node2 = raw_field_value(event, "node", raw->data); if (node1 != node2) nr_cross_allocs++; } @@ -257,7 +262,7 @@ static struct alloc_stat *search_alloc_stat(unsigned long ptr, return NULL; } -static void process_free_event(void *data, +static void process_free_event(struct raw_event_sample *raw, struct event *event, int cpu, u64 timestamp __used, @@ -266,7 +271,7 @@ static void process_free_event(void *data, unsigned long ptr; struct alloc_stat *s_alloc, *s_caller; - ptr = raw_field_value(event, "ptr", data); + ptr = raw_field_value(event, "ptr", raw->data); s_alloc = search_alloc_stat(ptr, 0, &root_alloc_stat, ptr_cmp); if (!s_alloc) @@ -284,30 +289,31 @@ static void process_free_event(void *data, } static void -process_raw_event(event_t *raw_event __used, void *data, +process_raw_event(event_t *raw_event __used, void *more_data, int cpu, u64 timestamp, struct thread *thread) { + struct raw_event_sample *raw = more_data; struct event *event; int type; - type = trace_parse_common_type(data); + type = trace_parse_common_type(raw->data); event = trace_find_event(type); if (!strcmp(event->name, "kmalloc") || !strcmp(event->name, "kmem_cache_alloc")) { - process_alloc_event(data, event, cpu, timestamp, thread, 0); + process_alloc_event(raw, event, cpu, timestamp, thread, 0); return; } if (!strcmp(event->name, "kmalloc_node") || !strcmp(event->name, "kmem_cache_alloc_node")) { - process_alloc_event(data, event, cpu, timestamp, thread, 1); + process_alloc_event(raw, event, cpu, timestamp, thread, 1); return; } if (!strcmp(event->name, "kfree") || !strcmp(event->name, "kmem_cache_free")) { - process_free_event(data, event, cpu, timestamp, thread); + process_free_event(raw, event, cpu, timestamp, thread); return; } } @@ -339,8 +345,7 @@ static int process_sample_event(event_t *event) dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); - process_raw_event(event, data.raw_data, data.cpu, - data.time, thread); + process_raw_event(event, data.raw_data, data.cpu, data.time, thread); return 0; } diff --git a/trunk/tools/perf/builtin-sched.c b/trunk/tools/perf/builtin-sched.c index 19f43faa9f81..45c46c790493 100644 --- a/trunk/tools/perf/builtin-sched.c +++ b/trunk/tools/perf/builtin-sched.c @@ -628,6 +628,11 @@ static void test_calibrations(void) printf("the sleep test took %Ld nsecs\n", T1-T0); } +struct raw_event_sample { + u32 size; + char data[0]; +}; + #define FILL_FIELD(ptr, field, event, data) \ ptr.field = (typeof(ptr.field)) raw_field_value(event, #field, data) @@ -1351,7 +1356,7 @@ static void sort_lat(void) static struct trace_sched_handler *trace_handler; static void -process_sched_wakeup_event(void *data, +process_sched_wakeup_event(struct raw_event_sample *raw, struct event *event, int cpu __used, u64 timestamp __used, @@ -1359,13 +1364,13 @@ process_sched_wakeup_event(void *data, { struct trace_wakeup_event wakeup_event; - FILL_COMMON_FIELDS(wakeup_event, event, data); + FILL_COMMON_FIELDS(wakeup_event, event, raw->data); - FILL_ARRAY(wakeup_event, comm, event, data); - FILL_FIELD(wakeup_event, pid, event, data); - FILL_FIELD(wakeup_event, prio, event, data); - FILL_FIELD(wakeup_event, success, event, data); - FILL_FIELD(wakeup_event, cpu, event, data); + FILL_ARRAY(wakeup_event, comm, event, raw->data); + FILL_FIELD(wakeup_event, pid, event, raw->data); + FILL_FIELD(wakeup_event, prio, event, raw->data); + FILL_FIELD(wakeup_event, success, event, raw->data); + FILL_FIELD(wakeup_event, cpu, event, raw->data); if (trace_handler->wakeup_event) trace_handler->wakeup_event(&wakeup_event, event, cpu, timestamp, thread); @@ -1464,7 +1469,7 @@ map_switch_event(struct trace_switch_event *switch_event, static void -process_sched_switch_event(void *data, +process_sched_switch_event(struct raw_event_sample *raw, struct event *event, int this_cpu, u64 timestamp __used, @@ -1472,15 +1477,15 @@ process_sched_switch_event(void *data, { struct trace_switch_event switch_event; - FILL_COMMON_FIELDS(switch_event, event, data); + FILL_COMMON_FIELDS(switch_event, event, raw->data); - FILL_ARRAY(switch_event, prev_comm, event, data); - FILL_FIELD(switch_event, prev_pid, event, data); - FILL_FIELD(switch_event, prev_prio, event, data); - FILL_FIELD(switch_event, prev_state, event, data); - FILL_ARRAY(switch_event, next_comm, event, data); - FILL_FIELD(switch_event, next_pid, event, data); - FILL_FIELD(switch_event, next_prio, event, data); + FILL_ARRAY(switch_event, prev_comm, event, raw->data); + FILL_FIELD(switch_event, prev_pid, event, raw->data); + FILL_FIELD(switch_event, prev_prio, event, raw->data); + FILL_FIELD(switch_event, prev_state, event, raw->data); + FILL_ARRAY(switch_event, next_comm, event, raw->data); + FILL_FIELD(switch_event, next_pid, event, raw->data); + FILL_FIELD(switch_event, next_prio, event, raw->data); if (curr_pid[this_cpu] != (u32)-1) { /* @@ -1497,7 +1502,7 @@ process_sched_switch_event(void *data, } static void -process_sched_runtime_event(void *data, +process_sched_runtime_event(struct raw_event_sample *raw, struct event *event, int cpu __used, u64 timestamp __used, @@ -1505,17 +1510,17 @@ process_sched_runtime_event(void *data, { struct trace_runtime_event runtime_event; - FILL_ARRAY(runtime_event, comm, event, data); - FILL_FIELD(runtime_event, pid, event, data); - FILL_FIELD(runtime_event, runtime, event, data); - FILL_FIELD(runtime_event, vruntime, event, data); + FILL_ARRAY(runtime_event, comm, event, raw->data); + FILL_FIELD(runtime_event, pid, event, raw->data); + FILL_FIELD(runtime_event, runtime, event, raw->data); + FILL_FIELD(runtime_event, vruntime, event, raw->data); if (trace_handler->runtime_event) trace_handler->runtime_event(&runtime_event, event, cpu, timestamp, thread); } static void -process_sched_fork_event(void *data, +process_sched_fork_event(struct raw_event_sample *raw, struct event *event, int cpu __used, u64 timestamp __used, @@ -1523,12 +1528,12 @@ process_sched_fork_event(void *data, { struct trace_fork_event fork_event; - FILL_COMMON_FIELDS(fork_event, event, data); + FILL_COMMON_FIELDS(fork_event, event, raw->data); - FILL_ARRAY(fork_event, parent_comm, event, data); - FILL_FIELD(fork_event, parent_pid, event, data); - FILL_ARRAY(fork_event, child_comm, event, data); - FILL_FIELD(fork_event, child_pid, event, data); + FILL_ARRAY(fork_event, parent_comm, event, raw->data); + FILL_FIELD(fork_event, parent_pid, event, raw->data); + FILL_ARRAY(fork_event, child_comm, event, raw->data); + FILL_FIELD(fork_event, child_pid, event, raw->data); if (trace_handler->fork_event) trace_handler->fork_event(&fork_event, event, cpu, timestamp, thread); @@ -1545,7 +1550,7 @@ process_sched_exit_event(struct event *event, } static void -process_sched_migrate_task_event(void *data, +process_sched_migrate_task_event(struct raw_event_sample *raw, struct event *event, int cpu __used, u64 timestamp __used, @@ -1553,42 +1558,42 @@ process_sched_migrate_task_event(void *data, { struct trace_migrate_task_event migrate_task_event; - FILL_COMMON_FIELDS(migrate_task_event, event, data); + FILL_COMMON_FIELDS(migrate_task_event, event, raw->data); - FILL_ARRAY(migrate_task_event, comm, event, data); - FILL_FIELD(migrate_task_event, pid, event, data); - FILL_FIELD(migrate_task_event, prio, event, data); - FILL_FIELD(migrate_task_event, cpu, event, data); + FILL_ARRAY(migrate_task_event, comm, event, raw->data); + FILL_FIELD(migrate_task_event, pid, event, raw->data); + FILL_FIELD(migrate_task_event, prio, event, raw->data); + FILL_FIELD(migrate_task_event, cpu, event, raw->data); if (trace_handler->migrate_task_event) trace_handler->migrate_task_event(&migrate_task_event, event, cpu, timestamp, thread); } static void -process_raw_event(event_t *raw_event __used, void *data, +process_raw_event(event_t *raw_event __used, void *more_data, int cpu, u64 timestamp, struct thread *thread) { + struct raw_event_sample *raw = more_data; struct event *event; int type; - - type = trace_parse_common_type(data); + type = trace_parse_common_type(raw->data); event = trace_find_event(type); if (!strcmp(event->name, "sched_switch")) - process_sched_switch_event(data, event, cpu, timestamp, thread); + process_sched_switch_event(raw, event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_stat_runtime")) - process_sched_runtime_event(data, event, cpu, timestamp, thread); + process_sched_runtime_event(raw, event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_wakeup")) - process_sched_wakeup_event(data, event, cpu, timestamp, thread); + process_sched_wakeup_event(raw, event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_wakeup_new")) - process_sched_wakeup_event(data, event, cpu, timestamp, thread); + process_sched_wakeup_event(raw, event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_process_fork")) - process_sched_fork_event(data, event, cpu, timestamp, thread); + process_sched_fork_event(raw, event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_process_exit")) process_sched_exit_event(event, cpu, timestamp, thread); if (!strcmp(event->name, "sched_migrate_task")) - process_sched_migrate_task_event(data, event, cpu, timestamp, thread); + process_sched_migrate_task_event(raw, event, cpu, timestamp, thread); } static int process_sample_event(event_t *event) @@ -1883,18 +1888,13 @@ static int __cmd_record(int argc, const char **argv) int cmd_sched(int argc, const char **argv, const char *prefix __used) { + symbol__init(0); + argc = parse_options(argc, argv, sched_options, sched_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) usage_with_options(sched_usage, sched_options); - /* - * Aliased to 'perf trace' for now: - */ - if (!strcmp(argv[0], "trace")) - return cmd_trace(argc, argv, prefix); - - symbol__init(0); if (!strncmp(argv[0], "rec", 3)) { return __cmd_record(argc, argv); } else if (!strncmp(argv[0], "lat", 3)) { @@ -1918,6 +1918,11 @@ int cmd_sched(int argc, const char **argv, const char *prefix __used) usage_with_options(replay_usage, replay_options); } __cmd_replay(); + } else if (!strcmp(argv[0], "trace")) { + /* + * Aliased to 'perf trace' for now: + */ + return cmd_trace(argc, argv, prefix); } else { usage_with_options(sched_usage, sched_options); } diff --git a/trunk/tools/perf/util/header.c b/trunk/tools/perf/util/header.c index 59a9c0b3033e..08b6759287f5 100644 --- a/trunk/tools/perf/util/header.c +++ b/trunk/tools/perf/util/header.c @@ -209,7 +209,7 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd) err = do_write(fd, pos->long_name, pos->long_name_len + 1); if (err < 0) return err; - err = do_write(fd, zero_buf, len - pos->long_name_len - 1); + err = do_write(fd, zero_buf, len - pos->long_name_len + 1); if (err < 0) return err; } diff --git a/trunk/tools/perf/util/trace-event-perl.c b/trunk/tools/perf/util/trace-event-perl.c index 59564b22d9ce..51e833fd58c3 100644 --- a/trunk/tools/perf/util/trace-event-perl.c +++ b/trunk/tools/perf/util/trace-event-perl.c @@ -32,6 +32,9 @@ void xs_init(pTHX); +void boot_Perf__Trace__Context(pTHX_ CV *cv); +void boot_DynaLoader(pTHX_ CV *cv); + void xs_init(pTHX) { const char *file = __FILE__; diff --git a/trunk/tools/perf/util/trace-event-perl.h b/trunk/tools/perf/util/trace-event-perl.h index e88fb26137bb..8fe0d866fe1a 100644 --- a/trunk/tools/perf/util/trace-event-perl.h +++ b/trunk/tools/perf/util/trace-event-perl.h @@ -34,13 +34,9 @@ typedef int INTERP; #define dXSUB_SYS #define pTHX_ static inline void newXS(const char *a, void *b, const char *c) {} -static void boot_Perf__Trace__Context(pTHX_ CV *cv) {} -static void boot_DynaLoader(pTHX_ CV *cv) {} #else #include #include -void boot_Perf__Trace__Context(pTHX_ CV *cv); -void boot_DynaLoader(pTHX_ CV *cv); typedef PerlInterpreter * INTERP; #endif