Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1736374imm; Thu, 12 Jul 2018 07:04:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfXH3OJH2aqY5a5UsjWR6T0dX/dB6kzKS6hXgW1dPjJ7Dk3bSpEskvqCLcsr1TUMaKug0gc X-Received: by 2002:a63:6ac6:: with SMTP id f189-v6mr2236552pgc.170.1531404247768; Thu, 12 Jul 2018 07:04:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531404247; cv=none; d=google.com; s=arc-20160816; b=qJD6fDJMfmB3culZz+t5PiVAZfcDdCEI3Fr9nIAGrflzSpyOAuPLwPcuMrm8UWnuPw i6MtExaHhfqmQYYRpLd1Tydxy52QPXMxtS3nHQzEn/p+6e5w1hSeu9VcfEBnYaZpm/5E YxG+nI0sRjusfRxV1bG4JcrdYgIvhK+Uv+l41QvndMUkcRcizuiDvXr/7RaJfkvqvzNN wY4rIt9i7lPTJogBIcmal2Hb3XJLk54Mc5AnlTybbm/ZGEndZL4J224OJdDQjE1nuR5J vFv/IpdY/4GWlzcKmMOinmHBgWqLNOWuPQSAiMDXoipaMu8KHKy6UY0r1cp6XY7qlWKa hXxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=jSKriYiP+j8+Vdj8CNCG4rTnqFqdpAjK820LdmFco9k=; b=LbKuaimbjTkWVUopUyCdotFXb9OiwDzSy/P3fnmV14LME1Ha0htbu6TodKgx0Mb5Md xRLF3aPjP6fNIrI+xpnbcEDGgJQ6geAvNgh9o7Bg1/iXhyR9jkhwYg61pE2iIr4yVF7J JncyN2v7An9RELWjzqNEQVr0ECT/oGnPCabUIKtAJ+lGV4IIwfoNbDRcaNTJTa/Htauu NN+/duFqn/+yQG2LWq2mGzWvmCYvFrTibKwDgnt3IhQFLrQeqLmeOhbd7JLLy2udsVH8 cw+KDcR9jhlMEM8XuM6zL0CXilf981ZVmM958VRZI6wCuNNU7KAT/kWaRKPIsSLu2X1s j96w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a24-v6si1009906pgh.357.2018.07.12.07.03.48; Thu, 12 Jul 2018 07:04:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732611AbeGLOL6 (ORCPT + 99 others); Thu, 12 Jul 2018 10:11:58 -0400 Received: from terminus.zytor.com ([198.137.202.136]:32775 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732403AbeGLOL6 (ORCPT ); Thu, 12 Jul 2018 10:11:58 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6CDxtxi3934399 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 12 Jul 2018 06:59:55 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6CDxthh3934396; Thu, 12 Jul 2018 06:59:55 -0700 Date: Thu, 12 Jul 2018 06:59:55 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Jeremy Cline Message-ID: Cc: hpa@zytor.com, peterz@infradead.org, linux-kernel@vger.kernel.org, acme@redhat.com, tglx@linutronix.de, jeremy@jcline.org, herton@redhat.com, jolsa@redhat.com, namhyung@kernel.org, alexander.shishkin@linux.intel.com, mingo@kernel.org Reply-To: peterz@infradead.org, hpa@zytor.com, acme@redhat.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, jeremy@jcline.org, herton@redhat.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, mingo@kernel.org In-Reply-To: <0100016341a737a5-44ec436f-3440-4cac-a03f-ddfa589bf308-000000@email.amazonses.com> References: <0100016341a737a5-44ec436f-3440-4cac-a03f-ddfa589bf308-000000@email.amazonses.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf scripts python: Add Python 3 support to sched-migration.py Git-Commit-ID: 8c1c1ab2d2a77cb50841822168e56d11c4ebfd6e X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 8c1c1ab2d2a77cb50841822168e56d11c4ebfd6e Gitweb: https://git.kernel.org/tip/8c1c1ab2d2a77cb50841822168e56d11c4ebfd6e Author: Jeremy Cline AuthorDate: Tue, 8 May 2018 21:27:47 +0000 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 11 Jul 2018 10:01:50 -0300 perf scripts python: Add Python 3 support to sched-migration.py Support both Python 2 and Python 3 in the sched-migration.py script. This should have no functional change. Signed-off-by: Jeremy Cline Cc: Alexander Shishkin Cc: Herton Krzesinski Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/0100016341a737a5-44ec436f-3440-4cac-a03f-ddfa589bf308-000000@email.amazonses.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/sched-migration.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/perf/scripts/python/sched-migration.py b/tools/perf/scripts/python/sched-migration.py index de66cb3b72c9..3473e7f66081 100644 --- a/tools/perf/scripts/python/sched-migration.py +++ b/tools/perf/scripts/python/sched-migration.py @@ -9,13 +9,17 @@ # 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 -from UserList import UserList +try: + from UserList import UserList +except ImportError: + # Python 3: UserList moved to the collections package + from collections import UserList sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') @@ -300,7 +304,7 @@ class TimeSliceList(UserList): if i == -1: return - for i in xrange(i, len(self.data)): + for i in range(i, len(self.data)): timeslice = self.data[i] if timeslice.start > end: return @@ -336,8 +340,8 @@ class SchedEventProxy: on_cpu_task = self.current_tsk[headers.cpu] if on_cpu_task != -1 and on_cpu_task != prev_pid: - print "Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \ - (headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid) + print("Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \ + headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid) threads[prev_pid] = prev_comm threads[next_pid] = next_comm