Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1ojcoi-0005bI-9N for mharc-grub-devel@gnu.org; Sat, 15 Oct 2022 04:46:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojcof-0005at-4e for grub-devel@gnu.org; Sat, 15 Oct 2022 04:46:45 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:56333) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojcod-0002gJ-5U for grub-devel@gnu.org; Sat, 15 Oct 2022 04:46:44 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 6C2B25C00CC; Sat, 15 Oct 2022 04:46:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 15 Oct 2022 04:46:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1665823600; x=1665910000; bh=Qr57XRfSRb xLWtcXC00RTZzBFUW3Vz/i49yqLhYpYwY=; b=fNvaRcviIAJJfvkVTY6soBnhQL zpctBLylWtDxxhfee2LxvTi0YezMZbEUmkTeJ9M7T3xpFfdlJJ006OiwUaYMzUW4 7MQesViqPGRM1sHwNARHiwZ68xHmuHuKmuOuxJZ8TpZ1X0dAY+roim4p5lB0mAZ9 u0Lx3CH64zMFr/8lu7yQS6IVnMh+c9srrWHuW6sCWWu7unN91ghG9bX2sgWxg9Sj bIt2nZ6qC/35eSKgIFmlYuY2wazEqUrAAfQ1e1YeNxpy5SvDlRmV47zb6Gi9Ue2d pD9yHypl2o7JAbTzwhm/h432uizN/IBSpYpWojhtXzFxNUFoV9OIwht6mEXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1665823600; x=1665910000; bh=Qr57XRfSRbxLWtcXC00RTZzBFUW3 Vz/i49yqLhYpYwY=; b=sBrUC7KOiXdDUpQzurBnLE9LVTscVdDGP6sNjDtIyvF3 bEEtqBp+6vOXMmbYDO+3CyVTLZ6sOuTlzy137U7CnTgGT/wEHWM0ylJcmWY/1vpE 6Auf5P5BcJWJtPbF7gy4FWEgvpT4LQmocdoHVwzSK9eu8XfNCXb5ly8HMfVZco3W vP+S/XqWB3LB/hA3gVUZ6qmf2+shS0htR28T01+Q51cUISp8ujyi28YcxtKmw/O0 eAh6Pi3I5zWl5nZhSUI36HUdeFNw2DmGKzkOpt15AzJksVxSeiz8io/B7rfZfKvc 5gBHAB5Z8/Rj8BsypxG7mO5qDXLW9ky1RtLchEco0w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekgedgtdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 15 Oct 2022 04:46:38 -0400 (EDT) Received: by pks.im (OpenSMTPD) with ESMTPSA id 4b1fee7e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 15 Oct 2022 08:46:34 +0000 (UTC) Date: Sat, 15 Oct 2022 10:46:55 +0200 From: Patrick Steinhardt To: Zhang Boyang Cc: grub-devel@gnu.org, dkiper@net-space.pl, jim945@mail.ru, glin@suse.com, dja@axtens.net, droidbittin@gmail.com, heinrich.schuchardt@canonical.com, langner.marcel@myiq.de, marcan@marcan.st Subject: Re: [RFC PATCH v3 1/2] mm: Try invalidate disk caches last when out of memory Message-ID: References: <20221013012919.173082-1-zhangboyang.id@gmail.com> <20221013012919.173082-2-zhangboyang.id@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="RZeEJ6MqGx9zSHeT" Content-Disposition: inline In-Reply-To: <20221013012919.173082-2-zhangboyang.id@gmail.com> Received-SPF: pass client-ip=66.111.4.25; envelope-from=ps@pks.im; helo=out1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2022 08:46:46 -0000 --RZeEJ6MqGx9zSHeT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 13, 2022 at 09:29:18AM +0800, Zhang Boyang wrote: > Previously, every heap grow will cause all disk caches invalidated, > which decreases performance severely. This patch moves disk cache > invalidation code to the last of memory squeezing measures, so disk > caches are released only when no other ways to get free memory. >=20 > Signed-off-by: Zhang Boyang > --- > grub-core/kern/mm.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) >=20 > diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c > index 75f6eacbe..ae2279133 100644 > --- a/grub-core/kern/mm.c > +++ b/grub-core/kern/mm.c > @@ -443,12 +443,6 @@ grub_memalign (grub_size_t align, grub_size_t size) > switch (count) > { > case 0: > - /* Invalidate disk caches. */ > - grub_disk_cache_invalidate_all (); > - count++; > - goto again; > - > - case 1: > /* Request additional pages, contiguous */ > count++; > =20 > @@ -458,7 +452,7 @@ grub_memalign (grub_size_t align, grub_size_t size) > =20 > /* fallthrough */ > =20 > - case 2: > + case 1: > /* Request additional pages, anything at all */ > count++; > =20 > @@ -474,6 +468,12 @@ grub_memalign (grub_size_t align, grub_size_t size) > =20 > /* fallthrough */ > =20 > + case 2: > + /* Invalidate disk caches. */ > + grub_disk_cache_invalidate_all (); > + count++; > + goto again; > + > default: > break; > } > --=20 > 2.30.2 >=20 Reviewed-by: Patrick Steinhardt --RZeEJ6MqGx9zSHeT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAmNKc34ACgkQVbJhu7ck PpRJLhAAp73nXhWVPR6tBBAj1MbqjWf6i2XBQXSNNwnD4KgDA4k4aYH7dWCHw0wV wah1FiKaiXFWaGRhxZNYy5X2o3Gcsi6pf6si8SPkAyzKN9QCVpOqO1emQn3RuxFf QCY9GMpIdY1ZBzYO8EiwdkO6KdslIajBqmLo2/a+wMSTCTdHcgPYXnJwx8TzerTC gOdBrZ1ldffLKVfqf5QjUa54wOucVYyKPeDhK8YDBiQz9uwzoNgRs8vCXa8avHG5 E1W69HoQh4xBmmQg5B7uZESmcK5wKtoW8N9nCBdQJ+2zGDOGPxHl9VgF5QOAXPx9 LYr98myzFFgKwJDW6QhnJ09s59H8jhb6ebSYtpgPm3U4SmrHdLR2ERNhZRbiJPgW oIPoJmhFh1IZqY0PqigeVDu0cyzWhVgG6E5dirgnW5fJfhNiK6V4oQeKoutLm5Ee c598zZb10mM/l1uq58vo5vLGYMOeWHYvXL33+QJtZNBOYw0QM7z+pDiSsnN6cWIs +rqVWl1JeEVPaOqMCHy4aoKNFJIf7IH7jyvv5QLeebm8MP8aqgmcUvbQ8c1yZTks 0g9jki8q9btDhFXiZGpfMHkqsZyMGpewSvK8f8Tn5KEH5DFoMbJSM94u9RBnxpuD mRWt8T+ty2pXojTMc9g5se0U71Nh4ndLHcoTv+leZFTFnGAURI0= =1ERW -----END PGP SIGNATURE----- --RZeEJ6MqGx9zSHeT--