lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 18 Jan 2019 17:46:26 -0800
From:   Tony Jones <tonyj@...e.de>
To:     Seeteena Thoufeek <s1seetee@...ux.vnet.ibm.com>,
        peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
        alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
        namhyung@...nel.org, linux-kernel@...r.kernel.org,
        Ravi Bangoria <ravi.bangoria@...ux.ibm.com>
Subject: Re: [PATCH v2] perf scripts python: Add Python 3 support to
 stackcollapse.py

On 1/17/19 1:45 AM, Seeteena Thoufeek wrote:
> Support both Python 2 and Python 3 in stackcollapse.py. ``print`` is now a
> function rather than a statement. This should have no functional change.
> 
> Signed-off-by: Seeteena Thoufeek <s1seetee@...ux.vnet.ibm.com>
> Reviewed-by: Ravi Bangoria <ravi.bangoria@...ux.ibm.com>
> ---
>  tools/perf/scripts/python/stackcollapse.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/scripts/python/stackcollapse.py b/tools/perf/scripts/python/stackcollapse.py
> index 1697b5e..f77bc0d 100755
> --- a/tools/perf/scripts/python/stackcollapse.py
> +++ b/tools/perf/scripts/python/stackcollapse.py
> @@ -18,6 +18,7 @@
>  #
>  # Written by Paolo Bonzini <pbonzini@...hat.com>
>  # Based on Brendan Gregg's stackcollapse-perf.pl script.
> +from __future__ import print_function

Again, not necessary.
  
>  import os
>  import sys
> @@ -123,4 +124,4 @@ def trace_end():
>      list = lines.keys()
>      list.sort()
>      for stack in list:
> -        print "%s %d" % (stack, lines[stack])
> +        print("%s %d" % (stack, lines[stack]))
> 

Did you test any of these changes with Python3?

If you run 'ldd /usr/bin/perf | grep python' when you've built with PYTHON=python3,  what do you see?

$ ldd /usr/bin/perf | grep python
	libpython3.6m.so.1.0 => /usr/lib64/libpython3.6m.so.1.0 (0x00007fea66701000)

If you do,  you'll run into this error:

$ /usr/bin/perf script -s scripts/python/stackcollapse.py -i /tmp/perf.data
Traceback (most recent call last):
  File "scripts/python/stackcollapse.py", line 124, in trace_end
    list.sort()
AttributeError: 'dict_keys' object has no attribute 'sort'
Fatal Python error: problem in Python trace event handler

You need the following change in addition:

--- a/tools/perf/scripts/python/stackcollapse.py
+++ b/tools/perf/scripts/python/stackcollapse.py
@@ -120,7 +120,6 @@ def process_event(param_dict):
     lines[stack_string] = lines[stack_string] + 1

 def trace_end():
-    list = lines.keys()
-    list.sort()
+    list = sorted(lines)
     for stack in list:
-        print "%s %d" % (stack, lines[stack])
+        print ("%s %d" % (stack, lines[stack]))


As I said in a different post,  I'd not yet posted my series as I was still trying to fix the failure of the "import perf" testcase (aka tools/perf/python) and (apologies) I'd missed your V1 but maybe I should post them as they've been thoroughly integrated into perf and tested with python2 and python3.

The full patchset is in SLE15-SP1 beta2 which I know IBM has access to.  A backport is also in Factory.

Tony



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