[RFC, PATCH] UBUNTU: fix perf kernel version detection for multiple-flavour strings

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[RFC, PATCH] UBUNTU: fix perf kernel version detection for multiple-flavour strings

Jeremy Kerr
Currently, the perf tool doesn't work for the generic-pae flavour:

 $ bash -x /usr/bin/perf
 ++ uname -r
 + version=2.6.32-21-generic-pae
 + version=2.6.32-21-generic
 + exec perf_2.6.32-21-generic
 /usr/bin/perf: line 4: exec: perf_2.6.32-21-generic: not found

- the PAE flavour has a version string ending in -generic-pae, but the
version cleaning in the perf script doesn't handle the multiple flavour
strings correctly. The perf tool is named perf_2.6.32-21, not
perf_2.6.32-21-generic.

This change fixes the perf wrapper script to throw away version data
after a 'dash, non-digit' sequence instead of just the last dash. This
fixes the problem on the PAE kernel. We need to do a special pass for
the -386 flavour, as it's virtually indisinguishable from a normal
version number. Testing this parsing against the possible flavours
gives:

        2.6.32-21-generic -> 2.6.32-21
         2.6.32-21-server -> 2.6.32-21
        2.6.32-21-preempt -> 2.6.32-21
      2.6.32-21-versatile -> 2.6.32-21
        2.6.32-21-generic -> 2.6.32-21
    2.6.32-21-generic-pae -> 2.6.32-21
            2.6.32-21-386 -> 2.6.32-21
           2.6.32-21-ia64 -> 2.6.32-21
           2.6.32-21-lpia -> 2.6.32-21
        2.6.32-21-powerpc -> 2.6.32-21
    2.6.32-21-powerpc-smp -> 2.6.32-21
  2.6.32-21-powerpc64-smp -> 2.6.32-21
        2.6.32-21-sparc64 -> 2.6.32-21
    2.6.32-21-sparc64-smp -> 2.6.32-21

Signed-off-by: Jeremy Kerr <[hidden email]>

---
 debian/tools/perf |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/debian/tools/perf b/debian/tools/perf
index 1a9915f..33df59d 100644
--- a/debian/tools/perf
+++ b/debian/tools/perf
@@ -1,4 +1,5 @@
 #!/bin/bash
 version=`uname -r`
-version=${version%-*}
+version=${version/-[^0-9]*}
+version=${version%-386}
 exec "perf_$version" "$@"

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [RFC, PATCH] UBUNTU: fix perf kernel version detection for multiple-flavour strings

Tim Gardner-2
On 04/21/2010 06:42 AM, Jeremy Kerr wrote:

> Currently, the perf tool doesn't work for the generic-pae flavour:
>
>   $ bash -x /usr/bin/perf
>   ++ uname -r
>   + version=2.6.32-21-generic-pae
>   + version=2.6.32-21-generic
>   + exec perf_2.6.32-21-generic
>   /usr/bin/perf: line 4: exec: perf_2.6.32-21-generic: not found
>
> - the PAE flavour has a version string ending in -generic-pae, but the
> version cleaning in the perf script doesn't handle the multiple flavour
> strings correctly. The perf tool is named perf_2.6.32-21, not
> perf_2.6.32-21-generic.
>
> This change fixes the perf wrapper script to throw away version data
> after a 'dash, non-digit' sequence instead of just the last dash. This
> fixes the problem on the PAE kernel. We need to do a special pass for
> the -386 flavour, as it's virtually indisinguishable from a normal
> version number. Testing this parsing against the possible flavours
> gives:
>
>          2.6.32-21-generic ->  2.6.32-21
>           2.6.32-21-server ->  2.6.32-21
>          2.6.32-21-preempt ->  2.6.32-21
>        2.6.32-21-versatile ->  2.6.32-21
>          2.6.32-21-generic ->  2.6.32-21
>      2.6.32-21-generic-pae ->  2.6.32-21
>              2.6.32-21-386 ->  2.6.32-21
>             2.6.32-21-ia64 ->  2.6.32-21
>             2.6.32-21-lpia ->  2.6.32-21
>          2.6.32-21-powerpc ->  2.6.32-21
>      2.6.32-21-powerpc-smp ->  2.6.32-21
>    2.6.32-21-powerpc64-smp ->  2.6.32-21
>          2.6.32-21-sparc64 ->  2.6.32-21
>      2.6.32-21-sparc64-smp ->  2.6.32-21
>
> Signed-off-by: Jeremy Kerr<[hidden email]>
>
> ---
>   debian/tools/perf |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/debian/tools/perf b/debian/tools/perf
> index 1a9915f..33df59d 100644
> --- a/debian/tools/perf
> +++ b/debian/tools/perf
> @@ -1,4 +1,5 @@
>   #!/bin/bash
>   version=`uname -r`
> -version=${version%-*}
> +version=${version/-[^0-9]*}
> +version=${version%-386}
>   exec "perf_$version" "$@"
>
Why not just drop everything after the second '-' inclusive ?

