Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

  * Fix version when building out of tree, as when using one of these:

    $ make help | grep perf
      perf-tar-src-pkg    - Build perf-3.12.0.tar source tarball
      perf-targz-src-pkg  - Build perf-3.12.0.tar.gz source tarball
      perf-tarbz2-src-pkg - Build perf-3.12.0.tar.bz2 source tarball
      perf-tarxz-src-pkg  - Build perf-3.12.0.tar.xz source tarball
    $

    from David Ahern.

  * Don't relookup fields by name in each sample in 'trace',
    by Arnaldo Carvalho de Melo.

  * 'perf record' code cleanups, from David Ahern.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Nov 7, 2013
2 parents 8a4d0b5 + 8ce000e commit 4d9218d
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 59 deletions.
4 changes: 3 additions & 1 deletion scripts/package/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \
-o $(perf-tar).tar; \
mkdir -p $(perf-tar); \
git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \
tar rf $(perf-tar).tar $(perf-tar)/HEAD; \
(cd $(srctree)/tools/perf; \
util/PERF-VERSION-GEN ../../$(perf-tar)/ 2>/dev/null); \
tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
rm -r $(perf-tar); \
$(if $(findstring tar-src,$@),, \
$(if $(findstring bz2,$@),bzip2, \
Expand Down
10 changes: 5 additions & 5 deletions tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ static int perf_event__repipe_sample(struct perf_tool *tool,
struct perf_evsel *evsel,
struct machine *machine)
{
if (evsel->handler.func) {
inject_handler f = evsel->handler.func;
if (evsel->handler) {
inject_handler f = evsel->handler;
return f(tool, event, sample, evsel, machine);
}

Expand Down Expand Up @@ -383,11 +383,11 @@ static int __cmd_inject(struct perf_inject *inject)
if (perf_evsel__check_stype(evsel, PERF_SAMPLE_TID, "TID"))
return -EINVAL;

evsel->handler.func = perf_inject__sched_switch;
evsel->handler = perf_inject__sched_switch;
} else if (!strcmp(name, "sched:sched_process_exit"))
evsel->handler.func = perf_inject__sched_process_exit;
evsel->handler = perf_inject__sched_process_exit;
else if (!strncmp(name, "sched:sched_stat_", 17))
evsel->handler.func = perf_inject__sched_stat;
evsel->handler = perf_inject__sched_stat;
}
}

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,

dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), thread->tid);

if (evsel->handler.func != NULL) {
tracepoint_handler f = evsel->handler.func;
if (evsel->handler != NULL) {
tracepoint_handler f = evsel->handler;
return f(evsel, sample);
}

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,8 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
return -1;
}

if (evsel->handler.func != NULL) {
tracepoint_handler f = evsel->handler.func;
if (evsel->handler != NULL) {
tracepoint_handler f = evsel->handler;
return f(evsel, sample);
}

Expand Down
48 changes: 25 additions & 23 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,8 @@ struct perf_record {
bool no_buildid;
bool no_buildid_cache;
long samples;
off_t post_processing_offset;
};

static void advance_output(struct perf_record *rec, size_t size)
{
rec->bytes_written += size;
}

static int write_output(struct perf_record *rec, void *buf, size_t size)
{
struct perf_data_file *file = &rec->file;
Expand Down Expand Up @@ -252,13 +246,14 @@ static int process_buildids(struct perf_record *rec)
{
struct perf_data_file *file = &rec->file;
struct perf_session *session = rec->session;
u64 start = session->header.data_offset;

u64 size = lseek(file->fd, 0, SEEK_CUR);
if (size == 0)
return 0;

return __perf_session__process_events(session, rec->post_processing_offset,
size - rec->post_processing_offset,
return __perf_session__process_events(session, start,
size - start,
size, &build_id__mark_dso_hit_ops);
}

Expand Down Expand Up @@ -342,9 +337,28 @@ static int perf_record__mmap_read_all(struct perf_record *rec)
return rc;
}

static void perf_record__init_features(struct perf_record *rec)
{
struct perf_evlist *evsel_list = rec->evlist;
struct perf_session *session = rec->session;
int feat;

for (feat = HEADER_FIRST_FEATURE; feat < HEADER_LAST_FEATURE; feat++)
perf_header__set_feat(&session->header, feat);

if (rec->no_buildid)
perf_header__clear_feat(&session->header, HEADER_BUILD_ID);

if (!have_tracepoints(&evsel_list->entries))
perf_header__clear_feat(&session->header, HEADER_TRACING_DATA);

if (!rec->opts.branch_stack)
perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
}

static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
{
int err, feat;
int err;
unsigned long waking = 0;
const bool forks = argc > 0;
struct machine *machine;
Expand All @@ -371,17 +385,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)

rec->session = session;

for (feat = HEADER_FIRST_FEATURE; feat < HEADER_LAST_FEATURE; feat++)
perf_header__set_feat(&session->header, feat);

if (rec->no_buildid)
perf_header__clear_feat(&session->header, HEADER_BUILD_ID);

if (!have_tracepoints(&evsel_list->entries))
perf_header__clear_feat(&session->header, HEADER_TRACING_DATA);

if (!rec->opts.branch_stack)
perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
perf_record__init_features(rec);

if (forks) {
err = perf_evlist__prepare_workload(evsel_list, &opts->target,
Expand Down Expand Up @@ -425,8 +429,6 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
goto out_delete_session;
}

rec->post_processing_offset = lseek(file->fd, 0, SEEK_CUR);

machine = &session->machines.host;

if (file->is_pipe) {
Expand All @@ -452,7 +454,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
pr_err("Couldn't record tracing data.\n");
goto out_delete_session;
}
advance_output(rec, err);
rec->bytes_written += err;
}
}

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,8 +1427,8 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __maybe_
evsel->hists.stats.total_period += sample->period;
hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);

if (evsel->handler.func != NULL) {
tracepoint_handler f = evsel->handler.func;
if (evsel->handler != NULL) {
tracepoint_handler f = evsel->handler;
err = f(tool, evsel, sample, machine);
}

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-timechart.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,8 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
if (sample->cpu > numcpus)
numcpus = sample->cpu;

if (evsel->handler.func != NULL) {
tracepoint_handler f = evsel->handler.func;
if (evsel->handler != NULL) {
tracepoint_handler f = evsel->handler;
return f(evsel, sample);
}

Expand Down
Loading

0 comments on commit 4d9218d

Please sign in to comment.