From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jDQiQ-0006nb-I1 for mharc-grub-devel@gnu.org; Sun, 15 Mar 2020 06:41:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39301) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDQiN-0006kg-9j for grub-devel@gnu.org; Sun, 15 Mar 2020 06:41:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDQiM-0007MF-4X for grub-devel@gnu.org; Sun, 15 Mar 2020 06:41:51 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:59173) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jDQiL-0007IG-Ld for grub-devel@gnu.org; Sun, 15 Mar 2020 06:41:50 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id BE72B4E0; Sun, 15 Mar 2020 06:41:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sun, 15 Mar 2020 06:41:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=13saUzu20WDZcbb5lRGNd3ZRyxB pLgK7XMjHjqU4mu0=; b=Xkw99rJTKo8x7UsxWS/mak2hvyW542vg99XEImWxWcE zIcXAbRcIMm2vmSxWsRME4J7Y/faPk/CVZOoMlo9iC1gMH55wSN3uY2QpuGTPOvk WNTx0JFANTFZdRXjzFIgiKNVY0N0QXoHE0cWm8DLAfp2Yq+M+B5v6oSQy+L0EKDl 3RI0h9a2zmP+0dtIDSDfxvQyU24LewPGYSRdptL8KIwWjNMKurlnaGbo8ob3BBr9 UDvXggbSR+Iph1Jf2rtQqYBAth9x941ykfueR/MvsuxH7hKUKYDjLEncU8eSD5Tw xelQkOHi+ob4yIXgZNaBltjdivREtUrkAyWStTqjQgw== 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=fm2; bh=13saUz u20WDZcbb5lRGNd3ZRyxBpLgK7XMjHjqU4mu0=; b=ylwSUwTdJKq7c5lrZzI1mi +FBL1onTe4YNEDmawNjxq/aeZJTJbqeeVAywSHnLvhNYJMOtXVAJ3JGzUomxngFd SCC4oy+4RmLe3BjVNnfoXzZvtoyYgH9nsDdSmY2gvO4a7PWyonQtc2OnC8oX4A4L sBaZWk3quYCVyjf5/0HOxuk5cuWm4Eo+1b/PsaPnMczOJSr2blR24/VZjUIlvBj4 R+w+FQp+m1UMrtkQTnYWpMdThdQ7Z1INperiTYS8BUephS2h95vA8+YTCfvcOd+B sem4AQoFcaRXLL1anIwACS1tupx5v2DRHIui9VhPMm1o8era8H6aBqtJ5Mo65H0A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudeftddgudefkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecukfhppeejkedrhe egrddukeehrdduieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: from vm-mail (x4e36b910.dyn.telefonica.de [78.54.185.16]) by mail.messagingengine.com (Postfix) with ESMTPA id 200C03061856; Sun, 15 Mar 2020 06:41:45 -0400 (EDT) Received: from localhost (ncase [10.192.0.11]) by vm-mail (OpenSMTPD) with ESMTPSA id 72a69433 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 15 Mar 2020 10:41:40 +0000 (UTC) Date: Sun, 15 Mar 2020 11:41:43 +0100 From: Patrick Steinhardt To: Leif Lindholm Cc: grub-devel@gnu.org, Daniel Kiper , agraf@csgraf.de, pjones@redhat.com, mjg59@google.com, phcoder@gmail.com, Milan Broz Subject: Re: [PATCH v3 1/5] efi: Always try to allocate heap size of 1.6GB Message-ID: <20200315104143.GB13363@ncase> References: <20200313125508.GO23627@bivouac.eciton.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4SFOXa2GPu3tIq4H" Content-Disposition: inline In-Reply-To: <20200313125508.GO23627@bivouac.eciton.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2020 10:41:52 -0000 --4SFOXa2GPu3tIq4H Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 13, 2020 at 12:55:08PM +0000, Leif Lindholm wrote: > My idea was something along the lines of (pseudocode - coding style, > macro use and naming may or may not be suitable): >=20 > target_heap_pages =3D MIN_HEAP_PAGES; > #ifdef GRUB_LUKS2_ARGON2_ENABLED > target_heap_pages +=3D GRUB_LUKS2_ARGON2_PAGES; > #endif >=20 > and then >=20 > if (target_heap_pages > (total_pages >> 2) > target_heap_pages =3D total_pages >> 2; >=20 > and then possibly >=20 > if (target_heap_pages > MAX_HEAP_PAGES) > target_heap_pages =3D MAX_HEAP_PAGES; What do you think about the following algorithm: /* Aim to satisfy requirements posed by both GRUB and other modules. */ target_pages =3D MIN_HEAP_PAGES; #ifdef GRUB_LUKS2_ARGON2_ENABLED target_pages +=3D GRUB_LUKS2_ARGON2_PAGES; #endif total_pages =3D get_total_pages (filtered_memory_map, desc_size, filtered_memory_map_end); /* By default, request a quarter of the available memory. */ required_pages =3D (total_pages >> 2); /* But try to satisfy requirements set forth by modules. */ required_pages =3D grub_max (required_pages, target_pages); /* And clamp to MIN_HEAP_PAGES <=3D required_pages <=3D MAX_HEAP_PAGES. = */ required_pages =3D grub_max (required_pages, MIN_HEAP_PAGES); required_pages =3D grub_min (required_pages, MAX_HEAP_PAGES); In the general case where GRUB_LUKS2_ARGON2_ENABLED is not set, it will behave exactly the same as before: we request a quarter of available pages and clamp to MIN_HEAP_PAGES <=3D required_pages <=3D MAX_HEAP_PAGES. If GRUB_LUKS2_ARGON2_ENABLED is set, it will also behave that way, except for the case where `required_pages < target_pages`, where we just set `required_pages =3D target_pages`. As we're still doing the clamping, we will end up with at most MAX_HEAP_PAGES (1.6GB), which should be sufficient. I think this is the least invasive way this can be implemented with minimal risk: in the general case it is exactly the same as before. Patrick --4SFOXa2GPu3tIq4H Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl5uBmQACgkQVbJhu7ck PpSj3A//atQMnAt2CfiVBNdSW+fe9e+raxEGx7afgRZri/mtaphthABFYkmC9xqE G+tN4AOHW5kcm5sl5mJLyo9jhtnUcOdsD33qupLGMa4+z9GWEpbDFG8qkWL9VZZp qRzUNqOdb84Ew8EE6JPK1Ez4TMXhoAOZGp+7QuKl2org3m1ZmRFqvOdDx9gzDDbv LbPFyNrPM1s28644OM3ZLrTUUIYsIudTQtnZuvWwzXxSiPxMSHomKP56pMgFAlVN pgkCtm4ETdFKmspYvqg1tyEZjnuW55zCOllgkaYGZImersRrXe5c/X8I7rnV9HpK sw+kWgtkkUezEV2Pjz6fo4HIYnM0w+1N3ggr7ZUkX84EO8iRxS4/xLmvuGdJLQfE DAPQepFXIyGSdOheFTFBPj4jTvf94qKmWdRd1FbUNThXgTVNnrLUYQ32YRdVVUUA tfy6wjOkZ4VPen0v3n/au3qDO4QMqEdVuZYTTC8YyQb7ysoFwTOulgjuH3o3yv6a R9oOBd78X98xWRdOMUKALcqZkaUrX+dBdOs0BJu6VjDVvlzfrNd7VtnEtObcWE+y Hjtb/rojzrsF2W7F9UYk8uaA2bU26ftq57fIlNs7kCMRXn8tQTTdmAhSIfFqM2f1 LcHcIDNdVwDMwm9CvQYeyM8XG8wxH540dALAqRqsyvN3qyY8UAQ= =DWTn -----END PGP SIGNATURE----- --4SFOXa2GPu3tIq4H--