Blame 0063-dracut-PATCH-es-parallelize-block_module-filter-and-.patch

Harald Hoyer 55891e
From d23159a69c818274486f1287ba6267b96f3febb7 Mon Sep 17 00:00:00 2001
Harald Hoyer 55891e
From: John Reiser <jreiser@bitwagon.com>
Harald Hoyer 55891e
Date: Fri, 23 Sep 2011 09:17:13 -0700
Harald Hoyer 55891e
Subject: [PATCH] dracut [PATCH]es: parallelize block_module filter and
Harald Hoyer 55891e
 net_module_filter
Harald Hoyer 55891e
Harald Hoyer 55891e
Filtering modules requires enough work that instmods() in the
Harald Hoyer 55891e
next pipeline stage was rarely busy.  Parallelize the two
Harald Hoyer 55891e
filters which do the most work.  Also fix a filename-vs-contents
Harald Hoyer 55891e
mistake in net_module_filter.
Harald Hoyer 55891e
Harald Hoyer 55891e
--
Harald Hoyer 55891e
John Reiser, jreiser@BitWagon.com
Harald Hoyer 55891e
Harald Hoyer 55891e
>From f4533a2ceca52c443ddebec01eeaa35d51c39c1b Mon Sep 17 00:00:00 2001
Harald Hoyer 55891e
From: John Reiser <jreiser@BitWagon.com>
Harald Hoyer 55891e
Date: Tue, 13 Sep 2011 17:41:43 -0700
Harald Hoyer 55891e
Subject: [PATCH 1/3] Parallelize block_module_filter
Harald Hoyer 55891e
---
Harald Hoyer 55891e
 modules.d/40network/module-setup.sh        |   33 +++++++++++++++++----------
Harald Hoyer 55891e
 modules.d/90kernel-modules/module-setup.sh |   22 +++++++++++++-----
Harald Hoyer 55891e
 2 files changed, 37 insertions(+), 18 deletions(-)
Harald Hoyer 55891e
Harald Hoyer 55891e
diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
Harald Hoyer 55891e
index cb81269..03684f1 100755
Harald Hoyer 55891e
--- a/modules.d/40network/module-setup.sh
Harald Hoyer 55891e
+++ b/modules.d/40network/module-setup.sh
Harald Hoyer 55891e
@@ -27,18 +27,27 @@ installkernel() {
Harald Hoyer 55891e
     net_module_filter() {
Harald Hoyer 55891e
         local _net_drivers='eth_type_trans|register_virtio_device'
Harald Hoyer 55891e
         local _unwanted_drivers='/(wireless|isdn|uwb)/'
Harald Hoyer 55891e
-        local _fname
Harald Hoyer 55891e
-        while read _fname; do
Harald Hoyer 55891e
-            local _fcont
Harald Hoyer 55891e
-            case "$_fname" in
Harald Hoyer 55891e
-                *.ko)    _fcont="$(<        $_fname)" ;;
Harald Hoyer 55891e
-                *.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
Harald Hoyer 55891e
-            esac
Harald Hoyer 55891e
-            [[   $_fcont =~ $_net_drivers
Harald Hoyer 55891e
-            && ! $_fcont =~ iw_handler_get_spy \
Harald Hoyer 55891e
-            && ! $_fname =~ $_unwanted_drivers ]] \
Harald Hoyer 55891e
-            && echo "$_fname"
Harald Hoyer 55891e
-        done
Harald Hoyer 55891e
+        function nmf1() {
Harald Hoyer 55891e
+            local _fname _fcont
Harald Hoyer 55891e
+            while read _fname; do
Harald Hoyer 55891e
+                [[ $_fname =~ $_unwanted_drivers ]] && continue
Harald Hoyer 55891e
+                case "$_fname" in
Harald Hoyer 55891e
+                    *.ko)    _fcont="$(<        $_fname)" ;;
Harald Hoyer 55891e
+                    *.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
Harald Hoyer 55891e
+                esac
Harald Hoyer 55891e
+                [[   $_fcont =~ $_net_drivers
Harald Hoyer 55891e
+                && ! $_fcont =~ iw_handler_get_spy ]] \
Harald Hoyer 55891e
+                && echo "$_fname"
Harald Hoyer 55891e
+            done
Harald Hoyer 55891e
+        }
Harald Hoyer 55891e
+        # Use two parallel streams to filter alternating modules.
Harald Hoyer 55891e
+        local merge side2
Harald Hoyer 55891e
+        ( ( local _f1 _f2
Harald Hoyer 55891e
+            while  read _f1; do   echo "$_f1"
Harald Hoyer 55891e
+                if read _f2; then echo "$_f2" 1>&${side2}; fi
Harald Hoyer 55891e
+            done \
Harald Hoyer 55891e
+            | nmf1     1>&${merge}    ) {side2}>&1 \
Harald Hoyer 55891e
+            | nmf1  )      {merge}>&1
Harald Hoyer 55891e
     }
Harald Hoyer 55891e
 
Harald Hoyer 55891e
     find_kernel_modules_by_path drivers/net | net_module_filter | instmods
Harald Hoyer 55891e
diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh
Harald Hoyer 55891e
index 9fc4248..09bd87e 100755
Harald Hoyer 55891e
--- a/modules.d/90kernel-modules/module-setup.sh
Harald Hoyer 55891e
+++ b/modules.d/90kernel-modules/module-setup.sh
Harald Hoyer 55891e
@@ -11,12 +11,22 @@ installkernel() {
Harald Hoyer 55891e
         }
Harald Hoyer 55891e
         block_module_filter() {
Harald Hoyer 55891e
             local _blockfuncs='ahci_init_controller|ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device'
Harald Hoyer 55891e
-            local _f
Harald Hoyer 55891e
-            while read _f; do case "$_f" in
Harald Hoyer 55891e
-                *.ko)    [[ $(<         $_f) =~ $_blockfuncs ]] && echo "$_f" ;;
Harald Hoyer 55891e
-                *.ko.gz) [[ $(gzip -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
Harald Hoyer 55891e
-                esac
Harald Hoyer 55891e
-            done
Harald Hoyer 55891e
+            function bmf1() {
Harald Hoyer 55891e
+                local _f
Harald Hoyer 55891e
+                while read _f; do case "$_f" in
Harald Hoyer 55891e
+                    *.ko)    [[ $(<         $_f) =~ $_blockfuncs ]] && echo "$_f" ;;
Harald Hoyer 55891e
+                    *.ko.gz) [[ $(gzip -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
Harald Hoyer 55891e
+                    esac
Harald Hoyer 55891e
+                done
Harald Hoyer 55891e
+            }
Harald Hoyer 55891e
+            # Use two parallel streams to filter alternating modules.
Harald Hoyer 55891e
+            local merge side2
Harald Hoyer 55891e
+            ( ( local _f1 _f2
Harald Hoyer 55891e
+                while  read _f1; do   echo "$_f1"
Harald Hoyer 55891e
+                    if read _f2; then echo "$_f2" 1>&${side2}; fi
Harald Hoyer 55891e
+                done \
Harald Hoyer 55891e
+                | bmf1     1>&${merge}    ) {side2}>&1 \
Harald Hoyer 55891e
+                | bmf1  )      {merge}>&1
Harald Hoyer 55891e
         }
Harald Hoyer 55891e
         hostonly='' instmods sr_mod sd_mod scsi_dh scsi_dh_rdac scsi_dh_emc
Harald Hoyer 55891e
         hostonly='' instmods pcmcia firewire-ohci