From 1eb37070b03e3dd96c68aa282d203a7cf065f211 Mon Sep 17 00:00:00 2001
From: Luis Gerhorst <luis.gerhorst@fau.de>
Date: Tue, 10 Jul 2018 16:43:01 +0200
Subject: [PATCH] Introduce Timestamp Type Bernhard

---
 arch/arm/measuremore/Kconfig   |  4 ++++
 arch/arm/measuremore/measure.c | 12 ++++++++++++
 include/linux/measuremore.h    | 17 +++++++++++++++++
 3 files changed, 33 insertions(+)

diff --git a/arch/arm/measuremore/Kconfig b/arch/arm/measuremore/Kconfig
index f96895f..8c18e9e 100644
--- a/arch/arm/measuremore/Kconfig
+++ b/arch/arm/measuremore/Kconfig
@@ -7,6 +7,10 @@ config MEASUREMORE_TIMESTAMP_TYPE_PMCCNTR
 	depends on MEASUREMORE && ARM
 	bool "Read PMCCNTR register"
 
+config MEASUREMORE_TIMESTAMP_TYPE_BERNHARD
+	depends on MEASUREMORE
+	bool "Read bernhards register"
+
 config MEASUREMORE_TIMESTAMP_TYPE_KTIME_MONO_FAST
     depends on MEASUREMORE
 	bool "Call ktime_get_mono_fast_ns()"
diff --git a/arch/arm/measuremore/measure.c b/arch/arm/measuremore/measure.c
index f8d79c3..6ee9bca 100644
--- a/arch/arm/measuremore/measure.c
+++ b/arch/arm/measuremore/measure.c
@@ -233,6 +233,14 @@ static void seq_write_nstimeofday_s_csv_field(struct seq_file *seq,
 }
 #endif
 
+#ifdef CONFIG_MEASUREMORE_TIMESTAMP_TYPE_BERNHARD
+static void seq_write_bernhard_csv_field(struct seq_file *seq,
+					 struct checkpoint_record *cpr)
+{
+	seq_printf(seq, "%llu", cpr->bernhard);
+}
+#endif
+
 static void seq_write_name_csv_field(struct seq_file *seq,
 				struct checkpoint_record *cpr)
 {
@@ -248,6 +256,10 @@ static void export_current_bmr_to_csv_results(void)
 	create_csv_file("pmccntr", seq_write_pmccntr_csv_field,
 			csv_results_folder);
 #endif
+#ifdef CONFIG_MEASUREMORE_TIMESTAMP_TYPE_BERNHARD
+	create_csv_file("bernhard", seq_write_bernhard_csv_field,
+			csv_results_folder);
+#endif
 #ifdef CONFIG_MEASUREMORE_TIMESTAMP_TYPE_KTIME_MONO_FAST
 	create_csv_file("ktime_mono_fast", seq_write_ktime_mono_fast_csv_field,
 			csv_results_folder);
diff --git a/include/linux/measuremore.h b/include/linux/measuremore.h
index 18f2a12..3ca7065 100644
--- a/include/linux/measuremore.h
+++ b/include/linux/measuremore.h
@@ -19,11 +19,25 @@ struct pmccntr_timestamp {
 
 #endif	/* CONFIG_MEASUREMORE_TIMESTAMP_TYPE_PMCCNTR */
 
+#ifdef CONFIG_MEASUREMORE_TIMESTAMP_TYPE_BERNHARD
+
+/* Hier den Code zum auslesen. Wenn du davor noch was einschalten musst / den
+ * Counter am Anfang jedes Runs resetten willst kannst du das analog zu
+ * pmccntr_reset() / pmccntr_enable() machen (im measuremore Verzeichnis). */
+
+#define bernhard_read(var) \
+	do { var = 42; } while (0)
+
+#endif	/* CONFIG_MEASUREMORE_TIMESTAMP_TYPE_BERNHARD */
+
 struct checkpoint_record {
 	const char *name;
 #ifdef CONFIG_MEASUREMORE_TIMESTAMP_TYPE_PMCCNTR
 	struct pmccntr_timestamp pmccntr_ts;
 #endif
+#ifdef CONFIG_MEASUREMORE_TIMESTAMP_TYPE_BERNHARD
+	uint64_t bernhard;
+#endif
 #ifdef CONFIG_MEASUREMORE_TIMESTAMP_TYPE_KTIME_MONO_FAST
 	u64 ktime_mono_fast; /* Alread in ns. */
 #endif
@@ -51,6 +65,9 @@ static __always_inline void memo_checkpoint(const char *name) {
 #ifdef CONFIG_MEASUREMORE_TIMESTAMP_TYPE_PMCCNTR
 	pmccntr_read(current_cpr->pmccntr_ts.value);
 #endif
+#ifdef CONFIG_MEASUREMORE_TIMESTAMP_TYPE_BERNHARD
+	bernhard_read(current_cpr->bernhard);
+#endif
 #ifdef CONFIG_MEASUREMORE_TIMESTAMP_TYPE_KTIME_MONO_FAST
 	current_cpr->ktime_mono_fast = ktime_get_mono_fast_ns();
 #endif
-- 
GitLab