From nobody Tue Apr 16 06:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70217+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70217+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610528116; cv=none; d=zohomail.com; s=zohoarc; b=HcG7/Z9PEG7JFfv4jApU1xj+Pi2feQLHtCIrKp8QyoEvxJZhOJlp7VKJ1yTLFYK1LmLokHuHfnjqyIwr5ADavJ48rnx6cMEmcxXpo7I8pIZ9J73bPHBfqlN14aJjDZNCCVIVpkbyiNqJJYkYkIGiCLaJFG1q82lAJyvHQsV2Siw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610528116; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ifrSK5DvpKdU7yhE8+uk7QShP2DxLK8Thj0DAHaMUWw=; b=dh11yeKbvnGgVNz3sVlYcVRE/ihpIjWkUQWSveiSZGbI4TFU778lAsSu/fkwpwcbqZ7cfiPwW+j/+IA1dReqTMpyV3dBdebGk88lVG8qrxIlmUIinJaESIJWldqv9ez6DNPmjvDQyL+NMyLrz3BQTHJVqHASF5rBGeng+BZRiQ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70217+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610528116196922.7096002278944; Wed, 13 Jan 2021 00:55:16 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id W878YY1788612xPSQa5tBK9V; Wed, 13 Jan 2021 00:55:15 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web11.5496.1610528110190179458 for ; Wed, 13 Jan 2021 00:55:10 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-507-Jz1UVM_4MFSVeojQbaP2AQ-1; Wed, 13 Jan 2021 03:55:02 -0500 X-MC-Unique: Jz1UVM_4MFSVeojQbaP2AQ-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 331E28144E6; Wed, 13 Jan 2021 08:55:01 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-238.ams2.redhat.com [10.36.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A2AD5C239; Wed, 13 Jan 2021 08:54:58 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ray Ni , Zhichao Gao Subject: [edk2-devel] [PATCH v2 01/10] ShellPkg/Comp: add file buffering Date: Wed, 13 Jan 2021 09:54:44 +0100 Message-Id: <20210113085453.10168-2-lersek@redhat.com> In-Reply-To: <20210113085453.10168-1-lersek@redhat.com> References: <20210113085453.10168-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: 8rWyMxw4lgvfKaEUaHIuy4pLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610528115; bh=ifrSK5DvpKdU7yhE8+uk7QShP2DxLK8Thj0DAHaMUWw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=QuGZYZszayHXTnidqQlb7gXjYh/aSlULf1HksiLmTHqMMZ2jVWnuf/vLjsJ2dXolqXx 73lU68LMogSZCoPG/CTHeCy5ALYmF/2HD/3SZr0WTvfgGknx8u80/wXLLAnG9bdEUGpqI gfwrlx1aftx+9PEk/Q8sorut8JuxsN8P+es= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The COMP shell command compares two files byte for byte. In order to retrieve the bytes to compare, it currently invokes gEfiShellProtocol->ReadFile() on both files, using a single-byte buffer every time. This is very inefficient; the underlying EFI_FILE_PROTOCOL.Read() function may be costly. Read both file operands in chunks of "PcdShellFileOperationSize" bytes. Draw bytes for comparison from the internal read-ahead buffers. Some ad-hoc measurements on my laptop, using OVMF, and the 4KB default of "PcdShellFileOperationSize": - When comparing two identical 1MB files that are served by EnhancedFatDxe on top of VirtioScsiDxe, this patch brings no noticeable improvement; the comparison completes in <1s both before and after. - When comparing two identical 1MB files served by VirtioFsDxe, the comparison time improves from 2 minutes 25 seconds to <1s. Cc: Philippe Mathieu-Daud=C3=A9 Cc: Ray Ni Cc: Zhichao Gao Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3123 Signed-off-by: Laszlo Ersek Reviewed-by: Zhichao Gao Reviewed-by: Philippe Mathieu-Daude --- Notes: v2: - no changes - pick up Zhichao's R-b ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf= | 1 + ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c = | 127 +++++++++++++++++++- 2 files changed, 125 insertions(+), 3 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Com= mandsLib.inf b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1C= ommandsLib.inf index ed94477a0642..74ad5facf6b1 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLi= b.inf +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLi= b.inf @@ -113,6 +113,7 @@ [LibraryClasses] BcfgCommandLib =20 [Pcd] + gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize ## CONSUMES gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask ## CONSUMES =20 [Protocols] diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c b/ShellPkg/= Library/UefiShellDebug1CommandsLib/Comp.c index 0a5d13f01c7b..0df0b3149369 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c @@ -21,6 +21,16 @@ typedef enum { InPrevDiffPoint } READ_STATUS; =20 +// +// Buffer type, for reading both file operands in chunks. +// +typedef struct { + UINT8 *Data; // dynamically allocated buffer + UINTN Allocated; // the allocated size of Data + UINTN Next; // next position in Data to fetch a byte at + UINTN Left; // number of bytes left in Data for fetching at Next +} FILE_BUFFER; + /** Function to print differnt point data. =20 @@ -76,6 +86,106 @@ PrintDifferentPoint( ShellPrintEx (-1, -1, L"*\r\n"); } =20 +/** + Initialize a FILE_BUFFER. + + @param[out] FileBuffer The FILE_BUFFER to initialize. On return, the ca= ller + is responsible for checking FileBuffer->Data: if + FileBuffer->Data is NULL on output, then memory + allocation failed. +**/ +STATIC +VOID +FileBufferInit ( + OUT FILE_BUFFER *FileBuffer + ) +{ + FileBuffer->Allocated =3D PcdGet32 (PcdShellFileOperationSize); + FileBuffer->Data =3D AllocatePool (FileBuffer->Allocated); + FileBuffer->Left =3D 0; +} + +/** + Uninitialize a FILE_BUFFER. + + @param[in,out] FileBuffer The FILE_BUFFER to uninitialize. The caller is + responsible for making sure FileBuffer was fi= rst + initialized with FileBufferInit(), successful= ly or + unsuccessfully. +**/ +STATIC +VOID +FileBufferUninit ( + IN OUT FILE_BUFFER *FileBuffer + ) +{ + SHELL_FREE_NON_NULL (FileBuffer->Data); +} + +/** + Read a byte from a SHELL_FILE_HANDLE, buffered with a FILE_BUFFER. + + @param[in] FileHandle The SHELL_FILE_HANDLE to replenish FileBuffer + from, if needed. + + @param[in,out] FileBuffer The FILE_BUFFER to read a byte from. If FileB= uffer + is empty on entry, then FileBuffer is refilled + from FileHandle, before outputting a byte from + FileBuffer to Byte. The caller is responsible= for + ensuring that FileBuffer was successfully + initialized with FileBufferInit(). + + @param[out] BytesRead On successful return, BytesRead is set to 1 i= f the + next byte from FileBuffer has been stored to = Byte. + On successful return, BytesRead is set to 0 if + FileBuffer is empty, and FileHandle is at EOF. + When an error is returned, BytesRead is not s= et. + + @param[out] Byte On output, the next byte from FileBuffer. Onl= y set + if (a) EFI_SUCCESS is returned and (b) BytesR= ead + is set to 1 on output. + + @retval EFI_SUCCESS BytesRead has been set to 0 or 1. In the latter cas= e, + Byte has been set as well. + + @return Error codes propagated from + gEfiShellProtocol->ReadFile(). +**/ +STATIC +EFI_STATUS +FileBufferReadByte ( + IN SHELL_FILE_HANDLE FileHandle, + IN OUT FILE_BUFFER *FileBuffer, + OUT UINTN *BytesRead, + OUT UINT8 *Byte + ) +{ + UINTN ReadSize; + EFI_STATUS Status; + + if (FileBuffer->Left =3D=3D 0) { + ReadSize =3D FileBuffer->Allocated; + Status =3D gEfiShellProtocol->ReadFile (FileHandle, &ReadSize, + FileBuffer->Data); + if (EFI_ERROR (Status)) { + return Status; + } + if (ReadSize =3D=3D 0) { + *BytesRead =3D 0; + return EFI_SUCCESS; + } + FileBuffer->Next =3D 0; + FileBuffer->Left =3D ReadSize; + } + + *BytesRead =3D 1; + *Byte =3D FileBuffer->Data[FileBuffer->Next]; + + FileBuffer->Next++; + FileBuffer->Left--; + return EFI_SUCCESS; +} + /** Function for 'comp' command. =20 @@ -107,6 +217,8 @@ ShellCommandRunComp ( UINT8 OneByteFromFile2; UINT8 *DataFromFile1; UINT8 *DataFromFile2; + FILE_BUFFER FileBuffer1; + FILE_BUFFER FileBuffer2; UINTN InsertPosition1; UINTN InsertPosition2; UINTN DataSizeFromFile1; @@ -234,10 +346,15 @@ ShellCommandRunComp ( if (ShellStatus =3D=3D SHELL_SUCCESS) { DataFromFile1 =3D AllocateZeroPool ((UINTN)DifferentBytes); DataFromFile2 =3D AllocateZeroPool ((UINTN)DifferentBytes); - if (DataFromFile1 =3D=3D NULL || DataFromFile2 =3D=3D NULL) { + FileBufferInit (&FileBuffer1); + FileBufferInit (&FileBuffer2); + if (DataFromFile1 =3D=3D NULL || DataFromFile2 =3D=3D NULL || + FileBuffer1.Data =3D=3D NULL || FileBuffer2.Data =3D=3D NULL) { ShellStatus =3D SHELL_OUT_OF_RESOURCES; SHELL_FREE_NON_NULL (DataFromFile1); SHELL_FREE_NON_NULL (DataFromFile2); + FileBufferUninit (&FileBuffer1); + FileBufferUninit (&FileBuffer2); } } =20 @@ -247,9 +364,11 @@ ShellCommandRunComp ( DataSizeFromFile2 =3D 1; OneByteFromFile1 =3D 0; OneByteFromFile2 =3D 0; - Status =3D gEfiShellProtocol->ReadFile (FileHandle1, &DataSizeFr= omFile1, &OneByteFromFile1); + Status =3D FileBufferReadByte (FileHandle1, &FileBuffer1, + &DataSizeFromFile1, &OneByteFromFile1); ASSERT_EFI_ERROR (Status); - Status =3D gEfiShellProtocol->ReadFile (FileHandle2, &DataSizeFr= omFile2, &OneByteFromFile2); + Status =3D FileBufferReadByte (FileHandle2, &FileBuffer2, + &DataSizeFromFile2, &OneByteFromFile2); ASSERT_EFI_ERROR (Status); =20 TempAddress++; @@ -346,6 +465,8 @@ ShellCommandRunComp ( =20 SHELL_FREE_NON_NULL (DataFromFile1); SHELL_FREE_NON_NULL (DataFromFile2); + FileBufferUninit (&FileBuffer1); + FileBufferUninit (&FileBuffer2); =20 if (DiffPointNumber =3D=3D 0) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS= ), gShellDebug1HiiHandle); --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70217): https://edk2.groups.io/g/devel/message/70217 Mute This Topic: https://groups.io/mt/79646579/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Apr 16 06:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70215+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70215+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610528110; cv=none; d=zohomail.com; s=zohoarc; b=dc8RsVIYvcNUmYm8ctthAac3mbo2lFCm4K7SdJHjAa7piSu3CaJjkJQVYnZG3Tdqd+zJqNBzQhTFbdWrVmnBj5r0zVlw2fRavYNIXtVCeYvpq+9q8rluK9vpFbEhZ7mqtg+9EovHoGbyCPyC1joof2uQWT7m9ra/GVWQGPtCtqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610528110; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=h7OhnTVnRfFUkWTndEndTCC+2FZZoEDJliPamCFOtOY=; b=CyMdtcRmIieDb7cVtqfM13iNGZBLIDfIAKnXDcwlfT9QzNdA2+ozbPWRjls8s0/5ljVsxQ7Plbcw15s/2aaZpB4vOHHQy194yn7qCEGqxVmQJCuAb62rmI8Zln67w8gBOfTrIk7Yxx4oLIHQoDaOpixQmvIMim5izPqzGmiBoPk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70215+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610528110452463.6572476769941; Wed, 13 Jan 2021 00:55:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0MMEYY1788612xSBUqIzshyA; Wed, 13 Jan 2021 00:55:09 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web12.5423.1610528108418628397 for ; Wed, 13 Jan 2021 00:55:08 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-157-oGNtVTtONP2bX15KL8CmZA-1; Wed, 13 Jan 2021 03:55:05 -0500 X-MC-Unique: oGNtVTtONP2bX15KL8CmZA-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B327D100C661; Wed, 13 Jan 2021 08:55:04 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-238.ams2.redhat.com [10.36.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id A15E471D5C; Wed, 13 Jan 2021 08:55:01 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Jordan Justen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [PATCH v2 02/10] OvmfPkg: raise PcdShellFileOperationSize to 128KB Date: Wed, 13 Jan 2021 09:54:45 +0100 Message-Id: <20210113085453.10168-3-lersek@redhat.com> In-Reply-To: <20210113085453.10168-1-lersek@redhat.com> References: <20210113085453.10168-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: wO06Cu37bSGGmfHZ9x6s58Ivx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610528109; bh=h7OhnTVnRfFUkWTndEndTCC+2FZZoEDJliPamCFOtOY=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=nRvfPzqAzlwI4PaVinXrtj6CBXk/xobiDTHErx4BnEdwvtI4FaKtgNaPXYD9bWD1rt/ itrjE11xbuPRbjKd4H7Kbkq/J4FgyZUGP2e0+IRJuUlAmpXIN7pZ83L6dsKnnwAyyJb+J R0joThFDF0e1YGwTMIooHOH03jrMZ9vCYIA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Some UEFI shell commands read and write files in chunks. The chunk size is given by "PcdShellFileOperationSize", whose default in "ShellPkg/ShellPkg.dec" is 4KB (0x1000). The virtio-fs daemon of QEMU advertizes a 128KB maximum buffer size by default, for the FUSE_WRITE operation. By raising PcdShellFileOperationSize 32-fold, the number of FUSE write requests shrinks proportionately, when writing large files. And when a Virtio Filesystem is not used, a 128KB chunk size is still not particularly wasteful. Some ad-hoc measurements on my laptop, using OVMF: - The time it takes to copy a ~270MB file from a Virtio Filesystem to the same Virtio Filesystem improves from ~9 seconds to ~1 second. - The time it takes to compare two identical ~270MB files on the same Virtio Filesystem improves from ~11 seconds to ~3 seconds. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Philippe Mathieu-Daud=C3=A9 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3125 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude --- Notes: v2: - no changes - pick up Ard's A-b OvmfPkg/OvmfPkgIa32.dsc | 2 ++ OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++ OvmfPkg/OvmfPkgX64.dsc | 2 ++ 3 files changed, 6 insertions(+) diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 75c5f46a7786..8b6dbb834505 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -562,6 +562,8 @@ [PcdsFixedAtBuild] # !include NetworkPkg/NetworkPcds.dsc.inc =20 + gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000 + !if $(SMM_REQUIRE) =3D=3D TRUE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x4000 !endif diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 8693248b4ea0..4d7a26636a72 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -568,6 +568,8 @@ [PcdsFixedAtBuild.X64] # !include NetworkPkg/NetworkPcds.dsc.inc =20 + gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000 + !if $(SMM_REQUIRE) =3D=3D TRUE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x4000 !endif diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 70ff2bcf2342..10f6a64d7f47 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -568,6 +568,8 @@ [PcdsFixedAtBuild] # !include NetworkPkg/NetworkPcds.dsc.inc =20 + gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000 + !if $(SMM_REQUIRE) =3D=3D TRUE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x4000 !endif --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70215): https://edk2.groups.io/g/devel/message/70215 Mute This Topic: https://groups.io/mt/79646576/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Apr 16 06:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70218+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70218+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610528115; cv=none; d=zohomail.com; s=zohoarc; b=BHPZFpokjU6zqxWTOpy+/hOC2rdhrX4ppnNQ6EFWS2yC7Khm0dq+r27lvVEfJN3VT2InI3ZhqwRuD6Gu+i1Xm5wG93BWDftTFrg0JUwy8v0E/s2OU79RWrRXsiB+q4BOf3NceHwbzs6F8pyI9DnEz9fbW2ypP8YPHv8F+AKgaOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610528115; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=9/vPxJt9caJysgNFFoTiTqYAV2b9KhjNZgfO3SxVSLI=; b=F4kXiucRIU96aFoVnkHVPNSnlE1COxGMB3/SHZ5HHlBNye34G5WtqT5YhyMwWOY+zESz/Z83N1h2i/P+YfFfzJ09EMyqZP7QOyd6v4hvP78WeFx1Ayy2Ah60qX45L5A6GjiAof95OToVrdbePbt56X0rSb4K/7SSPgt+6c4PCRs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70218+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610528115618705.882685601115; Wed, 13 Jan 2021 00:55:15 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id x6tfYY1788612xH8TyVWvl2u; Wed, 13 Jan 2021 00:55:15 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web11.5498.1610528114627357142 for ; Wed, 13 Jan 2021 00:55:14 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-TgzXqNWMOB-E4sta9GkOjA-1; Wed, 13 Jan 2021 03:55:12 -0500 X-MC-Unique: TgzXqNWMOB-E4sta9GkOjA-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 09E348144F4; Wed, 13 Jan 2021 08:55:11 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-238.ams2.redhat.com [10.36.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11A9571D5C; Wed, 13 Jan 2021 08:55:04 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [PATCH v2 03/10] ArmVirtPkg: raise PcdShellFileOperationSize to 128KB Date: Wed, 13 Jan 2021 09:54:46 +0100 Message-Id: <20210113085453.10168-4-lersek@redhat.com> In-Reply-To: <20210113085453.10168-1-lersek@redhat.com> References: <20210113085453.10168-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: wmhl1PJJzaYznPwH06ssJdRlx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610528115; bh=9/vPxJt9caJysgNFFoTiTqYAV2b9KhjNZgfO3SxVSLI=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=i6N9UYBe+c7aVBdFnzjr9AUzpX2cCDMADdBMy+Oa6s3rpGlTjsvd0bE0GsNWxel3c1i yu1/Qe1QAFsnUJvAfU7qegbRyvEu+h1TcEi/mgalmRB4U8Zp4F+TVfKRaO9vCDJemodO2 SD8bwoYBh0tnqQBWRjuvzMeQTD9BmsTUhTk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Some UEFI shell commands read and write files in chunks. The chunk size is given by "PcdShellFileOperationSize", whose default in "ShellPkg/ShellPkg.dec" is 4KB (0x1000). The virtio-fs daemon of QEMU advertizes a 128KB maximum buffer size by default, for the FUSE_WRITE operation. By raising PcdShellFileOperationSize 32-fold, the number of FUSE write requests shrinks proportionately, when writing large files. And when a Virtio Filesystem is not used, a 128KB chunk size is still not particularly wasteful. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Philippe Mathieu-Daud=C3=A9 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3125 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude --- Notes: v2: - no changes - pick up Ard's A-b ArmVirtPkg/ArmVirtQemu.dsc | 1 + ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 + 2 files changed, 2 insertions(+) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index ef5d6dbeaddc..b8bc08d73921 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -204,6 +204,7 @@ [PcdsFixedAtBuild.common] !endif =20 gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|3 + gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000 =20 [PcdsFixedAtBuild.AARCH64] # Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS entry po= int, diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKerne= l.dsc index f8f5f7f4b94b..2ef86f96688f 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -174,6 +174,7 @@ [PcdsFixedAtBuild.common] !endif =20 gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|3 + gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000 =20 [PcdsPatchableInModule.common] # we need to provide a resolution for this PCD that supports PcdSet64() --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70218): https://edk2.groups.io/g/devel/message/70218 Mute This Topic: https://groups.io/mt/79646580/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Apr 16 06:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70219+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70219+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610528121; cv=none; d=zohomail.com; s=zohoarc; b=NyMsqZx21f8670A73CJm6qYeiViug/a3oji28CaWsvgbE0SHi2+AMNaAwTzx4se40swHZTdeMdRV7fVoMCChaz1w+QyV3CO9YJ+0WIWAEfv2K2XFCBR0pS7pqNe8qknGS5Cd0JGHuCUpcH+oPHRNwG3cZ+zgsVNzz+/GTACxDNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610528121; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=j9dhJj473cVA6vrG3NxBU6/5X5vcT8Hprjk6djT1ntQ=; b=AKH9DbWeHX52ZuvUe/DIfHNFD8sjJy/13ku8FSwWlmY82Y0GkmQKvfH3MyUmeuOztdc70iYqF1ULSydw0x4LKcZBoBBdfz3G/qJFElAg1jjcPnmIzKakgdwJJeb/v4j3dDEPG+XpncKxAkT1FumsXaO8ngzINC1SWytXEaePfh4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70219+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610528121763362.13500167075335; Wed, 13 Jan 2021 00:55:21 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id e3PDYY1788612x0pjIqnkrkU; Wed, 13 Jan 2021 00:55:21 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web08.5571.1610528120882104763 for ; Wed, 13 Jan 2021 00:55:21 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-586-Jp6GPixmP3CB3Mw9-oJnxw-1; Wed, 13 Jan 2021 03:55:16 -0500 X-MC-Unique: Jp6GPixmP3CB3Mw9-oJnxw-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C26AAFA8F; Wed, 13 Jan 2021 08:55:15 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-238.ams2.redhat.com [10.36.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D72771D5C; Wed, 13 Jan 2021 08:55:11 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Andrew Fish , Jordan Justen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ray Ni Subject: [edk2-devel] [PATCH v2 04/10] EmulatorPkg: add OrderedCollectionLib class resolution Date: Wed, 13 Jan 2021 09:54:47 +0100 Message-Id: <20210113085453.10168-5-lersek@redhat.com> In-Reply-To: <20210113085453.10168-1-lersek@redhat.com> References: <20210113085453.10168-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: nQwOPmz0gYzzeI53C4ufHxzGx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610528121; bh=j9dhJj473cVA6vrG3NxBU6/5X5vcT8Hprjk6djT1ntQ=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Aw7DrwYB6/uXn3dYMi4tRxE+R0kY73jCUsrXKB9tJEllXlgAt105bViK6inS640fdFu 4PiFYPHhst6F9RFgfNnU5Xfr2QruUUpiQhQgtaiyjzrHHEC64oa/aHzOXm0BxfaGBgx5q 1Dragtqfdr4pAiMSJhoBdqpKxS9Sq5lqKEg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" A subsequent patch in the series will make the ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf instance dependent on the OrderedCollectionLib class. Because the shell binary in this platform consumes the above UefiShellCommandLib instance, resolve OrderedCollectionLib. Cc: Andrew Fish Cc: Jordan Justen Cc: Philippe Mathieu-Daud=C3=A9 Cc: Ray Ni Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3151 Signed-off-by: Laszlo Ersek Acked-by: Liming Gao Reviewed-by: Philippe Mathieu-Daude --- Notes: v2: - new patch EmulatorPkg/EmulatorPkg.dsc | 1 + 1 file changed, 1 insertion(+) diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc index de8144844c57..9ecc37334305 100644 --- a/EmulatorPkg/EmulatorPkg.dsc +++ b/EmulatorPkg/EmulatorPkg.dsc @@ -453,6 +453,7 @@ [Components] NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1= CommandsLib.inf NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1= CommandsLib.inf HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandlePar= singLib.inf + OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTre= eLib/BaseOrderedCollectionRedBlackTreeLib.inf SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf # SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70219): https://edk2.groups.io/g/devel/message/70219 Mute This Topic: https://groups.io/mt/79646581/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Apr 16 06:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70220+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70220+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610528124; cv=none; d=zohomail.com; s=zohoarc; b=U34d3AiC3AKR1YsCJ/DL8xFivJhPop8Fx1P7kCvnvDSM5X0tB2loEfnZWg+NPBRCh3Howae1vndGMMF1RU000WmvqCU/Ya18juwDRO0iXheXQM2l2UhUH6VtyetDO6lZUCwA4/cpXk9HUjcZmdbjE9Drg1TclDv8OJOEqJkt7Fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610528124; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=KtSREWkPXFYv96J06WQVNd1Cl/vz0A8se8YWS4fF3oQ=; b=KNPnkmliWUG9axEnL7ZTFYMW3eBQ31dILPlt3POwiID9th+WvMVOB3+PH+lSrq8EOoTBXnj/j+ZhI2WfbxbRSym5IFuKWl328t9MEzpgWA0JkLUac+HDF+mPqKRLmD7O2f2YorKqTjddL9WyS6vfAmZBaeZ5KE1VO06RBBY2Ar0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70220+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610528124651266.35850104038; Wed, 13 Jan 2021 00:55:24 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 446CYY1788612xbKYhSnlm4D; Wed, 13 Jan 2021 00:55:24 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web12.5428.1610528123467340104 for ; Wed, 13 Jan 2021 00:55:23 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-QA0ZLDhqMgqsqVIM_52XQA-1; Wed, 13 Jan 2021 03:55:19 -0500 X-MC-Unique: QA0ZLDhqMgqsqVIM_52XQA-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D7FA28144EB; Wed, 13 Jan 2021 08:55:17 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-238.ams2.redhat.com [10.36.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E7095C239; Wed, 13 Jan 2021 08:55:15 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Benjamin You , Guo Dong , Maurice Ma , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [PATCH v2 05/10] UefiPayloadPkg: add OrderedCollectionLib class resolution Date: Wed, 13 Jan 2021 09:54:48 +0100 Message-Id: <20210113085453.10168-6-lersek@redhat.com> In-Reply-To: <20210113085453.10168-1-lersek@redhat.com> References: <20210113085453.10168-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: nOTnAqkmOrZ9LIe9LSXgkEHrx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610528124; bh=KtSREWkPXFYv96J06WQVNd1Cl/vz0A8se8YWS4fF3oQ=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=t17Eu8QxzKeSdC6p+3F/qZat0p19yAkigyThVqwteebO7OfDvc7hnsrDl4S+1IOJWsb 6gVQHHBGUHQt5ecZjQVyT1k31hegYpKCdHJeggYRUZDo8cTvHN21nK/QIjrBWHJY+/VJa nDxIcsEDFlZEvTddbz/ACT3GO3SZay7DFAQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" A subsequent patch in the series will make the ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf instance dependent on the OrderedCollectionLib class. Because the shell binary in this platform consumes the above UefiShellCommandLib instance, resolve OrderedCollectionLib. Cc: Benjamin You Cc: Guo Dong Cc: Maurice Ma Cc: Philippe Mathieu-Daud=C3=A9 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3151 Signed-off-by: Laszlo Ersek Reviewed-by: Guo Dong Reviewed-by: Philippe Mathieu-Daude --- Notes: v2: - new patch UefiPayloadPkg/UefiPayloadPkg.dsc | 1 + 1 file changed, 1 insertion(+) diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc index ae62a9c4d66b..24dab157f1ef 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -556,6 +556,7 @@ [Components.X64] DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandlePar= singLib.inf + OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTre= eLib/BaseOrderedCollectionRedBlackTreeLib.inf PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLi= b.inf ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellComman= dLib.inf --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70220): https://edk2.groups.io/g/devel/message/70220 Mute This Topic: https://groups.io/mt/79646583/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Apr 16 06:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70221+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70221+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610528132; cv=none; d=zohomail.com; s=zohoarc; b=UrXvdmEjliG3/zUYnez8vL2rFi6vOS5VY10jBj6nXwR3nZOq1clSxAWK09qu6NSW7+RZ2j4jXbi/oyLWmwYYLjBAG6ieBRnAflzoS4vaG8on5ebt6lf1CNriPwiMUscZ2OcDl1K1pfqJQN9wufpRzlsVjmdrPV4f/BZh+569ft4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610528132; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=4Kr79trdIfHsZNk3QHSaggWCo/Vblbslxr20zruwaCY=; b=J/peHWZNgQQ5x+8+7l2hZvsSWhPNLu2Gg301+mW42D21sAM8FAEkYvc7ySYih1U+rP11pbaMhlCI5KSO7G1TlNhGabF9Qxd66rLd2Z1HSujNHey2NVZhgs3DX4Vqr+feVX4o2Us+gSQB5puZaegEuvo5UMaE38QlGdO53S7SM9c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70221+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610528132355437.65549949177057; Wed, 13 Jan 2021 00:55:32 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id pSCmYY1788612x88MYEbbqSS; Wed, 13 Jan 2021 00:55:32 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web10.5453.1610528126432671367 for ; Wed, 13 Jan 2021 00:55:26 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-nuSIEt-CNxmhxMBldQQOrw-1; Wed, 13 Jan 2021 03:55:23 -0500 X-MC-Unique: nuSIEt-CNxmhxMBldQQOrw-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57F278066E0; Wed, 13 Jan 2021 08:55:22 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-238.ams2.redhat.com [10.36.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3717D5C239; Wed, 13 Jan 2021 08:55:18 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ray Ni , Zhichao Gao Subject: [edk2-devel] [PATCH v2 06/10] ShellPkg/ShellCommandLib: add ShellSortFileList() Date: Wed, 13 Jan 2021 09:54:49 +0100 Message-Id: <20210113085453.10168-7-lersek@redhat.com> In-Reply-To: <20210113085453.10168-1-lersek@redhat.com> References: <20210113085453.10168-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: 8IUmpJYxDUqkVNlBpiaf5nK3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610528132; bh=4Kr79trdIfHsZNk3QHSaggWCo/Vblbslxr20zruwaCY=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=I2+NnSPwR/Koc6a2atGRg/jPEGvjB0kvwYCKE1C4IUjIZBIr27RZL5QpzQrauRKAjXx 9aRMM5KmtjZp1JKNE6Hzz0ftAjAsI10UdfN0BwioVnrW2BZTdaXymRZo0HlxOyQRAZ98q pXCT7o0aD3ZzWGkGqUPyhZSGUm8MTe0UPow= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Introduce the ShellSortFileList() function, for sorting an EFI_SHELL_FILE_INFO list, by FileName or by FullName. Duplicates can be kept in the same list, or separated out to a new list. In either case, the relative order between duplicates does not change (the sorting is stable). For the sorting, use OrderedCollectionLib rather than SortLib: - The PerformQuickSort() function from the latter has quadratic worst-case time complexity, plus it is implemented recursively (see "MdeModulePkg/Library/UefiSortLib/UefiSortLib.c"). It can also not return an error on memory allocation failure. - In comparison, the Red-Black Tree instance of OrderedCollectionLib sorts in O(n*log(n)) worst-case time, contains no recursion with the default PcdValidateOrderedCollection=3DFALSE setting, and the OrderedCollectionLib class APIs return errors appropriately. The OrderedCollectionLib APIs do not permit duplicates natively, but by using lists as collection entries, stable sorting of duplicates can be achieved. Cc: Philippe Mathieu-Daud=C3=A9 Cc: Ray Ni Cc: Zhichao Gao Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3151 Signed-off-by: Laszlo Ersek Reviewed-by: Zhichao Gao Reviewed-by: Philippe Mathieu-Daude --- Notes: v2: - no changes - pick up Zhichao's R-b ShellPkg/ShellPkg.dsc | 1 + ShellPkg/Include/Library/ShellCommandLib.h | 81 +++++ ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf | 1 + ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h | 19 ++ ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 312 +++++++= +++++++++++++ 5 files changed, 414 insertions(+) diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc index c42bc9464a0f..a8b6de334284 100644 --- a/ShellPkg/ShellPkg.dsc +++ b/ShellPkg/ShellPkg.dsc @@ -47,6 +47,7 @@ [LibraryClasses.common] ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib= .inf ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsing= Lib.inf + OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib= /BaseOrderedCollectionRedBlackTreeLib.inf =20 PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeC= offGetEntryPointLib.inf BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCom= mandLib.inf diff --git a/ShellPkg/Include/Library/ShellCommandLib.h b/ShellPkg/Include/= Library/ShellCommandLib.h index 63fcac82a2de..bc1afed5e7f5 100644 --- a/ShellPkg/Include/Library/ShellCommandLib.h +++ b/ShellPkg/Include/Library/ShellCommandLib.h @@ -714,4 +714,85 @@ CatSDumpHex ( IN UINTN DataSize, IN VOID *UserData ); + +// +// Determines the ordering operation for ShellSortFileList(). +// +typedef enum { + // + // Sort the EFI_SHELL_FILE_INFO objects by the FileName field, in increa= sing + // order, using gUnicodeCollation->StriColl(). + // + ShellSortFileListByFileName, + // + // Sort the EFI_SHELL_FILE_INFO objects by the FullName field, in increa= sing + // order, using gUnicodeCollation->StriColl(). + // + ShellSortFileListByFullName, + ShellSortFileListMax +} SHELL_SORT_FILE_LIST; + +/** + Sort an EFI_SHELL_FILE_INFO list, optionally moving duplicates to a sepa= rate + list. + + @param[in,out] FileList The list of EFI_SHELL_FILE_INFO objects to sort. + + If FileList is NULL on input, then FileList is + considered an empty, hence already sorted, list. + + Otherwise, if (*FileList) is NULL on input, then + EFI_INVALID_PARAMETER is returned. + + Otherwise, the caller is responsible for having + initialized (*FileList)->Link with + InitializeListHead(). No other fields in the + (**FileList) head element are accessed by this + function. + + On output, (*FileList) is sorted according to O= rder. + If Duplicates is NULL on input, then duplicate + elements are preserved, sorted stably, on + (*FileList). If Duplicates is not NULL on input, + then duplicates are moved (stably sorted) to the + new, dynamically allocated (*Duplicates) list. + + @param[out] Duplicates If Duplicates is NULL on input, (*FileList) wil= l be + a monotonically ordered list on output, with + duplicates stably sorted. + + If Duplicates is not NULL on input, (*FileList)= will + be a strictly monotonically oredered list on ou= tput, + with duplicates separated (stably sorted) to + (*Duplicates). All fields except Link will be + zero-initialized in the (**Duplicates) head ele= ment. + If no duplicates exist, then (*Duplicates) is s= et to + NULL on output. + + @param[in] Order Determines the comparison operation between + EFI_SHELL_FILE_INFO objects. + + @retval EFI_INVALID_PARAMETER (UINTN)Order is greater than or equal to + (UINTN)ShellSortFileListMax. Neither the + (*FileList) nor the (*Duplicates) list has + been modified. + + @retval EFI_INVALID_PARAMETER (*FileList) was NULL on input. Neither the + (*FileList) nor the (*Duplicates) list has + been modified. + + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. Neither the + (*FileList) nor the (*Duplicates) list has + been modified. + + @retval EFI_SUCCESS Sorting successful, including the case wh= en + FileList is NULL on input. +**/ +EFI_STATUS +EFIAPI +ShellSortFileList ( + IN OUT EFI_SHELL_FILE_INFO **FileList, + OUT EFI_SHELL_FILE_INFO **Duplicates OPTIONAL, + IN SHELL_SORT_FILE_LIST Order + ); #endif //_SHELL_COMMAND_LIB_ diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf b= /ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf index a1b5601c96b6..08ca7cb78842 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf @@ -42,6 +42,7 @@ [LibraryClasses] ShellLib HiiLib HandleParsingLib + OrderedCollectionLib =20 [Protocols] gEfiUnicodeCollation2ProtocolGuid ## CONSUMES diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h b/S= hellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h index 8ecc2f6bf5a2..0ca291e4f9bf 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h @@ -39,6 +39,7 @@ #include #include #include +#include =20 typedef struct{ LIST_ENTRY Link; @@ -60,6 +61,24 @@ typedef struct { CHAR16 *Path; } SHELL_COMMAND_FILE_HANDLE; =20 +// +// Collects multiple EFI_SHELL_FILE_INFO objects that share the same name. +// +typedef struct { + // + // A string that compares equal to either the FileName or the FullName f= ields + // of all EFI_SHELL_FILE_INFO objects on SameNameList, according to + // gUnicodeCollation->StriColl(). The string is not dynamically allocate= d; + // instead, it *aliases* the FileName or FullName field of the + // EFI_SHELL_FILE_INFO object that was first encountered with this name. + // + CONST CHAR16 *Alias; + // + // A list of EFI_SHELL_FILE_INFO objects whose FileName or FullName fiel= ds + // compare equal to Alias, according to gUnicodeCollation->StriColl(). + // + LIST_ENTRY SameNameList; +} SHELL_SORT_UNIQUE_NAME; =20 #endif //_UEFI_COMMAND_LIB_INTERNAL_HEADER_ =20 diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/S= hellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c index 345808a1eac6..b06d22592d33 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c @@ -1909,3 +1909,315 @@ CatSDumpHex ( =20 return RetVal; } + +/** + ORDERED_COLLECTION_USER_COMPARE function for SHELL_SORT_UNIQUE_NAME obje= cts. + + @param[in] Unique1AsVoid The first SHELL_SORT_UNIQUE_NAME object (Uniqu= e1), + passed in as a pointer-to-VOID. + + @param[in] Unique2AsVoid The second SHELL_SORT_UNIQUE_NAME object (Uniq= ue2), + passed in as a pointer-to-VOID. + + @retval <0 If Unique1 compares less than Unique2. + + @retval 0 If Unique1 compares equal to Unique2. + + @retval >0 If Unique1 compares greater than Unique2. +**/ +STATIC +INTN +EFIAPI +UniqueNameCompare ( + IN CONST VOID *Unique1AsVoid, + IN CONST VOID *Unique2AsVoid + ) +{ + CONST SHELL_SORT_UNIQUE_NAME *Unique1; + CONST SHELL_SORT_UNIQUE_NAME *Unique2; + + Unique1 =3D Unique1AsVoid; + Unique2 =3D Unique2AsVoid; + + // + // We need to cast away CONST for EFI_UNICODE_COLLATION_STRICOLL. + // + return gUnicodeCollation->StriColl ( + gUnicodeCollation, + (CHAR16 *)Unique1->Alias, + (CHAR16 *)Unique2->Alias + ); +} + +/** + ORDERED_COLLECTION_KEY_COMPARE function for SHELL_SORT_UNIQUE_NAME objec= ts. + + @param[in] UniqueAliasAsVoid The CHAR16 string UniqueAlias, passed in a= s a + pointer-to-VOID. + + @param[in] UniqueAsVoid The SHELL_SORT_UNIQUE_NAME object (Unique), + passed in as a pointer-to-VOID. + + @retval <0 If UniqueAlias compares less than Unique->Alias. + + @retval 0 If UniqueAlias compares equal to Unique->Alias. + + @retval >0 If UniqueAlias compares greater than Unique->Alias. +**/ +STATIC +INTN +EFIAPI +UniqueNameAliasCompare ( + IN CONST VOID *UniqueAliasAsVoid, + IN CONST VOID *UniqueAsVoid + ) +{ + CONST CHAR16 *UniqueAlias; + CONST SHELL_SORT_UNIQUE_NAME *Unique; + + UniqueAlias =3D UniqueAliasAsVoid; + Unique =3D UniqueAsVoid; + + // + // We need to cast away CONST for EFI_UNICODE_COLLATION_STRICOLL. + // + return gUnicodeCollation->StriColl ( + gUnicodeCollation, + (CHAR16 *)UniqueAlias, + (CHAR16 *)Unique->Alias + ); +} + +/** + Sort an EFI_SHELL_FILE_INFO list, optionally moving duplicates to a sepa= rate + list. + + @param[in,out] FileList The list of EFI_SHELL_FILE_INFO objects to sort. + + If FileList is NULL on input, then FileList is + considered an empty, hence already sorted, list. + + Otherwise, if (*FileList) is NULL on input, then + EFI_INVALID_PARAMETER is returned. + + Otherwise, the caller is responsible for having + initialized (*FileList)->Link with + InitializeListHead(). No other fields in the + (**FileList) head element are accessed by this + function. + + On output, (*FileList) is sorted according to O= rder. + If Duplicates is NULL on input, then duplicate + elements are preserved, sorted stably, on + (*FileList). If Duplicates is not NULL on input, + then duplicates are moved (stably sorted) to the + new, dynamically allocated (*Duplicates) list. + + @param[out] Duplicates If Duplicates is NULL on input, (*FileList) wil= l be + a monotonically ordered list on output, with + duplicates stably sorted. + + If Duplicates is not NULL on input, (*FileList)= will + be a strictly monotonically oredered list on ou= tput, + with duplicates separated (stably sorted) to + (*Duplicates). All fields except Link will be + zero-initialized in the (**Duplicates) head ele= ment. + If no duplicates exist, then (*Duplicates) is s= et to + NULL on output. + + @param[in] Order Determines the comparison operation between + EFI_SHELL_FILE_INFO objects. + + @retval EFI_INVALID_PARAMETER (UINTN)Order is greater than or equal to + (UINTN)ShellSortFileListMax. Neither the + (*FileList) nor the (*Duplicates) list has + been modified. + + @retval EFI_INVALID_PARAMETER (*FileList) was NULL on input. Neither the + (*FileList) nor the (*Duplicates) list has + been modified. + + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. Neither the + (*FileList) nor the (*Duplicates) list has + been modified. + + @retval EFI_SUCCESS Sorting successful, including the case wh= en + FileList is NULL on input. +**/ +EFI_STATUS +EFIAPI +ShellSortFileList ( + IN OUT EFI_SHELL_FILE_INFO **FileList, + OUT EFI_SHELL_FILE_INFO **Duplicates OPTIONAL, + IN SHELL_SORT_FILE_LIST Order + ) +{ + LIST_ENTRY *FilesHead; + ORDERED_COLLECTION *Sort; + LIST_ENTRY *FileEntry; + EFI_SHELL_FILE_INFO *FileInfo; + SHELL_SORT_UNIQUE_NAME *Unique; + EFI_STATUS Status; + EFI_SHELL_FILE_INFO *Dupes; + LIST_ENTRY *NextFileEntry; + CONST CHAR16 *Alias; + ORDERED_COLLECTION_ENTRY *SortEntry; + LIST_ENTRY *TargetFileList; + ORDERED_COLLECTION_ENTRY *NextSortEntry; + VOID *UniqueAsVoid; + + if ((UINTN)Order >=3D (UINTN)ShellSortFileListMax) { + return EFI_INVALID_PARAMETER; + } + + if (FileList =3D=3D NULL) { + // + // FileList is considered empty, hence already sorted, with no duplica= tes. + // + if (Duplicates !=3D NULL) { + *Duplicates =3D NULL; + } + return EFI_SUCCESS; + } + + if (*FileList =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + FilesHead =3D &(*FileList)->Link; + + // + // Collect all the unique names. + // + Sort =3D OrderedCollectionInit (UniqueNameCompare, UniqueNameAliasCompar= e); + if (Sort =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + BASE_LIST_FOR_EACH (FileEntry, FilesHead) { + FileInfo =3D (EFI_SHELL_FILE_INFO *)FileEntry; + + // + // Try to record the name of this file as a unique name. + // + Unique =3D AllocatePool (sizeof (*Unique)); + if (Unique =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto UninitSort; + } + Unique->Alias =3D ((Order =3D=3D ShellSortFileListByFileName) ? + FileInfo->FileName : + FileInfo->FullName); + InitializeListHead (&Unique->SameNameList); + + Status =3D OrderedCollectionInsert (Sort, NULL, Unique); + if (EFI_ERROR (Status)) { + // + // Only two errors are possible: memory allocation failed, or this n= ame + // has been encountered before. In either case, the + // SHELL_SORT_UNIQUE_NAME object being constructed has to be release= d. + // + FreePool (Unique); + // + // Memory allocation failure is fatal, while having seen the same na= me + // before is normal. + // + if (Status =3D=3D EFI_OUT_OF_RESOURCES) { + goto UninitSort; + } + ASSERT (Status =3D=3D EFI_ALREADY_STARTED); + } + } + + // + // If separation of duplicates has been requested, allocate the list for + // them. + // + if (Duplicates !=3D NULL) { + Dupes =3D AllocateZeroPool (sizeof (*Dupes)); + if (Dupes =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto UninitSort; + } + InitializeListHead (&Dupes->Link); + } + + // + // No memory allocation beyond this point; thus, no chance to fail. We c= an + // now migrate the EFI_SHELL_FILE_INFO objects from (*FileList) to Sort. + // + BASE_LIST_FOR_EACH_SAFE (FileEntry, NextFileEntry, FilesHead) { + FileInfo =3D (EFI_SHELL_FILE_INFO *)FileEntry; + // + // Look up the SHELL_SORT_UNIQUE_NAME that matches FileInfo's name. + // + Alias =3D ((Order =3D=3D ShellSortFileListByFileName) ? + FileInfo->FileName : + FileInfo->FullName); + SortEntry =3D OrderedCollectionFind (Sort, Alias); + ASSERT (SortEntry !=3D NULL); + Unique =3D OrderedCollectionUserStruct (SortEntry); + // + // Move FileInfo from (*FileList) to the end of the list of files whose + // names all compare identical to FileInfo's name. + // + RemoveEntryList (&FileInfo->Link); + InsertTailList (&Unique->SameNameList, &FileInfo->Link); + } + + // + // All EFI_SHELL_FILE_INFO objects originally in (*FileList) have been + // distributed to Sort. Now migrate them back to (*FileList), advancing = in + // unique name order. + // + for (SortEntry =3D OrderedCollectionMin (Sort); + SortEntry !=3D NULL; + SortEntry =3D OrderedCollectionNext (SortEntry)) { + Unique =3D OrderedCollectionUserStruct (SortEntry); + // + // The first FileInfo encountered for each unique name goes back on + // (*FileList) unconditionally. Further FileInfo instances for the same + // unique name -- that is, duplicates -- are either returned to (*File= List) + // or separated, dependent on the caller's request. + // + TargetFileList =3D FilesHead; + BASE_LIST_FOR_EACH_SAFE (FileEntry, NextFileEntry, &Unique->SameNameLi= st) { + RemoveEntryList (FileEntry); + InsertTailList (TargetFileList, FileEntry); + if (Duplicates !=3D NULL) { + TargetFileList =3D &Dupes->Link; + } + } + } + + // + // We're done. If separation of duplicates has been requested, output the + // list of duplicates -- and free that list at once, if it's empty (i.e.= , if + // no duplicates have been found). + // + if (Duplicates !=3D NULL) { + if (IsListEmpty (&Dupes->Link)) { + FreePool (Dupes); + *Duplicates =3D NULL; + } else { + *Duplicates =3D Dupes; + } + } + Status =3D EFI_SUCCESS; + + // + // Fall through. + // +UninitSort: + for (SortEntry =3D OrderedCollectionMin (Sort); + SortEntry !=3D NULL; + SortEntry =3D NextSortEntry) { + NextSortEntry =3D OrderedCollectionNext (SortEntry); + OrderedCollectionDelete (Sort, SortEntry, &UniqueAsVoid); + Unique =3D UniqueAsVoid; + ASSERT (IsListEmpty (&Unique->SameNameList)); + FreePool (Unique); + } + OrderedCollectionUninit (Sort); + + return Status; +} --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70221): https://edk2.groups.io/g/devel/message/70221 Mute This Topic: https://groups.io/mt/79646584/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Apr 16 06:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70222+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70222+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610528133; cv=none; d=zohomail.com; s=zohoarc; b=VVSkXQ1iQYbtu2Cw3ibJEbrLtSs30t4DHMrbtxBsY++Nmb/9mvgEAaq1DXduybOIRizNzZ6d/xjt4eqMX55oNjTqsp1VoNZCHJVk91gHo29zwQ4w1sofwcu1l8Bfbo6ks/106uSVK/8WcEr+CH3XQ8b6IEOEPCcnfCz29JSdP9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610528133; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=PSOUxzVEd5e/it9bj94homPbcjgSUQpHBIylEAzHtC8=; b=PTRTROsN7n5C2ypdBmdhMDMYKJ1DVfttuqUwgcyf6bkJUWTqMaVy+SwdOa83Y9e5onC/Tcny2eRJ4JuBP/rAOd3z5/K6aK2tE8Um0IzQQ72ccX7p3b2zG9i4lQcP+vttpUj9wwfakECLWh54UVOA1+xEIBJv00I7HMF/io7z2xs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70222+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610528133457204.93062743761357; Wed, 13 Jan 2021 00:55:33 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id YRKYYY1788612xz6copwEFJj; Wed, 13 Jan 2021 00:55:33 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web09.5511.1610528127594864582 for ; Wed, 13 Jan 2021 00:55:27 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-5-GH2MX0R4P3q1U03daOSeUQ-1; Wed, 13 Jan 2021 03:55:24 -0500 X-MC-Unique: GH2MX0R4P3q1U03daOSeUQ-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C48548144EA; Wed, 13 Jan 2021 08:55:23 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-238.ams2.redhat.com [10.36.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA5495C239; Wed, 13 Jan 2021 08:55:22 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ray Ni , Zhichao Gao Subject: [edk2-devel] [PATCH v2 07/10] ShellPkg/Ls: sort output by FileName in non-SFO mode Date: Wed, 13 Jan 2021 09:54:50 +0100 Message-Id: <20210113085453.10168-8-lersek@redhat.com> In-Reply-To: <20210113085453.10168-1-lersek@redhat.com> References: <20210113085453.10168-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: JbX1MrFqRRrMamnUOD9yrIwIx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610528133; bh=PSOUxzVEd5e/it9bj94homPbcjgSUQpHBIylEAzHtC8=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Ype3IviFFx6Bw4sajM4sfSDx1nA5mQ/38OrIjdkPBPI0TEn4ff1ypdvoZjBZBkYew1E FL51VFj8gujq+IQ0I8x226NZ/o+hSycjk290V4Pt5UDuaBSh3KI+JQ6SxznQFan//HMdj kHO8MEf61C9RXi9dxjPJxYcKKOzZ2CFTxto= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Sorting the LS output in non-SFO mode by FileName is best demonstrated with two examples. (1a) Before: > FS2:\> dir -r apps > Directory of: FS2:\apps\ > 01/01/1970 01:00 r 0 . > 12/22/2020 17:53 4,096 X64 > 12/22/2020 17:53 4,096 AARCH64 > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 4,096 IA32 > 0 File(s) 0 bytes > 5 Dir(s) > Directory of: FS2:\apps\X64\ > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 01/01/1970 01:00 r 0 . > 12/22/2020 17:52 11,456 VariableInfo.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 01/01/1970 01:00 r 0 .. > 6 File(s) 256,192 bytes > 2 Dir(s) > Directory of: FS2:\apps\AARCH64\ > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 01/01/1970 01:00 r 0 . > 12/22/2020 17:52 20,480 VariableInfo.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 01/01/1970 01:00 r 0 .. > 4 File(s) 233,472 bytes > 2 Dir(s) > Directory of: FS2:\apps\IA32\ > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 01/01/1970 01:00 r 0 . > 12/22/2020 17:52 10,880 VariableInfo.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 01/01/1970 01:00 r 0 .. > 6 File(s) 224,768 bytes > 2 Dir(s) (1b) After: > FS2:\> dir -r apps > Directory of: FS2:\apps\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 4,096 AARCH64 > 12/22/2020 17:53 4,096 IA32 > 12/22/2020 17:53 4,096 X64 > 0 File(s) 0 bytes > 5 Dir(s) > Directory of: FS2:\apps\X64\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 6 File(s) 256,192 bytes > 2 Dir(s) > Directory of: FS2:\apps\AARCH64\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 4 File(s) 233,472 bytes > 2 Dir(s) > Directory of: FS2:\apps\IA32\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 6 File(s) 224,768 bytes > 2 Dir(s) (2a) Before: > FS2:\> dir apps\*\*.efi > Directory of: FS2:\apps\*\ > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 16 File(s) 714,432 bytes > 0 Dir(s) (2b) After: > FS2:\> dir apps\*\*.efi > Directory of: FS2:\apps\*\ > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 16 File(s) 714,432 bytes > 0 Dir(s) (In example (2), note that the sorting is stable; that is, whatever order is established between identical FileNames by ShellOpenFileMetaArg(), it is preserved by ShellSortFileList().) Cc: Philippe Mathieu-Daud=C3=A9 Cc: Ray Ni Cc: Zhichao Gao Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3151 Signed-off-by: Laszlo Ersek Reviewed-by: Zhichao Gao Reviewed-by: Philippe Mathieu-Daude --- Notes: v2: - no changes - pick up Zhichao's R-b ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Li= brary/UefiShellLevel2CommandsLib/Ls.c index da2b1acab47c..8b97926d7f47 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c @@ -489,6 +489,20 @@ PrintLsOutput( PrintSfoVolumeInfoTableEntry(ListHead); } =20 + if (!Sfo) { + // + // Sort the file list by FileName, stably. + // + // If the call below fails, then the EFI_SHELL_FILE_INFO list anchor= ed to + // ListHead will not be changed in any way. + // + ShellSortFileList ( + &ListHead, + NULL, // Duplicates + ShellSortFileListByFileName + ); + } + for ( Node =3D (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link), L= ongestPath =3D 0 ; !IsNull(&ListHead->Link, &Node->Link) ; Node =3D (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &No= de->Link) --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70222): https://edk2.groups.io/g/devel/message/70222 Mute This Topic: https://groups.io/mt/79646585/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Apr 16 06:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70223+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70223+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610528136; cv=none; d=zohomail.com; s=zohoarc; b=lXzglPrTNnINxPqAunDkjEFWDnW/c2C9NruWiyUNwTKptwxp+Wb4ieGWpfK6i5MxKAZr0QkJSNAIw9Z4X/YWR+SdA0pLdXJNHIhlEL+ruTx5TO9xRxA6g851oNViegJSAlfUEboJqrGyXokvJwIGgwrizykApkWypT/gJhrvwIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610528136; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=AzVSYWpzJpXKklmNtd7Ytf+txUfGWSGdxdiINoNLdG4=; b=YVOH+2zcSDN7UlgTqTH7ZLjya1zARd94+68/UApFqhtZxyrS185aQQAKn4EIcsqNjnxF0H4uL4G2QYWnxIFgRoUkd4sOl56br7iv8ZmQ7G+imszJE/oDjv4AdeXJCD+Ga7FUNRd0MaLsCQBwttYQ7I7pT89XIDjMylN42rPI3yU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70223+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610528136865846.7728549163567; Wed, 13 Jan 2021 00:55:36 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id F5EuYY1788612xJvwewiMVRU; Wed, 13 Jan 2021 00:55:36 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web11.5499.1610528130830789082 for ; Wed, 13 Jan 2021 00:55:31 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-568-IUUHD7KGMvOWH0K5dl2jVA-1; Wed, 13 Jan 2021 03:55:26 -0500 X-MC-Unique: IUUHD7KGMvOWH0K5dl2jVA-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39B87107ACF7; Wed, 13 Jan 2021 08:55:25 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-238.ams2.redhat.com [10.36.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23EFC5C253; Wed, 13 Jan 2021 08:55:23 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ray Ni , Zhichao Gao Subject: [edk2-devel] [PATCH v2 08/10] ShellPkg/ShellProtocol: sort files by FullName in RemoveDupInFileList() Date: Wed, 13 Jan 2021 09:54:51 +0100 Message-Id: <20210113085453.10168-9-lersek@redhat.com> In-Reply-To: <20210113085453.10168-1-lersek@redhat.com> References: <20210113085453.10168-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: 2xdaa8ElBDcbKmqs1QEnLMAax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610528136; bh=AzVSYWpzJpXKklmNtd7Ytf+txUfGWSGdxdiINoNLdG4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=v86dAV7ceVqh6ruAgW8I8qKraznYViwd+vgGxAXk8NAxxM8kv27SZ1bgMcWt9Vo2qwt BwfT5E05nOZbjkBd9vSQGi2qxWw0pt+sjiMrimhAEbwF+o+3x4lrLBlGS9iuJgo4bJaN8 xcfbgBshNwxfn/PaZfjlYwr6A24XltszyXQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The current implementation of EfiShellRemoveDupInFileList(): - has quadratic time complexity, as a disadvantage, and - needs no dynamic memory, as an advantage. Because the UEFI Shell Spec requires EFI_SHELL_PROTOCOL.RemoveDupInFileList() to succeed at all times, keep the current method as a fallback (it cannot fail due to needing no dynamic memory). However, as a higher priority option, call the new ShellSortFileList() function at first, separating out and releasing duplicates. (ShellSortFileList() can fail due to EFI_OUT_OF_RESOURCES.) Beyond improving the runtime of EfiShellRemoveDupInFileList(), this change has the extremely desirable effect that the ShellOpenFileMetaArg() function in the ShellPkg/Library/UefiShellLib instance will produce file lists that are sorted by FullName. Consequently, when used with wildcards, the ATTRIB, CP, FOR, LOAD, LOADPCIROM, LS, MV, RM, TOUCH, TYPE commands will process files in FullName order. (LS in recursive mode uses wildcards internally.) Before: > FS2:\> dir -r -sfo apps > [...] > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\X64" > FileInfo,"FS2:\apps\AARCH64" > FileInfo,"FS2:\" > FileInfo,"FS2:\apps\IA32" > FileInfo,"FS2:\apps\X64\DumpDynPcd.efi" > FileInfo,"FS2:\apps\X64\SmiHandlerProfileInfo.efi" > FileInfo,"FS2:\apps\X64\" > FileInfo,"FS2:\apps\X64\VariableInfo.efi" > FileInfo,"FS2:\apps\X64\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\X64\AcpiViewApp.efi" > FileInfo,"FS2:\apps\X64\Cpuid.efi" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\AARCH64\DumpDynPcd.efi" > FileInfo,"FS2:\apps\AARCH64\" > FileInfo,"FS2:\apps\AARCH64\VariableInfo.efi" > FileInfo,"FS2:\apps\AARCH64\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\AARCH64\AcpiViewApp.efi" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\IA32\DumpDynPcd.efi" > FileInfo,"FS2:\apps\IA32\SmiHandlerProfileInfo.efi" > FileInfo,"FS2:\apps\IA32\" > FileInfo,"FS2:\apps\IA32\VariableInfo.efi" > FileInfo,"FS2:\apps\IA32\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\IA32\AcpiViewApp.efi" > FileInfo,"FS2:\apps\IA32\Cpuid.efi" > FileInfo,"FS2:\apps\" After: > FS2:\> dir -r -sfo apps > [...] > FileInfo,"FS2:\" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\AARCH64" > FileInfo,"FS2:\apps\IA32" > FileInfo,"FS2:\apps\X64" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\AARCH64\" > FileInfo,"FS2:\apps\AARCH64\AcpiViewApp.efi" > FileInfo,"FS2:\apps\AARCH64\DumpDynPcd.efi" > FileInfo,"FS2:\apps\AARCH64\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\AARCH64\VariableInfo.efi" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\IA32\" > FileInfo,"FS2:\apps\IA32\AcpiViewApp.efi" > FileInfo,"FS2:\apps\IA32\Cpuid.efi" > FileInfo,"FS2:\apps\IA32\DumpDynPcd.efi" > FileInfo,"FS2:\apps\IA32\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\IA32\SmiHandlerProfileInfo.efi" > FileInfo,"FS2:\apps\IA32\VariableInfo.efi" > FileInfo,"FS2:\apps\" > FileInfo,"FS2:\apps\X64\" > FileInfo,"FS2:\apps\X64\AcpiViewApp.efi" > FileInfo,"FS2:\apps\X64\Cpuid.efi" > FileInfo,"FS2:\apps\X64\DumpDynPcd.efi" > FileInfo,"FS2:\apps\X64\MemoryProfileInfo.efi" > FileInfo,"FS2:\apps\X64\SmiHandlerProfileInfo.efi" > FileInfo,"FS2:\apps\X64\VariableInfo.efi" Regarding LS in non-SFO mode, the stability of ShellSortFileList() shows. The ShellSortFileList() call added to LS in the previous patch re-sorts the output of ShellOpenFileMetaArg(); and so this patch improves the ordering between identical FileNames: Before: > FS2:\> dir -r apps > Directory of: FS2:\apps\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 4,096 AARCH64 > 12/22/2020 17:53 4,096 IA32 > 12/22/2020 17:53 4,096 X64 > 0 File(s) 0 bytes > 5 Dir(s) > Directory of: FS2:\apps\X64\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 6 File(s) 256,192 bytes > 2 Dir(s) > Directory of: FS2:\apps\AARCH64\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 4 File(s) 233,472 bytes > 2 Dir(s) > Directory of: FS2:\apps\IA32\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 6 File(s) 224,768 bytes > 2 Dir(s) > > FS2:\> dir apps\*\*.efi > Directory of: FS2:\apps\*\ > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 16 File(s) 714,432 bytes > 0 Dir(s) After: > FS2:\> dir -r apps > Directory of: FS2:\apps\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 4,096 AARCH64 > 12/22/2020 17:53 4,096 IA32 > 12/22/2020 17:53 4,096 X64 > 0 File(s) 0 bytes > 5 Dir(s) > Directory of: FS2:\apps\AARCH64\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 4 File(s) 233,472 bytes > 2 Dir(s) > Directory of: FS2:\apps\IA32\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 6 File(s) 224,768 bytes > 2 Dir(s) > Directory of: FS2:\apps\X64\ > 01/01/1970 01:00 r 0 . > 01/01/1970 01:00 r 0 .. > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 6 File(s) 256,192 bytes > 2 Dir(s) > > FS2:\> dir apps\*\*.efi > Directory of: FS2:\apps\*\ > 12/22/2020 17:53 139,264 AcpiViewApp.efi > 12/22/2020 17:53 105,536 AcpiViewApp.efi > 12/22/2020 17:53 126,656 AcpiViewApp.efi > 12/22/2020 17:53 36,096 Cpuid.efi > 12/22/2020 17:53 38,784 Cpuid.efi > 12/22/2020 17:52 32,768 DumpDynPcd.efi > 12/22/2020 17:52 17,344 DumpDynPcd.efi > 12/22/2020 17:52 18,752 DumpDynPcd.efi > 12/22/2020 17:52 40,960 MemoryProfileInfo.efi > 12/22/2020 17:52 24,192 MemoryProfileInfo.efi > 12/22/2020 17:52 26,304 MemoryProfileInfo.efi > 12/22/2020 17:52 30,720 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 34,240 SmiHandlerProfileInfo.efi > 12/22/2020 17:52 20,480 VariableInfo.efi > 12/22/2020 17:52 10,880 VariableInfo.efi > 12/22/2020 17:52 11,456 VariableInfo.efi > 16 File(s) 714,432 bytes > 0 Dir(s) Cc: Philippe Mathieu-Daud=C3=A9 Cc: Ray Ni Cc: Zhichao Gao Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3151 Signed-off-by: Laszlo Ersek Reviewed-by: Zhichao Gao Reviewed-by: Philippe Mathieu-Daude --- Notes: v2: - no changes - pick up Zhichao's R-b ShellPkg/Application/Shell/ShellProtocol.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Applicat= ion/Shell/ShellProtocol.c index 4e639fe35e4f..e79c39058b3e 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -1855,6 +1855,8 @@ EfiShellRemoveDupInFileList( IN EFI_SHELL_FILE_INFO **FileList ) { + EFI_STATUS Status; + EFI_SHELL_FILE_INFO *Duplicates; EFI_SHELL_FILE_INFO *ShellFileListItem; EFI_SHELL_FILE_INFO *ShellFileListItem2; EFI_SHELL_FILE_INFO *TempNode; @@ -1862,6 +1864,20 @@ EfiShellRemoveDupInFileList( if (FileList =3D=3D NULL || *FileList =3D=3D NULL) { return (EFI_INVALID_PARAMETER); } + + Status =3D ShellSortFileList ( + FileList, + &Duplicates, + ShellSortFileListByFullName + ); + if (!EFI_ERROR (Status)) { + EfiShellFreeFileList (&Duplicates); + return EFI_SUCCESS; + } + // + // Fall back to the slow method that needs no extra memory, and so cannot + // fail. + // for ( ShellFileListItem =3D (EFI_SHELL_FILE_INFO*)GetFirstNode(&(*FileLi= st)->Link) ; !IsNull(&(*FileList)->Link, &ShellFileListItem->Link) ; ShellFileListItem =3D (EFI_SHELL_FILE_INFO*)GetNextNode(&(*FileLis= t)->Link, &ShellFileListItem->Link) --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70223): https://edk2.groups.io/g/devel/message/70223 Mute This Topic: https://groups.io/mt/79646586/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Apr 16 06:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70225+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70225+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610528134; cv=none; d=zohomail.com; s=zohoarc; b=nS0ztnNV0R3OsHdH8T8c6lJpwxVlyxEet404cY5twc4wy+ixdKzk19PWG1KVrfq+rag1HoZNTrYf8NaW2NkywrEIpbE0Qh0qf7BW1zP7TuWmr7dXAmQpevLsaCmSYXG73TcUKLzlPKqGOswe30XBtWdKHtNcJ1K1GXp9lsQ90Zw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610528134; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=FXOrCUc54lETwZyDu9F2cjw1FZ229QwQbG31dpki+lA=; b=Dihv7FCp/PLzYuqN5Gu5tD0lk31lFrElTgH27QSb/l26Odzqg4P14DP4ttmGoGmMlYUMyfOsBCdW0uxrvJmlm24IDIYwvYV7JKBBD+zNJQot+wnuSs/I8McnBPqZxzTPQ8QomMdSuazc0M5Ts3Vl0ar3Pvie+zBsYMTRyDdrYYg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70225+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610528134878610.7830312583724; Wed, 13 Jan 2021 00:55:34 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id klcjYY1788612x6KgsckH3O3; Wed, 13 Jan 2021 00:55:34 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web11.5501.1610528133983455770 for ; Wed, 13 Jan 2021 00:55:34 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-dbTEphGTMTOhkejq0ALYSA-1; Wed, 13 Jan 2021 03:55:29 -0500 X-MC-Unique: dbTEphGTMTOhkejq0ALYSA-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B83938066E1; Wed, 13 Jan 2021 08:55:27 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-238.ams2.redhat.com [10.36.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CB765C239; Wed, 13 Jan 2021 08:55:25 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Anthony Perard , Ard Biesheuvel , Jordan Justen , Julien Grall , Leif Lindholm , Peter Grehan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Rebecca Cran , Sami Mujawar Subject: [edk2-devel] [PATCH v2 09/10] OvmfPkg: disable list length checks in NOOPT and DEBUG builds Date: Wed, 13 Jan 2021 09:54:52 +0100 Message-Id: <20210113085453.10168-10-lersek@redhat.com> In-Reply-To: <20210113085453.10168-1-lersek@redhat.com> References: <20210113085453.10168-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: 3nk32qlUJFgJE4ZWs5VYFV9kx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610528134; bh=FXOrCUc54lETwZyDu9F2cjw1FZ229QwQbG31dpki+lA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=rTWZnOxu3Ie26CVerh9I2dwCUYNA2Y/Pm43SF6Qj5d8hsx+JkztgA/AIcFk3BCt6f0a TTdlAhdgWfgWQgCKPH1QsXQgXWngrob4v2I7JUi4T9Oug6OrU9JDEIZhmGPIsMq+4s10k YUl3/CAO5/PJESMcz3i9tNBzBB5tGy0lhMI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In NOOPT and DEBUG builds, if "PcdMaximumLinkedListLength" is nonzero, then several LIST_ENTRY *node* APIs in BaseLib compare the *full* list length against the PCD. This turns the time complexity of node-level APIs from constant to linear, and that of full-list manipulations from linear to quadratic. As an example, consider the EFI_SHELL_FILE_INFO list, which is a data structure that's widely used in the UEFI shell. I randomly extracted 5000 files from "/usr/include" on my laptop, spanning 1095 subdirectories out of 1538, and then ran "DIR -R" in the UEFI shell on this tree. These are the wall-clock times: PcdMaximumLinkedListLength PcdMaximumLinkedListLength =3D1,000,000 =3D0 -------------------------- --------------------------- FAT 4 min 31 s 18 s virtio-fs 5 min 13 s 1 min 33 s Checking list lengths against an arbitrary maximum (default: 1,000,000) seems useless even in NOOPT and DEBUG builds, while the cost is significant; so set the PCD to 0. Cc: Anthony Perard Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Julien Grall Cc: Leif Lindholm Cc: Peter Grehan Cc: Philippe Mathieu-Daud=C3=A9 Cc: Rebecca Cran Cc: Sami Mujawar Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3152 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude --- Notes: v2: - no changes - pick up Ard's A-b OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + OvmfPkg/Bhyve/BhyveX64.dsc | 1 + OvmfPkg/OvmfPkgIa32.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgX64.dsc | 1 + OvmfPkg/OvmfXen.dsc | 1 + 6 files changed, 6 insertions(+) diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index dad8635c3388..e6d545ab522f 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -441,6 +441,7 @@ [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FAL= SE gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0 !if ($(FD_SIZE_IN_KB) =3D=3D 1024) || ($(FD_SIZE_IN_KB) =3D=3D 2048) gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc index 33edf3d2d6b5..a1f43eaa4d9c 100644 --- a/OvmfPkg/Bhyve/BhyveX64.dsc +++ b/OvmfPkg/Bhyve/BhyveX64.dsc @@ -431,6 +431,7 @@ [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FAL= SE gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0 !if ($(FD_SIZE_IN_KB) =3D=3D 1024) || ($(FD_SIZE_IN_KB) =3D=3D 2048) gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 8b6dbb834505..e5184ef06731 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -478,6 +478,7 @@ [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FAL= SE !endif gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0 !if ($(FD_SIZE_IN_KB) =3D=3D 1024) || ($(FD_SIZE_IN_KB) =3D=3D 2048) gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 4d7a26636a72..3bfec9196eba 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -482,6 +482,7 @@ [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FAL= SE !endif gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0 !if ($(FD_SIZE_IN_KB) =3D=3D 1024) || ($(FD_SIZE_IN_KB) =3D=3D 2048) gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 10f6a64d7f47..1376158e37e3 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -484,6 +484,7 @@ [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FAL= SE !endif gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0 !if ($(FD_SIZE_IN_KB) =3D=3D 1024) || ($(FD_SIZE_IN_KB) =3D=3D 2048) gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 7d31e88907ca..f3fe85d57209 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -358,6 +358,7 @@ [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FAL= SE gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0 !if ($(FD_SIZE_IN_KB) =3D=3D 1024) || ($(FD_SIZE_IN_KB) =3D=3D 2048) gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70225): https://edk2.groups.io/g/devel/message/70225 Mute This Topic: https://groups.io/mt/79646589/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Apr 16 06:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70224+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70224+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610528138; cv=none; d=zohomail.com; s=zohoarc; b=cd55sG2j1hh90qmmqwMyD7QGjuN3xbGlZqV8auM4cmRaQRPLyan0UOMS9TfQFrdZeOPazQ3GmAqctHZUQps5hi8kM2uE7vDkkj91939F8yCQjI2SAPWf91ong8sdfemOse9HVNtZ2YBlsiyKvUgWvx49l83ZP8BAodN6oTsMwXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610528138; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=WkU92hz6n6MCtkSvworow9dT3ZZfdTn6CQZVEQbhfVU=; b=jCzQRBM6exdbIRlyf7bPngNv3D14GR+YDgPCZoqs1U235aG8ejMVp9TJUl7Zc7MrUjOwcSaXcD8MHhvyeMV3AYIMjY9WCzkvoOhcflNi9qHSCVQD/YUbQgRZJbOLH4cgpm5r16BPLaRKnSo51AUivmWvVww5phtnkIEXqrsbINQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70224+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610528138953473.05861961437597; Wed, 13 Jan 2021 00:55:38 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id aGrVYY1788612xZ85UHh4lC3; Wed, 13 Jan 2021 00:55:38 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web08.5573.1610528133042689009 for ; Wed, 13 Jan 2021 00:55:33 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-529-hoN8thq6M42yOljWBKpkuQ-1; Wed, 13 Jan 2021 03:55:30 -0500 X-MC-Unique: hoN8thq6M42yOljWBKpkuQ-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85920100C662; Wed, 13 Jan 2021 08:55:29 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-238.ams2.redhat.com [10.36.112.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 158165C253; Wed, 13 Jan 2021 08:55:27 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Julien Grall , Leif Lindholm , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Sami Mujawar Subject: [edk2-devel] [PATCH v2 10/10] ArmVirtPkg: disable list length checks in NOOPT and DEBUG builds Date: Wed, 13 Jan 2021 09:54:53 +0100 Message-Id: <20210113085453.10168-11-lersek@redhat.com> In-Reply-To: <20210113085453.10168-1-lersek@redhat.com> References: <20210113085453.10168-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: yfIyhPs3PAtUrWQx0XPr1Sgzx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610528138; bh=WkU92hz6n6MCtkSvworow9dT3ZZfdTn6CQZVEQbhfVU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=tUA1AgDtMY6bmboagVSBjhLOmuh4mx3JqGQYS3vBTqT45ru9Wb0/IeIA2jT+LXPT/YK qM5yejH6wO6wqCyGEa1s4q8QRgsKkJSWHESqsGgrgkxaevGwFdnQjMkg9v3Drr6mFdib7 IwrnPfRFUS9IOGSw/cjkZwbvriVUSu4ofgI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In NOOPT and DEBUG builds, if "PcdMaximumLinkedListLength" is nonzero, then several LIST_ENTRY *node* APIs in BaseLib compare the *full* list length against the PCD. This turns the time complexity of node-level APIs from constant to linear, and that of full-list manipulations from linear to quadratic. (See some example OVMF numbers in the previous patch.) Checking list lengths against an arbitrary maximum -- default value, and current ArmVirtPkg setting: 1,000,000 -- seems useless even in NOOPT and DEBUG builds, while the cost is significant; so set the PCD to 0. Cc: Ard Biesheuvel Cc: Julien Grall Cc: Leif Lindholm Cc: Philippe Mathieu-Daud=C3=A9 Cc: Sami Mujawar Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3152 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude --- Notes: v2: - no changes - pick up Ard's A-b ArmVirtPkg/ArmVirt.dsc.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 9ec92930472d..d9abadbe708c 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -290,7 +290,7 @@ [PcdsFeatureFlag.AARCH64] [PcdsFixedAtBuild.common] gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000 - gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000 + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0 gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000 gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320 =20 --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70224): https://edk2.groups.io/g/devel/message/70224 Mute This Topic: https://groups.io/mt/79646588/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-