1 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (C) 2018 Ravi Bangoria, IBM Corporation
5 # Hypervisor call statisics
10 sys
.path
.append(os
.environ
['PERF_EXEC_PATH'] + \
11 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
13 from perf_trace_context
import *
19 # 'min': minimum time nsec
20 # 'max': maximum time nsec
21 # 'time': average time nsec
49 60: 'H_LOGICAL_CI_LOAD',
50 64: 'H_LOGICAL_CI_STORE',
51 68: 'H_LOGICAL_CACHE_LOAD',
52 72: 'H_LOGICAL_CACHE_STORE',
55 84: 'H_GET_TERM_CHAR',
56 88: 'H_PUT_TERM_CHAR',
57 92: 'H_REAL_TO_LOGICAL',
58 96: 'H_HYPERVISOR_DATA',
66 220: 'H_REGISTER_VPA',
79 276: 'H_REGISTER_LOGICAL_LAN',
80 280: 'H_FREE_LOGICAL_LAN',
81 284: 'H_ADD_LOGICAL_LAN_BUFFER',
82 288: 'H_SEND_LOGICAL_LAN',
84 304: 'H_MULTICAST_CTRL',
87 316: 'H_PUT_TCE_INDIRECT',
88 332: 'H_CHANGE_LOGICAL_LAN_MAC',
89 336: 'H_VTERM_PARTNER_INFO',
90 340: 'H_REGISTER_VTERM',
92 348: 'H_RESET_EVENTS',
93 352: 'H_ALLOC_RESOURCE',
94 356: 'H_FREE_RESOURCE',
97 368: 'H_REREGISTER_PMR',
98 372: 'H_REGISTER_SMR',
103 392: 'H_MODIFY_PORT',
104 396: 'H_DEFINE_AQP1',
105 400: 'H_GET_TRACE_BUFFER',
106 404: 'H_DEFINE_AQP0',
108 412: 'H_ATTACH_MCQP',
109 416: 'H_DETACH_MCQP',
112 428: 'H_REGISTER_RPAGES',
113 432: 'H_DISABLE_AND_GETC',
115 440: 'H_GET_HCA_INFO',
116 444: 'H_GET_PERF_COUNT',
117 448: 'H_MANAGE_TRACE',
118 468: 'H_FREE_LOGICAL_LAN_BUFFER',
119 472: 'H_POLL_PENDING',
120 484: 'H_QUERY_INT_STATE',
121 580: 'H_ILLAN_ATTRIBUTES',
122 592: 'H_MODIFY_HEA_QP',
123 596: 'H_QUERY_HEA_QP',
125 604: 'H_QUERY_HEA_PORT',
126 608: 'H_MODIFY_HEA_PORT',
129 620: 'H_REGISTER_HEA_RPAGES',
130 624: 'H_DISABLE_AND_GET_HEA',
131 628: 'H_GET_HEA_INFO',
132 632: 'H_ALLOC_HEA_RESOURCE',
138 696: 'H_GET_EM_PARMS',
141 748: 'H_HOME_NODE_ASSOCIATIVITY',
142 756: 'H_BEST_ENERGY',
151 def hcall_table_lookup(opcode
):
152 if (hcall_table
.has_key(opcode
)):
153 return hcall_table
[opcode
]
157 print_ptrn
= '%-28s%10s%10s%10s%10s'
160 print print_ptrn
% ('hcall', 'count', 'min(ns)', 'max(ns)', 'avg(ns)')
162 for opcode
in output
:
163 h_name
= hcall_table_lookup(opcode
)
164 time
= output
[opcode
]['time']
165 cnt
= output
[opcode
]['cnt']
166 min_t
= output
[opcode
]['min']
167 max_t
= output
[opcode
]['max']
169 print print_ptrn
% (h_name
, cnt
, min_t
, max_t
, time
/cnt
)
171 def powerpc__hcall_exit(name
, context
, cpu
, sec
, nsec
, pid
, comm
, callchain
,
173 if (d_enter
.has_key(cpu
) and d_enter
[cpu
].has_key(opcode
)):
174 diff
= nsecs(sec
, nsec
) - d_enter
[cpu
][opcode
]
176 if (output
.has_key(opcode
)):
177 output
[opcode
]['time'] += diff
178 output
[opcode
]['cnt'] += 1
179 if (output
[opcode
]['min'] > diff
):
180 output
[opcode
]['min'] = diff
181 if (output
[opcode
]['max'] < diff
):
182 output
[opcode
]['max'] = diff
191 del d_enter
[cpu
][opcode
]
193 # print "Can't find matching hcall_enter event. Ignoring sample"
195 def powerpc__hcall_entry(event_name
, context
, cpu
, sec
, nsec
, pid
, comm
,
197 if (d_enter
.has_key(cpu
)):
198 d_enter
[cpu
][opcode
] = nsecs(sec
, nsec
)
200 d_enter
[cpu
] = {opcode
: nsecs(sec
, nsec
)}