From: "Zeng, Star" <star.zeng@intel.com>
To: Laszlo Ersek <lersek@redhat.com>, "Ni, Ray" <ray.ni@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Dong, Eric" <eric.dong@intel.com>, "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [edk2-devel] [PATCH V2] UefiCpuPkg PiSmmCpuDxeSmm: Reduce SMRAM consumption in CpuS3.c
Date: Thu, 7 Jan 2021 10:47:11 +0000 [thread overview]
Message-ID: <DM6PR11MB4058864A4693C9D5A6A46A36E3AF0@DM6PR11MB4058.namprd11.prod.outlook.com> (raw)
In-Reply-To: <37d2bda3-5173-34d1-5338-92023b0fb2c5@redhat.com>
> -----Original Message-----
> From: Laszlo Ersek <lersek@redhat.com>
> Sent: Thursday, January 7, 2021 6:10 PM
> To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Zeng, Star
> <star.zeng@intel.com>
> Cc: Dong, Eric <eric.dong@intel.com>
> Subject: Re: [edk2-devel] [PATCH V2] UefiCpuPkg PiSmmCpuDxeSmm:
> Reduce SMRAM consumption in CpuS3.c
>
> On 01/07/21 06:23, Ni, Ray wrote:
> >> This patch is a step in the right direction, but, IMO, it can be improved.
> >>
> >> The IsRegisterTableEmpty() function should also handle the case when
> >> the "RegisterTable" parameter is NULL. The function should then also
> >> return TRUE.
> >>
> >> And then, two more patches would be nice:
> >>
> >>
> >> (2) The register table allocation in
> >> "UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c" should be removed.
> >>
> >> Right now, the code there allocates memory just so it can set the
> >> "TableLength" and "AllocatedSize" fields to zero, for each "InitialApicId".
> >>
> >> It's a waste -- the memory is allocated only for ensuring that
> >> PiSmmCpuDxeSmm does not program any CPU registers during S3 resume.
> >>
> >> Setting "AcpiCpuData->RegisterTable" and
> >> "AcpiCpuData->PreSmmInitRegisterTable" should have the same effect.
> >
> > Laszlo,
> > It's a good suggestion.
> > We also need to change CpuS3.c:SetRegister() to directly return when
> > mAcpiCpuData.[PreSmmInit]RegisterTable is NULL.
>
> The current (v2) patch already contains that shortcut; please see:
>
> > @@ -487,6 +487,9 @@ SetRegister (
> > } else {
> > RegisterTables = (CPU_REGISTER_TABLE
> *)(UINTN)mAcpiCpuData.RegisterTable;
> > }
> > + if (RegisterTables == NULL) {
> > + return;
> > + }
> >
> > InitApicId = GetInitialApicId ();
> > RegisterTable = NULL;
>
> So that's fine, IMO.
>
> The data flow is the following:
>
> (1) GetAcpiCpuData() determines whether each one of the two register
> tables *ouside of SMRAM* is empty or not;
>
> (2) for each one that is empty (outside of SMRAM), the pointer to the *copy
> in SMRAM* is set to NULL,
>
> (3) for each one that is not empty (outside of SMRAM), an SMRAM copy is
> made,
>
> (4) SetRegister() correctly deals -- already in this v2 patch -- with the the
> pointer into SMRAM being NULL.
>
>
> My update request refers to step (1). Namely, when we determine whether
> each register table *ouside of SMRAM* is empty or not, we should also
> recognize when the table (outside of SMRAM) doesn't even *exist*.
>
> Basically I'm asking that Star please post a v3 with the following update
> squashed into the patch:
>
> > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> > b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> > index 9b1f952c8a74..0e7a4ba5369d 100644
> > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> > @@ -998,6 +998,10 @@ IsRegisterTableEmpty ( {
> > UINTN Index;
> >
> > + if (RegisterTable == NULL) {
> > + return TRUE;
> > + }
> > +
> > for (Index = 0; Index < NumberOfCpus; Index++) {
> > if (RegisterTable[Index].TableLength != 0) {
> > return FALSE;
>
> Back to your email:
>
> On 01/07/21 06:23, Ni, Ray wrote:
> >
> > Considering the urgency of this patch (fix a system hang caused by
> > smram shortage), do you agree that we can first let this patch in?
>
> I agree that the CpuS3DataDxe changes can be done separately, later.
>
> However, I'd like the above small hunk -- in IsRegisterTableEmpty() -- to be
> squashed into the current patch, before committing it.
>
> If you think we should do this small update on commit, rather than posting a
> v3, that's fine with me as well. Just please don't merge the
> v2 patch without the IsRegisterTableEmpty() extension that I'm asking for,
> above.
>
> With the IsRegisterTableEmpty() update, even without a v3 posting:
>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Thanks Laszlo and Ray
This patch is majorly to reduce SMRAM consumption in *consumer* side of "RegisterTable".
I was preparing PATCH V3 before you sent this reply. 😊
About the change to *producer* side of "RegisterTable", UefiCpuPkg\Library\RegisterCpuFeaturesLib depended on CpuS3DataDxe before, the dependency seems have been removed by a6daab1f6cb836e4147324bb85fc17930be14e87. We may can do the change after doing more confirmation.
I just sent PATCH V3 with your both RB (suppose you both agree 😊) with a very very little difference to your proposal.
Thanks,
Star
>
> Thanks
> Laszlo
next prev parent reply other threads:[~2021-01-07 10:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 6:48 [PATCH V2] UefiCpuPkg PiSmmCpuDxeSmm: Reduce SMRAM consumption in CpuS3.c Zeng, Star
2021-01-06 9:44 ` Ni, Ray
2021-01-06 17:56 ` [edk2-devel] " Laszlo Ersek
2021-01-06 18:46 ` Laszlo Ersek
2021-01-07 5:23 ` Ni, Ray
2021-01-07 10:09 ` Laszlo Ersek
2021-01-07 10:47 ` Zeng, Star [this message]
2021-01-07 11:00 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM6PR11MB4058864A4693C9D5A6A46A36E3AF0@DM6PR11MB4058.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox