nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0301-mm-Drop-unused-unloading-of-modules-on-OOM.patch

b35c50
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b35c50
From: Patrick Steinhardt <ps@pks.im>
b35c50
Date: Thu, 21 Apr 2022 15:24:17 +1000
b35c50
Subject: [PATCH] mm: Drop unused unloading of modules on OOM
b35c50
b35c50
In grub_memalign(), there's a commented section which would allow for
b35c50
unloading of unneeded modules in case where there is not enough free
b35c50
memory available to satisfy a request. Given that this code is never
b35c50
compiled in, let's remove it together with grub_dl_unload_unneeded().
b35c50
b35c50
Signed-off-by: Patrick Steinhardt <ps@pks.im>
b35c50
Signed-off-by: Daniel Axtens <dja@axtens.net>
b35c50
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
b35c50
Tested-by: Patrick Steinhardt <ps@pks.im>
b35c50
(cherry picked from commit 139fd9b134a01e0b5fe0ebefafa7f48d1ffb6d60)
b35c50
---
b35c50
 grub-core/kern/dl.c | 20 --------------------
b35c50
 grub-core/kern/mm.c |  8 --------
b35c50
 include/grub/dl.h   |  1 -
b35c50
 3 files changed, 29 deletions(-)
b35c50
b35c50
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
b35c50
index d5de80186f..ab9101a5ad 100644
b35c50
--- a/grub-core/kern/dl.c
b35c50
+++ b/grub-core/kern/dl.c
b35c50
@@ -998,23 +998,3 @@ grub_dl_unload (grub_dl_t mod)
b35c50
   grub_free (mod);
b35c50
   return 1;
b35c50
 }
b35c50
-
b35c50
-/* Unload unneeded modules.  */
b35c50
-void
b35c50
-grub_dl_unload_unneeded (void)
b35c50
-{
b35c50
-  /* Because grub_dl_remove modifies the list of modules, this
b35c50
-     implementation is tricky.  */
b35c50
-  grub_dl_t p = grub_dl_head;
b35c50
-
b35c50
-  while (p)
b35c50
-    {
b35c50
-      if (grub_dl_unload (p))
b35c50
-	{
b35c50
-	  p = grub_dl_head;
b35c50
-	  continue;
b35c50
-	}
b35c50
-
b35c50
-      p = p->next;
b35c50
-    }
b35c50
-}
b35c50
diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
b35c50
index 38bfb01df9..1825dc8289 100644
b35c50
--- a/grub-core/kern/mm.c
b35c50
+++ b/grub-core/kern/mm.c
b35c50
@@ -444,14 +444,6 @@ grub_memalign (grub_size_t align, grub_size_t size)
b35c50
       count++;
b35c50
       goto again;
b35c50
 
b35c50
-#if 0
b35c50
-    case 1:
b35c50
-      /* Unload unneeded modules.  */
b35c50
-      grub_dl_unload_unneeded ();
b35c50
-      count++;
b35c50
-      goto again;
b35c50
-#endif
b35c50
-
b35c50
     default:
b35c50
       break;
b35c50
     }
b35c50
diff --git a/include/grub/dl.h b/include/grub/dl.h
b35c50
index 45ac8e339f..6bc2560bf0 100644
b35c50
--- a/include/grub/dl.h
b35c50
+++ b/include/grub/dl.h
b35c50
@@ -206,7 +206,6 @@ grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name);
b35c50
 grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
b35c50
 grub_dl_t EXPORT_FUNC(grub_dl_load_core_noinit) (void *addr, grub_size_t size);
b35c50
 int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
b35c50
-extern void grub_dl_unload_unneeded (void);
b35c50
 extern int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
b35c50
 extern int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
b35c50
 extern int EXPORT_FUNC(grub_dl_ref_count) (grub_dl_t mod);