mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
To: James Clark <james.clark@linaro.org>,
	james.clark@arm.com, mike.leach@linaro.org,
	suzuki.poulose@arm.com, Leo Yan <leo.yan@arm.com>
Cc: acme@redhat.com, coresight@lists.linaro.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, darren@os.amperecomputing.com,
	scclevenger@os.amperecomputing.com
Subject: Re: [PATCH] perf scripts python arm-cs-trace-disasm.py: Skip disasm if address continuity is broken
Date: Mon, 22 Jul 2024 15:32:00 +0530	[thread overview]
Message-ID: <6920de94-a9c8-47f4-840f-391d1ec85c0c@os.amperecomputing.com> (raw)
In-Reply-To: <7302367c-311f-4655-9a83-3c4034c50086@linaro.org>


Hi James,

On 19-07-2024 08:09 pm, James Clark wrote:
> 
> 
> On 19/07/2024 10:26 am, Ganapatrao Kulkarni wrote:
>> To generate the instruction tracing, script uses 2 contiguous packets
>> address range. If there a continuity brake due to discontiguous branch
>> address, it is required to reset the tracing and start tracing with the
>> new set of contiguous packets.
>>
>> Adding change to identify the break and complete the remaining tracing
>> of current packets and restart tracing from new set of packets, if
>> continuity is established.
>>
> 
> Hi Ganapatrao,
> 
> Can you add a before and after example of what's changed to the commit 
> message? It wasn't immediately obvious to me if this is adding missing 
> output, or it was correcting the tail end of the output that was 
> previously wrong.

It is adding tail end of the trace as well avoiding the segfault of the 
perf application. With out this change the perf segfaults with as below log


./perf script --script=python:./scripts/python/arm-cs-trace-disasm.py -- 
-d objdump -k ../../vmlinux -v $* > dump
objdump: error: the stop address should be after the start address
Traceback (most recent call last):
   File "./scripts/python/arm-cs-trace-disasm.py", line 271, in 
process_event
     print_disam(dso_fname, dso_vm_start, start_addr, stop_addr)
   File "./scripts/python/arm-cs-trace-disasm.py", line 105, in print_disam
     for line in read_disam(dso_fname, dso_start, start_addr, stop_addr):
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "./scripts/python/arm-cs-trace-disasm.py", line 99, in read_disam
     disasm_output = check_output(disasm).decode('utf-8').split('\n')
                     ^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib64/python3.12/subprocess.py", line 466, in check_output
     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib64/python3.12/subprocess.py", line 571, in run
     raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['objdump', '-d', '-z', 
'--start-address=0xffff80008125b758', 
'--stop-address=0xffff80008125a934', '../../vmlinux']' returned non-zero 
exit status 1.
Fatal Python error: handler_call_die: problem in Python trace event handler
Python runtime state: initialized

Current thread 0x0000ffffb05054e0 (most recent call first):
   <no Python frame>

Extension modules: perf_trace_context, systemd._journal, 
systemd._reader, systemd.id128, report._py3report, _dbus_bindings, 
problem._py3abrt (total: 7)
Aborted (core dumped)

> 
>> Signed-off-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
>> ---
>>   tools/perf/scripts/python/arm-cs-trace-disasm.py | 10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>
>> diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py 
>> b/tools/perf/scripts/python/arm-cs-trace-disasm.py
>> index d973c2baed1c..ad10cee2c35e 100755
>> --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py
>> +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py
>> @@ -198,6 +198,10 @@ def process_event(param_dict):
>>           cpu_data[str(cpu) + 'addr'] = addr
>>           return
>> +    if (cpu_data.get(str(cpu) + 'ip') == None):
>> +        cpu_data[str(cpu) + 'ip'] = ip
>> +
> 
> Do you need to write into the global cpu_data here? Doesn't it get 
> overwritten after you load it back into 'prev_ip'

No, the logic is same as holding the addr of previous packet.
Saving the previous packet saved ip in to prev_ip before overwriting 
with the current packet.
> 
>    prev_ip = cpu_data[str(cpu) + 'ip']
> 
>    ... then ...
> 
>    # Record for previous sample packet
>    cpu_data[str(cpu) + 'addr'] = addr
>    cpu_data[str(cpu) + 'ip'] = stop_addr
> 
> Would a local variable not accomplish the same thing?

