diff --git a/0001-change-script-from-py2-to-py3.patch b/0001-change-script-from-py2-to-py3.patch new file mode 100644 index 0000000..0536961 --- /dev/null +++ b/0001-change-script-from-py2-to-py3.patch @@ -0,0 +1,1897 @@ +Subject: [PATCH] [PATCH openEuler-1.0] : arm64/scripts: covert scripts from py2 to py3 + +euler inclusion +category:scripts +bugzilla:NA +CVE:NA +--- +Modify whole python2 scripts to python3, to remove the python2 dependencies. + +Signed-off-by:lihongjiang +--- + Documentation/networking/cxacru-cf.py | 2 +- + Documentation/target/tcm_mod_builder.py | 44 ++-- + Documentation/trace/postprocess/decode_msr.py | 4 +- + arch/ia64/scripts/unwcheck.py | 10 +- + drivers/staging/greybus/tools/lbtest | 6 +- + scripts/bloat-o-meter | 12 +- + scripts/check-kabi | 34 +-- + scripts/diffconfig | 14 +- + scripts/show_delta | 10 +- + scripts/spdxcheck.py | 2 +- + scripts/tracing/draw_functrace.py | 4 +- + tools/hv/lsvmbus | 14 +- + tools/kvm/kvm_stat/kvm_stat | 24 +- + tools/perf/python/tracepoint.py | 6 +- + tools/perf/python/twatch.py | 6 +- + tools/perf/scripts/python/call-graph-from-sql.py | 10 +- + tools/perf/scripts/python/sched-migration.py | 6 +- + tools/perf/scripts/python/stat-cpi.py | 4 +- + tools/perf/tests/attr.py | 36 +-- + tools/perf/util/setup.py | 4 +- + tools/power/pm-graph/bootgraph.py | 62 +++--- + tools/power/pm-graph/sleepgraph.py | 244 ++++++++++----------- + .../x86/intel_pstate_tracer/intel_pstate_tracer.py | 4 +- + 23 files changed, 281 insertions(+), 281 deletions(-) + +diff --git a/Documentation/networking/cxacru-cf.py b/Documentation/networking/cxacru-cf.py +index b41d298..1b960fb 100644 +--- a/Documentation/networking/cxacru-cf.py ++++ b/Documentation/networking/cxacru-cf.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # Copyright 2009 Simon Arlott + # + # This program is free software; you can redistribute it and/or modify it +diff --git a/Documentation/target/tcm_mod_builder.py b/Documentation/target/tcm_mod_builder.py +index 94bf694..3180283 100755 +--- a/Documentation/target/tcm_mod_builder.py ++++ b/Documentation/target/tcm_mod_builder.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # The TCM v4 multi-protocol fabric module generation script for drivers/target/$NEW_MOD + # + # Copyright (c) 2010 Rising Tide Systems +@@ -20,7 +20,7 @@ fabric_mod_port = "" + fabric_mod_init_port = "" + + def tcm_mod_err(msg): +- print msg ++ print(msg) + sys.exit(1) + + def tcm_mod_create_module_subdir(fabric_mod_dir_var): +@@ -28,7 +28,7 @@ def tcm_mod_create_module_subdir(fabric_mod_dir_var): + if os.path.isdir(fabric_mod_dir_var) == True: + return 1 + +- print "Creating fabric_mod_dir: " + fabric_mod_dir_var ++ print("Creating fabric_mod_dir: " + fabric_mod_dir_var) + ret = os.mkdir(fabric_mod_dir_var) + if ret: + tcm_mod_err("Unable to mkdir " + fabric_mod_dir_var) +@@ -41,7 +41,7 @@ def tcm_mod_build_FC_include(fabric_mod_dir_var, fabric_mod_name): + buf = "" + + f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" +- print "Writing file: " + f ++ print("Writing file: " + f) + + p = open(f, 'w'); + if not p: +@@ -85,7 +85,7 @@ def tcm_mod_build_SAS_include(fabric_mod_dir_var, fabric_mod_name): + buf = "" + + f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" +- print "Writing file: " + f ++ print("Writing file: " + f) + + p = open(f, 'w'); + if not p: +@@ -128,7 +128,7 @@ def tcm_mod_build_iSCSI_include(fabric_mod_dir_var, fabric_mod_name): + buf = "" + + f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" +- print "Writing file: " + f ++ print("Writing file: " + f) + + p = open(f, 'w'); + if not p: +@@ -172,7 +172,7 @@ def tcm_mod_build_base_includes(proto_ident, fabric_mod_dir_val, fabric_mod_name + elif proto_ident == "iSCSI": + tcm_mod_build_iSCSI_include(fabric_mod_dir_val, fabric_mod_name) + else: +- print "Unsupported proto_ident: " + proto_ident ++ print("Unsupported proto_ident: " + proto_ident) + sys.exit(1) + + return +@@ -181,7 +181,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name): + buf = "" + + f = fabric_mod_dir_var + "/" + fabric_mod_name + "_configfs.c" +- print "Writing file: " + f ++ print("Writing file: " + f) + + p = open(f, 'w'); + if not p: +@@ -340,7 +340,7 @@ def tcm_mod_scan_fabric_ops(tcm_dir): + + fabric_ops_api = tcm_dir + "include/target/target_core_fabric.h" + +- print "Using tcm_mod_scan_fabric_ops: " + fabric_ops_api ++ print("Using tcm_mod_scan_fabric_ops: " + fabric_ops_api) + process_fo = 0; + + p = open(fabric_ops_api, 'r') +@@ -376,14 +376,14 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name): + bufi = "" + + f = fabric_mod_dir_var + "/" + fabric_mod_name + "_fabric.c" +- print "Writing file: " + f ++ print("Writing file: " + f) + + p = open(f, 'w') + if not p: + tcm_mod_err("Unable to open file: " + f) + + fi = fabric_mod_dir_var + "/" + fabric_mod_name + "_fabric.h" +- print "Writing file: " + fi ++ print("Writing file: " + fi) + + pi = open(fi, 'w') + if not pi: +@@ -545,7 +545,7 @@ def tcm_mod_build_kbuild(fabric_mod_dir_var, fabric_mod_name): + + buf = "" + f = fabric_mod_dir_var + "/Makefile" +- print "Writing file: " + f ++ print("Writing file: " + f) + + p = open(f, 'w') + if not p: +@@ -566,7 +566,7 @@ def tcm_mod_build_kconfig(fabric_mod_dir_var, fabric_mod_name): + + buf = "" + f = fabric_mod_dir_var + "/Kconfig" +- print "Writing file: " + f ++ print("Writing file: " + f) + + p = open(f, 'w') + if not p: +@@ -611,20 +611,20 @@ def main(modname, proto_ident): + + tcm_dir = os.getcwd(); + tcm_dir += "/../../" +- print "tcm_dir: " + tcm_dir ++ print("tcm_dir: " + tcm_dir) + fabric_mod_name = modname + fabric_mod_dir = tcm_dir + "drivers/target/" + fabric_mod_name +- print "Set fabric_mod_name: " + fabric_mod_name +- print "Set fabric_mod_dir: " + fabric_mod_dir +- print "Using proto_ident: " + proto_ident ++ print("Set fabric_mod_name: " + fabric_mod_name) ++ print("Set fabric_mod_dir: " + fabric_mod_dir) ++ print("Using proto_ident: " + proto_ident) + + if proto_ident != "FC" and proto_ident != "SAS" and proto_ident != "iSCSI": +- print "Unsupported proto_ident: " + proto_ident ++ print("Unsupported proto_ident: " + proto_ident) + sys.exit(1) + + ret = tcm_mod_create_module_subdir(fabric_mod_dir) + if ret: +- print "tcm_mod_create_module_subdir() failed because module already exists!" ++ print("tcm_mod_create_module_subdir() failed because module already exists!") + sys.exit(1) + + tcm_mod_build_base_includes(proto_ident, fabric_mod_dir, fabric_mod_name) +@@ -634,11 +634,11 @@ def main(modname, proto_ident): + tcm_mod_build_kbuild(fabric_mod_dir, fabric_mod_name) + tcm_mod_build_kconfig(fabric_mod_dir, fabric_mod_name) + +- input = raw_input("Would you like to add " + fabric_mod_name + " to drivers/target/Makefile..? [yes,no]: ") ++ input = input("Would you like to add " + fabric_mod_name + " to drivers/target/Makefile..? [yes,no]: ") + if input == "yes" or input == "y": + tcm_mod_add_kbuild(tcm_dir, fabric_mod_name) + +- input = raw_input("Would you like to add " + fabric_mod_name + " to drivers/target/Kconfig..? [yes,no]: ") ++ input = input("Would you like to add " + fabric_mod_name + " to drivers/target/Kconfig..? [yes,no]: ") + if input == "yes" or input == "y": + tcm_mod_add_kconfig(tcm_dir, fabric_mod_name) + +@@ -655,7 +655,7 @@ parser.add_option('-p', '--protoident', help='Protocol Ident', dest='protoident' + mandatories = ['modname', 'protoident'] + for m in mandatories: + if not opts.__dict__[m]: +- print "mandatory option is missing\n" ++ print("mandatory option is missing\n") + parser.print_help() + exit(-1) + +diff --git a/Documentation/trace/postprocess/decode_msr.py b/Documentation/trace/postprocess/decode_msr.py +index 0ab40e0..dc58c58 100644 +--- a/Documentation/trace/postprocess/decode_msr.py ++++ b/Documentation/trace/postprocess/decode_msr.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # add symbolic names to read_msr / write_msr in trace + # decode_msr msr-index.h < trace + import sys +@@ -32,6 +32,6 @@ for j in sys.stdin: + break + if r: + j = j.replace(" " + m.group(2), " " + r + "(" + m.group(2) + ")") +- print j, ++ print(j, end=' ') + + +diff --git a/arch/ia64/scripts/unwcheck.py b/arch/ia64/scripts/unwcheck.py +index c55276e..b7ecaf7 100644 +--- a/arch/ia64/scripts/unwcheck.py ++++ b/arch/ia64/scripts/unwcheck.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # SPDX-License-Identifier: GPL-2.0 + # + # Usage: unwcheck.py FILE +@@ -16,7 +16,7 @@ import re + import sys + + if len(sys.argv) != 2: +- print("Usage: %s FILE" % sys.argv[0]) ++ print(("Usage: %s FILE" % sys.argv[0])) + sys.exit(2) + + readelf = os.getenv("READELF", "readelf") +@@ -29,7 +29,7 @@ def check_func (func, slots, rlen_sum): + global num_errors + num_errors += 1 + if not func: func = "[%#x-%#x]" % (start, end) +- print("ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum)) ++ print(("ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum))) + return + + num_funcs = 0 +@@ -55,11 +55,11 @@ for line in os.popen("%s -u %s" % (readelf, sys.argv[1])): + check_func(func, slots, rlen_sum) + + if num_errors == 0: +- print("No errors detected in %u functions." % num_funcs) ++ print(("No errors detected in %u functions." % num_funcs)) + else: + if num_errors > 1: + err="errors" + else: + err="error" +- print("%u %s detected in %u functions." % (num_errors, err, num_funcs)) ++ print(("%u %s detected in %u functions." % (num_errors, err, num_funcs))) + sys.exit(1) +diff --git a/drivers/staging/greybus/tools/lbtest b/drivers/staging/greybus/tools/lbtest +index 47c4812..ed71c6e 100755 +--- a/drivers/staging/greybus/tools/lbtest ++++ b/drivers/staging/greybus/tools/lbtest +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # SPDX-License-Identifier: BSD-3-Clause + + # Copyright (c) 2015 Google, Inc. +@@ -28,7 +28,7 @@ + # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-from __future__ import print_function ++ + import csv + import datetime + import sys +@@ -161,7 +161,7 @@ def main(): + if len(sys.argv) < 5: + usage() + +- if sys.argv[1] in dict.keys(): ++ if sys.argv[1] in list(dict.keys()): + loopback_run(sys.argv[1], sys.argv[2], int(sys.argv[3]), sys.argv[4]) + else: + usage() +diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter +index a923f05..cbd267d 100755 +--- a/scripts/bloat-o-meter ++++ b/scripts/bloat-o-meter +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # + # Copyright 2004 Matt Mackall + # +@@ -77,17 +77,17 @@ def print_result(symboltype, symbolformat, argc): + grow, shrink, add, remove, up, down, delta, old, new, otot, ntot = \ + calc(sys.argv[argc - 1], sys.argv[argc], symbolformat) + +- print("add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \ +- (add, remove, grow, shrink, up, -down, up-down)) +- print("%-40s %7s %7s %+7s" % (symboltype, "old", "new", "delta")) ++ print(("add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \ ++ (add, remove, grow, shrink, up, -down, up-down))) ++ print(("%-40s %7s %7s %+7s" % (symboltype, "old", "new", "delta"))) + for d, n in delta: +- if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)) ++ if d: print(("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d))) + + if otot: + percent = (ntot - otot) * 100.0 / otot + else: + percent = 0 +- print("Total: Before=%d, After=%d, chg %+.2f%%" % (otot, ntot, percent)) ++ print(("Total: Before=%d, After=%d, chg %+.2f%%" % (otot, ntot, percent))) + + if sys.argv[1] == "-c": + print_result("Function", "tT", 3) +diff --git a/scripts/check-kabi b/scripts/check-kabi +index e3ec97c..b173422 100755 +--- a/scripts/check-kabi ++++ b/scripts/check-kabi +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # SPDX-License-Identifier: GPL-2.0 + # + # check-kabi - Red Hat kABI reference checking tool +@@ -71,7 +71,7 @@ def check_kabi(symvers,kabi): + + for symbol in kabi: + abi_hash,abi_sym,abi_dir,abi_type = string.split(kabi[symbol]) +- if symvers.has_key(symbol): ++ if symbol in symvers: + sym_hash,sym_sym,sym_dir,sym_type = string.split(symvers[symbol]) + if abi_hash != sym_hash: + fail=1 +@@ -85,23 +85,23 @@ def check_kabi(symvers,kabi): + changed_symbols.append(symbol) + + if fail: +- print "*** ERROR - ABI BREAKAGE WAS DETECTED ***" +- print "" +- print "The following symbols have been changed (this will cause an ABI breakage):" +- print "" ++ print("*** ERROR - ABI BREAKAGE WAS DETECTED ***") ++ print("") ++ print("The following symbols have been changed (this will cause an ABI breakage):") ++ print("") + for symbol in changed_symbols: +- print symbol +- print "" ++ print(symbol) ++ print("") + + if warn: +- print "*** WARNING - ABI SYMBOLS MOVED ***" +- print "" +- print "The following symbols moved (typically caused by moving a symbol from being" +- print "provided by the kernel vmlinux out to a loadable module):" +- print "" ++ print("*** WARNING - ABI SYMBOLS MOVED ***") ++ print("") ++ print("The following symbols moved (typically caused by moving a symbol from being") ++ print("provided by the kernel vmlinux out to a loadable module):") ++ print("") + for symbol in moved_symbols: +- print symbol +- print "" ++ print(symbol) ++ print("") + + """Halt the build, if we got errors and/or warnings. In either case, + double-checkig is required to avoid introducing / concealing +@@ -111,12 +111,12 @@ def check_kabi(symvers,kabi): + sys.exit(0) + + def usage(): +- print """ ++ print(""" + check-kabi: check Module.kabi and Module.symvers files. + + check-kabi [ -k Module.kabi ] [ -s Module.symvers ] + +-""" ++""") + + if __name__ == "__main__": + +diff --git a/scripts/diffconfig b/scripts/diffconfig +index 89abf77..5c07d57 100755 +--- a/scripts/diffconfig ++++ b/scripts/diffconfig +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # SPDX-License-Identifier: GPL-2.0 + # + # diffconfig - a tool to compare .config files. +@@ -54,16 +54,16 @@ def print_config(op, config, value, new_value): + if merge_style: + if new_value: + if new_value=="n": +- print("# CONFIG_%s is not set" % config) ++ print(("# CONFIG_%s is not set" % config)) + else: +- print("CONFIG_%s=%s" % (config, new_value)) ++ print(("CONFIG_%s=%s" % (config, new_value))) + else: + if op=="-": +- print("-%s %s" % (config, value)) ++ print(("-%s %s" % (config, value))) + elif op=="+": +- print("+%s %s" % (config, new_value)) ++ print(("+%s %s" % (config, new_value))) + else: +- print(" %s %s -> %s" % (config, value, new_value)) ++ print((" %s %s -> %s" % (config, value, new_value))) + + def main(): + global merge_style +@@ -98,7 +98,7 @@ def main(): + b = readconfig(open(configb_filename)) + except (IOError): + e = sys.exc_info()[1] +- print("I/O error[%s]: %s\n" % (e.args[0],e.args[1])) ++ print(("I/O error[%s]: %s\n" % (e.args[0],e.args[1]))) + usage() + + # print items in a but not b (accumulate, sort and print) +diff --git a/scripts/show_delta b/scripts/show_delta +index 5b36500..78b4b73 100755 +--- a/scripts/show_delta ++++ b/scripts/show_delta +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # + # show_deltas: Read list of printk messages instrumented with + # time data, and format with time deltas. +@@ -94,11 +94,11 @@ def main(): + try: + lines = open(filein,"r").readlines() + except: +- print ("Problem opening file: %s" % filein) ++ print(("Problem opening file: %s" % filein)) + sys.exit(1) + + if base_str: +- print ('base= "%s"' % base_str) ++ print(('base= "%s"' % base_str)) + # assume a numeric base. If that fails, try searching + # for a matching line. + try: +@@ -117,12 +117,12 @@ def main(): + # stop at first match + break + if not found: +- print ('Couldn\'t find line matching base pattern "%s"' % base_str) ++ print(('Couldn\'t find line matching base pattern "%s"' % base_str)) + sys.exit(1) + else: + base_time = 0.0 + + for line in lines: +- print (convert_line(line, base_time),) ++ print((convert_line(line, base_time),)) + + main() +diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py +index e559c62..1b88b6b 100755 +--- a/scripts/spdxcheck.py ++++ b/scripts/spdxcheck.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # SPDX-License-Identifier: GPL-2.0 + # Copyright Thomas Gleixner + +diff --git a/scripts/tracing/draw_functrace.py b/scripts/tracing/draw_functrace.py +index 9b6dd4f..87974cc 100755 +--- a/scripts/tracing/draw_functrace.py ++++ b/scripts/tracing/draw_functrace.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + + """ + Copyright 2008 (c) Frederic Weisbecker +@@ -123,7 +123,7 @@ def main(): + tree = tree.getParent(caller) + tree = tree.calls(callee, calltime) + +- print(CallTree.ROOT) ++ print((CallTree.ROOT)) + + if __name__ == "__main__": + main() +diff --git a/tools/hv/lsvmbus b/tools/hv/lsvmbus +index 099f2c4..80517ab 100644 +--- a/tools/hv/lsvmbus ++++ b/tools/hv/lsvmbus +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # SPDX-License-Identifier: GPL-2.0 + + import os +@@ -17,7 +17,7 @@ if options.verbose is not None: + + vmbus_sys_path = '/sys/bus/vmbus/devices' + if not os.path.isdir(vmbus_sys_path): +- print("%s doesn't exist: exiting..." % vmbus_sys_path) ++ print(("%s doesn't exist: exiting..." % vmbus_sys_path)) + exit(-1) + + vmbus_dev_dict = { +@@ -96,17 +96,17 @@ format2 = '%2s: Class_ID = %s - %s\n\tDevice_ID = %s\n\tSysfs path: %s\n%s' + + for d in vmbus_dev_list: + if verbose == 0: +- print(('VMBUS ID ' + format0) % (d.vmbus_id, d.dev_desc)) ++ print((('VMBUS ID ' + format0) % (d.vmbus_id, d.dev_desc))) + elif verbose == 1: +- print( ++ print(( + ('VMBUS ID ' + format1) % + (d.vmbus_id, d.class_id, d.dev_desc, d.chn_vp_mapping) +- ) ++ )) + else: +- print( ++ print(( + ('VMBUS ID ' + format2) % + ( + d.vmbus_id, d.class_id, d.dev_desc, + d.device_id, d.sysfs_path, d.chn_vp_mapping + ) +- ) ++ )) +diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat +index f6ca0a2..054c80f 100755 +--- a/tools/kvm/kvm_stat/kvm_stat ++++ b/tools/kvm/kvm_stat/kvm_stat +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # + # top-like utility for displaying kvm statistics + # +@@ -19,7 +19,7 @@ Three different ways of output formatting are available: + + The data is sampled from the KVM's debugfs entries and its perf events. + """ +-from __future__ import print_function ++ + + import curses + import sys +@@ -388,9 +388,9 @@ class Group(object): + """ + length = 8 * (1 + len(self.events)) + read_format = 'xxxxxxxx' + 'Q' * len(self.events) +- return dict(zip([event.name for event in self.events], ++ return dict(list(zip([event.name for event in self.events], + struct.unpack(read_format, +- os.read(self.events[0].fd, length)))) ++ os.read(self.events[0].fd, length))))) + + + class Event(object): +@@ -600,8 +600,8 @@ class TracepointProvider(Provider): + integers.append(int(member)) + else: + int_range = member.split('-') +- integers.extend(range(int(int_range[0]), +- int(int_range[1]) + 1)) ++ integers.extend(list(range(int(int_range[0]), ++ int(int_range[1]) + 1))) + + return integers + +@@ -704,7 +704,7 @@ class TracepointProvider(Provider): + """Returns 'event name: current value' for all enabled events.""" + ret = defaultdict(int) + for group in self.group_leaders: +- for name, val in group.read().items(): ++ for name, val in list(group.read().items()): + if name not in self._fields: + continue + parent = ARCH.tracepoint_is_child(name) +@@ -771,7 +771,7 @@ class DebugfsProvider(Provider): + if len(vms) == 0: + self.do_read = False + +- self.paths = list(filter(lambda x: "{}-".format(pid) in x, vms)) ++ self.paths = list([x for x in vms if "{}-".format(pid) in x]) + + else: + self.paths = [] +@@ -959,7 +959,7 @@ class Stats(object): + for provider in self.providers: + if isinstance(provider, DebugfsProvider): + for key in provider.fields: +- if key in self.values.keys(): ++ if key in list(self.values.keys()): + del self.values[key] + else: + oldvals = self.values.copy() +@@ -1165,7 +1165,7 @@ class Tui(object): + sorted_items = [] + # we can't rule out child events to appear prior to parents even + # when sorted - separate out all children first, and add in later +- for key, values in sorted(stats.items(), key=sortkey, ++ for key, values in sorted(list(stats.items()), key=sortkey, + reverse=True): + if values == (0, 0): + continue +@@ -1201,7 +1201,7 @@ class Tui(object): + stats = self.stats.get(self._display_guests) + total = 0. + ctotal = 0. +- for key, values in stats.items(): ++ for key, values in list(stats.items()): + if self._display_guests: + if self.get_gname_from_pid(key): + total += values.value +@@ -1699,7 +1699,7 @@ def main(): + if options.fields == 'help': + stats.fields_filter = None + event_list = [] +- for key in stats.get().keys(): ++ for key in list(stats.get().keys()): + event_list.append(key.split('(', 1)[0]) + sys.stdout.write(' ' + '\n '.join(sorted(set(event_list))) + '\n') + sys.exit(0) +diff --git a/tools/perf/python/tracepoint.py b/tools/perf/python/tracepoint.py +index eb76f65..4afbeeb 100755 +--- a/tools/perf/python/tracepoint.py ++++ b/tools/perf/python/tracepoint.py +@@ -1,4 +1,4 @@ +-#! /usr/bin/python ++#!/usr/bin/python3 + # SPDX-License-Identifier: GPL-2.0 + # -*- python -*- + # -*- coding: utf-8 -*- +@@ -34,7 +34,7 @@ def main(): + if not isinstance(event, perf.sample_event): + continue + +- print "time %u prev_comm=%s prev_pid=%d prev_prio=%d prev_state=0x%x ==> next_comm=%s next_pid=%d next_prio=%d" % ( ++ print("time %u prev_comm=%s prev_pid=%d prev_prio=%d prev_state=0x%x ==> next_comm=%s next_pid=%d next_prio=%d" % ( + event.sample_time, + event.prev_comm, + event.prev_pid, +@@ -42,7 +42,7 @@ def main(): + event.prev_state, + event.next_comm, + event.next_pid, +- event.next_prio) ++ event.next_prio)) + + if __name__ == '__main__': + main() +diff --git a/tools/perf/python/twatch.py b/tools/perf/python/twatch.py +index 0a29c5c..987ddf7 100755 +--- a/tools/perf/python/twatch.py ++++ b/tools/perf/python/twatch.py +@@ -1,4 +1,4 @@ +-#! /usr/bin/python ++#!/usr/bin/python3 + # -*- python -*- + # -*- coding: utf-8 -*- + # twatch - Experimental use of the perf python interface +@@ -42,10 +42,10 @@ def main(context_switch = 0, thread = -1): + event = evlist.read_on_cpu(cpu) + if not event: + continue +- print("cpu: {0}, pid: {1}, tid: {2} {3}".format(event.sample_cpu, ++ print(("cpu: {0}, pid: {1}, tid: {2} {3}".format(event.sample_cpu, + event.sample_pid, + event.sample_tid, +- event)) ++ event))) + + if __name__ == '__main__': + """ +diff --git a/tools/perf/scripts/python/call-graph-from-sql.py b/tools/perf/scripts/python/call-graph-from-sql.py +index b494a67..d30af15 100644 +--- a/tools/perf/scripts/python/call-graph-from-sql.py ++++ b/tools/perf/scripts/python/call-graph-from-sql.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python2 ++#!/usr/bin/python3 + # call-graph-from-sql.py: create call-graph from sql database + # Copyright (c) 2014-2017, Intel Corporation. + # +@@ -84,7 +84,7 @@ class TreeItem(): + ret = query.exec_('SELECT id, comm FROM comms') + if not ret: + raise Exception("Query failed: " + query.lastError().text()) +- while query.next(): ++ while next(query): + if not query.value(0): + continue + child_item = TreeItem(self.db, self.child_count, self) +@@ -102,7 +102,7 @@ class TreeItem(): + ret = query.exec_('SELECT thread_id, ( SELECT pid FROM threads WHERE id = thread_id ), ( SELECT tid FROM threads WHERE id = thread_id ) FROM comm_threads WHERE comm_id = ' + str(comm_id)) + if not ret: + raise Exception("Query failed: " + query.lastError().text()) +- while query.next(): ++ while next(query): + child_item = TreeItem(self.db, self.child_count, self) + self.child_items.append(child_item) + self.child_count += 1 +@@ -172,7 +172,7 @@ class TreeItem(): + total_branch_count = 0 + time = 0 + total_time = 0 +- while query.next(): ++ while next(query): + if query.value(1) == last_call_path_id: + count += 1 + branch_count += query.value(2) +@@ -292,7 +292,7 @@ class MainWindow(QMainWindow): + + if __name__ == '__main__': + if (len(sys.argv) < 2): +- print >> sys.stderr, "Usage is: call-graph-from-sql.py " ++ print("Usage is: call-graph-from-sql.py ", file=sys.stderr) + raise Exception("Too few arguments") + + dbname = sys.argv[1] +diff --git a/tools/perf/scripts/python/sched-migration.py b/tools/perf/scripts/python/sched-migration.py +index 3473e7f..981562c 100644 +--- a/tools/perf/scripts/python/sched-migration.py ++++ b/tools/perf/scripts/python/sched-migration.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # + # Cpu task migration overview toy + # +@@ -9,14 +9,14 @@ + # This software is distributed under the terms of the GNU General + # Public License ("GPL") version 2 as published by the Free Software + # Foundation. +-from __future__ import print_function ++ + + import os + import sys + + from collections import defaultdict + try: +- from UserList import UserList ++ from collections import UserList + except ImportError: + # Python 3: UserList moved to the collections package + from collections import UserList +diff --git a/tools/perf/scripts/python/stat-cpi.py b/tools/perf/scripts/python/stat-cpi.py +index 8410672..246ce58 100644 +--- a/tools/perf/scripts/python/stat-cpi.py ++++ b/tools/perf/scripts/python/stat-cpi.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # SPDX-License-Identifier: GPL-2.0 + + data = {} +@@ -59,7 +59,7 @@ def stat__interval(time): + if ins != 0: + cpi = cyc/float(ins) + +- print "%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins) ++ print("%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins)) + + def trace_end(): + pass +diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py +index 44090a9..42c241e 100644 +--- a/tools/perf/tests/attr.py ++++ b/tools/perf/tests/attr.py +@@ -1,4 +1,4 @@ +-#! /usr/bin/python ++#!/usr/bin/python3 + # SPDX-License-Identifier: GPL-2.0 + + import os +@@ -8,7 +8,7 @@ import optparse + import tempfile + import logging + import shutil +-import ConfigParser ++import configparser + + def data_equal(a, b): + # Allow multiple values in assignment separated by '|' +@@ -100,20 +100,20 @@ class Event(dict): + def equal(self, other): + for t in Event.terms: + log.debug(" [%s] %s %s" % (t, self[t], other[t])); +- if not self.has_key(t) or not other.has_key(t): ++ if t not in self or t not in other: + return False + if not data_equal(self[t], other[t]): + return False + return True + + def optional(self): +- if self.has_key('optional') and self['optional'] == '1': ++ if 'optional' in self and self['optional'] == '1': + return True + return False + + def diff(self, other): + for t in Event.terms: +- if not self.has_key(t) or not other.has_key(t): ++ if t not in self or t not in other: + continue + if not data_equal(self[t], other[t]): + log.warning("expected %s=%s, got %s" % (t, self[t], other[t])) +@@ -134,7 +134,7 @@ class Event(dict): + # - expected values assignments + class Test(object): + def __init__(self, path, options): +- parser = ConfigParser.SafeConfigParser() ++ parser = configparser.SafeConfigParser() + parser.read(path) + + log.warning("running '%s'" % path) +@@ -193,7 +193,7 @@ class Test(object): + return True + + def load_events(self, path, events): +- parser_event = ConfigParser.SafeConfigParser() ++ parser_event = configparser.SafeConfigParser() + parser_event.read(path) + + # The event record section header contains 'event' word, +@@ -207,7 +207,7 @@ class Test(object): + # Read parent event if there's any + if (':' in section): + base = section[section.index(':') + 1:] +- parser_base = ConfigParser.SafeConfigParser() ++ parser_base = configparser.SafeConfigParser() + parser_base.read(self.test_dir + '/' + base) + base_items = parser_base.items('event') + +@@ -236,11 +236,11 @@ class Test(object): + + # For each expected event find all matching + # events in result. Fail if there's not any. +- for exp_name, exp_event in expect.items(): ++ for exp_name, exp_event in list(expect.items()): + exp_list = [] + res_event = {} + log.debug(" matching [%s]" % exp_name) +- for res_name, res_event in result.items(): ++ for res_name, res_event in list(result.items()): + log.debug(" to [%s]" % res_name) + if (exp_event.equal(res_event)): + exp_list.append(res_name) +@@ -265,7 +265,7 @@ class Test(object): + + # For each defined group in the expected events + # check we match the same group in the result. +- for exp_name, exp_event in expect.items(): ++ for exp_name, exp_event in list(expect.items()): + group = exp_event.group + + if (group == ''): +@@ -282,12 +282,12 @@ class Test(object): + log.debug(" matched") + + def resolve_groups(self, events): +- for name, event in events.items(): ++ for name, event in list(events.items()): + group_fd = event['group_fd']; + if group_fd == '-1': + continue; + +- for iname, ievent in events.items(): ++ for iname, ievent in list(events.items()): + if (ievent['fd'] == group_fd): + event.group = iname + log.debug('[%s] has group leader [%s]' % (name, iname)) +@@ -322,9 +322,9 @@ def run_tests(options): + for f in glob.glob(options.test_dir + '/' + options.test): + try: + Test(f, options).run() +- except Unsup, obj: ++ except Unsup as obj: + log.warning("unsupp %s" % obj.getMsg()) +- except Notest, obj: ++ except Notest as obj: + log.warning("skipped %s" % obj.getMsg()) + + def setup_log(verbose): +@@ -373,7 +373,7 @@ def main(): + setup_log(options.verbose) + + if not options.test_dir: +- print 'FAILED no -d option specified' ++ print('FAILED no -d option specified') + sys.exit(-1) + + if not options.test: +@@ -382,8 +382,8 @@ def main(): + try: + run_tests(options) + +- except Fail, obj: +- print "FAILED %s" % obj.getMsg(); ++ except Fail as obj: ++ print("FAILED %s" % obj.getMsg()); + sys.exit(-1) + + sys.exit(0) +diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py +index 1942f6d..383a9fb 100644 +--- a/tools/perf/util/setup.py ++++ b/tools/perf/util/setup.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + + from os import getenv + from subprocess import Popen, PIPE +@@ -49,7 +49,7 @@ ext_sources = [f.strip() for f in open('util/python-ext-sources') + if len(f.strip()) > 0 and f[0] != '#'] + + # use full paths with source files +-ext_sources = list(map(lambda x: '%s/%s' % (src_perf, x) , ext_sources)) ++ext_sources = list(['%s/%s' % (src_perf, x) for x in ext_sources]) + + perf = Extension('perf', + sources = ext_sources, +diff --git a/tools/power/pm-graph/bootgraph.py b/tools/power/pm-graph/bootgraph.py +index 8ee626c..9a174e0 100755 +--- a/tools/power/pm-graph/bootgraph.py ++++ b/tools/power/pm-graph/bootgraph.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python2 ++#!/usr/bin/python3 + # + # Tool for analyzing boot timing + # Copyright (c) 2013, Intel Corporation. +@@ -141,13 +141,13 @@ class SystemValues(aslib.SystemValues): + if arg in ['-h', '-v', '-cronjob', '-reboot', '-verbose']: + continue + elif arg in ['-o', '-dmesg', '-ftrace', '-func']: +- args.next() ++ next(args) + continue + elif arg == '-result': +- cmdline += ' %s "%s"' % (arg, os.path.abspath(args.next())) ++ cmdline += ' %s "%s"' % (arg, os.path.abspath(next(args))) + continue + elif arg == '-cgskip': +- file = self.configFile(args.next()) ++ file = self.configFile(next(args)) + cmdline += ' %s "%s"' % (arg, os.path.abspath(file)) + continue + cmdline += ' '+arg +@@ -157,11 +157,11 @@ class SystemValues(aslib.SystemValues): + return cmdline + def manualRebootRequired(self): + cmdline = self.kernelParams() +- print 'To generate a new timeline manually, follow these steps:\n' +- print '1. Add the CMDLINE string to your kernel command line.' +- print '2. Reboot the system.' +- print '3. After reboot, re-run this tool with the same arguments but no command (w/o -reboot or -manual).\n' +- print 'CMDLINE="%s"' % cmdline ++ print('To generate a new timeline manually, follow these steps:\n') ++ print('1. Add the CMDLINE string to your kernel command line.') ++ print('2. Reboot the system.') ++ print('3. After reboot, re-run this tool with the same arguments but no command (w/o -reboot or -manual).\n') ++ print('CMDLINE="%s"' % cmdline) + sys.exit() + def blGrub(self): + blcmd = '' +@@ -431,7 +431,7 @@ def parseTraceLog(data): + if len(cg.list) < 1 or cg.invalid or (cg.end - cg.start == 0): + continue + if(not cg.postProcess()): +- print('Sanity check failed for %s-%d' % (proc, pid)) ++ print(('Sanity check failed for %s-%d' % (proc, pid))) + continue + # match cg data to devices + devname = data.deviceMatch(pid, cg) +@@ -442,8 +442,8 @@ def parseTraceLog(data): + sysvals.vprint('%s callgraph found for %s %s-%d [%f - %f]' %\ + (kind, cg.name, proc, pid, cg.start, cg.end)) + elif len(cg.list) > 1000000: +- print 'WARNING: the callgraph found for %s is massive! (%d lines)' %\ +- (devname, len(cg.list)) ++ print('WARNING: the callgraph found for %s is massive! (%d lines)' %\ ++ (devname, len(cg.list))) + + # Function: retrieveLogs + # Description: +@@ -733,8 +733,8 @@ def updateCron(restore=False): + op.write('@reboot python %s\n' % sysvals.cronjobCmdString()) + op.close() + res = call([cmd, cronfile]) +- except Exception, e: +- print 'Exception: %s' % str(e) ++ except Exception as e: ++ print('Exception: %s' % str(e)) + shutil.move(backfile, cronfile) + res = -1 + if res != 0: +@@ -749,8 +749,8 @@ def updateGrub(restore=False): + try: + call(sysvals.blexec, stderr=PIPE, stdout=PIPE, + env={'PATH': '.:/sbin:/usr/sbin:/usr/bin:/sbin:/bin'}) +- except Exception, e: +- print 'Exception: %s\n' % str(e) ++ except Exception as e: ++ print('Exception: %s\n' % str(e)) + return + # extract the option and create a grub config without it + sysvals.rootUser(True) +@@ -796,8 +796,8 @@ def updateGrub(restore=False): + op.close() + res = call(sysvals.blexec) + os.remove(grubfile) +- except Exception, e: +- print 'Exception: %s' % str(e) ++ except Exception as e: ++ print('Exception: %s' % str(e)) + res = -1 + # cleanup + shutil.move(tempfile, grubfile) +@@ -821,7 +821,7 @@ def updateKernelParams(restore=False): + def doError(msg, help=False): + if help == True: + printHelp() +- print 'ERROR: %s\n' % msg ++ print('ERROR: %s\n' % msg) + sysvals.outputResult({'error':msg}) + sys.exit() + +@@ -830,7 +830,7 @@ def doError(msg, help=False): + # print out the help text + def printHelp(): + print('') +- print('%s v%s' % (sysvals.title, sysvals.version)) ++ print(('%s v%s' % (sysvals.title, sysvals.version))) + print('Usage: bootgraph ') + print('') + print('Description:') +@@ -895,7 +895,7 @@ if __name__ == '__main__': + printHelp() + sys.exit() + elif(arg == '-v'): +- print("Version %s" % sysvals.version) ++ print(("Version %s" % sysvals.version)) + sys.exit() + elif(arg == '-verbose'): + sysvals.verbose = True +@@ -912,13 +912,13 @@ if __name__ == '__main__': + sysvals.mincglen = aslib.getArgFloat('-mincg', args, 0.0, 10000.0) + elif(arg == '-cgfilter'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No callgraph functions supplied', True) + sysvals.setCallgraphFilter(val) + elif(arg == '-cgskip'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No file supplied', True) + if val.lower() in switchoff: +@@ -929,7 +929,7 @@ if __name__ == '__main__': + doError('%s does not exist' % cgskip) + elif(arg == '-bl'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No boot loader name supplied', True) + if val.lower() not in ['grub']: +@@ -942,7 +942,7 @@ if __name__ == '__main__': + sysvals.max_graph_depth = aslib.getArgInt('-maxdepth', args, 0, 1000) + elif(arg == '-func'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No filter functions supplied', True) + sysvals.useftrace = True +@@ -951,7 +951,7 @@ if __name__ == '__main__': + sysvals.setGraphFilter(val) + elif(arg == '-ftrace'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No ftrace file supplied', True) + if(os.path.exists(val) == False): +@@ -964,7 +964,7 @@ if __name__ == '__main__': + sysvals.cgexp = True + elif(arg == '-dmesg'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No dmesg file supplied', True) + if(os.path.exists(val) == False): +@@ -973,13 +973,13 @@ if __name__ == '__main__': + sysvals.dmesgfile = val + elif(arg == '-o'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No subdirectory name supplied', True) + sysvals.testdir = sysvals.setOutputFolder(val) + elif(arg == '-result'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No result file supplied', True) + sysvals.result = val +@@ -1013,10 +1013,10 @@ if __name__ == '__main__': + updateKernelParams() + elif cmd == 'flistall': + for f in sysvals.getBootFtraceFilterFunctions(): +- print f ++ print(f) + elif cmd == 'checkbl': + sysvals.getBootLoader() +- print 'Boot Loader: %s\n%s' % (sysvals.bootloader, sysvals.blexec) ++ print('Boot Loader: %s\n%s' % (sysvals.bootloader, sysvals.blexec)) + elif(cmd == 'sysinfo'): + sysvals.printSystemInfo(True) + sys.exit() +diff --git a/tools/power/pm-graph/sleepgraph.py b/tools/power/pm-graph/sleepgraph.py +index 0c76047..3a6c07f 100755 +--- a/tools/power/pm-graph/sleepgraph.py ++++ b/tools/power/pm-graph/sleepgraph.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python2 ++#!/usr/bin/python3 + # + # Tool for analyzing suspend/resume timing + # Copyright (c) 2013, Intel Corporation. +@@ -56,7 +56,7 @@ import re + import platform + from datetime import datetime + import struct +-import ConfigParser ++import configparser + import gzip + from threading import Thread + from subprocess import call, Popen, PIPE +@@ -265,7 +265,7 @@ class SystemValues: + return True + if fatal: + msg = 'This command requires sysfs mount and root access' +- print('ERROR: %s\n') % msg ++ print(('ERROR: %s\n') % msg) + self.outputResult({'error':msg}) + sys.exit() + return False +@@ -274,7 +274,7 @@ class SystemValues: + return True + if fatal: + msg = 'This command must be run as root' +- print('ERROR: %s\n') % msg ++ print(('ERROR: %s\n') % msg) + self.outputResult({'error':msg}) + sys.exit() + return False +@@ -329,10 +329,10 @@ class SystemValues: + return + fmt = '%-24s: %s' + for name in sorted(out): +- print fmt % (name, out[name]) +- print fmt % ('cpucount', ('%d' % self.cpucount)) +- print fmt % ('memtotal', ('%d kB' % self.memtotal)) +- print fmt % ('memfree', ('%d kB' % self.memfree)) ++ print(fmt % (name, out[name])) ++ print(fmt % ('cpucount', ('%d' % self.cpucount))) ++ print(fmt % ('memtotal', ('%d kB' % self.memtotal))) ++ print(fmt % ('memfree', ('%d kB' % self.memfree))) + def cpuInfo(self): + self.cpucount = 0 + fp = open('/proc/cpuinfo', 'r') +@@ -447,9 +447,9 @@ class SystemValues: + if 'func' in self.tracefuncs[i]: + i = self.tracefuncs[i]['func'] + if i in master: +- print i ++ print(i) + else: +- print self.colorText(i) ++ print(self.colorText(i)) + def setFtraceFilterFunctions(self, list): + master = self.listFromFile(self.tpath+'available_filter_functions') + flist = '' +@@ -557,7 +557,7 @@ class SystemValues: + else: + kpl[2].append(name) + if output: +- print(' %s: %s' % (name, res)) ++ print((' %s: %s' % (name, res))) + kplist = kpl[0] + kpl[1] + kpl[2] + kpl[3] + # remove all failed ones from the list + for name in rejects: +@@ -571,7 +571,7 @@ class SystemValues: + if output: + check = self.fgetVal('kprobe_events') + linesack = (len(check.split('\n')) - 1) / 2 +- print(' kprobe functions enabled: %d/%d' % (linesack, linesout)) ++ print((' kprobe functions enabled: %d/%d' % (linesack, linesout))) + self.fsetVal('1', 'events/kprobes/enable') + def testKprobe(self, kname, kprobe): + self.fsetVal('0', 'events/kprobes/enable') +@@ -658,7 +658,7 @@ class SystemValues: + if tgtsize < 65536: + tgtsize = int(self.fgetVal('buffer_size_kb')) * cpus + break +- print 'Setting trace buffers to %d kB (%d kB per cpu)' % (tgtsize, tgtsize/cpus) ++ print('Setting trace buffers to %d kB (%d kB per cpu)' % (tgtsize, tgtsize/cpus)) + # initialize the callgraph trace + if(self.usecallgraph): + # set trace type +@@ -808,7 +808,7 @@ class DevProps: + def out(self, dev): + return '%s,%s,%d;' % (dev, self.altname, self.async) + def debug(self, dev): +- print '%s:\n\taltname = %s\n\t async = %s' % (dev, self.altname, self.async) ++ print('%s:\n\taltname = %s\n\t async = %s' % (dev, self.altname, self.async)) + def altName(self, dev): + if not self.altname or self.altname == dev: + return dev +@@ -1633,14 +1633,14 @@ class FTraceLine: + return len(str)/2 + def debugPrint(self, info=''): + if self.isLeaf(): +- print(' -- %12.6f (depth=%02d): %s(); (%.3f us) %s' % (self.time, \ +- self.depth, self.name, self.length*1000000, info)) ++ print((' -- %12.6f (depth=%02d): %s(); (%.3f us) %s' % (self.time, \ ++ self.depth, self.name, self.length*1000000, info))) + elif self.freturn: +- print(' -- %12.6f (depth=%02d): %s} (%.3f us) %s' % (self.time, \ +- self.depth, self.name, self.length*1000000, info)) ++ print((' -- %12.6f (depth=%02d): %s} (%.3f us) %s' % (self.time, \ ++ self.depth, self.name, self.length*1000000, info))) + else: +- print(' -- %12.6f (depth=%02d): %s() { (%.3f us) %s' % (self.time, \ +- self.depth, self.name, self.length*1000000, info)) ++ print((' -- %12.6f (depth=%02d): %s() { (%.3f us) %s' % (self.time, \ ++ self.depth, self.name, self.length*1000000, info))) + def startMarker(self): + # Is this the starting line of a suspend? + if not self.fevent: +@@ -1786,7 +1786,7 @@ class FTraceCallGraph: + if warning and ('[make leaf]', line) not in info: + info.append(('', line)) + if warning: +- print 'WARNING: ftrace data missing, corrections made:' ++ print('WARNING: ftrace data missing, corrections made:') + for i in info: + t, obj = i + if obj: +@@ -1846,11 +1846,11 @@ class FTraceCallGraph: + id = 'task %s' % (self.pid) + window = '(%f - %f)' % (self.start, line.time) + if(self.depth < 0): +- print('Data misalignment for '+id+\ +- ' (buffer overflow), ignoring this callback') ++ print(('Data misalignment for '+id+\ ++ ' (buffer overflow), ignoring this callback')) + else: +- print('Too much data for '+id+\ +- ' '+window+', ignoring this callback') ++ print(('Too much data for '+id+\ ++ ' '+window+', ignoring this callback')) + def slice(self, dev): + minicg = FTraceCallGraph(dev['pid'], self.sv) + minicg.name = self.name +@@ -1875,7 +1875,7 @@ class FTraceCallGraph: + # bring the depth back to 0 with additional returns + fixed = False + last = self.list[-1] +- for i in reversed(range(enddepth)): ++ for i in reversed(list(range(enddepth))): + t = FTraceLine(last.time) + t.depth = i + t.freturn = True +@@ -1902,7 +1902,7 @@ class FTraceCallGraph: + elif l.isReturn(): + if(l.depth not in stack): + if self.sv.verbose: +- print 'Post Process Error: Depth missing' ++ print('Post Process Error: Depth missing') + l.debugPrint() + return False + # calculate call length from call/return lines +@@ -1919,7 +1919,7 @@ class FTraceCallGraph: + return True + elif(cnt < 0): + if self.sv.verbose: +- print 'Post Process Error: Depth is less than 0' ++ print('Post Process Error: Depth is less than 0') + return False + # trace ended before call tree finished + return self.repair(cnt) +@@ -1978,19 +1978,19 @@ class FTraceCallGraph: + phase, myname = out + data.dmesg[phase]['list'][myname]['ftrace'] = self + def debugPrint(self, info=''): +- print('%s pid=%d [%f - %f] %.3f us') % \ ++ print(('%s pid=%d [%f - %f] %.3f us') % \ + (self.name, self.pid, self.start, self.end, +- (self.end - self.start)*1000000) ++ (self.end - self.start)*1000000)) + for l in self.list: + if l.isLeaf(): +- print('%f (%02d): %s(); (%.3f us)%s' % (l.time, \ +- l.depth, l.name, l.length*1000000, info)) ++ print(('%f (%02d): %s(); (%.3f us)%s' % (l.time, \ ++ l.depth, l.name, l.length*1000000, info))) + elif l.freturn: +- print('%f (%02d): %s} (%.3f us)%s' % (l.time, \ +- l.depth, l.name, l.length*1000000, info)) ++ print(('%f (%02d): %s} (%.3f us)%s' % (l.time, \ ++ l.depth, l.name, l.length*1000000, info))) + else: +- print('%f (%02d): %s() { (%.3f us)%s' % (l.time, \ +- l.depth, l.name, l.length*1000000, info)) ++ print(('%f (%02d): %s() { (%.3f us)%s' % (l.time, \ ++ l.depth, l.name, l.length*1000000, info))) + print(' ') + + class DevItem: +@@ -3040,8 +3040,8 @@ def parseTraceLog(live=False): + sortkey = '%f%f%d' % (cg.start, cg.end, pid) + sortlist[sortkey] = cg + elif len(cg.list) > 1000000: +- print 'WARNING: the callgraph for %s is massive (%d lines)' %\ +- (devname, len(cg.list)) ++ print('WARNING: the callgraph for %s is massive (%d lines)' %\ ++ (devname, len(cg.list))) + # create blocks for orphan cg data + for sortkey in sorted(sortlist): + cg = sortlist[sortkey] +@@ -3061,7 +3061,7 @@ def parseTraceLog(live=False): + for p in data.phases: + if(data.dmesg[p]['start'] < 0 and data.dmesg[p]['end'] < 0): + if not terr: +- print 'TEST%s FAILED: %s failed in %s phase' % (tn, sysvals.suspendmode, lp) ++ print('TEST%s FAILED: %s failed in %s phase' % (tn, sysvals.suspendmode, lp)) + terr = '%s%s failed in %s phase' % (sysvals.suspendmode, tn, lp) + error.append(terr) + sysvals.vprint('WARNING: phase "%s" is missing!' % p) +@@ -3158,8 +3158,8 @@ def loadKernelLog(): + if data: + testruns.append(data) + if len(testruns) < 1: +- print('ERROR: dmesg log has no suspend/resume data: %s' \ +- % sysvals.dmesgfile) ++ print(('ERROR: dmesg log has no suspend/resume data: %s' \ ++ % sysvals.dmesgfile)) + + # fix lines with same timestamp/function with the call and return swapped + for data in testruns: +@@ -3401,10 +3401,10 @@ def parseKernelLog(data): + lp = data.phases[0] + for p in data.phases: + if(data.dmesg[p]['start'] < 0 and data.dmesg[p]['end'] < 0): +- print('WARNING: phase "%s" is missing, something went wrong!' % p) +- print(' In %s, this dmesg line denotes the start of %s:' % \ +- (sysvals.suspendmode, p)) +- print(' "%s"' % dm[p]) ++ print(('WARNING: phase "%s" is missing, something went wrong!' % p)) ++ print((' In %s, this dmesg line denotes the start of %s:' % \ ++ (sysvals.suspendmode, p))) ++ print((' "%s"' % dm[p])) + if(data.dmesg[p]['start'] < 0): + data.dmesg[p]['start'] = data.dmesg[lp]['end'] + if(p == 'resume_machine'): +@@ -4526,14 +4526,14 @@ def setRuntimeSuspend(before=True): + sv.rslist = deviceInfo(sv.rstgt) + for i in sv.rslist: + sv.setVal(sv.rsval, i) +- print('runtime suspend %s on all devices (%d changed)' % (sv.rsdir, len(sv.rslist))) ++ print(('runtime suspend %s on all devices (%d changed)' % (sv.rsdir, len(sv.rslist)))) + print('waiting 5 seconds...') + time.sleep(5) + else: + # runtime suspend re-enable or re-disable + for i in sv.rslist: + sv.setVal(sv.rstgt, i) +- print('runtime suspend settings restored on %d devices' % len(sv.rslist)) ++ print(('runtime suspend settings restored on %d devices' % len(sv.rslist))) + + # Function: executeSuspend + # Description: +@@ -4581,7 +4581,7 @@ def executeSuspend(): + print('SUSPEND START (press a key to resume)') + # set rtcwake + if(sysvals.rtcwake): +- print('will issue an rtcwake in %d seconds' % sysvals.rtcwaketime) ++ print(('will issue an rtcwake in %d seconds' % sysvals.rtcwaketime)) + sysvals.rtcWakeAlarmOn() + # start of suspend trace marker + if(sysvals.usecallgraph or sysvals.usetraceevents): +@@ -4723,7 +4723,7 @@ def deviceInfo(output=''): + ms2nice(power['runtime_active_time']), \ + ms2nice(power['runtime_suspended_time'])) + for i in sorted(lines): +- print lines[i] ++ print(lines[i]) + return res + + # Function: devProps +@@ -5056,16 +5056,16 @@ def getFPDT(output): + table = struct.unpack('4sIBB6s8sI4sI', buf[0:36]) + if(output): + print('') +- print('Firmware Performance Data Table (%s)' % table[0]) +- print(' Signature : %s' % table[0]) +- print(' Table Length : %u' % table[1]) +- print(' Revision : %u' % table[2]) +- print(' Checksum : 0x%x' % table[3]) +- print(' OEM ID : %s' % table[4]) +- print(' OEM Table ID : %s' % table[5]) +- print(' OEM Revision : %u' % table[6]) +- print(' Creator ID : %s' % table[7]) +- print(' Creator Revision : 0x%x' % table[8]) ++ print(('Firmware Performance Data Table (%s)' % table[0])) ++ print((' Signature : %s' % table[0])) ++ print((' Table Length : %u' % table[1])) ++ print((' Revision : %u' % table[2])) ++ print((' Checksum : 0x%x' % table[3])) ++ print((' OEM ID : %s' % table[4])) ++ print((' OEM Table ID : %s' % table[5])) ++ print((' OEM Revision : %u' % table[6])) ++ print((' Creator ID : %s' % table[7])) ++ print((' Creator Revision : 0x%x' % table[8])) + print('') + + if(table[0] != 'FPDT'): +@@ -5092,22 +5092,22 @@ def getFPDT(output): + first = fp.read(8) + except: + if(output): +- print('Bad address 0x%x in %s' % (addr, sysvals.mempath)) ++ print(('Bad address 0x%x in %s' % (addr, sysvals.mempath))) + return [0, 0] + rechead = struct.unpack('4sI', first) + recdata = fp.read(rechead[1]-8) + if(rechead[0] == 'FBPT'): + record = struct.unpack('HBBIQQQQQ', recdata) + if(output): +- print('%s (%s)' % (rectype[header[0]], rechead[0])) +- print(' Reset END : %u ns' % record[4]) +- print(' OS Loader LoadImage Start : %u ns' % record[5]) +- print(' OS Loader StartImage Start : %u ns' % record[6]) +- print(' ExitBootServices Entry : %u ns' % record[7]) +- print(' ExitBootServices Exit : %u ns' % record[8]) ++ print(('%s (%s)' % (rectype[header[0]], rechead[0]))) ++ print((' Reset END : %u ns' % record[4])) ++ print((' OS Loader LoadImage Start : %u ns' % record[5])) ++ print((' OS Loader StartImage Start : %u ns' % record[6])) ++ print((' ExitBootServices Entry : %u ns' % record[7])) ++ print((' ExitBootServices Exit : %u ns' % record[8])) + elif(rechead[0] == 'S3PT'): + if(output): +- print('%s (%s)' % (rectype[header[0]], rechead[0])) ++ print(('%s (%s)' % (rectype[header[0]], rechead[0]))) + j = 0 + while(j < len(recdata)): + prechead = struct.unpack('HBB', recdata[j:j+4]) +@@ -5117,24 +5117,24 @@ def getFPDT(output): + record = struct.unpack('IIQQ', recdata[j:j+prechead[1]]) + fwData[1] = record[2] + if(output): +- print(' %s' % prectype[prechead[0]]) +- print(' Resume Count : %u' % \ +- record[1]) +- print(' FullResume : %u ns' % \ +- record[2]) +- print(' AverageResume : %u ns' % \ +- record[3]) ++ print((' %s' % prectype[prechead[0]])) ++ print((' Resume Count : %u' % \ ++ record[1])) ++ print((' FullResume : %u ns' % \ ++ record[2])) ++ print((' AverageResume : %u ns' % \ ++ record[3])) + elif(prechead[0] == 1): + record = struct.unpack('QQ', recdata[j+4:j+prechead[1]]) + fwData[0] = record[1] - record[0] + if(output): +- print(' %s' % prectype[prechead[0]]) +- print(' SuspendStart : %u ns' % \ +- record[0]) +- print(' SuspendEnd : %u ns' % \ +- record[1]) +- print(' SuspendTime : %u ns' % \ +- fwData[0]) ++ print((' %s' % prectype[prechead[0]])) ++ print((' SuspendStart : %u ns' % \ ++ record[0])) ++ print((' SuspendEnd : %u ns' % \ ++ record[1])) ++ print((' SuspendTime : %u ns' % \ ++ fwData[0])) + j += prechead[1] + if(output): + print('') +@@ -5151,13 +5151,13 @@ def getFPDT(output): + def statusCheck(probecheck=False): + status = True + +- print('Checking this system (%s)...' % platform.node()) ++ print(('Checking this system (%s)...' % platform.node())) + + # check we have root access + res = sysvals.colorText('NO (No features of this tool will work!)') + if(sysvals.rootCheck(False)): + res = 'YES' +- print(' have root access: %s' % res) ++ print((' have root access: %s' % res)) + if(res != 'YES'): + print(' Try running this script with sudo') + return False +@@ -5166,7 +5166,7 @@ def statusCheck(probecheck=False): + res = sysvals.colorText('NO (No features of this tool will work!)') + if(os.path.exists(sysvals.powerfile)): + res = 'YES' +- print(' is sysfs mounted: %s' % res) ++ print((' is sysfs mounted: %s' % res)) + if(res != 'YES'): + return False + +@@ -5178,9 +5178,9 @@ def statusCheck(probecheck=False): + res = 'YES' + else: + status = False +- print(' is "%s" a valid power mode: %s' % (sysvals.suspendmode, res)) ++ print((' is "%s" a valid power mode: %s' % (sysvals.suspendmode, res))) + if(res == 'NO'): +- print(' valid power modes are: %s' % modes) ++ print((' valid power modes are: %s' % modes)) + print(' please choose one with -m') + + # check if ftrace is available +@@ -5190,7 +5190,7 @@ def statusCheck(probecheck=False): + res = 'YES' + elif(sysvals.usecallgraph): + status = False +- print(' is ftrace supported: %s' % res) ++ print((' is ftrace supported: %s' % res)) + + # check if kprobes are available + res = sysvals.colorText('NO') +@@ -5199,7 +5199,7 @@ def statusCheck(probecheck=False): + res = 'YES' + else: + sysvals.usedevsrc = False +- print(' are kprobes supported: %s' % res) ++ print((' are kprobes supported: %s' % res)) + + # what data source are we using + res = 'DMESG' +@@ -5210,7 +5210,7 @@ def statusCheck(probecheck=False): + sysvals.usetraceevents = False + if(sysvals.usetraceevents): + res = 'FTRACE (all trace events found)' +- print(' timeline data source: %s' % res) ++ print((' timeline data source: %s' % res)) + + # check if rtcwake + res = sysvals.colorText('NO') +@@ -5218,7 +5218,7 @@ def statusCheck(probecheck=False): + res = 'YES' + elif(sysvals.rtcwake): + status = False +- print(' is rtcwake supported: %s' % res) ++ print((' is rtcwake supported: %s' % res)) + + if not probecheck: + return status +@@ -5243,7 +5243,7 @@ def statusCheck(probecheck=False): + def doError(msg, help=False): + if(help == True): + printHelp() +- print('ERROR: %s\n') % msg ++ print(('ERROR: %s\n') % msg) + sysvals.outputResult({'error':msg}) + sys.exit() + +@@ -5253,7 +5253,7 @@ def doError(msg, help=False): + def getArgInt(name, args, min, max, main=True): + if main: + try: +- arg = args.next() ++ arg = next(args) + except: + doError(name+': no argument supplied', True) + else: +@@ -5272,7 +5272,7 @@ def getArgInt(name, args, min, max, main=True): + def getArgFloat(name, args, min, max, main=True): + if main: + try: +- arg = args.next() ++ arg = next(args) + except: + doError(name+': no argument supplied', True) + else: +@@ -5388,7 +5388,7 @@ def runSummary(subdir, local=True, genhtml=False): + outpath = inpath + if local: + outpath = os.path.abspath('.') +- print('Generating a summary of folder "%s"' % inpath) ++ print(('Generating a summary of folder "%s"' % inpath)) + if genhtml: + for dirname, dirnames, filenames in os.walk(subdir): + sysvals.dmesgfile = sysvals.ftracefile = sysvals.htmlfile = '' +@@ -5400,9 +5400,9 @@ def runSummary(subdir, local=True, genhtml=False): + sysvals.setOutputFile() + if sysvals.ftracefile and sysvals.htmlfile and \ + not os.path.exists(sysvals.htmlfile): +- print('FTRACE: %s' % sysvals.ftracefile) ++ print(('FTRACE: %s' % sysvals.ftracefile)) + if sysvals.dmesgfile: +- print('DMESG : %s' % sysvals.dmesgfile) ++ print(('DMESG : %s' % sysvals.dmesgfile)) + rerunTest() + testruns = [] + for dirname, dirnames, filenames in os.walk(subdir): +@@ -5441,7 +5441,7 @@ def runSummary(subdir, local=True, genhtml=False): + } + testruns.append(data) + outfile = os.path.join(outpath, 'summary.html') +- print('Summary file: %s' % outfile) ++ print(('Summary file: %s' % outfile)) + createHTMLSummarySimple(testruns, outfile, inpath) + + # Function: checkArgBool +@@ -5459,7 +5459,7 @@ def checkArgBool(name, value): + # Description: + # Configure the script via the info in a config file + def configFromFile(file): +- Config = ConfigParser.ConfigParser() ++ Config = configparser.ConfigParser() + + Config.read(file) + sections = Config.sections() +@@ -5661,7 +5661,7 @@ def configFromFile(file): + # print out the help text + def printHelp(): + print('') +- print('%s v%s' % (sysvals.title, sysvals.version)) ++ print(('%s v%s' % (sysvals.title, sysvals.version))) + print('Usage: sudo sleepgraph ') + print('') + print('Description:') +@@ -5686,7 +5686,7 @@ def printHelp(): + print(' -v Print the current tool version') + print(' -config fn Pull arguments and config options from file fn') + print(' -verbose Print extra information during execution and analysis') +- print(' -m mode Mode to initiate for suspend (default: %s)') % (sysvals.suspendmode) ++ print((' -m mode Mode to initiate for suspend (default: %s)') % (sysvals.suspendmode)) + print(' -o name Overrides the output subdirectory name when running a new test') + print(' default: suspend-{date}-{time}') + print(' -rtcwake t Wakeup t seconds after suspend, set t to "off" to disable (default: 15)') +@@ -5753,7 +5753,7 @@ if __name__ == '__main__': + for arg in args: + if(arg == '-m'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No mode supplied', True) + if val == 'command' and not sysvals.testcommand: +@@ -5765,7 +5765,7 @@ if __name__ == '__main__': + printHelp() + sys.exit() + elif(arg == '-v'): +- print("Version %s" % sysvals.version) ++ print(("Version %s" % sysvals.version)) + sys.exit() + elif(arg == '-x2'): + sysvals.execcount = 2 +@@ -5797,7 +5797,7 @@ if __name__ == '__main__': + sysvals.gzip = True + elif(arg == '-rs'): + try: +- val = args.next() ++ val = next(args) + except: + doError('-rs requires "enable" or "disable"', True) + if val.lower() in switchvalues: +@@ -5809,7 +5809,7 @@ if __name__ == '__main__': + doError('invalid option: %s, use "enable/disable" or "on/off"' % val, True) + elif(arg == '-display'): + try: +- val = args.next() ++ val = next(args) + except: + doError('-display requires "on" or "off"', True) + if val.lower() in switchvalues: +@@ -5823,7 +5823,7 @@ if __name__ == '__main__': + sysvals.max_graph_depth = getArgInt('-maxdepth', args, 0, 1000) + elif(arg == '-rtcwake'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No rtcwake time supplied', True) + if val.lower() in switchoff: +@@ -5843,7 +5843,7 @@ if __name__ == '__main__': + sysvals.cgtest = getArgInt('-cgtest', args, 0, 1) + elif(arg == '-cgphase'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No phase name supplied', True) + d = Data(0) +@@ -5853,13 +5853,13 @@ if __name__ == '__main__': + sysvals.cgphase = val + elif(arg == '-cgfilter'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No callgraph functions supplied', True) + sysvals.setCallgraphFilter(val) + elif(arg == '-cgskip'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No file supplied', True) + if val.lower() in switchoff: +@@ -5874,7 +5874,7 @@ if __name__ == '__main__': + sysvals.callloopmaxlen = getArgFloat('-callloop-maxlen', args, 0.0, 1.0) + elif(arg == '-cmd'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No command string supplied', True) + sysvals.testcommand = val +@@ -5889,13 +5889,13 @@ if __name__ == '__main__': + sysvals.multitest['delay'] = getArgInt('-multi n d (delay between tests)', args, 0, 3600) + elif(arg == '-o'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No subdirectory name supplied', True) + sysvals.outdir = sysvals.setOutputFolder(val) + elif(arg == '-config'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No text file supplied', True) + file = sysvals.configFile(val) +@@ -5904,7 +5904,7 @@ if __name__ == '__main__': + configFromFile(file) + elif(arg == '-fadd'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No text file supplied', True) + file = sysvals.configFile(val) +@@ -5913,7 +5913,7 @@ if __name__ == '__main__': + sysvals.addFtraceFilterFunctions(file) + elif(arg == '-dmesg'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No dmesg file supplied', True) + sysvals.notestrun = True +@@ -5922,7 +5922,7 @@ if __name__ == '__main__': + doError('%s does not exist' % sysvals.dmesgfile) + elif(arg == '-ftrace'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No ftrace file supplied', True) + sysvals.notestrun = True +@@ -5931,7 +5931,7 @@ if __name__ == '__main__': + doError('%s does not exist' % sysvals.ftracefile) + elif(arg == '-summary'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No directory supplied', True) + cmd = 'summary' +@@ -5941,13 +5941,13 @@ if __name__ == '__main__': + doError('%s is not accesible' % val) + elif(arg == '-filter'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No devnames supplied', True) + sysvals.setDeviceFilter(val) + elif(arg == '-result'): + try: +- val = args.next() ++ val = next(args) + except: + doError('No result file supplied', True) + sysvals.result = val +@@ -5980,13 +5980,13 @@ if __name__ == '__main__': + elif(cmd == 'fpdt'): + getFPDT(True) + elif(cmd == 'battery'): +- print 'AC Connect: %s\nCharge: %d' % getBattery() ++ print('AC Connect: %s\nCharge: %d' % getBattery()) + elif(cmd == 'sysinfo'): + sysvals.printSystemInfo(True) + elif(cmd == 'devinfo'): + deviceInfo() + elif(cmd == 'modes'): +- print getModes() ++ print(getModes()) + elif(cmd == 'flist'): + sysvals.getFtraceFilterFunctions(True) + elif(cmd == 'flistall'): +@@ -6036,13 +6036,13 @@ if __name__ == '__main__': + os.mkdir(sysvals.outdir) + for i in range(sysvals.multitest['count']): + if(i != 0): +- print('Waiting %d seconds...' % (sysvals.multitest['delay'])) ++ print(('Waiting %d seconds...' % (sysvals.multitest['delay']))) + time.sleep(sysvals.multitest['delay']) +- print('TEST (%d/%d) START' % (i+1, sysvals.multitest['count'])) ++ print(('TEST (%d/%d) START' % (i+1, sysvals.multitest['count']))) + fmt = 'suspend-%y%m%d-%H%M%S' + sysvals.testdir = os.path.join(sysvals.outdir, datetime.now().strftime(fmt)) + runTest(i+1) +- print('TEST (%d/%d) COMPLETE' % (i+1, sysvals.multitest['count'])) ++ print(('TEST (%d/%d) COMPLETE' % (i+1, sysvals.multitest['count']))) + sysvals.logmsg = '' + if not sysvals.skiphtml: + runSummary(sysvals.outdir, False, False) +diff --git a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py +index 2fa3c57..b1e2abc 100755 +--- a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py ++++ b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + # -*- coding: utf-8 -*- + # + """ This utility can be used to debug and tune the performance of the +@@ -22,7 +22,7 @@ Prerequisites: + see print_help(): for Usage and Output details + + """ +-from __future__ import print_function ++ + from datetime import datetime + import subprocess + import os +-- +1.8.3.1 +