1 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (C) 2018 Ravi Bangoria, IBM Corporation
5 # Hypervisor call statisics
7 from __future__
import print_function
12 sys
.path
.append(os
.environ
['PERF_EXEC_PATH'] + \
13 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
15 from perf_trace_context
import *
21 # 'min': minimum time nsec
22 # 'max': maximum time nsec
23 # 'time': average time nsec
51 60: 'H_LOGICAL_CI_LOAD',
52 64: 'H_LOGICAL_CI_STORE',
53 68: 'H_LOGICAL_CACHE_LOAD',
54 72: 'H_LOGICAL_CACHE_STORE',
57 84: 'H_GET_TERM_CHAR',
58 88: 'H_PUT_TERM_CHAR',
59 92: 'H_REAL_TO_LOGICAL',
60 96: 'H_HYPERVISOR_DATA',
68 220: 'H_REGISTER_VPA',
81 276: 'H_REGISTER_LOGICAL_LAN',
82 280: 'H_FREE_LOGICAL_LAN',
83 284: 'H_ADD_LOGICAL_LAN_BUFFER',
84 288: 'H_SEND_LOGICAL_LAN',
86 304: 'H_MULTICAST_CTRL',
89 316: 'H_PUT_TCE_INDIRECT',
90 332: 'H_CHANGE_LOGICAL_LAN_MAC',
91 336: 'H_VTERM_PARTNER_INFO',
92 340: 'H_REGISTER_VTERM',
94 348: 'H_RESET_EVENTS',
95 352: 'H_ALLOC_RESOURCE',
96 356: 'H_FREE_RESOURCE',
99 368: 'H_REREGISTER_PMR',
100 372: 'H_REGISTER_SMR',
105 392: 'H_MODIFY_PORT',
106 396: 'H_DEFINE_AQP1',
107 400: 'H_GET_TRACE_BUFFER',
108 404: 'H_DEFINE_AQP0',
110 412: 'H_ATTACH_MCQP',
111 416: 'H_DETACH_MCQP',
114 428: 'H_REGISTER_RPAGES',
115 432: 'H_DISABLE_AND_GETC',
117 440: 'H_GET_HCA_INFO',
118 444: 'H_GET_PERF_COUNT',
119 448: 'H_MANAGE_TRACE',
120 468: 'H_FREE_LOGICAL_LAN_BUFFER',
121 472: 'H_POLL_PENDING',
122 484: 'H_QUERY_INT_STATE',
123 580: 'H_ILLAN_ATTRIBUTES',
124 592: 'H_MODIFY_HEA_QP',
125 596: 'H_QUERY_HEA_QP',
127 604: 'H_QUERY_HEA_PORT',
128 608: 'H_MODIFY_HEA_PORT',
131 620: 'H_REGISTER_HEA_RPAGES',
132 624: 'H_DISABLE_AND_GET_HEA',
133 628: 'H_GET_HEA_INFO',
134 632: 'H_ALLOC_HEA_RESOURCE',
140 696: 'H_GET_EM_PARMS',
143 748: 'H_HOME_NODE_ASSOCIATIVITY',
144 756: 'H_BEST_ENERGY',
153 def hcall_table_lookup(opcode
):
154 if (opcode
in hcall_table
):
155 return hcall_table
[opcode
]
159 print_ptrn
= '%-28s%10s%10s%10s%10s'
162 print(print_ptrn
% ('hcall', 'count', 'min(ns)', 'max(ns)', 'avg(ns)'))
164 for opcode
in output
:
165 h_name
= hcall_table_lookup(opcode
)
166 time
= output
[opcode
]['time']
167 cnt
= output
[opcode
]['cnt']
168 min_t
= output
[opcode
]['min']
169 max_t
= output
[opcode
]['max']
171 print(print_ptrn
% (h_name
, cnt
, min_t
, max_t
, time
//cnt
))
173 def powerpc__hcall_exit(name
, context
, cpu
, sec
, nsec
, pid
, comm
, callchain
,
175 if (cpu
in d_enter
and opcode
in d_enter
[cpu
]):
176 diff
= nsecs(sec
, nsec
) - d_enter
[cpu
][opcode
]
178 if (opcode
in output
):
179 output
[opcode
]['time'] += diff
180 output
[opcode
]['cnt'] += 1
181 if (output
[opcode
]['min'] > diff
):
182 output
[opcode
]['min'] = diff
183 if (output
[opcode
]['max'] < diff
):
184 output
[opcode
]['max'] = diff
193 del d_enter
[cpu
][opcode
]
195 # print("Can't find matching hcall_enter event. Ignoring sample")
197 def powerpc__hcall_entry(event_name
, context
, cpu
, sec
, nsec
, pid
, comm
,
200 d_enter
[cpu
][opcode
] = nsecs(sec
, nsec
)
202 d_enter
[cpu
] = {opcode
: nsecs(sec
, nsec
)}