From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lNQKN-0008SF-4J for mharc-grub-devel@gnu.org; Fri, 19 Mar 2021 21:22:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNQKK-0008S0-AO for grub-devel@gnu.org; Fri, 19 Mar 2021 21:22:53 -0400 Received: from b-painless.mh.aa.net.uk ([2001:8b0:0:30::52]:37533) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNQKH-0003RI-SA for grub-devel@gnu.org; Fri, 19 Mar 2021 21:22:52 -0400 Received: from f.b.1.7.2.1.e.f.f.f.a.c.5.0.a.6.4.1.b.e.2.f.f.b.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:bff2:eb14:6a05:caff:fe12:71bf] helo=riva.pelham.vpn.ucam.org) by painless-b.tch.aa.net.uk with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lNQKE-00009Y-Kz; Sat, 20 Mar 2021 01:22:46 +0000 Received: from ns1.pelham.vpn.ucam.org ([172.20.153.2] helo=riva.ucam.org) by riva.pelham.vpn.ucam.org with esmtp (Exim 4.92) (envelope-from ) id 1lNQKC-00018b-W1; Sat, 20 Mar 2021 01:22:45 +0000 Date: Sat, 20 Mar 2021 01:22:44 +0000 From: Colin Watson To: grub-devel@gnu.org Cc: Vladimir Serbinenko Subject: [PATCH] kern/dl: Disable grub_dl_unload_unneeded Message-ID: <20210320012244.GA4330@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Received-SPF: none client-ip=2001:8b0:0:30::52; envelope-from=cjwatson@debian.org; helo=b-painless.mh.aa.net.uk X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Mar 2021 01:22:53 -0000 grub_dl_unload_unneeded has been unused by default since de04eecfa9 put its only call within an "#if 0", so there's no point in it sitting around taking up space in the core image. Turn the "#if 0" into "#ifdef GRUB_UNLOAD_UNNEEDED_MODULES" just in case somebody is turning this code back on locally for some reason, and guard all the relevant code with it rather than just the call in grub_memalign. DOWN: obj/i386-pc/grub-core/kernel.img (31740 > 31708) - change: -32 DOWN: i386-pc core image (biosdisk ext2 part_msdos) (27453 > 27430) - change: -23 DOWN: i386-pc core image (biosdisk ext2 part_msdos diskfilter mdraid09) (32367 > 32334) - change: -33 DOWN: i386-pc core image (biosdisk ext2 part_msdos lvm mdraid1x) (35595 > 35594) - change: -1 Signed-off-by: Colin Watson --- grub-core/kern/dl.c | 2 ++ grub-core/kern/mm.c | 2 +- include/grub/dl.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 48f8a7907..88cd2fddc 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -804,6 +804,7 @@ grub_dl_unload (grub_dl_t mod) return 1; } +#ifdef GRUB_UNLOAD_UNNEEDED_MODULES /* Unload unneeded modules. */ void grub_dl_unload_unneeded (void) @@ -823,3 +824,4 @@ grub_dl_unload_unneeded (void) p = p->next; } } +#endif diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c index c070afc62..a913d66bf 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c @@ -360,7 +360,7 @@ grub_memalign (grub_size_t align, grub_size_t size) count++; goto again; -#if 0 +#ifdef GRUB_UNLOAD_UNNEEDED_MODULES case 1: /* Unload unneeded modules. */ grub_dl_unload_unneeded (); diff --git a/include/grub/dl.h b/include/grub/dl.h index b3753c9ca..4a0712406 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -203,7 +203,9 @@ grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name); grub_dl_t grub_dl_load_core (void *addr, grub_size_t size); grub_dl_t EXPORT_FUNC(grub_dl_load_core_noinit) (void *addr, grub_size_t size); int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod); +#ifdef GRUB_UNLOAD_UNNEEDED_MODULES extern void grub_dl_unload_unneeded (void); +#endif extern int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod); extern int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod); extern int EXPORT_FUNC(grub_dl_ref_count) (grub_dl_t mod); -- 2.25.1