From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.groups.io with SMTP id smtpd.web11.4713.1570706998062363550 for ; Thu, 10 Oct 2019 04:29:58 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDF3F18CB8E5; Thu, 10 Oct 2019 11:29:57 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-48.rdu2.redhat.com [10.10.120.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA0115D6B2; Thu, 10 Oct 2019 11:29:56 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Eric Dong , Ray Ni Subject: [PATCH v2 1/2] UefiCpuPkg/MpInitLib: expand comment on initial AP enumeration Date: Thu, 10 Oct 2019 13:29:51 +0200 Message-Id: <20191010112952.7187-2-lersek@redhat.com> In-Reply-To: <20191010112952.7187-1-lersek@redhat.com> References: <20191010112952.7187-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Thu, 10 Oct 2019 11:29:57 +0000 (UTC) Content-Transfer-Encoding: quoted-printable Before adding another AP enumeration mode, clarify the documentation on the current logic. No functional changes. Cc: Eric Dong Cc: Ray Ni Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek --- Notes: v2: - new patch UefiCpuPkg/Library/MpInitLib/MpLib.c | 38 +++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/Mp= InitLib/MpLib.c index d6f84c6f45c0..594a035d8b92 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1045,14 +1045,36 @@ WakeUpAP ( } if (CpuMpData->InitFlag =3D=3D ApInitConfig) { // - // Here support two methods to collect AP count through adjust - // PcdCpuApInitTimeOutInMicroSeconds values. - // - // one way is set a value to just let the first AP to start the - // initialization, then through the later while loop to wait all A= ps - // finsh the initialization. - // The other way is set a value to let all APs finished the initia= lzation. - // In this case, the later while loop is useless. + // The AP enumeration algorithm below is suitable for two use case= s. + // + // (1) The check-in time for an individual AP is bounded, and APs = run + // through their initialization routines strongly concurrently= . In + // particular, the number of concurrently running APs + // ("NumApsExecuting") is never expected to fall to zero + // *temporarily* -- it is expected to fall to zero only when a= ll + // APs have checked-in. + // + // In this case, the platform is supposed to set + // PcdCpuApInitTimeOutInMicroSeconds to a low-ish value (just = long + // enough for one AP to start initialization). The timeout wil= l be + // reached soon, and remaining APs are collected by watching + // NumApsExecuting fall to zero. If NumApsExecuting falls to z= ero + // mid-process, while some APs have not completed initializati= on, + // the behavior is undefined. + // + // (2) The check-in time for an individual AP is unbounded, and/or= APs + // may complete their initializations widely spread out. In + // particular, some APs may finish initialization before some = APs + // even start. + // + // In this case, the platform is supposed to set + // PcdCpuApInitTimeOutInMicroSeconds to a high-ish value. The = AP + // enumeration will always take that long (except when the boo= t CPU + // count happens to be maximal, that is, + // PcdCpuMaxLogicalProcessorNumber). All APs are expected to + // check-in before the timeout, and NumApsExecuting is assumed= zero + // at timeout. APs that miss the time-out may cause undefined + // behavior. // TimedWaitForApFinish ( CpuMpData, --=20 2.19.1.3.g30247aa5d201