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

2018-06-07 Thread Arnaldo Carvalho de Melo
Em Thu, Jun 07, 2018 at 08:41:46AM -0500, Paul Clarke escreveu:
> 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 
> >>>
> >>> 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
> >>> hcallcount   min(ns)   max(ns)   avg(ns)
> >>> 
> >>> H_RANDOM82   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_TCE294   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_BUFFER53  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.

If you don't have any restriction, then its interesting to have it
included, I think, this way we can find these kinds of needed common
infrastructure more easily, and also when doing changes take into
account existing scripts.

- Arnaldo


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

2018-06-07 Thread Arnaldo Carvalho de Melo
Em Thu, Jun 07, 2018 at 08:41:46AM -0500, Paul Clarke escreveu:
> 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 
> >>>
> >>> 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
> >>> hcallcount   min(ns)   max(ns)   avg(ns)
> >>> 
> >>> H_RANDOM82   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_TCE294   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_BUFFER53  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.

If you don't have any restriction, then its interesting to have it
included, I think, this way we can find these kinds of needed common
infrastructure more easily, and also when doing changes take into
account existing scripts.

- Arnaldo


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

2018-06-07 Thread Paul Clarke
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 
>>>
>>> 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
>>> hcallcount   min(ns)   max(ns)   avg(ns)
>>> 
>>> H_RANDOM82   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_TCE294   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_BUFFER53  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



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

2018-06-07 Thread Paul Clarke
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 
>>>
>>> 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
>>> hcallcount   min(ns)   max(ns)   avg(ns)
>>> 
>>> H_RANDOM82   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_TCE294   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_BUFFER53  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



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

2018-06-06 Thread Ravi Bangoria
Hi Paul,

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 
>>
>> 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
>> hcallcount   min(ns)   max(ns)   avg(ns)
>> 
>> H_RANDOM82   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_TCE294   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_BUFFER53  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.

Ravi



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

2018-06-06 Thread Ravi Bangoria
Hi Paul,

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 
>>
>> 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
>> hcallcount   min(ns)   max(ns)   avg(ns)
>> 
>> H_RANDOM82   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_TCE294   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_BUFFER53  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.

Ravi



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

2018-06-06 Thread Paul Clarke
On 06/05/2018 12:50 PM, Arnaldo Carvalho de Melo wrote:
> From: Ravi Bangoria 
> 
> 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
> hcallcount   min(ns)   max(ns)   avg(ns)
> 
> H_RANDOM82   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_TCE294   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_BUFFER53  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.

