summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Pihet <jean.pihet@linaro.org>2014-10-10 11:34:43 +0200
committerBorislav Petkov <bp@suse.de>2014-11-06 11:54:55 +0100
commit69517cad219ee92360845231daa813fc3fed7994 (patch)
treed60647c4083cb0263200fcf9c7fb4dcc15ac1c91
parent20ae0f1947163b221a5a8798e8309d09afd8a7fe (diff)
downloadrasd-69517cad219ee92360845231daa813fc3fed7994.tar.gz
rasd: Enable system wide tracing, on all CPUs
Map the events buffers on all CPUs; set cpu and threads maps in evlist. The maps are used to parse the per-cpu and per-thread events. Note: rasd performs system-wide tracing, however at least one thread mapping is required. Create one thread mapping for the current PID. Boris: - make add_tp_event() void - cleanup excessive comments Signed-off-by: Jean Pihet <jean.pihet@linaro.org> Link: http://lkml.kernel.org/r/1412933690-25576-7-git-send-email-jean.pihet@linaro.org Signed-off-by: Borislav Petkov <bp@suse.de>
-rw-r--r--src/rasd.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/rasd.c b/src/rasd.c
index d7495c9..a72f854 100644
--- a/src/rasd.c
+++ b/src/rasd.c
@@ -64,26 +64,26 @@ static int extract_sys_name(char **str, char **sys, char **name)
}
/* Add the requested tracepoint event to evlist */
-static int add_tp_event(char *event_str)
+static void add_tp_event(char *event_str)
{
struct perf_evsel *tp;
char **str = &event_str;
- int ret;
+ static int idx;
if (extract_sys_name(str, &rasd.sys, &rasd.name))
err("invalid event specified, syntax is sys:name");
/* Initialize tracepoint evsel */
- tp = perf_evsel__newtp_idx(rasd.sys, rasd.name, 0);
+ tp = perf_evsel__newtp_idx(rasd.sys, rasd.name, idx);
if (!tp)
- err("init tracepoint evsel");
+ err("init tracepoint evsel, idx: %d", idx);
/* Add the event to the lists of events, enable events ids */
perf_evlist__add(evlist, tp);
perf_evsel__set_sample_id(tp, false);
perf_evsel__calc_id_pos(tp);
- return ret;
+ idx++;
}
/*
@@ -120,37 +120,44 @@ static int read_config_file(void)
int main()
{
struct perf_evsel *c;
+ struct thread_map *threads;
+ struct cpu_map *cpus;
page_size = sysconf(_SC_PAGE_SIZE);
- /*
- * Mount debugfs. The basepath is in debugfs_mountpoint
- */
if (!debugfs_mount(NULL))
err("mounting debugfs");
- /* Initialize evlist */
evlist = perf_evlist__new();
if (!evlist)
err("allocating evlist");
- /* Read config file */
if (read_config_file())
err("error reading config file");
+ threads = thread_map__new(-1, getpid(), UINT_MAX);
+ if (!threads)
+ err("allocating threads_map\n");
+
+ cpus = cpu_map__new(NULL);
+ if (!cpus)
+ err("allocating cpu_map\n");
+
+ perf_evlist__set_maps(evlist, cpus, threads);
+
+ /* On all online CPUs by default, system wide tracing */
evlist__for_each(evlist, c) {
- /*
- * On all online cpus by default.
- */
- if (perf_evsel__open(c, cpu_map__new(NULL), NULL) < 0)
+ if (perf_evsel__open(c, evlist->cpus, NULL) < 0)
err("opening tracepoint, are you root?");
}
perf_evlist__set_id_pos(evlist);
+ /* mmap buffers */
if (perf_evlist__mmap(evlist, 4 /* opts->mmap_pages */, false) < 0)
err("Failed to mmap with %d (%s)\n", errno, strerror(errno));
- /* mmap it and all that, consume it */
+ /* Enable at kernel level */
+ perf_evlist__enable(evlist);
perf_evlist__delete(evlist);