From: Matt Mullins <mmullins@twopensource.com>
To: acme@kernel.org
Cc: Matt Mullins <mmullins@twopensource.com>,
Vinson Lee <vlee@twopensource.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@intel.com>, Andi Kleen <ak@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] perf tools: get version from uname(2), not /proc
Date: Tue, 6 Oct 2015 15:53:14 -0700 [thread overview]
Message-ID: <1444171996-24030-1-git-send-email-mmullins@twopensource.com> (raw)
Tools in kmod (e.g. modprobe) compose the module path from the release
from uname(2). Because we use the UNAME26 personality, we need perf to
find modules located at the same path as the system tools.
Signed-off-by: Matt Mullins <mmullins@twopensource.com>
Cc: Vinson Lee <vlee@twopensource.com>
---
tools/perf/util/machine.c | 28 ++++++----------------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 5ef90be2a249..51199bc271e9 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -11,6 +11,7 @@
#include "vdso.h"
#include <stdbool.h>
#include <symbol/kallsyms.h>
+#include <sys/utsname.h>
#include "unwind.h"
#include "linux/hash.h"
@@ -903,31 +904,14 @@ static void map_groups__fixup_end(struct map_groups *mg)
__map_groups__fixup_end(mg, i);
}
-static char *get_kernel_version(const char *root_dir)
+static char *get_kernel_version(void)
{
- char version[PATH_MAX];
- FILE *file;
- char *name, *tmp;
- const char *prefix = "Linux version ";
+ struct utsname utsname;
- sprintf(version, "%s/proc/version", root_dir);
- file = fopen(version, "r");
- if (!file)
+ if (uname(&utsname))
return NULL;
- version[0] = '\0';
- tmp = fgets(version, sizeof(version), file);
- fclose(file);
-
- name = strstr(version, prefix);
- if (!name)
- return NULL;
- name += strlen(prefix);
- tmp = strchr(name, ' ');
- if (tmp)
- *tmp = '\0';
-
- return strdup(name);
+ return strdup(utsname.release);
}
static bool is_kmod_dso(struct dso *dso)
@@ -1027,7 +1011,7 @@ static int machine__set_modules_path(struct machine *machine)
char *version;
char modules_path[PATH_MAX];
- version = get_kernel_version(machine->root_dir);
+ version = get_kernel_version();
if (!version)
return -1;
--
2.1.0
next reply other threads:[~2015-10-06 23:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-06 22:53 Matt Mullins [this message]
2015-10-07 8:18 ` Jiri Olsa
2015-10-07 8:19 ` Adrian Hunter
2015-10-07 17:11 ` Matt Mullins
2015-10-08 6:26 ` Adrian Hunter
2015-10-07 15:34 ` Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1444171996-24030-1-git-send-email-mmullins@twopensource.com \
--to=mmullins@twopensource.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=vlee@twopensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®