No, We need global to hold the ip of previous packet.
> 
>> +    prev_ip = cpu_data[str(cpu) + 'ip']
>>       if (options.verbose == True):
>>           print("Event type: %s" % name)
>> @@ -243,12 +247,18 @@ def process_event(param_dict):
>>       # Record for previous sample packet
>>       cpu_data[str(cpu) + 'addr'] = addr
>> +    cpu_data[str(cpu) + 'ip'] = stop_addr
>>       # Handle CS_ETM_TRACE_ON packet if start_addr=0 and stop_addr=4
>>       if (start_addr == 0 and stop_addr == 4):
>>           print("CPU%d: CS_ETM_TRACE_ON packet is inserted" % cpu)
>>           return
>> +    if (stop_addr < start_addr):
>> +        # Continuity of the Packets broken, set start_addr to previous
>> +        # packet ip to complete the remaining tracing of the address 
>> range.
>> +        start_addr = prev_ip
>> +
>>       if (start_addr < int(dso_start) or start_addr > int(dso_end)):
>>           print("Start address 0x%x is out of range [ 0x%x .. 0x%x ] 
>> for dso %s" % (start_addr, int(dso_start), int(dso_end), dso))
>>           return

Thanks,
Ganapat

  reply	other threads:[~2024-07-22 10:02 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19  9:26 Ganapatrao Kulkarni
2024-07-19 14:39 ` James Clark
2024-07-22 10:02   ` Ganapatrao Kulkarni [this message]
2024-07-23 13:10     ` James Clark
2024-07-23 15:26       ` Ganapatrao Kulkarni
2024-07-23 15:46         ` James Clark
2024-07-24  6:38           ` Ganapatrao Kulkarni
2024-07-24 14:45             ` James Clark
2024-08-01 10:00               ` James Clark
2024-08-01 10:28                 ` Al Grant
2024-08-01 11:26                   ` James Clark
2024-08-01 11:58                     ` Al Grant
2024-08-01 14:58                       ` James Clark
2024-08-05 12:22                 ` Ganapatrao Kulkarni
2024-08-05 13:59                   ` James Clark
2024-08-06  7:02                     ` Ganapatrao Kulkarni
2024-08-06  9:47                       ` James Clark
2024-08-06  9:57                         ` James Clark
2024-08-06 15:02                           ` Steve Clevenger
2024-08-06 16:14                             ` James Clark
2024-08-07 12:17                               ` Ganapatrao Kulkarni
2024-08-07 14:53                                 ` James Clark
2024-08-07 16:18                                   ` Ganapatrao Kulkarni
2024-08-07 19:20                                     ` Leo Yan
2024-08-08  4:36                                       ` Ganapatrao Kulkarni
2024-08-08  7:42                                         ` Leo Yan
2024-08-08  9:21                                           ` James Clark
2024-08-08 10:51                                             ` James Clark
2024-08-08 11:14                                               ` Ganapatrao Kulkarni
2024-08-08 15:01                                                 ` Mike Leach
2024-08-07 16:48                                   ` Leo Yan
2024-08-08  9:32                                     ` James Clark
2024-08-08 11:05                                       ` Leo Yan
2024-08-09 14:13                                       ` Mike Leach
2024-08-09 15:19                                         ` James Clark
2024-08-19 10:59                                           ` Mike Leach
2024-08-23  9:03                                             ` James Clark
2024-08-23  9:57                                               ` Ganapatrao Kulkarni
2024-08-23 10:36                                                 ` James Clark
2024-08-23 10:37                                                   ` James Clark
2024-08-30  9:58                                                 ` James Clark
2024-09-02  6:12                                                   ` Ganapatrao Kulkarni
2024-08-28  9:33                                               ` Mike Leach
2024-08-29 13:35                                                 ` James Clark
2024-08-08  7:54                               ` Leo Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6920de94-a9c8-47f4-840f-391d1ec85c0c@os.amperecomputing.com \
    --to=gankulkarni@os.amperecomputing.com \
    --cc=acme@redhat.com \
    --cc=coresight@lists.linaro.org \
    --cc=darren@os.amperecomputing.com \
    --cc=james.clark@arm.com \
    --cc=james.clark@linaro.org \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@linaro.org \
    --cc=scclevenger@os.amperecomputing.com \
    --cc=suzuki.poulose@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®