[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-edac
Subject: [PATCH 10/10] rasd: read the events data
From: Jean Pihet <jean.pihet () linaro ! org>
Date: 2014-09-25 9:56:01
Message-ID: 1411638961-8112-10-git-send-email-jean.pihet () linaro ! org
[Download RAW message or body]
Read the mmaped buffers.
For the moment, just print out the events origin and the number of
samples. Parsing of the data is yet to implement.
Signed-off-by: Jean Pihet <jean.pihet@linaro.org>
---
src/rasd.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/src/rasd.c b/src/rasd.c
index 255b995..35f12c5 100644
--- a/src/rasd.c
+++ b/src/rasd.c
@@ -5,6 +5,7 @@
#include "debugfs.h"
#include "trace_event.h"
+#define POLL_TIMEOUT_MS 1000
#define EVENT_STR_MAX_LENGTH 1024
#define SYS_NAME_SEPARATOR ":"
#define RASD_CFG_FILE "rasd.cfg"
@@ -131,11 +132,62 @@ static int read_config_file(void)
return ret;
}
+/* Read and parse samples */
+static int mmap_read_idx(int idx)
+{
+ struct perf_sample sample;
+ struct perf_evsel *evsel;
+ union perf_event *event;
+ u8 origin;
+ int ret, nr_samples = 0;
+
+ while ((event = perf_evlist__mmap_read(evlist, idx))) {
+ ret = perf_evlist__parse_sample(evlist, event, &sample);
+ if (ret) {
+ pr_err("Can't parse sample, err = %d\n", ret);
+ goto next_event;
+ }
+
+ evsel = perf_evlist__id2evsel(evlist, sample.id);
+ assert(evsel != NULL);
+
+ origin = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
+
+ if (event->header.type == PERF_RECORD_SAMPLE)
+ nr_samples++;
+
+ switch (origin) {
+ case PERF_RECORD_MISC_USER:
+ fprintf(stderr, "%s: MISC_USER\n", __func__);
+ break;
+ case PERF_RECORD_MISC_KERNEL:
+ fprintf(stderr, "%s: MISC_KERNEL\n", __func__);
+ break;
+ case PERF_RECORD_MISC_GUEST_KERNEL:
+ fprintf(stderr, "%s: MISC_GUEST_KERNEL\n", __func__);
+ break;
+ case PERF_RECORD_MISC_GUEST_USER:
+ fprintf(stderr, "%s: MISC_GUEST_USER\n", __func__);
+ break;
+ default:
+ goto next_event;
+ }
+
+ /* Parse raw data */
+
+next_event:
+ perf_evlist__mmap_consume(evlist, idx);
+ }
+
+ return nr_samples;
+}
+
int main()
{
struct perf_evsel *c;
struct thread_map *threads;
struct cpu_map *cpus;
+ int i, ret;
page_size = sysconf(_SC_PAGE_SIZE);
@@ -183,6 +235,19 @@ int main()
perf_evlist__enable(evlist);
/* Poll, read, consume etc. */
+ while (1) {
+ /*
+ * Relax the CPUs by polling for events coming in, with a
+ * timeout
+ */
+ poll(evlist->pollfd, evlist->nr_fds, POLL_TIMEOUT_MS);
+ /* Read and parse the events buffers */
+ for (i = 0; i < evlist->nr_mmaps; i++) {
+ ret = mmap_read_idx(i);
+ if (ret > 0)
+ fprintf(stderr, "read %d samples\n", ret);
+ }
+ }
/* Prepare to quit */
perf_evlist__delete(evlist);
--
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic