Re: [PATCH 42/46] perf script powerpc: Python script for hypervisor call statistics

From: Paul Clarke
Date: Thu Jun 07 2018 - 09:41:59 EST


On 06/07/2018 12:34 AM, Ravi Bangoria wrote:
> On 06/06/2018 08:23 PM, Paul Clarke wrote:
>> On 06/05/2018 12:50 PM, Arnaldo Carvalho de Melo wrote:
>>> From: Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxx>
>>>
>>> Add python script to show hypervisor call statistics. Ex,
>>>
>>> # perf record -a -e "{powerpc:hcall_entry,powerpc:hcall_exit}"
>>> # perf script -s scripts/python/powerpc-hcalls.py
>>> hcall count min(ns) max(ns) avg(ns)
>>> --------------------------------------------------------------------
>>> H_RANDOM 82 838 1164 904
>>> H_PUT_TCE 47 1078 5928 2003
>>> H_EOI 266 1336 3546 1654
>>> H_ENTER 28 1646 4038 1952
>>> H_PUT_TCE_INDIRECT 230 2166 18168 6109
>>> H_IPI 238 1072 3232 1688
>>> H_SEND_LOGICAL_LAN 42 5488 21366 7694
>>> H_STUFF_TCE 294 986 6210 3591
>>> H_XIRR 266 2286 6990 3783
>>> H_PROTECT 10 2196 3556 2555
>>> H_VIO_SIGNAL 294 1028 2784 1311
>>> H_ADD_LOGICAL_LAN_BUFFER 53 1978 3450 2600
>>> H_SEND_CRQ 77 1762 7240 2447
>>
>> This translation from HCALL code to mnemonic is more generally useful. Is there a good way to make the "hcall_table_lookup" function more generally available, like "syscall_name" in scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py ? It's even simpler than the syscall ID-to-name mapping, because the HCALL codes are constant, unlike syscall IDs which vary between arches.
>>
>
> Right, but I don't see any other python script for hcalls. So, I thought
> to add it in the script itself. Let me know if you are planning to add
> any :) We will move it in a generic module.

We're already doing the same thing in an external script. (https://github.com/open-power-sdk/curt/blob/master/curt.py#L264 revision 107c97c3aadba3177bc8cf35b06ba165e6ac557f.)

...which reminds me that I should consider sending that script to linux-perf-users to see if it's interesting enough to be included upstream.

PC