|
|
b35c50 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
b35c50 |
From: Zhang Boyang <zhangboyang.id@gmail.com>
|
|
|
b35c50 |
Date: Sat, 15 Oct 2022 22:15:11 +0800
|
|
|
b35c50 |
Subject: [PATCH] mm: Try invalidate disk caches last when out of memory
|
|
|
b35c50 |
|
|
|
b35c50 |
Every heap grow will cause all disk caches invalidated which decreases
|
|
|
b35c50 |
performance severely. This patch moves disk cache invalidation code to
|
|
|
b35c50 |
the last of memory squeezing measures. So, disk caches are released only
|
|
|
b35c50 |
when there are no other ways to get free memory.
|
|
|
b35c50 |
|
|
|
b35c50 |
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
|
|
|
b35c50 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
b35c50 |
Reviewed-by: Patrick Steinhardt <ps@pks.im>
|
|
|
b35c50 |
(cherry picked from commit 17975d10a80e2457e5237f87fa58a7943031983e)
|
|
|
b35c50 |
---
|
|
|
b35c50 |
grub-core/kern/mm.c | 14 +++++++-------
|
|
|
b35c50 |
1 file changed, 7 insertions(+), 7 deletions(-)
|
|
|
b35c50 |
|
|
|
b35c50 |
diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
|
|
|
b35c50 |
index f2e27f263b..da1ac9427c 100644
|
|
|
b35c50 |
--- a/grub-core/kern/mm.c
|
|
|
b35c50 |
+++ b/grub-core/kern/mm.c
|
|
|
b35c50 |
@@ -443,12 +443,6 @@ grub_memalign (grub_size_t align, grub_size_t size)
|
|
|
b35c50 |
switch (count)
|
|
|
b35c50 |
{
|
|
|
b35c50 |
case 0:
|
|
|
b35c50 |
- /* Invalidate disk caches. */
|
|
|
b35c50 |
- grub_disk_cache_invalidate_all ();
|
|
|
b35c50 |
- count++;
|
|
|
b35c50 |
- goto again;
|
|
|
b35c50 |
-
|
|
|
b35c50 |
- case 1:
|
|
|
b35c50 |
/* Request additional pages, contiguous */
|
|
|
b35c50 |
count++;
|
|
|
b35c50 |
|
|
|
b35c50 |
@@ -458,7 +452,7 @@ grub_memalign (grub_size_t align, grub_size_t size)
|
|
|
b35c50 |
|
|
|
b35c50 |
/* fallthrough */
|
|
|
b35c50 |
|
|
|
b35c50 |
- case 2:
|
|
|
b35c50 |
+ case 1:
|
|
|
b35c50 |
/* Request additional pages, anything at all */
|
|
|
b35c50 |
count++;
|
|
|
b35c50 |
|
|
|
b35c50 |
@@ -474,6 +468,12 @@ grub_memalign (grub_size_t align, grub_size_t size)
|
|
|
b35c50 |
|
|
|
b35c50 |
/* fallthrough */
|
|
|
b35c50 |
|
|
|
b35c50 |
+ case 2:
|
|
|
b35c50 |
+ /* Invalidate disk caches. */
|
|
|
b35c50 |
+ grub_disk_cache_invalidate_all ();
|
|
|
b35c50 |
+ count++;
|
|
|
b35c50 |
+ goto again;
|
|
|
b35c50 |
+
|
|
|
b35c50 |
default:
|
|
|
b35c50 |
break;
|
|
|
b35c50 |
}
|