Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1955306pxb; Thu, 28 Oct 2021 13:18:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaTg08IZDgQOYHmw5qu8rMPXVVZjZaCic5RA3NPfleh27CWBMSwvKxhNavwe8bwXlr1XmP X-Received: by 2002:a17:902:6ac7:b0:140:14d5:cfb6 with SMTP id i7-20020a1709026ac700b0014014d5cfb6mr5767885plt.58.1635452313432; Thu, 28 Oct 2021 13:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635452313; cv=none; d=google.com; s=arc-20160816; b=vAHfZCwuws3GGzSM8q4leWIXSyH1zWmlRpP9hVuCZDUc/rJ+2f8fGR3u/e01/ZRdr8 HCj0Eu15ce7hnVT9Azr3A4/fjZ5PnaW43tjper0d5X9TncXlHiQ8FlRsMngMhNYffzD3 1FVBkuAEOa0emScnOm06jQ/iCKyXxy02K/aA4MbiMAzuEdAjGwck4VIHiWyKOalrkGVE 3ljvP5ZS3ZyVewkTEdSB/Pj95IAiJav12LzFqn/rnQyGWzcUB+cUPMP2oRpodpYac692 ihITFP5/85YuWTNWzy/qr4POi9oCPbnT+3oXwN3Ji3LfyIXVY/h4rhEbT7QdnpectZqU ve+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5lHMBpj8jcGhebPQpTOYiDXSyqlgx4IThAJ8eNFDX74=; b=a8ys5KNy/gJDowcq+50y5XAIX6Q2PZs1NT6OG9Qgt7jMNwXS7ikqGHEwW9RD4QLLTh N6D4uiEifLG2RG8jDjjengm9T1QBmFdDeecfaNjT++9EglTKgDXjYBcoKRHuSeXalpFb o7PCDgsw9vsebW69J6u5DstI94n1mRQSLZH/4ENC+dEpb8AeWBRykfnX8XRHJpvrRt5t kE8vUxzDR25k3TNzsrRcN0CSqXiDkxBkVg3NTVkZxbNoUjse7Sz37wokys1fteeFnY7n Pg0bZByEkugceYeG9mLa3io0SLQnsesw6+j77PodCD+PeYsDLf0LlwYRD9+xLGTfJprm VZKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=EdZx+kAd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w190si4727683pgd.354.2021.10.28.13.18.20; Thu, 28 Oct 2021 13:18:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=EdZx+kAd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230424AbhJ1UTe (ORCPT + 99 others); Thu, 28 Oct 2021 16:19:34 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:38061 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbhJ1UTd (ORCPT ); Thu, 28 Oct 2021 16:19:33 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 707855C00D4; Thu, 28 Oct 2021 16:17:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 28 Oct 2021 16:17:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=5lHMBp j8jcGhebPQpTOYiDXSyqlgx4IThAJ8eNFDX74=; b=EdZx+kAdnMwb+jYdhFSU3e bjAyzKrEqfJWbH8NMq+8P3rgLpwXXxothhyPrsrrB7FijmdAiE3kTdiSaL6ELrkT 6usso22/FeGG99cGO+Ph93+EJpvTpQEcnJWoyivkRRkiZJjj6bA2Urq20u3f9cQw +IvnaGABJKbPCBezGm7NpTY8bqaMWPNpXN/HHIFM98l8qNxwoZQ6l3u7F9rwv6Py GPv0hTLLcRhCHj9+tPx3DpKtsBAqWRuVhYW1Wq7M11DTUCSjWnFDxMGzlF66hdW4 w9438SdXzq3mTqfgWTnu9KpP07Ew1QKyAlYDPTmcGg1cVmBANbfP2ugyf6TB7VxQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvdegvddgheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeetveff iefghfekhffggeeffffhgeevieektedthfehveeiheeiiedtudegfeetffenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrghrmhgrrhgvkhes ihhnvhhishhisghlvghthhhinhhgshhlrggsrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 28 Oct 2021 16:17:03 -0400 (EDT) Date: Thu, 28 Oct 2021 22:16:59 +0200 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= To: Juergen Gross Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Boris Ostrovsky , Stefano Stabellini , stable@vger.kernel.org Subject: Re: [PATCH] xen/balloon: add late_initcall_sync() for initial ballooning done Message-ID: References: <20211028105952.10011-1-jgross@suse.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="E2YpY0crIIXSHyLi" Content-Disposition: inline In-Reply-To: <20211028105952.10011-1-jgross@suse.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --E2YpY0crIIXSHyLi Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Thu, 28 Oct 2021 22:16:59 +0200 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= To: Juergen Gross Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Boris Ostrovsky , Stefano Stabellini , stable@vger.kernel.org Subject: Re: [PATCH] xen/balloon: add late_initcall_sync() for initial ballooning done On Thu, Oct 28, 2021 at 12:59:52PM +0200, Juergen Gross wrote: > When running as PVH or HVM guest with actual memory < max memory the > hypervisor is using "populate on demand" in order to allow the guest > to balloon down from its maximum memory size. For this to work > correctly the guest must not touch more memory pages than its target > memory size as otherwise the PoD cache will be exhausted and the guest > is crashed as a result of that. >=20 > In extreme cases ballooning down might not be finished today before > the init process is started, which can consume lots of memory. >=20 > In order to avoid random boot crashes in such cases, add a late init > call to wait for ballooning down having finished for PVH/HVM guests. >=20 > Cc: > Reported-by: Marek Marczykowski-G=C3=B3recki > Signed-off-by: Juergen Gross It may happen that initial balloon down fails (state=3D=3DBP_ECANCELED). In that case, it waits indefinitely. I think it should rather report a failure (and panic? it's similar to OOM before PID 1 starts, so rather hard to recover), instead of hanging. Anyway, it does fix the boot crashes. > --- > drivers/xen/balloon.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) >=20 > diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c > index 3a50f097ed3e..d19b851c3d3b 100644 > --- a/drivers/xen/balloon.c > +++ b/drivers/xen/balloon.c > @@ -765,3 +765,23 @@ static int __init balloon_init(void) > return 0; > } > subsys_initcall(balloon_init); > + > +static int __init balloon_wait_finish(void) > +{ > + if (!xen_domain()) > + return -ENODEV; > + > + /* PV guests don't need to wait. */ > + if (xen_pv_domain() || !current_credit()) > + return 0; > + > + pr_info("Waiting for initial ballooning down having finished.\n"); > + > + while (current_credit()) > + schedule_timeout_interruptible(HZ / 10); > + > + pr_info("Initial ballooning down finished.\n"); > + > + return 0; > +} > +late_initcall_sync(balloon_wait_finish); > --=20 > 2.26.2 >=20 --=20 Best Regards, Marek Marczykowski-G=C3=B3recki Invisible Things Lab --E2YpY0crIIXSHyLi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhrpukzGPukRmQqkK24/THMrX1ywFAmF7BTsACgkQ24/THMrX 1yyExQf8C+Zlijc1idL0I+sDb62ywXLbZxjsytrZOhBRNZO84RpHwSdxw1Q3Nbpq KWfXMw4PJX6IWvACg4Oy7VVfpXR/6/pZLJStFl4j8iPha+gF5kph2uFwQhHbNjSO kk3E9UIQpwLHNixP4CPG5Aa74Ta8Seth7Fl63JpYc4H0eR4rwwEL2ifOz73ElBEK VpMxsPf/20XEHITTeluwxv/otMuZtBok9ZEC5irOmOfkghwVJ855dcBYk+FSFlX3 +1ZKbB+CU0SOkqnEjSBjlctJl9awkdpKD8voE1IjMDSDdGcDHE50MSjQdfZqtWF6 Ehku7nMKd8rRz8Xz1pwE3+3Ny2SlDw== =4WvB -----END PGP SIGNATURE----- --E2YpY0crIIXSHyLi--