* [PATCH] perf tools: get version from uname(2), not /proc
@ 2015-10-06 22:53 Matt Mullins
2015-10-07 8:18 ` Jiri Olsa
2015-10-07 15:34 ` Andi Kleen
0 siblings, 2 replies; 6+ messages in thread
From: Matt Mullins @ 2015-10-06 22:53 UTC (permalink / raw)
To: acme
Cc: Matt Mullins, Vinson Lee, Peter Zijlstra, Ingo Molnar, Jiri Olsa,
Namhyung Kim, Adrian Hunter, Kan Liang, Andi Kleen, linux-kernel
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
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] perf tools: get version from uname(2), not /proc
2015-10-06 22:53 [PATCH] perf tools: get version from uname(2), not /proc Matt Mullins
@ 2015-10-07 8:18 ` Jiri Olsa
2015-10-07 8:19 ` Adrian Hunter
2015-10-07 15:34 ` Andi Kleen
1 sibling, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2015-10-07 8:18 UTC (permalink / raw)
To: Matt Mullins
Cc: acme, Vinson Lee, Peter Zijlstra, Ingo Molnar, Namhyung Kim,
Adrian Hunter, Kan Liang, Andi Kleen, linux-kernel
On Tue, Oct 06, 2015 at 03:53:14PM -0700, Matt Mullins wrote:
> 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.
I guess it's easy to google this up, but could you
please state in the changelog what's the difference
between the current version and the UNAME26 one?
Also state (and check) this change wouldn't affect other
parts of the code that use this version (if there's any).
thanks,
jirka
>
> 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] perf tools: get version from uname(2), not /proc
2015-10-07 8:18 ` Jiri Olsa
@ 2015-10-07 8:19 ` Adrian Hunter
2015-10-07 17:11 ` Matt Mullins
0 siblings, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2015-10-07 8:19 UTC (permalink / raw)
To: Jiri Olsa, Matt Mullins
Cc: acme, Vinson Lee, Peter Zijlstra, Ingo Molnar, Namhyung Kim,
Kan Liang, Andi Kleen, linux-kernel
On 07/10/15 11:18, Jiri Olsa wrote:
> On Tue, Oct 06, 2015 at 03:53:14PM -0700, Matt Mullins wrote:
>> 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.
>
> I guess it's easy to google this up, but could you
> please state in the changelog what's the difference
> between the current version and the UNAME26 one?
>
> Also state (and check) this change wouldn't affect other
> parts of the code that use this version (if there's any).
Isn't the machine root dir for guests? uname() won't work for them.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] perf tools: get version from uname(2), not /proc
2015-10-07 8:19 ` Adrian Hunter
@ 2015-10-07 17:11 ` Matt Mullins
2015-10-08 6:26 ` Adrian Hunter
0 siblings, 1 reply; 6+ messages in thread
From: Matt Mullins @ 2015-10-07 17:11 UTC (permalink / raw)
To: Adrian Hunter
Cc: Jiri Olsa, acme, Vinson Lee, Peter Zijlstra, Ingo Molnar,
Namhyung Kim, Kan Liang, Andi Kleen, linux-kernel
On Wed, Oct 07, 2015 at 11:19:17AM +0300, Adrian Hunter wrote:
> On 07/10/15 11:18, Jiri Olsa wrote:
> > On Tue, Oct 06, 2015 at 03:53:14PM -0700, Matt Mullins wrote:
> >> 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.
> >
> > I guess it's easy to google this up, but could you
> > please state in the changelog what's the difference
> > between the current version and the UNAME26 one?
> >
> > Also state (and check) this change wouldn't affect other
> > parts of the code that use this version (if there's any).
This is the only caller of get_kernel_version.
> Isn't the machine root dir for guests? uname() won't work for them.
Aye, this would break --guestmount. Would it make sense to use uname()
iff root_dir is the empty string, or is that too much special-casing for
good taste?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] perf tools: get version from uname(2), not /proc
2015-10-07 17:11 ` Matt Mullins
@ 2015-10-08 6:26 ` Adrian Hunter
0 siblings, 0 replies; 6+ messages in thread
From: Adrian Hunter @ 2015-10-08 6:26 UTC (permalink / raw)
To: Jiri Olsa, acme, Vinson Lee, Peter Zijlstra, Ingo Molnar,
Namhyung Kim, Kan Liang, Andi Kleen, linux-kernel
On 07/10/15 20:11, Matt Mullins wrote:
> On Wed, Oct 07, 2015 at 11:19:17AM +0300, Adrian Hunter wrote:
>> On 07/10/15 11:18, Jiri Olsa wrote:
>>> On Tue, Oct 06, 2015 at 03:53:14PM -0700, Matt Mullins wrote:
>>>> 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.
>>>
>>> I guess it's easy to google this up, but could you
>>> please state in the changelog what's the difference
>>> between the current version and the UNAME26 one?
>>>
>>> Also state (and check) this change wouldn't affect other
>>> parts of the code that use this version (if there's any).
>
> This is the only caller of get_kernel_version.
>
>> Isn't the machine root dir for guests? uname() won't work for them.
>
> Aye, this would break --guestmount. Would it make sense to use uname()
> iff root_dir is the empty string, or is that too much special-casing for
> good taste?
There is machine__is_host(), but what about /proc/sys/kernel/osrelease or
does that have the same problem?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] perf tools: get version from uname(2), not /proc
2015-10-06 22:53 [PATCH] perf tools: get version from uname(2), not /proc Matt Mullins
2015-10-07 8:18 ` Jiri Olsa
@ 2015-10-07 15:34 ` Andi Kleen
1 sibling, 0 replies; 6+ messages in thread
From: Andi Kleen @ 2015-10-07 15:34 UTC (permalink / raw)
To: Matt Mullins
Cc: acme, Vinson Lee, Peter Zijlstra, Ingo Molnar, Jiri Olsa,
Namhyung Kim, Adrian Hunter, Kan Liang, linux-kernel
On Tue, Oct 06, 2015 at 03:53:14PM -0700, Matt Mullins wrote:
> 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.
May be easier to just reset the personality.
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-10-08 6:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-06 22:53 [PATCH] perf tools: get version from uname(2), not /proc Matt Mullins
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).