perf build-id: Move the routine to find DSOs with hits to the lib
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 3 Feb 2010 18:52:04 +0000 (16:52 -0200)
committerIngo Molnar <mingo@elte.hu>
Thu, 4 Feb 2010 08:33:26 +0000 (09:33 +0100)
Because 'perf record' will have to find the build-ids in after
we stop recording, so as to reduce even more the impact in the
workload while we do the measurement.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1265223128-11786-5-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/Makefile
tools/perf/builtin-buildid-list.c
tools/perf/util/build-id.c [new file with mode: 0644]
tools/perf/util/build-id.h [new file with mode: 0644]

index 42969303e20b98b16962f3a63d6b7b553a80e259..3a5fb36ccc9759dd150885c992b066e756b1600c 100644 (file)
@@ -357,6 +357,7 @@ LIB_H += util/include/asm/uaccess.h
 LIB_H += perf.h
 LIB_H += util/cache.h
 LIB_H += util/callchain.h
+LIB_H += util/build-id.h
 LIB_H += util/debug.h
 LIB_H += util/debugfs.h
 LIB_H += util/event.h
@@ -390,6 +391,7 @@ LIB_H += util/probe-event.h
 
 LIB_OBJS += util/abspath.o
 LIB_OBJS += util/alias.o
+LIB_OBJS += util/build-id.o
 LIB_OBJS += util/config.o
 LIB_OBJS += util/ctype.o
 LIB_OBJS += util/debugfs.o
index 431f204bde64165be4d159214e7e7693dc97db3e..d0675c02f81eb0a45f5d2b8185dc6b26a15f98fd 100644 (file)
@@ -8,6 +8,7 @@
  */
 #include "builtin.h"
 #include "perf.h"
+#include "util/build-id.h"
 #include "util/cache.h"
 #include "util/debug.h"
 #include "util/parse-options.h"
@@ -33,34 +34,6 @@ static const struct option options[] = {
        OPT_END()
 };
 
-static int build_id_list__process_event(event_t *event,
-                                       struct perf_session *session)
-{
-       struct addr_location al;
-       u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
-       struct thread *thread = perf_session__findnew(session, event->ip.pid);
-
-       if (thread == NULL) {
-               pr_err("problem processing %d event, skipping it.\n",
-                       event->header.type);
-               return -1;
-       }
-
-       thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION,
-                             event->ip.ip, &al);
-
-       if (al.map != NULL)
-               al.map->dso->hit = 1;
-
-       return 0;
-}
-
-static struct perf_event_ops build_id_list__event_ops = {
-       .sample = build_id_list__process_event,
-       .mmap   = event__process_mmap,
-       .fork   = event__process_task,
-};
-
 static int __cmd_buildid_list(void)
 {
        int err = -1;
@@ -71,7 +44,7 @@ static int __cmd_buildid_list(void)
                return -1;
 
        if (with_hits)
-               perf_session__process_events(session, &build_id_list__event_ops);
+               perf_session__process_events(session, &build_id__mark_dso_hit_ops);
 
        dsos__fprintf_buildid(stdout, with_hits);
 
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
new file mode 100644 (file)
index 0000000..04904b3
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * build-id.c
+ *
+ * build-id support
+ *
+ * Copyright (C) 2009, 2010 Red Hat Inc.
+ * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <acme@redhat.com>
+ */
+#include "build-id.h"
+#include "event.h"
+#include "symbol.h"
+#include <linux/kernel.h>
+
+static int build_id__mark_dso_hit(event_t *event, struct perf_session *session)
+{
+       struct addr_location al;
+       u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
+       struct thread *thread = perf_session__findnew(session, event->ip.pid);
+
+       if (thread == NULL) {
+               pr_err("problem processing %d event, skipping it.\n",
+                       event->header.type);
+               return -1;
+       }
+
+       thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION,
+                             event->ip.ip, &al);
+
+       if (al.map != NULL)
+               al.map->dso->hit = 1;
+
+       return 0;
+}
+
+struct perf_event_ops build_id__mark_dso_hit_ops = {
+       .sample = build_id__mark_dso_hit,
+       .mmap   = event__process_mmap,
+       .fork   = event__process_task,
+};
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
new file mode 100644 (file)
index 0000000..1d981d6
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef PERF_BUILD_ID_H_
+#define PERF_BUILD_ID_H_ 1
+
+#include "session.h"
+
+extern struct perf_event_ops build_id__mark_dso_hit_ops;
+
+#endif