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