Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1219189
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 27/31] perf probe: Link trace_probe_event into perf_probe_event |
| Date | 2015-09-04 19:00 +0200 |
| Message-ID | <q52vh-7V0-33@gated-at.bofh.it> (permalink) |
| References | <q52lz-7Jv-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Wang Nan <wangnan0@huawei.com>
This patch drops struct __event_package structure. Instead, it adds a
'struct trace_probe_event' pointer to 'struct perf_probe_event'.
The trace_probe_event information gives further patches a chance to
access actual probe points and actual arguments.
Using them, 'perf probe' can get the whole list of added probes and
print them at once.
Other users like the upcoming bpf_loader will be able to attach one bpf
program to different probing points of an inline function (which has
multiple probing points) and glob functions.
Moreover, by reading the arguments information, bpf code for reading
those arguments can be generated.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1441368963-11565-2-git-send-email-namhyung@kernel.org
[namhyung: extract necessary part from the existing patch]
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-event.c | 57 +++++++++++++------------------------------
tools/perf/util/probe-event.h | 5 ++++
2 files changed, 22 insertions(+), 40 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 2c762f41e7a5..0d3a051b9202 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2759,59 +2759,39 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,
return find_probe_trace_events_from_map(pev, tevs);
}
-struct __event_package {
- struct perf_probe_event *pev;
- struct probe_trace_event *tevs;
- int ntevs;
-};
-
-static int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs,
- struct __event_package **ppkgs)
+int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs)
{
int i, ret;
- struct __event_package *pkgs;
-
- ret = 0;
- pkgs = zalloc(sizeof(struct __event_package) * npevs);
-
- if (pkgs == NULL)
- return -ENOMEM;
ret = init_symbol_maps(pevs->uprobes);
- if (ret < 0) {
- free(pkgs);
+ if (ret < 0)
return ret;
- }
/* Loop 1: convert all events */
for (i = 0; i < npevs; i++) {
- pkgs[i].pev = &pevs[i];
/* Init kprobe blacklist if needed */
- if (!pkgs[i].pev->uprobes)
+ if (!pevs[i].uprobes)
kprobe_blacklist__init();
/* Convert with or without debuginfo */
- ret = convert_to_probe_trace_events(pkgs[i].pev,
- &pkgs[i].tevs);
+ ret = convert_to_probe_trace_events(&pevs[i], &pevs[i].tevs);
if (ret < 0)
return ret;
- pkgs[i].ntevs = ret;
+ pevs[i].ntevs = ret;
}
/* This just release blacklist only if allocated */
kprobe_blacklist__release();
- *ppkgs = pkgs;
-
return 0;
}
-static int apply_perf_probe_events(struct __event_package *pkgs, int npevs)
+int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs)
{
int i, ret = 0;
/* Loop 2: add all events */
for (i = 0; i < npevs; i++) {
- ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs,
- pkgs[i].ntevs,
+ ret = __add_probe_trace_events(&pevs[i], pevs[i].tevs,
+ pevs[i].ntevs,
probe_conf.force_add);
if (ret < 0)
break;
@@ -2819,33 +2799,30 @@ static int apply_perf_probe_events(struct __event_package *pkgs, int npevs)
return ret;
}
-static void cleanup_perf_probe_events(struct __event_package *pkgs, int npevs)
+void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs)
{
int i, j;
- if (pkgs == NULL)
- return;
-
/* Loop 3: cleanup and free trace events */
for (i = 0; i < npevs; i++) {
- for (j = 0; j < pkgs[i].ntevs; j++)
- clear_probe_trace_event(&pkgs[i].tevs[j]);
- zfree(&pkgs[i].tevs);
+ for (j = 0; j < pevs[i].ntevs; j++)
+ clear_probe_trace_event(&pevs[i].tevs[j]);
+ zfree(&pevs[i].tevs);
+ pevs[i].ntevs = 0;
}
- free(pkgs);
+
exit_symbol_maps();
}
int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
{
int ret;
- struct __event_package *pkgs = NULL;
- ret = convert_perf_probe_events(pevs, npevs, &pkgs);
+ ret = convert_perf_probe_events(pevs, npevs);
if (ret == 0)
- ret = apply_perf_probe_events(pkgs, npevs);
+ ret = apply_perf_probe_events(pevs, npevs);
- cleanup_perf_probe_events(pkgs, npevs);
+ cleanup_perf_probe_events(pevs, npevs);
return ret;
}
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index 6e7ec68a4aa8..70c327bd61de 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -87,6 +87,8 @@ struct perf_probe_event {
bool uprobes; /* Uprobe event flag */
char *target; /* Target binary */
struct perf_probe_arg *args; /* Arguments */
+ struct probe_trace_event *tevs;
+ int ntevs;
};
/* Line range */
@@ -138,6 +140,9 @@ extern void line_range__clear(struct line_range *lr);
extern int line_range__init(struct line_range *lr);
extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs);
+extern int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs);
+extern int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs);
+extern void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs);
extern int del_perf_probe_events(struct strfilter *filter);
extern int show_perf_probe_events(struct strfilter *filter);
extern int show_line_range(struct line_range *lr, const char *module,
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL 00/31] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 23/31] x86/insn: perf tools: Add new xsave instructions Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 08/31] perf tools: Move tracing_path stuff under same namespace Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 30/31] perf probe: Print deleted events in cmd_probe() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 29/31] perf probe: Split del_perf_probe_events() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 11/31] tools lib api fs: Add STR and PATH_MAX macros to fs object Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 14/31] tools lib api fs: Add tracefs into fs.c object Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 01/31] perf tools: Always use non inlined file name for 'srcfile' sort key Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 19/31] x86/insn: perf tools: Pedantically tweak opcode map for MPX instructions Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 25/31] perf intel-pt: Add support for PERF_RECORD_SWITCH Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 28/31] perf probe: Move print logic into cmd_probe() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 18:50 +0200
[PATCH 16/31] tools lib api fs: Add FSTYPE__configured() method Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 24/31] perf session: Don't call dump_sample() when evsel is NULL Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
Re: [PATCH 10/31] tools lib api fs: Move debugfs__strerror_open into tracing_path.c object Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-04 19:00 +0200
Re: [PATCH 10/31] tools lib api fs: Move debugfs__strerror_open into tracing_path.c object Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> - 2015-09-04 22:40 +0200
[PATCH 06/31] perf stat: Quieten failed to read counter message Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 27/31] perf probe: Link trace_probe_event into perf_probe_event Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 09/31] tools lib api fs: Move tracing_path interface into api/fs/tracing_path.c Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 31/31] perf trace: Add read/write to the file group Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 22/31] x86/insn: perf tools: Add new memory protection keys instructions Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 04/31] perf cpumap: Factor out functions to get core_id and socket_id Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 12/31] tools lib api fs: Move SYSFS_MAGIC PROC_SUPER_MAGIC into fs.c Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 15/31] tools lib api fs: Add FSTYPE__mount() method Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
Re: [PATCH 15/31] tools lib api fs: Add FSTYPE__mount() method Raphaël Beamonte <raphael.beamonte@gmail.com> - 2015-09-04 19:10 +0200
[PATCH 10/31] tools lib api fs: Move debugfs__strerror_open into tracing_path.c object Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 07/31] perf tools: Remove mountpoint arg from perf_debugfs_mount Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 13/31] tools lib api fs: Add debugfs into fs.c object Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 26/31] perf probe: Split add_perf_probe_events() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
[PATCH 05/31] perf tools: Store the cpu socket and core ids in the perf.data header Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-04 19:00 +0200
csiph-web