Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6C71C433ED for ; Fri, 16 Apr 2021 02:01:36 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 305576101E for ; Fri, 16 Apr 2021 02:01:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 305576101E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=invisiblethingslab.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.111553.213369 (Exim 4.92) (envelope-from ) id 1lXDnD-0000yE-4k; Fri, 16 Apr 2021 02:01:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 111553.213369; Fri, 16 Apr 2021 02:01:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lXDnC-0000y6-Va; Fri, 16 Apr 2021 02:01:10 +0000 Received: by outflank-mailman (input) for mailman id 111553; Fri, 16 Apr 2021 02:01:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lXDnC-0000y1-AT for xen-devel@lists.xenproject.org; Fri, 16 Apr 2021 02:01:10 +0000 Received: from out4-smtp.messagingengine.com (unknown [66.111.4.28]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id be0891ad-d479-450f-92fe-261c642593ef; Fri, 16 Apr 2021 02:01:09 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id BDED95C0065 for ; Thu, 15 Apr 2021 22:01:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 15 Apr 2021 22:01:08 -0400 Received: from mail-itl (ip5b434f04.dynamic.kabel-deutschland.de [91.67.79.4]) by mail.messagingengine.com (Postfix) with ESMTPA id 4A4EF24005A for ; Thu, 15 Apr 2021 22:01:08 -0400 (EDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: be0891ad-d479-450f-92fe-261c642593ef DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=ER5ob46IhoIPdLqiOw6y/LsjmCgWz DAdOxZJUDKZVPg=; b=oSRXTBMyPh+qwovt+Oj5xN/0vrvG9WBxumUvnfWMz55JC GwokOBg/4FJ6z39iTymiOeiPsIw3/qSKyLccpAaOmWScpNgEG0LW7xtFtrwHYll9 LYAw/T81lSCOdA8tAXrcWdVgBr1C7emFRG7C86xmmC/ckiW0Bft/TCveCh52nFui s28v00Zh1cVU5aEqstTjrMV+9NfWdlPxpcjgS9OLzx7jp0UnSYoglq35AZHiCvuJ V6IWTPGvA1ToFa3IE8BvS4Y7nL6FaO1RebfeW83yCeFOk8QKSfeZ6vwWpEPNZghE 6UasxxOAMjpIqss36pNicZrOGODGMkhBVy4t3jGGw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudelgedgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkgggtugesghdtreertd dtjeenucfhrhhomhepofgrrhgvkhcuofgrrhgtiiihkhhofihskhhiqdfikphrvggtkhhi uceomhgrrhhmrghrvghksehinhhvihhsihgslhgvthhhihhnghhslhgrsgdrtghomheqne cuggftrfgrthhtvghrnhepgfdvfffhiedvvdejleejfeehvdegffduhfekveejffehudeg leeutdeuleejvdelnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghdpmhgrrhhkmhgrih hlrdhorhhgpdhgihhthhhusgdrtghomhenucfkphepledurdeijedrjeelrdegnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvg hksehinhhvihhsihgslhgvthhhihhnghhslhgrsgdrtghomh X-ME-Proxy: Date: Fri, 16 Apr 2021 04:01:03 +0200 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= To: xen-devel Subject: Slow HVM start with direct kernel boot Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GYUzbTmlz0P1c9cp" Content-Disposition: inline --GYUzbTmlz0P1c9cp Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Fri, 16 Apr 2021 04:01:03 +0200 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= To: xen-devel Subject: Slow HVM start with direct kernel boot Hi, I observe much slower HVM start time than PVH, on Xen 4.14. It is using qemu in (linux) stubdomain and direct kernel boot. The overall difference is ~50s vs ~20s on some not particularly new laptop. On a newer one I get 24s vs 6s, but I choose to debug it on the older one, as the difference is more apparent. My measurements are taken with `time qvm-start `, which includes some (constant time) preparation, starting the domain via libvirt and then waiting until system is fully started. I've identified several factors: 1. qemu is running in stubdomain there - it needs to start, and also get all domU's disk attached - slowness of block script is doubled here (4 disks, configured as block devices so the simplest case - it takes nearly 2s to run all the scripts) 2. Linux in HVM takes 64MB for SWIOTLB, which is significant given the domU has 400MB in total - this makes later system startup slower (less page cache, some swapping) 3. Finally, there is a huge delay between starting qemu (actually, last line of SeaBIOS output) and first output from Linux - about 10s or more. For part of the debugging I've switched to qemu in dom0 - which reduced point 1 above, but other points still applies. What I've got so far for the above: 1. Some solutions discussed in https://lore.kernel.org/xen-devel/YGyCECo8O0rwS8Z5@mail-itl/ and https://xen.markmail.org/thread/ytikjjbs4kpihzi5. I've made the simplest test of replacing the whole block script with a one-liner xenstore-write (no locking, no sharing check etc), but it didn't helped much. 2. I don't have PCI passthrough there. Is the SWIOTLB needed there? Can I disable it (I know how to reduce its size with swiotlb=3D, but is there an option for disabling?) 3. This one, I discussed on IRC today and Anthony gave me this link: https://lore.kernel.org/xen-devel/20180216204031.000052e9@gmail.com/ I've applied the change to qemu (fw_cfg_init_io -> fw_cfg_init_io_dma), without any mentioned further work, and it does wonders already. The kernel loading time is reduced from 10-15s, down to 1-2s. That said, I/O handling in qemu seems to be slow. For example, a large amount of time is spent on locking/unlocking map-cache. I believe this may add to subjectively HVM feeling slower than PVH. Here is 'perf' report collected while domU was loading kernel (via fw_cfg apparently): https://gist.github.com/marmarek/350158269b77ebb8492d7c9392db686f --=20 Best Regards, Marek Marczykowski-G=C3=B3recki Invisible Things Lab --GYUzbTmlz0P1c9cp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhrpukzGPukRmQqkK24/THMrX1ywFAmB47+AACgkQ24/THMrX 1yyA+Qf/e4NkxDojZqQs29TKY23p/i+WMVFnvTFyR9EpOvwCoF85gv8zrRXmiELZ rd4GC5z3mm1XJ7HvTbc8I9bbrarI+A23U1c5iS4m5HjeSsZxFizH2aFNGWPQEP+L 2D94FOBrYMTDpQ6w5PcDSSU1oBKd1DqIyANkVPZxzaTWHuEgvKUoHy+IS3KlrUrl u9nsVKYF2o10KJ/P4tN+1JHIuPWBl4tn7aLpdVKuDTypJzVimGAaZUw2467vnMns ZgpY1AsUF0DN787D9IMELiDBOZ3gcdSclvs+Hv71UJxqvuaE9dWpOfO9byo9GHo6 MxY3s0m9tFBsxFa49PkR7bkH/e2jEQ== =+Usq -----END PGP SIGNATURE----- --GYUzbTmlz0P1c9cp--