From: tip-bot for Tom Zanussi <tzanussi@gmail.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
tzanussi@gmail.com, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:perf/live] perf: Convert perf header build_ids into build_id events
Date: Wed, 14 Apr 2010 10:05:38 GMT [thread overview]
Message-ID: <tip-c7929e4727e8ff2d6fc8327188820e3b1c2f1dc3@git.kernel.org> (raw)
In-Reply-To: <1270184365-8281-9-git-send-email-tzanussi@gmail.com>
Commit-ID: c7929e4727e8ff2d6fc8327188820e3b1c2f1dc3
Gitweb: http://git.kernel.org/tip/c7929e4727e8ff2d6fc8327188820e3b1c2f1dc3
Author: Tom Zanussi <tzanussi@gmail.com>
AuthorDate: Thu, 1 Apr 2010 23:59:22 -0500
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 14 Apr 2010 11:56:08 +0200
perf: Convert perf header build_ids into build_id events
Bypasses the build_id perf header code and replaces it with a
synthesized event and processing function that accomplishes the
same thing, used when reading/writing perf data to/from a pipe.
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: fweisbec@gmail.com
Cc: rostedt@goodmis.org
Cc: k-keiichi@bx.jp.nec.com
Cc: acme@ghostprotocols.net
LKML-Reference: <1270184365-8281-9-git-send-email-tzanussi@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
tools/perf/builtin-record.c | 15 ++++++-
tools/perf/builtin-report.c | 1 +
tools/perf/builtin-trace.c | 1 +
tools/perf/util/event.h | 2 +
| 90 +++++++++++++++++++++++++++++++++++++++++++
| 7 +++
tools/perf/util/session.c | 6 +++
tools/perf/util/session.h | 3 +-
8 files changed, 121 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 3775abe..0bde31b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -426,10 +426,19 @@ static int process_buildids(void)
static void atexit_header(void)
{
- session->header.data_size += bytes_written;
+ if (!pipe_output) {
+ session->header.data_size += bytes_written;
- process_buildids();
- perf_header__write(&session->header, output, true);
+ 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");
+ }
}
static int __cmd_record(int argc, const char **argv)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 76f03a7..7da5fb3 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -270,6 +270,7 @@ static struct perf_event_ops event_ops = {
.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;
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 1509744..1ee1e30 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -107,6 +107,7 @@ static struct perf_event_ops event_ops = {
.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;
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index b896a17..e5740ea 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -87,6 +87,7 @@ 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
};
@@ -125,6 +126,7 @@ typedef union event_union {
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 {
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c6874ec..628173b 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -986,3 +986,93 @@ int event__process_tracing_data(event_t *self,
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;
+}
--git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 3ed3d98..4214e23 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -118,4 +118,11 @@ int event__synthesize_tracing_data(int fd, struct perf_event_attr *pattrs,
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/tools/perf/util/session.c b/tools/perf/util/session.c
index 1516c40..0fdf3eb 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -206,6 +206,8 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
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[] = {
@@ -222,6 +224,7 @@ static const char *event__name[] = {
[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];
@@ -332,6 +335,7 @@ static event__swap_op event__swap_ops[] = {
[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,
};
@@ -380,6 +384,8 @@ static int perf_session__process_event(struct perf_session *self,
/* 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;
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 0739ebb..0ac14d4 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -47,7 +47,8 @@ struct perf_event_ops {
unthrottle,
attr,
event_type,
- tracing_data;
+ tracing_data,
+ build_id;
};
struct perf_session *perf_session__new(const char *filename, int mode, bool force);
next prev parent reply other threads:[~2010-04-14 10:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-02 4:59 [RFC v2][PATCH 0/7] perf: 'live mode' Tom Zanussi
2010-04-02 4:59 ` [RFC v2][PATCH 01/11] perf: add pipe-specific header read/write and event processing code Tom Zanussi
2010-04-14 10:03 ` [tip:perf/live] perf: Add " tip-bot for Tom Zanussi
2010-04-02 4:59 ` [RFC v2][PATCH 02/11] perf record: introduce special handling for pipe output Tom Zanussi
2010-04-14 10:03 ` [tip:perf/live] perf record: Introduce " tip-bot for Tom Zanussi
2010-04-02 4:59 ` [RFC v2][PATCH 03/11] perf report: introduce special handling for pipe input Tom Zanussi
2010-04-14 10:04 ` [tip:perf/live] perf report: Introduce " tip-bot for Tom Zanussi
2010-04-02 4:59 ` [RFC v2][PATCH 04/11] perf trace: introduce " Tom Zanussi
2010-04-14 10:04 ` [tip:perf/live] perf trace: Introduce " tip-bot for Tom Zanussi
2010-04-02 4:59 ` [RFC v2][PATCH 05/11] perf: convert perf header attrs into attr events Tom Zanussi
2010-04-14 10:04 ` [tip:perf/live] perf: Convert " tip-bot for Tom Zanussi
2010-04-02 4:59 ` [RFC v2][PATCH 06/11] perf: convert perf event types into event type events Tom Zanussi
2010-04-14 10:05 ` [tip:perf/live] perf: Convert " tip-bot for Tom Zanussi
2010-04-02 4:59 ` [RFC v2][PATCH 07/11] perf: convert perf tracing data into a tracing_data event Tom Zanussi
2010-04-14 10:05 ` [tip:perf/live] perf: Convert " tip-bot for Tom Zanussi
2010-04-02 4:59 ` [RFC v2][PATCH 08/11] perf: convert perf header build_ids into build_id events Tom Zanussi
2010-04-03 13:54 ` Arnaldo Carvalho de Melo
2010-04-14 10:05 ` tip-bot for Tom Zanussi [this message]
2010-04-02 4:59 ` [RFC v2][PATCH 09/11] perf trace/scripting: rwtop and sctop scripts Tom Zanussi
2010-04-14 10:05 ` [tip:perf/live] perf trace/scripting: Add " tip-bot for Tom Zanussi
2010-04-02 4:59 ` [RFC v2][PATCH 10/11] perf trace/scripting: enable scripting shell scripts for live mode Tom Zanussi
2010-04-14 10:06 ` [tip:perf/live] perf trace/scripting: Enable " tip-bot for Tom Zanussi
2010-04-02 4:59 ` [RFC v2][PATCH 11/11] perf trace: invoke live mode automatically if record/report not specified Tom Zanussi
2010-04-14 10:06 ` [tip:perf/live] perf trace: Invoke " tip-bot for Tom Zanussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-c7929e4727e8ff2d6fc8327188820e3b1c2f1dc3@git.kernel.org \
--to=tzanussi@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome