From patchwork Thu Sep 5 10:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13792157 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 DCE89CD5BA9 for ; Thu, 5 Sep 2024 11:00:18 +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=5GQHcRgyK3UIumQ8Zryug5s4B7 LLXt0ZMIzSWfwRM+uCAUp6YqXpamRmPfKVVkiIYzEKR6t7v7ncVgxQE6RCgvYKUyl1efI2Ae4z0Dw icnrw5/bI8vqNAY3PS5UKJFM0S/uj/axRlDeWRE2si+qLqixVVprHwpQwmZCGvOxiI4V2PM14eAU9 aCm/d5OIjdNPgcJJPcHGF3KmFvfmtMQgLtsGUhTdxTNLY4xYRD8U2fzqRXYy1d02MeTa4yC4MgV/u eK4pGh0FxLNEnz1w0HzFwdk54OlMtsi2zLhKdgMQI3Y7/R/yjHhQ0bY9gMrR/81jn+tD7dAKjdTPd L+lhw2Tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smADf-000000083MR-1OnV; Thu, 05 Sep 2024 11:00:07 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smA5X-000000081WH-3d6u for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 10:51:46 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42bb81e795bso4713135e9.1 for ; Thu, 05 Sep 2024 03:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725533502; x=1726138302; 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=hPbLLQF3Qt2eaZz6wABDq7e8ifGx9WM3fQRs5nKnRVGQ2C//Th18Mxgd2uHjuo0pqU uMCkxbQOVM/iCSwBeS5RwZO++Iddfs31B/GJfDkvKZWAqU/1PGJT0598yEf0bu03g/7o MAHskGIWNhisXAFjxAFXhf6OP/2Ln1SF2M79VlkyT9/sO24ooOpqN2CSypJlM/s4m8u5 Q+E6J3GJ/QNxzk6yqA8iyCUFbWicYIXkl9S4bq3dTsWcXkfQ8LMU8t3xyYyxLqLn1ZMh GJIK55rOMc5Ta0R5sLOO5iHGFvQJcs1RIbLFcq3sLLYoi+ut4YZOIoY9L/UiWrHCvjik DUyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725533502; x=1726138302; 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=poVyqNWwsQYOJ7N7ugVovc53htQUoDxA5eeKQzOIaA7+LnN/ZKaerNtSOgF8l5V0UX Hfi7I/It+Yu7sz4z3VSoZjBMeAjRZWRKLBf/byoZzETaV7aBatO4j3r9vrxD6hq54LIU Qw6rW31hMzpOb7GmqagPSK382oQHOyv7PAjY9d5MfrMdVtKks3VbwRQFbStyt7TmjIT1 OzTC4hoxdqdwv/6HWBkV14Jr2euunrCA9Ed7YSeUmfYaeFVh6eDVQgCV8+TZeqaMRFoJ FHQQktPZr7uAr6lfmoloPNqBO0q/TI+l3jtqCMvbaW1qGLIe2L3W99FlnJfVTzuAjxh0 +uSQ== X-Forwarded-Encrypted: i=1; AJvYcCUhbuEDEjl3/+5PpHdWONXbZvE9Rr0+2boen0aQL+w8RhsyWnEIUjEWWNBKY0TqpvNKiZApw/f4k1x8k1pD/wsi@lists.infradead.org X-Gm-Message-State: AOJu0YwUaEu/7oH7lywrWerasWqkwN7u0+vZgIS1zIKuQZMh1jlUE44r vUQ+aHZP++XkGHTsvgectM6oidNJCF10jovfY1CA/8HCsls/un4DbueCqE6sKc4= X-Google-Smtp-Source: AGHT+IGfFJqAayaXo8MfaP4LB16SCu3PZkqeamC6wY0GLppIU48zgj0W6/Wqg+hZrLLyTod8T3h8wA== X-Received: by 2002:a05:600c:4fd6:b0:426:60d7:d299 with SMTP id 5b1f17b1804b1-42bbb10d27dmr151939485e9.7.1725533501983; Thu, 05 Sep 2024 03:51:41 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6df0dbcsm231089965e9.17.2024.09.05.03.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 03:51:41 -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 7/8] perf scripts python cs-etm: Add start and stop arguments Date: Thu, 5 Sep 2024 11:50:38 +0100 Message-Id: <20240905105043.160225-8-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905105043.160225-1-james.clark@linaro.org> References: <20240905105043.160225-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-20240905_035143_911315_2A349C61 X-CRM114-Status: GOOD ( 15.66 ) 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 --- .../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)