summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2019-08-29 14:16:27 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-08-29 16:38:32 -0400
commitf37110205c3065546d6995b1463751c7bbb50e89 (patch)
treec08803b9629f81d98ed48f7b68d2feca7c312e89
parent91854f9a077e18e43ed30ebe9c61f8089bec9166 (diff)
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. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-0zzt1u9rpyjukdy1ccr2u5r9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-stat.c1
-rw-r--r--tools/perf/perf.h9
-rw-r--r--tools/perf/util/event.c1
-rw-r--r--tools/perf/util/time-utils.h9
4 files changed, 11 insertions, 9 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index a7e8c26635db..2741bcb049fb 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -62,6 +62,7 @@
62#include "util/string2.h" 62#include "util/string2.h"
63#include "util/metricgroup.h" 63#include "util/metricgroup.h"
64#include "util/target.h" 64#include "util/target.h"
65#include "util/time-utils.h"
65#include "util/top.h" 66#include "util/top.h"
66#include "asm/bug.h" 67#include "asm/bug.h"
67 68
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 7a1a92127b9b..74014033df60 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -2,17 +2,8 @@
2#ifndef _PERF_PERF_H 2#ifndef _PERF_PERF_H
3#define _PERF_PERF_H 3#define _PERF_PERF_H
4 4
5#include <time.h>
6#include <stdbool.h> 5#include <stdbool.h>
7 6
8static inline unsigned long long rdclock(void)
9{
10 struct timespec ts;
11
12 clock_gettime(CLOCK_MONOTONIC, &ts);
13 return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
14}
15
16#ifndef MAX_NR_CPUS 7#ifndef MAX_NR_CPUS
17#define MAX_NR_CPUS 2048 8#define MAX_NR_CPUS 2048
18#endif 9#endif
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index c9d1f83c747a..7fa7a303e476 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -21,6 +21,7 @@
21#include "strlist.h" 21#include "strlist.h"
22#include "thread.h" 22#include "thread.h"
23#include "thread_map.h" 23#include "thread_map.h"
24#include "time-utils.h"
24#include <linux/ctype.h> 25#include <linux/ctype.h>
25#include "map.h" 26#include "map.h"
26#include "symbol.h" 27#include "symbol.h"
diff --git a/tools/perf/util/time-utils.h b/tools/perf/util/time-utils.h
index 72a42ea1d513..4f42988eb2f7 100644
--- a/tools/perf/util/time-utils.h
+++ b/tools/perf/util/time-utils.h
@@ -3,6 +3,7 @@
3#define _TIME_UTILS_H_ 3#define _TIME_UTILS_H_
4 4
5#include <stddef.h> 5#include <stddef.h>
6#include <time.h>
6#include <linux/types.h> 7#include <linux/types.h>
7 8
8struct perf_time_interval { 9struct perf_time_interval {
@@ -34,4 +35,12 @@ int timestamp__scnprintf_nsec(u64 timestamp, char *buf, size_t sz);
34 35
35int fetch_current_timestamp(char *buf, size_t sz); 36int fetch_current_timestamp(char *buf, size_t sz);
36 37
38static inline unsigned long long rdclock(void)
39{
40 struct timespec ts;
41
42 clock_gettime(CLOCK_MONOTONIC, &ts);
43 return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
44}
45
37#endif 46#endif