From patchwork Fri Dec 1 10:29:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikunj A Dadhania X-Patchwork-Id: 843450 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yp9Wx12Dmz9t9n for ; Fri, 1 Dec 2017 21:30:21 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yp9Ww1NLWzDrZW for ; Fri, 1 Dec 2017 21:30:20 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=nikunj@linux.vnet.ibm.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yp9Wf2NSVzDrTp for ; Fri, 1 Dec 2017 21:30:01 +1100 (AEDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vB1ATGrU070941 for ; Fri, 1 Dec 2017 05:29:58 -0500 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ek229rxsj-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 01 Dec 2017 05:29:58 -0500 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 1 Dec 2017 10:29:55 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 1 Dec 2017 10:29:52 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vB1ATpop33947690; Fri, 1 Dec 2017 10:29:51 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 756E4A4053; Fri, 1 Dec 2017 10:24:22 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADABEA4040; Fri, 1 Dec 2017 10:24:21 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.124.35.65]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Dec 2017 10:24:19 +0000 (GMT) From: Nikunj A Dadhania To: slof@lists.ozlabs.org Date: Fri, 1 Dec 2017 15:59:46 +0530 X-Mailer: git-send-email 2.13.6 X-TM-AS-GCONF: 00 x-cbid: 17120110-0008-0000-0000-000004B1C1C1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17120110-0009-0000-0000-00001E44AA90 Message-Id: <20171201102946.15717-1-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-01_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712010132 Subject: [SLOF] [PATCH v2] boot: do not use catpad to concatenate strings X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" 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 --- 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 ;