You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.7 KiB
58 lines
1.7 KiB
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Zhang Boyang <zhangboyang.id@gmail.com>
|
|
Date: Sat, 15 Oct 2022 22:15:11 +0800
|
|
Subject: [PATCH] mm: Try invalidate disk caches last when out of memory
|
|
|
|
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 there are no other ways to get free memory.
|
|
|
|
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
Reviewed-by: Patrick Steinhardt <ps@pks.im>
|
|
(cherry picked from commit 17975d10a80e2457e5237f87fa58a7943031983e)
|
|
---
|
|
grub-core/kern/mm.c | 14 +++++++-------
|
|
1 file changed, 7 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
|
|
index f2e27f263b..da1ac9427c 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++;
|
|
|
|
@@ -458,7 +452,7 @@ grub_memalign (grub_size_t align, grub_size_t size)
|
|
|
|
/* fallthrough */
|
|
|
|
- case 2:
|
|
+ case 1:
|
|
/* Request additional pages, anything at all */
|
|
count++;
|
|
|
|
@@ -474,6 +468,12 @@ grub_memalign (grub_size_t align, grub_size_t size)
|
|
|
|
/* fallthrough */
|
|
|
|
+ case 2:
|
|
+ /* Invalidate disk caches. */
|
|
+ grub_disk_cache_invalidate_all ();
|
|
+ count++;
|
|
+ goto again;
|
|
+
|
|
default:
|
|
break;
|
|
}
|