From patchwork Thu Sep 12 15:11:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13802300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 92B06EED618 for ; Thu, 12 Sep 2024 15:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lyScag8p5nZQgcpgovS0Br7oaCoB8CMogAdxSo53VSM=; b=0o2xDiXzxV7NvumOPqyI/v5B94 u2408WMlQS2mtK4iIvdaVty8AP5S9AygF11xJ8lLqB8uo+/K6m5d43u2q6hdGoKF1jH7EV23sNWoA YHPaAQs2TFhwwACL5A6UWTAnB3otW2PWnVaLy67CLU1mHYtlxgcgMeyHX8BEsVlLO80Wv4e66IObj E/vUC7yY/UCL9thmn+2QJ/azVUvvL40BuNdrhwF4+6ad5Zyqr43FQZPAjd7+pBQGoyypgfLzuva2R Sw/apFDgKmdAdU2T1Wv+zjriKJupQ+ixsZE89N3Ym6YyVzgpZB94Sbys6XMN1faewaf8+HOdOc/f0 7xUd9kgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1solg4-0000000DXqK-0KAb; Thu, 12 Sep 2024 15:24:12 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1solVI-0000000DVKZ-0PuJ for linux-arm-kernel@lists.infradead.org; Thu, 12 Sep 2024 15:13:05 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-5356ab89665so1241990e87.1 for ; Thu, 12 Sep 2024 08:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726153982; x=1726758782; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lyScag8p5nZQgcpgovS0Br7oaCoB8CMogAdxSo53VSM=; b=TAV6yZ/JP7q6BxGujYmVqrZU94d2YFcDGvDdLNhmIaID/b3qpkuFIXpU8SFyQ5iHn/ RkgMEBNa0u9Iq/mujaXVS5C6L0c6DaKu1miQ8QMornozspuzZ7r95EQDkK7ZFYUnbtHX dsjUowy6V5vuxozye1ITNNEUmAXoyy+l9kuOBndDrQ7vflPqggkIOK2kNRgvhZI6yT8n DteUgcQ41i3fchVUJwE7rYJW0xBmwxgnnLJdx8svchmqjjhVL4l4uTW44bgbbJwUpkty +LpgUXxQo1AJHs0D/8nezXpu9uHwyWo3aSbPFCp63n6E5JLXxkDQQFxl+8YjXVGKRSzK 0uYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726153982; x=1726758782; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lyScag8p5nZQgcpgovS0Br7oaCoB8CMogAdxSo53VSM=; b=YR8yLC3BsclcKYEGsEkqf8vKgxBLnbJmzxItWRXTdDJGCaVj4KA+CPFBSYh7zWKd12 +tRLdORK4J0NYrf6HZcTXQjh0kYyGBDPQvNe/ggmac7y6KF/ZAmDB2iI73kkciMsk50K w4orSCF1CuIXIhTjWTpx603Uxxmt9ujDfrGr53CMhsG6lnqd3+3uL7DOjfwuSIJGEoBl JGtgU/D7aHwiMnspt3l6PQkZBS/F1stojtayV5cDI4q2/MaaiHiEaEJTZnjkmFjnURIt yxHnCo6RNKBreDNjp7Fd7WmBQ5r25j54/ixr1+rnOR1zEB7KzwLXAQLPZOJ7CzaR16i7 3Amg== X-Forwarded-Encrypted: i=1; AJvYcCX5Bq1LtKAG3rbRVl6mEWGhRgsXypR8VDRK/6sDg+L6ehyDJ8INKgBad6RuQGig9MwwMRqWt8bGEb7vRU7oTaPM@lists.infradead.org X-Gm-Message-State: AOJu0Ywe41UDzfd0EHRIk0pMXgpf2UY3iv+YksjevDOWVbj4drx2swZt fW8FLKJayra2tGO+rMDNSc+rRvjw0pe5gx/HsffsRBpcGsFQeMPWkg4NQssMRM8= X-Google-Smtp-Source: AGHT+IEU6nXG+B4QFLcwDCDs/5zj2w0oRrKPhJUxJ9n5pG2+xKrqgQBx/Dpn46aYZQ7Zt78NIeVlOg== X-Received: by 2002:a05:6512:e94:b0:530:b871:eb9a with SMTP id 2adb3069b0e04-53678feb5ffmr1855771e87.47.1726153981495; Thu, 12 Sep 2024 08:13:01 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42cb0dbcb6bsm171928845e9.30.2024.09.12.08.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 08:13:00 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, gankulkarni@os.amperecomputing.com, coresight@lists.linaro.org, leo.yan@arm.com, scclevenger@os.amperecomputing.com Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Leo Yan , Ben Gainey , Ruidong Tian , Benjamin Gray , Mathieu Poirier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 6/7] perf scripts python cs-etm: Add start and stop arguments Date: Thu, 12 Sep 2024 16:11:37 +0100 Message-Id: <20240912151143.1264483-7-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240912151143.1264483-1-james.clark@linaro.org> References: <20240912151143.1264483-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240912_081304_183178_B0520F3E X-CRM114-Status: GOOD ( 16.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Make it possible to only disassemble a range of timestamps or sample indexes. This will be used by the test to limit the runtime, but it's also useful for users. Signed-off-by: James Clark Reviewed-by: Leo Yan --- .../scripts/python/arm-cs-trace-disasm.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py index 02e957d037ea..a097995d8e7b 100755 --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py @@ -55,6 +55,11 @@ args.add_argument("-k", "--vmlinux", args.add_argument("-d", "--objdump", nargs="?", const=default_objdump(), help="Show disassembly. Can also be used to change the objdump path"), args.add_argument("-v", "--verbose", action="store_true", help="Enable debugging log") +args.add_argument("--start-time", type=int, help="Time of sample to start from") +args.add_argument("--stop-time", type=int, help="Time of sample to stop at") +args.add_argument("--start-sample", type=int, help="Index of sample to start from") +args.add_argument("--stop-sample", type=int, help="Index of sample to stop at") + options = args.parse_args() # Initialize global dicts and regular expression @@ -63,6 +68,7 @@ cpu_data = dict() disasm_re = re.compile(r"^\s*([0-9a-fA-F]+):") disasm_func_re = re.compile(r"^\s*([0-9a-fA-F]+)\s.*:") cache_size = 64*1024 +sample_idx = -1 glb_source_file_name = None glb_line_number = None @@ -151,10 +157,10 @@ def print_disam(dso_fname, dso_start, start_addr, stop_addr): def print_sample(sample): print("Sample = { cpu: %04d addr: 0x%016x phys_addr: 0x%016x ip: 0x%016x " \ - "pid: %d tid: %d period: %d time: %d }" % \ + "pid: %d tid: %d period: %d time: %d index: %d}" % \ (sample['cpu'], sample['addr'], sample['phys_addr'], \ sample['ip'], sample['pid'], sample['tid'], \ - sample['period'], sample['time'])) + sample['period'], sample['time'], sample_idx)) def trace_begin(): print('ARM CoreSight Trace Data Assembler Dump') @@ -216,6 +222,7 @@ def print_srccode(comm, param_dict, sample, symbol, dso): def process_event(param_dict): global cache_size global options + global sample_idx sample = param_dict["sample"] comm = param_dict["comm"] @@ -231,6 +238,17 @@ def process_event(param_dict): ip = sample["ip"] addr = sample["addr"] + sample_idx += 1 + + if (options.start_time and sample["time"] < options.start_time): + return + if (options.stop_time and sample["time"] > options.stop_time): + exit(0) + if (options.start_sample and sample_idx < options.start_sample): + return + if (options.stop_sample and sample_idx > options.stop_sample): + exit(0) + if (options.verbose == True): print("Event type: %s" % name) print_sample(sample)