From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 6BB88740039 for ; Mon, 19 Feb 2024 11:18:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ePR62QVoXVupyrqXlVWgHyevR0DKNQzoM4bkKFPuMK8=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1708341494; v=1; b=RmuDViJ3PE6vfSxhkh84hnvtRLFZM4rsSmaDn8Bg/2Tqe9Ik9ovXHVsL3Y5CANAZKDHKh72V 0KIDrhJxEsXPeI2ZmuPYnLdQPnGV7y3uEWAfojeIwvFLPwuxDQa4UzYzrUhWhEsUq72HXbQIzYd bYdfa05dnWHIqM2KjyO0hqNE= X-Received: by 127.0.0.2 with SMTP id ONOHYY7687511xsYhDyHhZr8; Mon, 19 Feb 2024 03:18:14 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.39060.1708341493389250323 for ; Mon, 19 Feb 2024 03:18:13 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-6ZTuR1XaODmh7DJj2EQkKQ-1; Mon, 19 Feb 2024 06:18:09 -0500 X-MC-Unique: 6ZTuR1XaODmh7DJj2EQkKQ-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 07A3D85A588; Mon, 19 Feb 2024 11:18:09 +0000 (UTC) X-Received: from [10.39.194.20] (unknown [10.39.194.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB42F492BE9; Mon, 19 Feb 2024 11:18:07 +0000 (UTC) Message-ID: <392712ae-99d9-eced-2b9c-ce87403be4ce@redhat.com> Date: Mon, 19 Feb 2024 12:18:06 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH 2/5] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to GetBspNumber() To: devel@edk2.groups.io, kraxel@redhat.com Cc: Oliver Steffen , Ray Ni , Rahul Kumar References: <20240215093149.251319-1-kraxel@redhat.com> <20240215093149.251319-3-kraxel@redhat.com> From: "Laszlo Ersek" In-Reply-To: <20240215093149.251319-3-kraxel@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: 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 List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: iO1pOPUsAmdsxzanxze1Ix8Fx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=RmuDViJ3; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 2/15/24 10:31, Gerd Hoffmann wrote: > Remove the MpHandOff parameter. This is not useful in case multiple > HOBs are present in the system. The function will use GetMpHandOffHob() > to loop over all HOBs instead. >=20 > Signed-off-by: Gerd Hoffmann > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 26 ++++++++++++++++---------- > 1 file changed, 16 insertions(+), 10 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/Mp= InitLib/MpLib.c > index e0a2366073a7..8e6cf50ed171 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -1894,26 +1894,32 @@ CheckAllAPs ( > /** > This function Get BspNumber. > =20 > - @param[in] MpHandOff Pointer to MpHandOff > @return BspNumber > **/ > UINT32 > GetBspNumber ( > - IN CONST MP_HAND_OFF *MpHandOff > + VOID > ) > { > - UINT32 ApicId; > - UINT32 BspNumber; > - UINT32 Index; > + UINT32 ApicId; > + UINT32 BspNumber; > + UINT32 Index; > + MP_HAND_OFF *MpHandOff; > =20 > // > // Get the processor number for the BSP > // > BspNumber =3D MAX_UINT32; > ApicId =3D GetInitialApicId (); > - for (Index =3D 0; Index < MpHandOff->CpuCount; Index++) { > - if (MpHandOff->Info[Index].ApicId =3D=3D ApicId) { > - BspNumber =3D Index; > + > + for (MpHandOff =3D GetMpHandOffHob (0); > + MpHandOff !=3D NULL; > + MpHandOff =3D GetMpHandOffHob (MpHandOff->ProcessorIndex + MpHand= Off->CpuCount)) > + { > + for (Index =3D 0; Index < MpHandOff->CpuCount; Index++) { > + if (MpHandOff->Info[Index].ApicId =3D=3D ApicId) { > + BspNumber =3D MpHandOff->ProcessorIndex + Index; > + } > } > } > =20 (I'm missing the larger picture here -- is this related to the problem -- too many CPUs to fit their infos into a single HOB -- that Pawel worked on for a while? "UefiCpuPkg/Library/MpInitLib/MpHandOff.h" was created in commit 8bb018afaf2a ("UefiCpuPkg: Create MpHandOff.", 2023-07-11); I don't have memories from that time frame. Either way, I do have a question / observation here:) The outer loop is suboptimal, IMO, to just open-coding another HOB scan -- this approach looks quadratic, even though it could be linear. More or less, as proposed, we call GetMpHandOffHob() for each MP_HAND_OFF HOB, which will scan n/2 HOBs on average. (Even if the GUID HOB list is sorted by ProcessorIndex, we'll scan 1 + 2 + 3 +... HOBs.) But if we open-coded GetFirstGuidHob() and GetNextGuidHob() here, then a single scan would suffice. Laszlo > @@ -1941,7 +1947,7 @@ SwitchApContext ( > UINTN Index; > UINT32 BspNumber; > =20 > - BspNumber =3D GetBspNumber (MpHandOff); > + BspNumber =3D GetBspNumber (); > =20 > for (Index =3D 0; Index < MpHandOff->CpuCount; Index++) { > if (Index !=3D BspNumber) { > @@ -2191,7 +2197,7 @@ MpInitLibInitialize ( > } > =20 > CpuMpData->CpuCount =3D MpHandOff->CpuCount; > - CpuMpData->BspNumber =3D GetBspNumber (MpHandOff); > + CpuMpData->BspNumber =3D GetBspNumber (); > CpuInfoInHob =3D (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInf= oInHob; > for (Index =3D 0; Index < CpuMpData->CpuCount; Index++) { > InitializeSpinLock (&CpuMpData->CpuData[Index].ApLock); -=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 (#115590): https://edk2.groups.io/g/devel/message/115590 Mute This Topic: https://groups.io/mt/104369845/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-