public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob 1193af8680730278d3f76a3788b19f72fe63de75 4219 bytes (raw)

  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
 
# SPDX-License-Identifier: GPL-2.0-or-later
#
# PASST - Plug A Simple Socket Transport
#  for qemu/UNIX domain socket mode
#
# PASTA - Pack A Subtle Tap Abstraction
#  for network namespace/tap device mode
#
# test/memory/passt - Show memory usage of passt in kernel and userspace
#
# Copyright (c) 2022 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com>

gtools	sed cat diff nm sort kill tee head tail chroot unshare mount mkdir cp 

def	meminfo_row
gout	DIFF meminfo_diff /tmp/meminfo.before /tmp/meminfo.after __WHAT__
tl	__NAME__
td	__DIFF__ 3 0 0
endef

def	meminfo_reverse_row
gout	DIFF meminfo_diff /tmp/meminfo.after /tmp/meminfo.before __WHAT__
tl	__NAME__
td	__DIFF__ 3 0 0
endef

def	nm_row
gout	SIZE nm_size /tmp/nm.size __WHAT__
tl	__WHAT__
td	__SIZE__ 6 0 0
endef

def	slab_row
gout	COUNT slab_diff_count /tmp/slabinfo.before /tmp/slabinfo.after __WHAT__
gout	SIZE slab_size /tmp/slabinfo.before __WHAT__
gout	DIFF slab_diff_size /tmp/slabinfo.before /tmp/slabinfo.after __WHAT__
tl	__WHAT__
td	__COUNT__ 0 0 0
td	__SIZE__ 0 0 0
td	__DIFF__ 6 0 0
endef

def	start_stop_diff
guest	sed /proc/slabinfo -ne 's/^\([^ ]* *[^ ]* *[^ ]* *[^ ]*\).*/\\\1/p' > /tmp/slabinfo.before
guest	cat /proc/meminfo > /tmp/meminfo.before
guest	/bin/passt.avx2 -l /tmp/log -s /tmp/sock -P /tmp/pid __OPTS__ --netns-only
sleep	2
guest	cat /proc/meminfo > /tmp/meminfo.after
guest	sed /proc/slabinfo -ne 's/^\([^ ]* *[^ ]* *[^ ]* *[^ ]*\).*/\\\1/p' > /tmp/slabinfo.after
guest	kill \$(cat /tmp/pid)
guest	diff -y --suppress-common-lines /tmp/meminfo.before /tmp/meminfo.after || :
guest	nm -td -Sr --size-sort -P /bin/passt.avx2 | head -30 | tee /tmp/nm.size
guest	sed /proc/slabinfo -ne 's/\(.*<objsize>\).*$/\1/p' | tail -1; (diff -y --suppress-common-lines /tmp/slabinfo.before /tmp/slabinfo.after | sort -grk8)
endef

def	summary
info	Memory usage summary
info	
th	type MiB
set	WHAT MemFree
set	NAME used
meminfo_reverse_row
set	WHAT AnonPages
set	NAME userspace
meminfo_row
set	WHAT Slab
set	NAME kernel
meminfo_row
te
endef


guest	mkdir /test
guest	mount -t tmpfs none /test
guest	mkdir /test/proc /test/dev /test/tmp
guest	mount -o bind /proc /test/proc
guest	mount -o bind /dev /test/dev
guest	cp -Lr /bin /lib /lib64 /usr /sbin /test/

guest	ulimit -Hn 300000
guest	unshare -rUm -R /test
guest	chroot .

guest	meminfo_size() { grep "^$2:" $1 | tr -s ' ' | cut -f2 -d ' '; }
guest	meminfo_diff() { echo $(( $(meminfo_size $2 $3) - $(meminfo_size $1 $3) )); }

guest	nm_size() { grep -m1 "^$2 " $1 | cut -f4 -d ' '; }

guest	slab_count() { grep "^$2 " $1 | tr -s ' ' | cut -f3 -d ' '; }
guest	slab_size() { grep "^$2 " $1 | tr -s ' ' | cut -f4 -d ' '; }
guest	slab_diff_count() { echo $(( $(slab_count $2 $3) - $(slab_count $1 $3) )); }
guest	slab_diff_size() { echo $(( $(slab_count $2 $3) * $(slab_size $2 $3) - $(slab_count $1 $3) * $(slab_size $1 $3) )); }


test	Memory usage: all TCP and UDP ports forwarded, IPv4 and IPv6
set	OPTS -t all -u all
start_stop_diff
summary

info	Userspace memory detail
info	
th	symbol MiB
set	WHAT tcp_buf_discard
nm_row
set	WHAT tcp6_l2_buf
nm_row
set	WHAT tcp4_l2_buf
nm_row
set	WHAT tc
nm_row
set	WHAT pkt_buf
nm_row
set	WHAT udp_splice_map
nm_row
set	WHAT udp6_l2_buf
nm_row
set	WHAT udp4_l2_buf
nm_row
set	WHAT udp_tap_map
nm_row
set	WHAT icmp_id_map
nm_row
set	WHAT udp_splice_buf
nm_row
set	WHAT tc_hash
nm_row
set	WHAT pool_tap6_storage
nm_row
set	WHAT pool_tap4_storage
nm_row
set	WHAT tap6_l4
nm_row
set	WHAT tap4_l4
nm_row
te

info	Kernel memory detail
info	
th	objects count size MiB
set	WHAT pid
slab_row
set	WHAT dentry
slab_row
set	WHAT Acpi-Parse
slab_row
set	WHAT kmalloc-64
slab_row
set	WHAT kmalloc-32
slab_row
set	WHAT lsm_file_cache
slab_row
set	WHAT filp
slab_row
set	WHAT anon_vma_chain
slab_row
set	WHAT ep_head
slab_row
set	WHAT sock_inode_cache
slab_row
set	WHAT signal_cache
slab_row
set	WHAT TCPv6
slab_row
set	WHAT TCP
slab_row
set	WHAT UDPv6
slab_row
te


test	Memory usage: all TCP ports forwarded, IPv4
set	OPTS -t all -4
start_stop_diff
summary


test	Memory usage: all TCP and UDP ports forwarded, IPv4
set	OPTS -t all -u all -4
start_stop_diff
summary


test	Memory usage: no ports forwarded
set	OPTS -t none -u none
start_stop_diff
summary

debug log:

solving 1193af8 ...
found 1193af8 in https://passt.top/passt

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).