supermin/0001-ext2-simplify-tracking-of-visited-modules.patch
Richard W.M. Jones 5c44b1ee43 Add all upstream patches since 5.1.15 was released.
- These should improve boot performance and initrd size.
2016-03-18 13:17:56 +00:00

56 lines
2.0 KiB
Diff

From 2f69f0f78f32e1860b003464eaa86d3e5f3280ae Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Thu, 18 Feb 2016 12:02:07 +0100
Subject: [PATCH 1/9] ext2: simplify tracking of visited modules
When visiting the modules we need to copy into the initrd, use a
simplier StringSet instead of a Hashtbl with bool values; this also
avoids the need for a separate variable with the number of modules
visited.
---
src/ext2_initrd.ml | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/ext2_initrd.ml b/src/ext2_initrd.ml
index 09536d3..63ed493 100644
--- a/src/ext2_initrd.ml
+++ b/src/ext2_initrd.ml
@@ -82,14 +82,13 @@ let rec build_initrd debug tmpdir modpath initrd =
(* Do depth-first search to locate the modules we need to load. Keep
* track of which modules we've added so we don't add them twice.
*)
- let visited = Hashtbl.create 13 in
- let loaded = ref 0 in
+ let visited = ref StringSet.empty in
let chan = open_out (initdir // "modules") in
let rec visit set =
StringSet.iter (
fun modl ->
- if not (Hashtbl.mem visited modl) then (
- Hashtbl.add visited modl true;
+ if not (StringSet.mem modl !visited) then (
+ visited := StringSet.add modl !visited;
if debug >= 2 then
printf "supermin: ext2: initrd: visiting module %s\n%!" modl;
@@ -141,7 +140,6 @@ let rec build_initrd debug tmpdir modpath initrd =
(* Write module name to 'modules' file. *)
fprintf chan "%s\n" basename;
- incr loaded
)
) set
in
@@ -149,7 +147,7 @@ let rec build_initrd debug tmpdir modpath initrd =
close_out chan;
if debug >= 1 then
- printf "supermin: ext2: wrote %d modules to minimal initrd\n%!" !loaded;
+ printf "supermin: ext2: wrote %d modules to minimal initrd\n%!" (StringSet.cardinal !visited);
(* This is the binary blob containing the init "script". *)
let init = binary_init () in
--
2.5.0