2010-08-04 21:26:33

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [GIT PULL 0/3] perf/core fixes and improvements


Hi Ingo,

Please pull from:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf/core

Regards,

- Arnaldo

Dave Martin (1):
perf events: Fix mmap offset determination

Srikar Dronamraju (2):
perf: expose event__process function
tracing/kprobes: unregister_trace_probe needs to be called under mutex

kernel/trace/trace_kprobe.c | 3 +++
tools/perf/builtin-top.c | 20 --------------------
tools/perf/util/event.c | 28 +++++++++++++++++++++-------
tools/perf/util/event.h | 1 +
4 files changed, 25 insertions(+), 27 deletions(-)


2010-08-04 21:26:16

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 2/3] perf: expose event__process function

From: Srikar Dronamraju <[email protected]>

The event__process function is useful in processing /proc/<pid>/maps. All of
the functions that are called from event__process are defined in util/event.c.
Though its defined in builtin-top.c, it could be reused for perf probe for
uprobes. Hence moving it to util/event.c and exporting the function.

LKML-Reference: <[email protected]>
Signed-off-by: Srikar Dronamraju <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-top.c | 20 --------------------
tools/perf/util/event.c | 20 ++++++++++++++++++++
tools/perf/util/event.h | 1 +
3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 1e8e92e..b513e40 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1082,26 +1082,6 @@ static void event__process_sample(const event_t *self,
}
}

-static int event__process(event_t *event, struct perf_session *session)
-{
- switch (event->header.type) {
- case PERF_RECORD_COMM:
- event__process_comm(event, session);
- break;
- case PERF_RECORD_MMAP:
- event__process_mmap(event, session);
- break;
- case PERF_RECORD_FORK:
- case PERF_RECORD_EXIT:
- event__process_task(event, session);
- break;
- default:
- break;
- }
-
- return 0;
-}
-
struct mmap_data {
int counter;
void *base;
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index db8a1d4..dab9e75 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -548,6 +548,26 @@ int event__process_task(event_t *self, struct perf_session *session)
return 0;
}

+int event__process(event_t *event, struct perf_session *session)
+{
+ switch (event->header.type) {
+ case PERF_RECORD_COMM:
+ event__process_comm(event, session);
+ break;
+ case PERF_RECORD_MMAP:
+ event__process_mmap(event, session);
+ break;
+ case PERF_RECORD_FORK:
+ case PERF_RECORD_EXIT:
+ event__process_task(event, session);
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
void thread__find_addr_map(struct thread *self,
struct perf_session *session, u8 cpumode,
enum map_type type, pid_t pid, u64 addr,
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 887ee63..8e790da 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -154,6 +154,7 @@ int event__process_comm(event_t *self, struct perf_session *session);
int event__process_lost(event_t *self, struct perf_session *session);
int event__process_mmap(event_t *self, struct perf_session *session);
int event__process_task(event_t *self, struct perf_session *session);
+int event__process(event_t *event, struct perf_session *session);

struct addr_location;
int event__preprocess_sample(const event_t *self, struct perf_session *session,
--
1.6.2.5

2010-08-04 21:26:23

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 3/3] tracing/kprobes: unregister_trace_probe needs to be called under mutex

From: Srikar Dronamraju <[email protected]>

Comment in unregister_trace_probe() says probe_lock will be held when it
gets called. However there is a case where it might called without the
probe_lock being held. Also since we are traversing the probe_list and
deleting an element from the probe_list, probe_lock should be held.

This was first pointed in uprobes traceevent review by Frederic
Weisbecker here. (http://lkml.org/lkml/2010/5/12/106)

Cc: Ingo Molnar <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Acked-by: Masami Hiramatsu <[email protected]>
Acked-by: Steven Rostedt <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Srikar Dronamraju <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
kernel/trace/trace_kprobe.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 1b79d1c..8b27c98 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -925,14 +925,17 @@ static int create_trace_probe(int argc, char **argv)
pr_info("Delete command needs an event name.\n");
return -EINVAL;
}
+ mutex_lock(&probe_lock);
tp = find_probe_event(event, group);
if (!tp) {
+ mutex_unlock(&probe_lock);
pr_info("Event %s/%s doesn't exist.\n", group, event);
return -ENOENT;
}
/* delete an event */
unregister_trace_probe(tp);
free_trace_probe(tp);
+ mutex_unlock(&probe_lock);
return 0;
}

--
1.6.2.5

2010-08-04 21:26:44

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 1/3] perf events: Fix mmap offset determination

From: Dave Martin <[email protected]>

Fix buggy-looking code which unnecessarily adjusts the file offset
fields read from /proc/*/maps.

This may have gone unnoticed since the offset is usually 0 (and the
logic in util/symbol.c may work incorrectly for other offset values).

Commiter note:

This fixes a bug introduced in 4af8b35, there is no need to shift pgoff
twice, the show_map_vma routine in fs/proc/task_mmu.c already converts
it from the number of pages to the size in bytes, and that is what
appears in /proc/PID/map.

Cc: Anton Blanchard <[email protected]>
Cc: Nicolas Pitre <[email protected]>
Cc: Will Deacon <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Dave Martin <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/event.c | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 6b0db55..db8a1d4 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -151,7 +151,6 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
continue;
pbf += n + 3;
if (*pbf == 'x') { /* vm_exec */
- u64 vm_pgoff;
char *execname = strchr(bf, '/');

/* Catch VDSO */
@@ -162,12 +161,7 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
continue;

pbf += 3;
- n = hex2u64(pbf, &vm_pgoff);
- /* pgoff is in bytes, not pages */
- if (n >= 0)
- ev.mmap.pgoff = vm_pgoff << getpagesize();
- else
- ev.mmap.pgoff = 0;
+ n = hex2u64(pbf, &ev.mmap.pgoff);

size = strlen(execname);
execname[size - 1] = '\0'; /* Remove \n */
--
1.6.2.5

2010-08-05 06:46:39

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL 0/3] perf/core fixes and improvements


* Arnaldo Carvalho de Melo <[email protected]> wrote:

>
> Hi Ingo,
>
> Please pull from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf/core
>
> Regards,
>
> - Arnaldo
>
> Dave Martin (1):
> perf events: Fix mmap offset determination
>
> Srikar Dronamraju (2):
> perf: expose event__process function
> tracing/kprobes: unregister_trace_probe needs to be called under mutex
>
> kernel/trace/trace_kprobe.c | 3 +++
> tools/perf/builtin-top.c | 20 --------------------
> tools/perf/util/event.c | 28 +++++++++++++++++++++-------
> tools/perf/util/event.h | 1 +
> 4 files changed, 25 insertions(+), 27 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo