[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180405151645.19130-3-jolsa@kernel.org>
Date: Thu, 5 Apr 2018 17:16:38 +0200
From: Jiri Olsa <jolsa@...nel.org>
To: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>
Cc: lkml <linux-kernel@...r.kernel.org>, netdev@...r.kernel.org,
linux-kbuild@...r.kernel.org,
Quentin Monnet <quentin.monnet@...ronome.com>,
Eugene Syromiatnikov <esyr@...hat.com>,
Jiri Benc <jbenc@...hat.com>,
Stanislav Kozina <skozina@...hat.com>,
Jerome Marchand <jmarchan@...hat.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Michal Marek <michal.lkml@...kovi.net>,
Jiri Kosina <jkosina@...e.cz>
Subject: [PATCH 2/9] perf tools: Add fetch_kernel_buildid function
Adding fetch_kernel_buildid helper function to
retrieve build id from running kernel. It will
be used in following patches.
Link: http://lkml.kernel.org/n/tip-at98orsncas8v2ito61u3qod@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/util/util.c | 18 ++++++++++++++++++
tools/perf/util/util.h | 2 ++
2 files changed, 20 insertions(+)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 41fc61d941ef..26f93866bc02 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -495,6 +495,24 @@ int parse_notes_buildid(void *note_data, size_t note_len, void *bf,
return -1;
}
+int fetch_kernel_buildid(char *buildid, int size)
+{
+ char path[PATH_MAX], *buf;
+ size_t len;
+ int err;
+
+ scnprintf(path, PATH_MAX, "%s/kernel/notes",
+ sysfs__mountpoint());
+
+ if (filename__read_str(path, &buf, &len))
+ return -EINVAL;
+
+ err = parse_notes_buildid(buf, len, buildid, size, false);
+
+ free(buf);
+ return err;
+}
+
const char *perf_tip(const char *dirpath)
{
struct strlist *tips;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 27106548396b..1ccaa957e3ab 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -48,6 +48,8 @@ extern int cacheline_size;
int fetch_kernel_version(unsigned int *puint,
char *str, size_t str_sz);
+int fetch_kernel_buildid(char *buildid, int size);
+
int parse_notes_buildid(void *note_data, size_t note_len, void *bf,
size_t size, bool need_swap);
--
2.13.6
Powered by blists - more mailing lists