aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/powerpc-hcalls.py
blob: 00e0e7476e55efa8a077355fececafc2aadcf6c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
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: 'H_REGISTER_RPAGES',
	432: 'H_DISABLE_AND_GETC',
	436: 'H_ERROR_DATA',
	440: 'H_GET_HCA_INFO',
	444: 'H_GET_PERF_COUNT',
	448: 'H_MANAGE_TRACE',
	468: 'H_FREE_LOGICAL_LAN_BUFFER',
	472: 'H_POLL_PENDING',
	484: 'H_QUERY_INT_STATE',
	580: 'H_ILLAN_ATTRIBUTES',
	592: 'H_MODIFY_HEA_QP',
	596: 'H_QUERY_HEA_QP',
	600: 'H_QUERY_HEA',
	604: 'H_QUERY_HEA_PORT',
	608: 'H_MODIFY_HEA_PORT',
	612: 'H_REG_BCMC',
	616: 'H_DEREG_BCMC',
	620: 'H_REGISTER_HEA_RPAGES',
	624: 'H_DISABLE_AND_GET_HEA',
	628: 'H_GET_HEA_INFO',
	632: 'H_ALLOC_HEA_RESOURCE',
	644: 'H_ADD_CONN',
	648: 'H_DEL_CONN',
	664: 'H_JOIN',
	676: 'H_VASI_STATE',
	688: 'H_ENABLE_CRQ',
	696: 'H_GET_EM_PARMS',
	720: 'H_SET_MPP',
	724: 'H_GET_MPP',
	748: 'H_HOME_NODE_ASSOCIATIVITY',
	756: 'H_BEST_ENERGY',
	764: 'H_XIRR_X',
	768: 'H_RANDOM',
	772: 'H_COP',
	788: 'H_GET_MPP_X',
	796: 'H_SET_MODE',
	61440: 'H_RTAS',
}

def hcall_table_lookup(opcode):
	if (hcall_table.has_key(opcode)):
		return hcall_table[opcode]
	else:
		return opcode

print_ptrn = '%-28s%10s%10s%10s%10s'

def trace_end():
	print print_ptrn % ('hcall', 'count', 'min(ns)', 'max(ns)', 'avg(ns)')
	print '-' * 68
	for opcode in output:
		h_name = hcall_table_lookup(opcode)
		time = output[opcode]['time']
		cnt = output[opcode]['cnt']
		min_t = output[opcode]['min']
		max_t = output[opcode]['max']

		print print_ptrn % (h_name, cnt, min_t, max_t, time/cnt)

def powerpc__hcall_exit(name, context, cpu, sec, nsec, pid, comm, callchain,
			opcode, retval):
	if (d_enter.has_key(cpu) and d_enter[cpu].has_key(opcode)):
		diff = nsecs(sec, nsec) - d_enter[cpu][opcode]

		if (output.has_key(opcode)):
			output[opcode]['time'] += diff
			output[opcode]['cnt'] += 1
			if (output[opcode]['min'] > diff):
				output[opcode]['min'] = diff
			if (output[opcode]['max'] < diff):
				output[opcode]['max'] = diff
		else:
			output[opcode] = {
				'time': diff,
				'cnt': 1,
				'min': diff,
				'max': diff,
			}

		del d_enter[cpu][opcode]
#	else:
#		print "Can't find matching hcall_enter event. Ignoring sample"

def powerpc__hcall_entry(event_name, context, cpu, sec, nsec, pid, comm,
			 callchain, opcode):
		if (d_enter.has_key(cpu)):
			d_enter[cpu][opcode] = nsecs(sec, nsec)
		else:
			d_enter[cpu] = {opcode: nsecs(sec, nsec)}
7 -0300'>2018-02-16perf machine: Generalize machine__set_kernel_mmap()Jiri Olsa1-6/+7 2018-02-16perf machine: Move kernel mmap name into struct machineJiri Olsa5-49/+39 2018-02-16perf machine: Free root_dir in machine__init() error pathJiri Olsa1-1/+7 2018-02-16perf symbols: Check if we read regular file in dso__load()Jiri Olsa1-6/+4 2018-02-16tools lib symbol: Skip non-address kallsyms lineJiri Olsa1-0/+4 2018-02-16perf stat: Add support to print counts after a period of timeyuzhoujian3-2/+37 2018-02-16perf stat: Add support to print counts for fixed timesyuzhoujian3-1/+25 2018-02-16perf report: Add support to display group output for non group eventsJiri Olsa2-2/+7 2018-02-16perf report: Ask for ordered events for --tasks optionJiri Olsa1-0/+1 2018-02-16perf tools: Fix comment for sort__* compare functionsJiri Olsa1-2/+5 2018-02-16perf tests: Fix dwarf unwind for stripped binariesJiri Olsa1-16/+30 2018-02-16tools lib api fs: Add sysfs__read_xll functionJiri Olsa2-2/+14 2018-02-16tools lib api fs: Add filename__read_xll functionJiri Olsa2-7/+23 2018-02-16perf script: Add --show-round-event to display PERF_RECORD_FINISHED_ROUNDJiri Olsa2-0/+20 2018-02-16perf record: Put new line after target override warningJiri Olsa1-1/+1 2018-02-16kprobes: Propagate error from disarm_kprobe_ftrace()Jessica Yu1-25/+53 2018-02-16kprobes: Propagate error from arm_kprobe_ftrace()Jessica Yu1-25/+75 2018-02-15Revert "tools include s390: Grab a copy of arch/s390/include/uapi/asm/unistd.h"Hendrik Brueckner2-413/+0 2018-02-15perf s390: Rework system call table creation by using syscall.tblHendrik Brueckner2-14/+14