[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200805093444.314999-3-jolsa@kernel.org>
Date: Wed, 5 Aug 2020 11:34:39 +0200
From: Jiri Olsa <jolsa@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Michael Petlan <mpetlan@...hat.com>,
Ian Rogers <irogers@...gle.com>,
Andi Kleen <ak@...ux.intel.com>,
David Ahern <dsahern@...il.com>,
Geneviève Bastien <gbastien@...satic.net>,
Wang Nan <wangnan0@...wei.com>,
Jeremie Galarneau <jgalar@...icios.com>
Subject: [PATCH v2 2/7] perf tools: Add clockid_name function
Adding clockid_name function to get the clock name based
on its clockid. It will be used in following changes.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/util/clockid.c | 11 +++++++++++
tools/perf/util/clockid.h | 2 ++
2 files changed, 13 insertions(+)
diff --git a/tools/perf/util/clockid.c b/tools/perf/util/clockid.c
index b7a08606dc3e..74365a5d99c1 100644
--- a/tools/perf/util/clockid.c
+++ b/tools/perf/util/clockid.c
@@ -106,3 +106,14 @@ int parse_clockid(const struct option *opt, const char *str, int unset)
ui__warning("unknown clockid %s, check man page\n", ostr);
return -1;
}
+
+const char *clockid_name(clockid_t clk_id)
+{
+ const struct clockid_map *cm;
+
+ for (cm = clockids; cm->name; cm++) {
+ if (cm->clockid == clk_id)
+ return cm->name;
+ }
+ return "(not found)";
+}
diff --git a/tools/perf/util/clockid.h b/tools/perf/util/clockid.h
index 8e567b3ebbbd..9b49b4711c76 100644
--- a/tools/perf/util/clockid.h
+++ b/tools/perf/util/clockid.h
@@ -6,4 +6,6 @@
struct option;
int parse_clockid(const struct option *opt, const char *str, int unset);
+const char *clockid_name(clockid_t clk_id);
+
#endif
--
2.25.4
Powered by blists - more mailing lists