rtg
--
Tim Gardner [hidden email]

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team

0001-UBUNTU-Do-a-better-job-of-stripping-version-informat.patch (753 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [RFC, PATCH] UBUNTU: fix perf kernel version detection for multiple-flavour strings

Andy Whitcroft-3
In reply to this post by Jeremy Kerr
On Wed, Apr 21, 2010 at 08:42:59PM +0800, Jeremy Kerr wrote:

> Currently, the perf tool doesn't work for the generic-pae flavour:
>
>  $ bash -x /usr/bin/perf
>  ++ uname -r
>  + version=2.6.32-21-generic-pae
>  + version=2.6.32-21-generic
>  + exec perf_2.6.32-21-generic
>  /usr/bin/perf: line 4: exec: perf_2.6.32-21-generic: not found
>
> - the PAE flavour has a version string ending in -generic-pae, but the
> version cleaning in the perf script doesn't handle the multiple flavour
> strings correctly. The perf tool is named perf_2.6.32-21, not
> perf_2.6.32-21-generic.
>
> This change fixes the perf wrapper script to throw away version data
> after a 'dash, non-digit' sequence instead of just the last dash. This
> fixes the problem on the PAE kernel. We need to do a special pass for
> the -386 flavour, as it's virtually indisinguishable from a normal
> version number. Testing this parsing against the possible flavours
> gives:
>
>         2.6.32-21-generic -> 2.6.32-21
>          2.6.32-21-server -> 2.6.32-21
>         2.6.32-21-preempt -> 2.6.32-21
>       2.6.32-21-versatile -> 2.6.32-21
>         2.6.32-21-generic -> 2.6.32-21
>     2.6.32-21-generic-pae -> 2.6.32-21
>             2.6.32-21-386 -> 2.6.32-21
>            2.6.32-21-ia64 -> 2.6.32-21
>            2.6.32-21-lpia -> 2.6.32-21
>         2.6.32-21-powerpc -> 2.6.32-21
>     2.6.32-21-powerpc-smp -> 2.6.32-21
>   2.6.32-21-powerpc64-smp -> 2.6.32-21
>         2.6.32-21-sparc64 -> 2.6.32-21
>     2.6.32-21-sparc64-smp -> 2.6.32-21
>
> Signed-off-by: Jeremy Kerr <[hidden email]>
>
> ---
>  debian/tools/perf |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/debian/tools/perf b/debian/tools/perf
> index 1a9915f..33df59d 100644
> --- a/debian/tools/perf
> +++ b/debian/tools/perf
> @@ -1,4 +1,5 @@
>  #!/bin/bash
>  version=`uname -r`
> -version=${version%-*}
> +version=${version/-[^0-9]*}
> +version=${version%-386}
>  exec "perf_$version" "$@"

Yep, there is clearly an issue here.  I don't like the fact we have to know
the form of some of the flavours here.  I think we can more generically do
this by stripping the version-abi from the front which has a known form
(two lots of *-) and stripping the result from the original version.
Something like the patch below.  Testing this gives:

    2.6.32-21-generic -> 2.6.32-21
    2.6.32-21-server -> 2.6.32-21
    2.6.32-21-preempt -> 2.6.32-21
    2.6.32-21-versatile -> 2.6.32-21
    2.6.32-21-generic -> 2.6.32-21
    2.6.32-21-generic-pae -> 2.6.32-21
    2.6.32-21-386 -> 2.6.32-21
    2.6.32-21-ia64 -> 2.6.32-21
    2.6.32-21-lpia -> 2.6.32-21
    2.6.32-21-powerpc -> 2.6.32-21
    2.6.32-21-powerpc-smp -> 2.6.32-21
    2.6.32-21-powerpc64-smp -> 2.6.32-21
    2.6.32-21-sparc64 -> 2.6.32-21
    2.6.32-21-sparc64-smp -> 2.6.32-21

-apw

From 753b853b11e201905f7f0a183637b2951068993b Mon Sep 17 00:00:00 2001
From: Andy Whitcroft <[hidden email]>
Date: Wed, 21 Apr 2010 14:19:55 +0100
Subject: [PATCH] UBUNTU: tools -- fix perf version extraction for multi-part flavours

Currently, the perf tool doesn't work for the generic-pae flavour:

 $ bash -x /usr/bin/perf
 ++ uname -r
 + version=2.6.32-21-generic-pae
 + version=2.6.32-21-generic
 + exec perf_2.6.32-21-generic
 /usr/bin/perf: line 4: exec: perf_2.6.32-21-generic: not found

We can work out the flavour by removing the known shaped version-abi
combination from the start of the version string (which is two lots of
*-), and then remove this flavour suffix from the original version to
leave us with the version-abi we need.

Based on a patch by Jeremy Kerr <[hidden email]>.

Signed-off-by: Andy Whitcroft <[hidden email]>
---
 debian/tools/perf |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/debian/tools/perf b/debian/tools/perf
index 1a9915f..79253d2 100644
--- a/debian/tools/perf
+++ b/debian/tools/perf
@@ -1,4 +1,7 @@
 #!/bin/bash
 version=`uname -r`
-version=${version%-*}
+flavour=${version#*-}
+flavour=${flavour#*-}
+version=${version%-$flavour}
+
 exec "perf_$version" "$@"
--
1.7.0.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [RFC, PATCH] UBUNTU: fix perf kernel version detection for multiple-flavour strings

Andy Whitcroft-3
In reply to this post by Tim Gardner-2
On Wed, Apr 21, 2010 at 07:25:58AM -0600, Tim Gardner wrote:

> On 04/21/2010 06:42 AM, Jeremy Kerr wrote:
> >Currently, the perf tool doesn't work for the generic-pae flavour:
> >
> >  $ bash -x /usr/bin/perf
> >  ++ uname -r
> >  + version=2.6.32-21-generic-pae
> >  + version=2.6.32-21-generic
> >  + exec perf_2.6.32-21-generic
> >  /usr/bin/perf: line 4: exec: perf_2.6.32-21-generic: not found
> >
> >- the PAE flavour has a version string ending in -generic-pae, but the
> >version cleaning in the perf script doesn't handle the multiple flavour
> >strings correctly. The perf tool is named perf_2.6.32-21, not
> >perf_2.6.32-21-generic.
> >
> >This change fixes the perf wrapper script to throw away version data
> >after a 'dash, non-digit' sequence instead of just the last dash. This
> >fixes the problem on the PAE kernel. We need to do a special pass for
> >the -386 flavour, as it's virtually indisinguishable from a normal
> >version number. Testing this parsing against the possible flavours
> >gives:
> >
> >         2.6.32-21-generic ->  2.6.32-21
> >          2.6.32-21-server ->  2.6.32-21
> >         2.6.32-21-preempt ->  2.6.32-21
> >       2.6.32-21-versatile ->  2.6.32-21
> >         2.6.32-21-generic ->  2.6.32-21
> >     2.6.32-21-generic-pae ->  2.6.32-21
> >             2.6.32-21-386 ->  2.6.32-21
> >            2.6.32-21-ia64 ->  2.6.32-21
> >            2.6.32-21-lpia ->  2.6.32-21
> >         2.6.32-21-powerpc ->  2.6.32-21
> >     2.6.32-21-powerpc-smp ->  2.6.32-21
> >   2.6.32-21-powerpc64-smp ->  2.6.32-21
> >         2.6.32-21-sparc64 ->  2.6.32-21
> >     2.6.32-21-sparc64-smp ->  2.6.32-21
> >
> >Signed-off-by: Jeremy Kerr<[hidden email]>
> >
> >---
> >  debian/tools/perf |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> >diff --git a/debian/tools/perf b/debian/tools/perf
> >index 1a9915f..33df59d 100644
> >--- a/debian/tools/perf
> >+++ b/debian/tools/perf
> >@@ -1,4 +1,5 @@
> >  #!/bin/bash
> >  version=`uname -r`
> >-version=${version%-*}
> >+version=${version/-[^0-9]*}
> >+version=${version%-386}
> >  exec "perf_$version" "$@"
> >
>
> Why not just drop everything after the second '-' inclusive ?
>
> rtg
> --
> Tim Gardner [hidden email]

> From f935a6337ea4a1b8d7061fc249cbbfa13c38f631 Mon Sep 17 00:00:00 2001
> From: Tim Gardner <[hidden email]>
> Date: Wed, 21 Apr 2010 07:24:13 -0600
> Subject: [PATCH] UBUNTU: Do a better job of stripping version information from the perf binary name
>
> Signed-off-by: Tim Gardner <[hidden email]>
> ---
>  debian/tools/perf |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/debian/tools/perf b/debian/tools/perf
> index 1a9915f..7a3c10b 100644
> --- a/debian/tools/perf
> +++ b/debian/tools/perf
> @@ -1,4 +1,3 @@
>  #!/bin/bash
> -version=`uname -r`
> -version=${version%-*}
> +version=`uname -r|sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)-\([0-9]*\)-.*$/\1\.\2\.\3-\4/'`
>  exec "perf_$version" "$@"

Yes we should use the known bits here.  I would prefer to avoid the
additional fork here if possible.  I think we can do that, see my other
reply for an alternative patch.

-apw

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [RFC, PATCH] UBUNTU: fix perf kernel version detection for multiple-flavour strings

Tim Gardner-2
On 04/21/2010 07:30 AM, Andy Whitcroft wrote:

> On Wed, Apr 21, 2010 at 07:25:58AM -0600, Tim Gardner wrote:
>> On 04/21/2010 06:42 AM, Jeremy Kerr wrote:
>>> Currently, the perf tool doesn't work for the generic-pae flavour:
>>>
>>>   $ bash -x /usr/bin/perf
>>>   ++ uname -r
>>>   + version=2.6.32-21-generic-pae
>>>   + version=2.6.32-21-generic
>>>   + exec perf_2.6.32-21-generic
>>>   /usr/bin/perf: line 4: exec: perf_2.6.32-21-generic: not found
>>>
>>> - the PAE flavour has a version string ending in -generic-pae, but the
>>> version cleaning in the perf script doesn't handle the multiple flavour
>>> strings correctly. The perf tool is named perf_2.6.32-21, not
>>> perf_2.6.32-21-generic.
>>>
>>> This change fixes the perf wrapper script to throw away version data
>>> after a 'dash, non-digit' sequence instead of just the last dash. This
>>> fixes the problem on the PAE kernel. We need to do a special pass for
>>> the -386 flavour, as it's virtually indisinguishable from a normal
>>> version number. Testing this parsing against the possible flavours
>>> gives:
>>>
>>>          2.6.32-21-generic ->   2.6.32-21
>>>           2.6.32-21-server ->   2.6.32-21
>>>          2.6.32-21-preempt ->   2.6.32-21
>>>        2.6.32-21-versatile ->   2.6.32-21
>>>          2.6.32-21-generic ->   2.6.32-21
>>>      2.6.32-21-generic-pae ->   2.6.32-21
>>>              2.6.32-21-386 ->   2.6.32-21
>>>             2.6.32-21-ia64 ->   2.6.32-21
>>>             2.6.32-21-lpia ->   2.6.32-21
>>>          2.6.32-21-powerpc ->   2.6.32-21
>>>      2.6.32-21-powerpc-smp ->   2.6.32-21
>>>    2.6.32-21-powerpc64-smp ->   2.6.32-21
>>>          2.6.32-21-sparc64 ->   2.6.32-21
>>>      2.6.32-21-sparc64-smp ->   2.6.32-21
>>>
>>> Signed-off-by: Jeremy Kerr<[hidden email]>
>>>
>>> ---
>>>   debian/tools/perf |    3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/debian/tools/perf b/debian/tools/perf
>>> index 1a9915f..33df59d 100644
>>> --- a/debian/tools/perf
>>> +++ b/debian/tools/perf
>>> @@ -1,4 +1,5 @@
>>>   #!/bin/bash
>>>   version=`uname -r`
>>> -version=${version%-*}
>>> +version=${version/-[^0-9]*}
>>> +version=${version%-386}
>>>   exec "perf_$version" "$@"
>>>
>>
>> Why not just drop everything after the second '-' inclusive ?
>>
>> rtg
>> --
>> Tim Gardner [hidden email]
>
>>  From f935a6337ea4a1b8d7061fc249cbbfa13c38f631 Mon Sep 17 00:00:00 2001
>> From: Tim Gardner<[hidden email]>
>> Date: Wed, 21 Apr 2010 07:24:13 -0600
>> Subject: [PATCH] UBUNTU: Do a better job of stripping version information from the perf binary name
>>
>> Signed-off-by: Tim Gardner<[hidden email]>
>> ---
>>   debian/tools/perf |    3 +--
>>   1 files changed, 1 insertions(+), 2 deletions(-)
>>
>> diff --git a/debian/tools/perf b/debian/tools/perf
>> index 1a9915f..7a3c10b 100644
>> --- a/debian/tools/perf
>> +++ b/debian/tools/perf
>> @@ -1,4 +1,3 @@
>>   #!/bin/bash
>> -version=`uname -r`
>> -version=${version%-*}
>> +version=`uname -r|sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)-\([0-9]*\)-.*$/\1\.\2\.\3-\4/'`
>>   exec "perf_$version" "$@"
>
> Yes we should use the known bits here.  I would prefer to avoid the
> additional fork here if possible.  I think we can do that, see my other
> reply for an alternative patch.
>
> -apw

meh. I have no strong opinion.

--
Tim Gardner [hidden email]

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [RFC, PATCH] UBUNTU: fix perf kernel version detection for multiple-flavour strings

Jeremy Kerr
In reply to this post by Andy Whitcroft-3
Hi Andy,

> +flavour=${version#*-}
> +flavour=${flavour#*-}
> +version=${version%-$flavour}

Looks good.

Acked-By: Jeremy Kerr <[hidden email]>

Cheers,


Jeremy

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[APPLIED] [RFC, PATCH] UBUNTU: fix perf kernel version detection for multiple-flavour strings

Andy Whitcroft-3
In reply to this post by Andy Whitcroft-3
Applied to Lucid.

-apw

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team