Skip to contentSkip to conversation

perf time-utils: Adopt rdclock() from perf.h

tip: perf/core tip-bot2 for Arnaldo Carvalho de Melo 1 participant 1 message Sep 2, 2019 1 message not in the archive perf events

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

tip-bot2 for Arnaldo Carvalho de Melo

author merge bot Applied
#1 lore raw

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     f37110205c3065546d6995b1463751c7bbb50e89
Gitweb:        https://git.kernel.org/tip/f37110205c3065546d6995b1463751c7bbb50e89
Author:        Arnaldo Carvalho de Melo <[email protected]>
AuthorDate:    Thu, 29 Aug 2019 15:16:27 -03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Thu, 29 Aug 2019 17:38:32 -03:00

perf time-utils: Adopt rdclock() from perf.h

Seems to be a better place for this function to live, further shrinking the hodge-podge that perf.h was.

---
 tools/perf/builtin-stat.c    |  1 +
 tools/perf/perf.h            |  9 ---------
 tools/perf/util/event.c      |  1 +
 tools/perf/util/time-utils.h |  9 +++++++++
 4 files changed, 11 insertions(+), 9 deletions(-)
tools/perf/builtin-stat.c +1 -0
index a7e8c26..2741bcb 100644
@@ -62,6 +62,7 @@
 #include "util/string2.h"
 #include "util/metricgroup.h"
 #include "util/target.h"
+#include "util/time-utils.h"
 #include "util/top.h"
 #include "asm/bug.h"
 
tools/perf/perf.h +0 -9
index 7a1a921..7401403 100644
@@ -2,17 +2,8 @@
 #ifndef _PERF_PERF_H
 #define _PERF_PERF_H
 
-#include <time.h>
 #include <stdbool.h>
 
-static inline unsigned long long rdclock(void)
-{
-	struct timespec ts;
-
-	clock_gettime(CLOCK_MONOTONIC, &ts);
-	return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
-}
-
 #ifndef MAX_NR_CPUS
 #define MAX_NR_CPUS			2048
 #endif
tools/perf/util/event.c +1 -0
index c9d1f83..7fa7a30 100644
@@ -21,6 +21,7 @@
 #include "strlist.h"
 #include "thread.h"
 #include "thread_map.h"
+#include "time-utils.h"
 #include <linux/ctype.h>
 #include "map.h"
 #include "symbol.h"
tools/perf/util/time-utils.h +9 -0
index 72a42ea..4f42988 100644
@@ -3,6 +3,7 @@
 #define _TIME_UTILS_H_
 
 #include <stddef.h>
+#include <time.h>
 #include <linux/types.h>
 
 struct perf_time_interval {
@@ -34,4 +35,12 @@ int timestamp__scnprintf_nsec(u64 timestamp, char *buf, size_t sz);
 
 int fetch_current_timestamp(char *buf, size_t sz);
 
+static inline unsigned long long rdclock(void)
+{
+	struct timespec ts;
+
+	clock_gettime(CLOCK_MONOTONIC, &ts);
+	return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
+}
+
 #endif