Blame SOURCES/0308-mm-Try-invalidate-disk-caches-last-when-out-of-memor.patch

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