From mboxrd@z Thu Jan 1 00:00:00 1970 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 9982AC3ABB2 for ; Mon, 16 Sep 2024 10:50: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: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Uh4NEkHKiMJymObaXISine8gbvwHrlRosoYUXwllM2M=; b=R0FKxphnwUsyBVkKmOErkP445h 50zxapXaAedbNhI408pM4tWfpWJ6J00bNddSCRH25TkRQ6ADflqNbcWl+zrcxTxN/WH9VzD+zZBJQ HNtoyFuNg7Whdq5GZCNjVzkLuQ/lEsFgsqidW2V3UI73paK0oFWrOHsu6/Sh2r8fqJ5gPh8JE4oRD 2T9Dv+6MNlOLnKmDYdu0gj5X372JnqHFFLdXRlCClz26F6p2v8mRWHMeXs3oououzc+XJTPoaX4x7 nafuta6dSgBrWhgJleairI+xieN/WkwxNV/ZoYlVQYpgkzE64kzxHyMs2ijzaMrfAU13UskRNdnQo hSocaUTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sq9J0-00000003mM2-1XUI; Mon, 16 Sep 2024 10:50:06 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sq9AB-00000003kg5-19Pw for linux-arm-kernel@lists.infradead.org; Mon, 16 Sep 2024 10:41:13 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42cb7a2e4d6so35237405e9.0 for ; Mon, 16 Sep 2024 03:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726483254; x=1727088054; darn=lists.infradead.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Uh4NEkHKiMJymObaXISine8gbvwHrlRosoYUXwllM2M=; b=dg0TBhsfKBItw2cT/jGmZbWR1+pYiudhR/Ixg6CQy40ceaunI+8T4MywnMkbbb4SS5 s75JmNuj5Bi0epcxzqByzzsLBBYnk2XP+V22SK8tbesIDdrh7yxbgf5uhhN0P9OqqY0t XT/4hijcwy8UewfqCNGgn2ZRT2/qgoqpKQU3vHLnNugFlirSz5PyS7/Ss+2XdI0hgwfD PpURX7L2GjbvyexAAuVWNYidmcGw7dbwt3TnNJs/fNxtiIEokdb17nzqCUrHakn4QF0q oAkrzZUrUD1dJcegjcnzUWefZQTQJBXgyatgQsn+IlnmoOMtM6L93AkzIBFpjaO8CZBg paEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726483254; x=1727088054; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Uh4NEkHKiMJymObaXISine8gbvwHrlRosoYUXwllM2M=; b=NpuASWJO/EcunSYfiH6vHEHfxuAj5BOmRBBzDYo5uIoxsAy+7jICogp9VA8oDDPyWF rKza0/5Lt2jPIUzV5XIpQpsOtSNfzabNrwVvPtVOcx74Qaze5cWzaosflz+0wkXUMT6i jUIAjxcYewgqnqHMiy5xhpsy44i94fH7yqTqsXNsBITJ0RMEb50T0fHeMJxQM8NJX/Gv wJMh5qBvPv+AS4nhw+wXtz6bSTvVT9S3MwpeMp1VZTYOhzEeKFyOVctGpApny7oIZe0y 7Zf6lmsqd0poigSw8CxXZYJit9fbr5l5ajIq7J9SzpP3q9Y8RF2zzdg1hloZ+LxO7jlb U4Fw== X-Forwarded-Encrypted: i=1; AJvYcCXcsN7jM4g1FBSpgTAJ2Dh3cnAyidzbDQCYeRsQALa9cvJYFOOGqOTJ35w4i+rBj90AUK4WRhNATLnMwn861+3q@lists.infradead.org X-Gm-Message-State: AOJu0Yxxzguz4dlJakA7UakPSmRa4YgEr7Tb5bY1bbdZAWeSDbFkUJOU dsVG7lvs7uCYFz4E6NnGj2W7sMOLokXWX6NQgvQwFR02gWfVe667I4nCzNdkbJk= X-Google-Smtp-Source: AGHT+IEW1CK4xoE0JM0fHQi3amnmo4pcWJsFhe6LIWUR9maOlvX3yzg2IUc6+DHriOOF104fsotm+Q== X-Received: by 2002:a05:600c:1c84:b0:42c:b5f1:4508 with SMTP id 5b1f17b1804b1-42cdb57c056mr110924355e9.23.1726483253100; Mon, 16 Sep 2024 03:40:53 -0700 (PDT) Received: from [192.168.1.61] ([84.67.228.188]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378e7800237sm6875635f8f.83.2024.09.16.03.40.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Sep 2024 03:40:52 -0700 (PDT) Message-ID: Date: Mon, 16 Sep 2024 11:41:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 6/7] perf scripts python cs-etm: Add start and stop arguments To: Leo Yan Cc: 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, linux-perf-users@vger.kernel.org, gankulkarni@os.amperecomputing.com, coresight@lists.linaro.org, scclevenger@os.amperecomputing.com References: <20240912151143.1264483-1-james.clark@linaro.org> <20240912151143.1264483-7-james.clark@linaro.org> <11bca9b1-7eb1-4a13-8f05-9ba5b9c46d24@arm.com> Content-Language: en-US From: James Clark In-Reply-To: <11bca9b1-7eb1-4a13-8f05-9ba5b9c46d24@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240916_034059_507757_E3A54DF1 X-CRM114-Status: GOOD ( 21.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 On 13/09/2024 14:20, Leo Yan wrote: > On 9/12/24 16:11, James Clark wrote:> >> 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") >> + > > It is good to validate the ranges for time and sample indexes, in case > the user passes unexpected values and can directly report the error. > > BTW, I think it is good to clarify the time is based on monotonic clock > but not wall-clock time. > > With above changes, LGTM: > > Reviewed-by: Leo Yan > Yep makes sense, I can add that >>   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) >> -- >> 2.34.1 >>