[SLOF] [PATCH v2] boot: do not use catpad to concatenate strings

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Fri Dec 1 21:29:46 AEDT 2017


The catpad size is 1K size, which can be hit easily hit with around 20 devices
with bootindex.

Open code EVALUATE such that concatenation is not required. Replace usage of
$cat with a 16K buffer allocated here.

Reported here: https://github.com/qemu/SLOF/issues/3

Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>

---

qemu-system-ppc64 -nographic -nodefaults -serial stdio -monitor pty -m 2G \
-device virtio-scsi-pci    \
`for ((i=2;i<=50;i++)) ; \
do echo -n "  -drive file=/tmp/storage$i.qcow2,if=none,id=drive$i,format=qcow2 \
-device
scsi-hd,drive=drive$i,id=disk$i,channel=0,scsi-id=0,lun=$i,bootindex=$i"; \
done;` \
-drive file=guest.disk,if=none,id=drv1,format=qcow2,cache=none \
-device scsi-hd,drive=drv1,bootindex=1 -boot menu=on,splash-time=3000,strict=on
---
 slof/fs/boot.fs | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/slof/fs/boot.fs b/slof/fs/boot.fs
index 1fd7439..8a30195 100644
--- a/slof/fs/boot.fs
+++ b/slof/fs/boot.fs
@@ -15,6 +15,9 @@
 VARIABLE state-valid false state-valid !
 CREATE go-args 2 cells allot go-args 2 cells erase
 
+4000 CONSTANT BOOT_DEV_SIZE
+CREATE bootdev-buf BOOT_DEV_SIZE allot
+
 \ \\\\\\\\\\\\\\ Structure/Implementation Dependent Methods
 
 : $bootargs
@@ -24,13 +27,17 @@ CREATE go-args 2 cells allot go-args 2 cells erase
 ;
 
 : $bootdev ( -- device-name len )
-   bootdevice 2@ dup IF s"  " $cat THEN
+   bootdev-buf BOOT_DEV_SIZE erase
+   bootdevice 2@ dup IF
+      swap bootdev-buf 2 pick move
+      bootdev-buf swap s"  " string-cat
+   THEN
    s" diagnostic-mode?" evaluate IF
       s" diag-device" evaluate
    ELSE
       s" boot-device" evaluate
    THEN
-   $cat \ prepend bootdevice setting from vpd-bootlist
+   string-cat \ concatenate both
    strdup
    ?dup 0= IF
       disable-watchdog
@@ -51,7 +58,12 @@ CREATE go-args 2 cells allot go-args 2 cells erase
 ' (set-boot-device) to set-boot-device
 
 : (add-boot-device) ( str len -- )	\ Concatenate " str" to "bootdevice"
-   bootdevice 2@ ?dup IF $cat-space ELSE drop THEN set-boot-device
+   bootdevice 2@ ?dup IF
+      swap bootdev-buf 2 pick move
+      bootdev-buf swap s"  " string-cat
+      2swap string-cat
+   ELSE drop THEN
+   set-boot-device
 ;
 
 ' (add-boot-device) to add-boot-device
@@ -221,11 +233,19 @@ defer go ( -- )
    ELSE
       drop
    THEN
-   set-boot-args s" parse-load " $bootdev $cat strdup evaluate
+   set-boot-args
+   save-source  -1 to source-id
+   $bootdev dup #ib ! span ! to ib
+   0 >in !
+   ['] parse-load catch restore-source throw
 ;
 
 : load-next ( -- success )	\ Continue after go failed
-   load-list 2@ ?dup IF s" parse-load " 2swap $cat strdup evaluate
+   load-list 2@ ?dup IF
+      save-source  -1 to source-id
+      dup #ib ! span ! to ib
+      0 >in !
+      ['] parse-load catch restore-source throw
    ELSE drop false THEN
 ;
 
-- 
2.13.6



More information about the SLOF mailing list