From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id B7C1D5A0265 for ; Tue, 1 Nov 2022 08:59:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667289575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UWMpornfRcI/PrljtoRV9usaT8LIWQvXUD/oM+X5b1U=; b=UGHfQ5L12Uq83Y73VK5SrHAb2JjVgH6is7AocqJD6p63W27Svbq8F23u0HOhZodoGySqv0 hAA0nxY70kPru6pgpKO6uqWgFWyc2t8cWjtR+wRGA2FK5m1jT3cbw5QtroZonEKlNGJ3br pfXT1u+FUdnVzD89mV1Wz/g/xF4eoNU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-410-ylwL1g7YNXWqOZ0D3DoDww-1; Tue, 01 Nov 2022 03:59:34 -0400 X-MC-Unique: ylwL1g7YNXWqOZ0D3DoDww-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0759F3815D21; Tue, 1 Nov 2022 07:59:34 +0000 (UTC) Received: from maya.cloud.tilaa.com (ovpn-208-31.brq.redhat.com [10.40.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D46E111F3BB; Tue, 1 Nov 2022 07:59:33 +0000 (UTC) Date: Tue, 1 Nov 2022 08:59:30 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 5/5] test: Add memory/passt test cases Message-ID: <20221101085930.30e9b7bf@elisabeth> In-Reply-To: References: <20221031112059.170269-1-sbrivio@redhat.com> <20221031112059.170269-6-sbrivio@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4JD2PKAUQSXSLCOCYXPZL4ROP3B2LTGS X-Message-ID-Hash: 4JD2PKAUQSXSLCOCYXPZL4ROP3B2LTGS X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: <> Archived-At: List-Archive: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, 1 Nov 2022 11:58:26 +1100 David Gibson wrote: > On Mon, Oct 31, 2022 at 12:20:59PM +0100, Stefano Brivio wrote: > > These show a summary of memory usage in kernel and userspace with > > different port forwarding configurations, details of userspace usage > > using 'nm' (passt only uses statically allocated memory), and details > > of kernel memory from slab reporting facilities. > >=20 > > This adds a new test image, mbuto.mem.img, with harcoded IPv4 and > > IPv6 addresses and routes, and just the tools we need to start and > > stop passt, to report from /proc/slabinfo, /proc/meminfo, and to > > print and parse symbol sizes using nm(1). > >=20 > > passt can't pivot_root() for sandboxing purposes on ramfs, so we need > > to create another filesystem and chroot into it, first. =20 >=20 > Huh.. weird. Yeah, it also surprised me, but man 2 pivot_root says: The rootfs (initial ramfs) cannot be pivot_root()ed. The recommen= ded method of changing the root filesystem in this case is to delete eve= ry=E2=80=90 thing in rootfs, overmount rootfs with the new root, attach stdin/s= td=E2=80=90 out/stderr to the new /dev/console, and exec the new init(1). Hel= per programs for this process exist; see switch_root(8). (of course I got the documented case of EINVAL before reading that). > > We don't want to use pane context functions, as we're checking memory > > usage for sockets: resort to screen-scraping. =20 >=20 > So, we don't do it at the moment, but it should be pretty easy to make > the ssh-over-vsock stuff use a persistent control socket > (ControlPersist / ControlMaster). That would mean we'd just establish > one connection then all the subsequent guest bound commands would go > over that one initial connection. >=20 > It wouldn't take zero socket memory of course, but it should be small > and more importantly stable. So, if we take a diff of usage as you > already do, the results should still be good. Ah, yes, I guess so. I would track this as a ticket instead of trying to implement it now. > This patch is not working for me, for reasons I'm still debugging. > Some more minor comments in the interim. >=20 > >=20 > > Signed-off-by: Stefano Brivio > > --- > > test/Makefile | 5 +- > > test/lib/layout_ugly | 39 +++++++++ > > test/lib/setup_ugly | 37 +++++++++ > > test/memory/passt | 187 +++++++++++++++++++++++++++++++++++++++++++ > > test/passt.mem.mbuto | 42 ++++++++++ > > test/run | 4 + > > 6 files changed, 313 insertions(+), 1 deletion(-) > > create mode 100644 test/memory/passt > > create mode 100755 test/passt.mem.mbuto > >=20 > > diff --git a/test/Makefile b/test/Makefile > > index 91498ff..9f2bc42 100644 > > --- a/test/Makefile > > +++ b/test/Makefile > > @@ -55,7 +55,7 @@ UBUNTU_IMGS =3D $(UBUNTU_OLD_IMGS) $(UBUNTU_NEW_IMGS) > > DOWNLOAD_ASSETS =3D mbuto \ > > =09$(DEBIAN_IMGS) $(FEDORA_IMGS) $(OPENSUSE_IMGS) $(UBUNTU_IMGS) > > TESTDATA_ASSETS =3D small.bin big.bin medium.bin > > -LOCAL_ASSETS =3D mbuto.img QEMU_EFI.fd \ > > +LOCAL_ASSETS =3D mbuto.img mbuto.mem.img QEMU_EFI.fd \ > > =09$(DEBIAN_IMGS:%=3Dprepared-%) $(FEDORA_IMGS:%=3Dprepared-%) \ > > =09$(UBUNTU_NEW_IMGS:%=3Dprepared-%) \ > > =09nsholder guest-key guest-key.pub \ > > @@ -76,6 +76,9 @@ guest-key guest-key.pub: > > mbuto.img: passt.mbuto mbuto guest-key.pub $(TESTDATA_ASSETS) > > =09./mbuto/mbuto -p ./$< -c lz4 -f $@ > > =20 > > +mbuto.mem.img: passt.mem.mbuto mbuto ../passt.avx2 > > +=09./mbuto/mbuto -p ./$< -c lz4 -f $@ > > + > > nsholder: nsholder.c > > =09$(CC) $(CFLAGS) -o $@ $^ > > =20 > > diff --git a/test/lib/layout_ugly b/test/lib/layout_ugly > > index 9397b7d..d62d337 100644 > > --- a/test/lib/layout_ugly > > +++ b/test/lib/layout_ugly > > @@ -81,3 +81,42 @@ layout_pasta_simple() { > > =20 > > =09sleep 1 > > } > > + > > +# layout_memory() - Screen-scraped panes for memory usage tests, big g= uest pane > > +layout_memory() { > > +=09sleep 3 > > + > > +=09tmux kill-pane -a -t 0 > > +=09cmd_write 0 clear > > + > > +=09tmux split-window -h -l '35%' -t passt_test > > +=09tmux split-window -v -l '15%' -t passt_test > > + > > +=09PANE_PASST=3D2 > > +=09PANE_GUEST=3D0 > > +=09PANE_INFO=3D1 > > + > > +=09get_info_cols > > + > > +=09tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"= '; do :; done' > > +=09tmux send-keys -t ${PANE_INFO} -N 100 C-m > > +=09tmux select-pane -t ${PANE_INFO} -T "test log" > > + > > +=09if context_exists guest; then > > +=09=09pane_watch_contexts ${PANE_GUEST} guest guest > > +=09else > > +=09=09tmux pipe-pane -O -t ${PANE_GUEST} "cat >> ${LOGDIR}/pane_guest.= log" > > +=09=09tmux select-pane -t ${PANE_GUEST} -T "guest" > > +=09fi > > + > > +=09if context_exists passt; then =20 >=20 > AFAICT you're always using a context pane for passt, so you don't need > this conditional. Right, I'll drop this. > > +=09=09pane_watch_contexts ${PANE_PASST} passt passt > > +=09else > > +=09=09tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.= log" > > +=09=09tmux select-pane -t ${PANE_PASST} -T "passt" > > +=09fi > > + > > +=09info_layout "memory usage" > > + > > +=09sleep 1 > > +} > > diff --git a/test/lib/setup_ugly b/test/lib/setup_ugly > > index 764177e..f2e07ba 100755 > > --- a/test/lib/setup_ugly > > +++ b/test/lib/setup_ugly > > @@ -13,6 +13,8 @@ > > # Copyright (c) 2022 Red Hat GmbH > > # Author: Stefano Brivio > > =20 > > +INITRAMFS_MEM=3D"${BASEPATH}/mbuto.mem.img" > > + > > # setup_distro() - Set up pane layout for distro tests > > setup_distro() { > > =09layout_host > > @@ -25,6 +27,30 @@ setup_pasta_options() { > > =09layout_pasta_simple > > } > > =20 > > +# setup_memory() - Start qemu in guest pane, and passt in passt contex= t > > +setup_memory() { > > +=09context_setup_host passt > > + > > +=09layout_memory > > + > > +=09context_run passt "./passt -P ${STATESETUP}/passt.pid" > > + > > +=09# pidfile isn't created until passt is listening > > +=09wait_for [ -f "${STATESETUP}/passt.pid" ] > > + > > +=09pane_or_context_run guest './qrap 5 qemu-system-$(uname -m)'=09 \ > > +=09=09' -machine accel=3Dkvm' \ > > +=09=09' -m '${VMEM}' -cpu host -smp '${VCPUS} \ > > +=09=09' -kernel ' "/boot/vmlinuz-$(uname -r)"=09=09=09 \ > > +=09=09' -initrd '${INITRAMFS_MEM}' -nographic -serial stdio'=09 \ > > +=09=09' -nodefaults'=09=09=09=09=09=09 \ > > +=09=09' -append "console=3DttyS0 mitigations=3Doff apparmor=3D0 '=09 = \ > > +=09=09'virtio-net.napi_tx=3D1"'=09=09=09=09=09 \ > > +=09=09" -device virtio-net-pci,netdev=3Dhostnet0,x-txburst=3D16384" \ > > +=09=09" -netdev socket,fd=3D5,id=3Dhostnet0"=09=09=09 \ > > +=09=09" -pidfile ${STATESETUP}/qemu.pid" > > +} > > + > > # teardown_distro() - Nothing to do, yet > > teardown_distro() { > > =09: > > @@ -36,3 +62,14 @@ teardown_pasta_options() { > > =09teardown_context_watch ${PANE_PASST} passt > > } > > =20 > > +# teardown_passt() - Kill qemu with ^C, remove passt PID file > > +teardown_memory() { > > +=09kill $(cat "${STATESETUP}/qemu.pid") > > + > > +=09rm "${STATESETUP}/passt.pid" > > + > > +=09tmux send-keys -t ${PANE_PASST} "C-c" =20 >=20 > You shouldn't need this for the passt pane, since it is context based, > the teardown_context_watch will do it. Oops, yes, I added this in a previous version where it was also not context based. I'll drop this, > > +=09teardown_context_watch ${PANE_PASST} passt > > +=09teardown_context_watch ${PANE_GUEST} qemu =20 >=20 > Likewise you don't want this for the guest pane since it is *not* > context based. =20 and this, of course. --=20 Stefano