> diff --git a/tools/perf/scripts/python/powerpc-hcalls.py 
> b/tools/perf/scripts/python/powerpc-hcalls.py
> new file mode 100644
> index ..00e0e7476e55
> --- /dev/null
> +++ b/tools/perf/scripts/python/powerpc-hcalls.py
> @@ -0,0 +1,200 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (C) 2018 Ravi Bangoria, IBM Corporation
> +#
> +# Hypervisor call statisics
> +
> +import os
> +import sys
> +
> +sys.path.append(os.environ['PERF_EXEC_PATH'] + \
> + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
> +
> +from perf_trace_context import *
> +from Core import *
> +from Util import *
> +
> +# output: {
> +#opcode: {
> +#'min': minimum time nsec
> +#'max': maximum time nsec
> +#'time': average time nsec
> +#'cnt': counter
> +#} ...
> +# }
> +output = {}
> +
> +# d_enter: {
> +#cpu: {
> +#opcode: nsec
> +#} ...
> +# }
> +d_enter = {}
> +
> +hcall_table = {
> + 4: 'H_REMOVE',
> + 8: 'H_ENTER',
> + 12: 'H_READ',
> + 16: 'H_CLEAR_MOD',
> + 20: 'H_CLEAR_REF',
> + 24: 'H_PROTECT',
> + 28: 'H_GET_TCE',
> + 32: 'H_PUT_TCE',
> + 36: 'H_SET_SPRG0',
> + 40: 'H_SET_DABR',
> + 44: 'H_PAGE_INIT',
> + 48: 'H_SET_ASR',
> + 52: 'H_ASR_ON',
> + 56: 'H_ASR_OFF',
> + 60: 'H_LOGICAL_CI_LOAD',
> + 64: 'H_LOGICAL_CI_STORE',
> + 68: 'H_LOGICAL_CACHE_LOAD',
> + 72: 'H_LOGICAL_CACHE_STORE',
> + 76: 'H_LOGICAL_ICBI',
> + 80: 'H_LOGICAL_DCBF',
> + 84: 'H_GET_TERM_CHAR',
> + 88: 'H_PUT_TERM_CHAR',
> + 92: 'H_REAL_TO_LOGICAL',
> + 96: 'H_HYPERVISOR_DATA',
> + 100: 'H_EOI',
> + 104: 'H_CPPR',
> + 108: 'H_IPI',
> + 112: 'H_IPOLL',
> + 116: 'H_XIRR',
> + 120: 'H_MIGRATE_DMA',
> + 124: 'H_PERFMON',
> + 220: 'H_REGISTER_VPA',
> + 224: 'H_CEDE',
> + 228: 'H_CONFER',
> + 232: 'H_PROD',
> + 236: 'H_GET_PPP',
> + 240: 'H_SET_PPP',
> + 244: 'H_PURR',
> + 248: 'H_PIC',
> + 252: 'H_REG_CRQ',
> + 256: 'H_FREE_CRQ',
> + 260: 'H_VIO_SIGNAL',
> + 264: 'H_SEND_CRQ',
> + 272: 'H_COPY_RDMA',
> + 276: 'H_REGISTER_LOGICAL_LAN',
> + 280: 'H_FREE_LOGICAL_LAN',
> + 284: 'H_ADD_LOGICAL_LAN_BUFFER',
> + 288: 'H_SEND_LOGICAL_LAN',
> + 292: 'H_BULK_REMOVE',
> + 304: 'H_MULTICAST_CTRL',
> + 308: 'H_SET_XDABR',
> + 312: 'H_STUFF_TCE',
> + 316: 'H_PUT_TCE_INDIRECT',
> + 332: 'H_CHANGE_LOGICAL_LAN_MAC',
> + 336: 'H_VTERM_PARTNER_INFO',
> + 340: 'H_REGISTER_VTERM',
> + 344: 'H_FREE_VTERM',
> + 348: 'H_RESET_EVENTS',
> + 352: 'H_ALLOC_RESOURCE',
> + 356: 'H_FREE_RESOURCE',
> + 360: 'H_MODIFY_QP',
> + 364: 'H_QUERY_QP',
> + 368: 'H_REREGISTER_PMR',
> + 372: 'H_REGISTER_SMR',
> + 376: 'H_QUERY_MR',
> + 380: 'H_QUERY_MW',
> + 384: 'H_QUERY_HCA',
> + 388: 'H_QUERY_PORT',
> + 392: 'H_MODIFY_PORT',
> + 396: 'H_DEFINE_AQP1',
> + 400: 'H_GET_TRACE_BUFFER',
> + 404: 'H_DEFINE_AQP0',
> + 408: 'H_RESIZE_MR',
> + 412: 'H_ATTACH_MCQP',
> + 416: 'H_DETACH_MCQP',
> + 420: 'H_CREATE_RPT',
> + 424: 'H_REMOVE_RPT',
> + 428: 

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

2018-06-06 Thread Paul Clarke
On 06/05/2018 12:50 PM, Arnaldo Carvalho de Melo wrote:
> From: Ravi Bangoria 
> 
> 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
> hcallcount   min(ns)   max(ns)   avg(ns)
> 
> H_RANDOM82   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_TCE294   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_BUFFER53  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.

> diff --git a/tools/perf/scripts/python/powerpc-hcalls.py 
> b/tools/perf/scripts/python/powerpc-hcalls.py
> new file mode 100644
> index ..00e0e7476e55
> --- /dev/null
> +++ b/tools/perf/scripts/python/powerpc-hcalls.py
> @@ -0,0 +1,200 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (C) 2018 Ravi Bangoria, IBM Corporation
> +#
> +# Hypervisor call statisics
> +
> +import os
> +import sys
> +
> +sys.path.append(os.environ['PERF_EXEC_PATH'] + \
> + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
> +
> +from perf_trace_context import *
> +from Core import *
> +from Util import *
> +
> +# output: {
> +#opcode: {
> +#'min': minimum time nsec
> +#'max': maximum time nsec
> +#'time': average time nsec
> +#'cnt': counter
> +#} ...
> +# }
> +output = {}
> +
> +# d_enter: {
> +#cpu: {
> +#opcode: nsec
> +#} ...
> +# }
> +d_enter = {}
> +
> +hcall_table = {
> + 4: 'H_REMOVE',
> + 8: 'H_ENTER',
> + 12: 'H_READ',
> + 16: 'H_CLEAR_MOD',
> + 20: 'H_CLEAR_REF',
> + 24: 'H_PROTECT',
> + 28: 'H_GET_TCE',
> + 32: 'H_PUT_TCE',
> + 36: 'H_SET_SPRG0',
> + 40: 'H_SET_DABR',
> + 44: 'H_PAGE_INIT',
> + 48: 'H_SET_ASR',
> + 52: 'H_ASR_ON',
> + 56: 'H_ASR_OFF',
> + 60: 'H_LOGICAL_CI_LOAD',
> + 64: 'H_LOGICAL_CI_STORE',
> + 68: 'H_LOGICAL_CACHE_LOAD',
> + 72: 'H_LOGICAL_CACHE_STORE',
> + 76: 'H_LOGICAL_ICBI',
> + 80: 'H_LOGICAL_DCBF',
> + 84: 'H_GET_TERM_CHAR',
> + 88: 'H_PUT_TERM_CHAR',
> + 92: 'H_REAL_TO_LOGICAL',
> + 96: 'H_HYPERVISOR_DATA',
> + 100: 'H_EOI',
> + 104: 'H_CPPR',
> + 108: 'H_IPI',
> + 112: 'H_IPOLL',
> + 116: 'H_XIRR',
> + 120: 'H_MIGRATE_DMA',
> + 124: 'H_PERFMON',
> + 220: 'H_REGISTER_VPA',
> + 224: 'H_CEDE',
> + 228: 'H_CONFER',
> + 232: 'H_PROD',
> + 236: 'H_GET_PPP',
> + 240: 'H_SET_PPP',
> + 244: 'H_PURR',
> + 248: 'H_PIC',
> + 252: 'H_REG_CRQ',
> + 256: 'H_FREE_CRQ',
> + 260: 'H_VIO_SIGNAL',
> + 264: 'H_SEND_CRQ',
> + 272: 'H_COPY_RDMA',
> + 276: 'H_REGISTER_LOGICAL_LAN',
> + 280: 'H_FREE_LOGICAL_LAN',
> + 284: 'H_ADD_LOGICAL_LAN_BUFFER',
> + 288: 'H_SEND_LOGICAL_LAN',
> + 292: 'H_BULK_REMOVE',
> + 304: 'H_MULTICAST_CTRL',
> + 308: 'H_SET_XDABR',
> + 312: 'H_STUFF_TCE',
> + 316: 'H_PUT_TCE_INDIRECT',
> + 332: 'H_CHANGE_LOGICAL_LAN_MAC',
> + 336: 'H_VTERM_PARTNER_INFO',
> + 340: 'H_REGISTER_VTERM',
> + 344: 'H_FREE_VTERM',
> + 348: 'H_RESET_EVENTS',
> + 352: 'H_ALLOC_RESOURCE',
> + 356: 'H_FREE_RESOURCE',
> + 360: 'H_MODIFY_QP',
> + 364: 'H_QUERY_QP',
> + 368: 'H_REREGISTER_PMR',
> + 372: 'H_REGISTER_SMR',
> + 376: 'H_QUERY_MR',
> + 380: 'H_QUERY_MW',
> + 384: 'H_QUERY_HCA',
> + 388: 'H_QUERY_PORT',
> + 392: 'H_MODIFY_PORT',
> + 396: 'H_DEFINE_AQP1',
> + 400: 'H_GET_TRACE_BUFFER',
> + 404: 'H_DEFINE_AQP0',
> + 408: 'H_RESIZE_MR',
> + 412: 'H_ATTACH_MCQP',
> + 416: 'H_DETACH_MCQP',
> + 420: 'H_CREATE_RPT',
> + 424: 'H_REMOVE_RPT',
> + 428: 

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

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Ravi Bangoria 

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
hcallcount   min(ns)   max(ns)   avg(ns)

H_RANDOM82   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_TCE294   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_BUFFER53  1978  3450  2600
H_SEND_CRQ  77  1762  7240  2447

Signed-off-by: Ravi Bangoria 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Michael Ellerman 
Cc: Namhyung Kim 
Cc: Naveen N. Rao 
Link: 
http://lkml.kernel.org/r/20180605124801.17210-1-ravi.bango...@linux.ibm.com
[ Fixup typo: table_loockup -> table_lookup ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 .../perf/scripts/python/bin/powerpc-hcalls-record  |   2 +
 .../perf/scripts/python/bin/powerpc-hcalls-report  |   2 +
 tools/perf/scripts/python/powerpc-hcalls.py| 200 +
 3 files changed, 204 insertions(+)
 create mode 100644 tools/perf/scripts/python/bin/powerpc-hcalls-record
 create mode 100644 tools/perf/scripts/python/bin/powerpc-hcalls-report
 create mode 100644 tools/perf/scripts/python/powerpc-hcalls.py

diff --git a/tools/perf/scripts/python/bin/powerpc-hcalls-record 
b/tools/perf/scripts/python/bin/powerpc-hcalls-record
new file mode 100644
index ..b7402aa9147d
--- /dev/null
+++ b/tools/perf/scripts/python/bin/powerpc-hcalls-record
@@ -0,0 +1,2 @@
+#!/bin/bash
+perf record -e "{powerpc:hcall_entry,powerpc:hcall_exit}" $@
diff --git a/tools/perf/scripts/python/bin/powerpc-hcalls-report 
b/tools/perf/scripts/python/bin/powerpc-hcalls-report
new file mode 100644
index ..dd32ad7465f6
--- /dev/null
+++ b/tools/perf/scripts/python/bin/powerpc-hcalls-report
@@ -0,0 +1,2 @@
+#!/bin/bash
+perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/powerpc-hcalls.py
diff --git a/tools/perf/scripts/python/powerpc-hcalls.py 
b/tools/perf/scripts/python/powerpc-hcalls.py
new file mode 100644
index ..00e0e7476e55
--- /dev/null
+++ b/tools/perf/scripts/python/powerpc-hcalls.py
@@ -0,0 +1,200 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2018 Ravi Bangoria, IBM Corporation
+#
+# Hypervisor call statisics
+
+import os
+import sys
+
+sys.path.append(os.environ['PERF_EXEC_PATH'] + \
+   '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
+
+from perf_trace_context import *
+from Core import *
+from Util import *
+
+# output: {
+#  opcode: {
+#  'min': minimum time nsec
+#  'max': maximum time nsec
+#  'time': average time nsec
+#  'cnt': counter
+#  } ...
+# }
+output = {}
+
+# d_enter: {
+#  cpu: {
+#  opcode: nsec
+#  } ...
+# }
+d_enter = {}
+
+hcall_table = {
+   4: 'H_REMOVE',
+   8: 'H_ENTER',
+   12: 'H_READ',
+   16: 'H_CLEAR_MOD',
+   20: 'H_CLEAR_REF',
+   24: 'H_PROTECT',
+   28: 'H_GET_TCE',
+   32: 'H_PUT_TCE',
+   36: 'H_SET_SPRG0',
+   40: 'H_SET_DABR',
+   44: 'H_PAGE_INIT',
+   48: 'H_SET_ASR',
+   52: 'H_ASR_ON',
+   56: 'H_ASR_OFF',
+   60: 'H_LOGICAL_CI_LOAD',
+   64: 'H_LOGICAL_CI_STORE',
+   68: 'H_LOGICAL_CACHE_LOAD',
+   72: 'H_LOGICAL_CACHE_STORE',
+   76: 'H_LOGICAL_ICBI',
+   80: 'H_LOGICAL_DCBF',
+   84: 'H_GET_TERM_CHAR',
+   88: 'H_PUT_TERM_CHAR',
+   92: 'H_REAL_TO_LOGICAL',
+   96: 'H_HYPERVISOR_DATA',
+   100: 'H_EOI',
+   104: 'H_CPPR',
+   108: 'H_IPI',
+   112: 'H_IPOLL',
+   116: 'H_XIRR',
+   120: 'H_MIGRATE_DMA',
+   124: 'H_PERFMON',
+   220: 'H_REGISTER_VPA',
+   224: 'H_CEDE',
+   228: 'H_CONFER',
+   232: 'H_PROD',
+   236: 'H_GET_PPP',
+   240: 'H_SET_PPP',
+   244: 'H_PURR',
+   248: 'H_PIC',
+   252: 'H_REG_CRQ',
+   256: 'H_FREE_CRQ',
+   260: 'H_VIO_SIGNAL',
+   264: 'H_SEND_CRQ',
+   272: 'H_COPY_RDMA',
+   276: 'H_REGISTER_LOGICAL_LAN',
+   280: 'H_FREE_LOGICAL_LAN',
+   284: 'H_ADD_LOGICAL_LAN_BUFFER',
+   288: 'H_SEND_LOGICAL_LAN',
+   292: 'H_BULK_REMOVE',
+   

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

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Ravi Bangoria 

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
hcallcount   min(ns)   max(ns)   avg(ns)

H_RANDOM82   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_TCE294   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_BUFFER53  1978  3450  2600
H_SEND_CRQ  77  1762  7240  2447

Signed-off-by: Ravi Bangoria 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Michael Ellerman 
Cc: Namhyung Kim 
Cc: Naveen N. Rao 
Link: 
http://lkml.kernel.org/r/20180605124801.17210-1-ravi.bango...@linux.ibm.com
[ Fixup typo: table_loockup -> table_lookup ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 .../perf/scripts/python/bin/powerpc-hcalls-record  |   2 +
 .../perf/scripts/python/bin/powerpc-hcalls-report  |   2 +
 tools/perf/scripts/python/powerpc-hcalls.py| 200 +
 3 files changed, 204 insertions(+)
 create mode 100644 tools/perf/scripts/python/bin/powerpc-hcalls-record
 create mode 100644 tools/perf/scripts/python/bin/powerpc-hcalls-report
 create mode 100644 tools/perf/scripts/python/powerpc-hcalls.py

diff --git a/tools/perf/scripts/python/bin/powerpc-hcalls-record 
b/tools/perf/scripts/python/bin/powerpc-hcalls-record
new file mode 100644
index ..b7402aa9147d
--- /dev/null
+++ b/tools/perf/scripts/python/bin/powerpc-hcalls-record
@@ -0,0 +1,2 @@
+#!/bin/bash
+perf record -e "{powerpc:hcall_entry,powerpc:hcall_exit}" $@
diff --git a/tools/perf/scripts/python/bin/powerpc-hcalls-report 
b/tools/perf/scripts/python/bin/powerpc-hcalls-report
new file mode 100644
index ..dd32ad7465f6
--- /dev/null
+++ b/tools/perf/scripts/python/bin/powerpc-hcalls-report
@@ -0,0 +1,2 @@
+#!/bin/bash
+perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/powerpc-hcalls.py
diff --git a/tools/perf/scripts/python/powerpc-hcalls.py 
b/tools/perf/scripts/python/powerpc-hcalls.py
new file mode 100644
index ..00e0e7476e55
--- /dev/null
+++ b/tools/perf/scripts/python/powerpc-hcalls.py
@@ -0,0 +1,200 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2018 Ravi Bangoria, IBM Corporation
+#
+# Hypervisor call statisics
+
+import os
+import sys
+
+sys.path.append(os.environ['PERF_EXEC_PATH'] + \
+   '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
+
+from perf_trace_context import *
+from Core import *
+from Util import *
+
+# output: {
+#  opcode: {
+#  'min': minimum time nsec
+#  'max': maximum time nsec
+#  'time': average time nsec
+#  'cnt': counter
+#  } ...
+# }
+output = {}
+
+# d_enter: {
+#  cpu: {
+#  opcode: nsec
+#  } ...
+# }
+d_enter = {}
+
+hcall_table = {
+   4: 'H_REMOVE',
+   8: 'H_ENTER',
+   12: 'H_READ',
+   16: 'H_CLEAR_MOD',
+   20: 'H_CLEAR_REF',
+   24: 'H_PROTECT',
+   28: 'H_GET_TCE',
+   32: 'H_PUT_TCE',
+   36: 'H_SET_SPRG0',
+   40: 'H_SET_DABR',
+   44: 'H_PAGE_INIT',
+   48: 'H_SET_ASR',
+   52: 'H_ASR_ON',
+   56: 'H_ASR_OFF',
+   60: 'H_LOGICAL_CI_LOAD',
+   64: 'H_LOGICAL_CI_STORE',
+   68: 'H_LOGICAL_CACHE_LOAD',
+   72: 'H_LOGICAL_CACHE_STORE',
+   76: 'H_LOGICAL_ICBI',
+   80: 'H_LOGICAL_DCBF',
+   84: 'H_GET_TERM_CHAR',
+   88: 'H_PUT_TERM_CHAR',
+   92: 'H_REAL_TO_LOGICAL',
+   96: 'H_HYPERVISOR_DATA',
+   100: 'H_EOI',
+   104: 'H_CPPR',
+   108: 'H_IPI',
+   112: 'H_IPOLL',
+   116: 'H_XIRR',
+   120: 'H_MIGRATE_DMA',
+   124: 'H_PERFMON',
+   220: 'H_REGISTER_VPA',
+   224: 'H_CEDE',
+   228: 'H_CONFER',
+   232: 'H_PROD',
+   236: 'H_GET_PPP',
+   240: 'H_SET_PPP',
+   244: 'H_PURR',
+   248: 'H_PIC',
+   252: 'H_REG_CRQ',
+   256: 'H_FREE_CRQ',
+   260: 'H_VIO_SIGNAL',
+   264: 'H_SEND_CRQ',
+   272: 'H_COPY_RDMA',
+   276: 'H_REGISTER_LOGICAL_LAN',
+   280: 'H_FREE_LOGICAL_LAN',
+   284: 'H_ADD_LOGICAL_LAN_BUFFER',
+   288: 'H_SEND_LOGICAL_LAN',
+   292: 'H_BULK_REMOVE',
+