public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/1] EmbeddedPkg: Only print LibGetTime message about compile time epoch once
@ 2021-03-05 16:11 Rebecca Cran
  2021-03-05 16:12 ` Ard Biesheuvel
  0 siblings, 1 reply; 3+ messages in thread
From: Rebecca Cran @ 2021-03-05 16:11 UTC (permalink / raw)
  To: devel; +Cc: Rebecca Cran, Leif Lindholm, Ard Biesheuvel, Samer El-Haj-Mahmoud

The message "LibGetTime: RtcEpochSeconds non volatile variable was not
found - Using compilation time epoch." can be printed a very large
number of times, causing log files to become excessively large. This is
because the RtcEpochSeconds variable only gets set if LibSetTime is
called, for example by running 'time 12:00' in the UEFI Shell.

Avoid this by setting RtcEpochSeconds to BUILD_EPOCH (EpochSeconds)
after printing the message. It's set to a volatile variable so the
message will be displayed on future boots and not hidden.

Commit 44ae214591e58af468eacb7b873eaa0bc187c4fa reduced the verbosity of
the message to DEBUG_VERBOSE. Revert it back to DEBUG_INFO so it's more
prominent now that it doesn't get printed so frequently.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
---
 EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
index 4210708cff36..de6fbb40e61b 100644
--- a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
+++ b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
@@ -88,10 +88,18 @@ LibGetTime (
     //
     EpochSeconds = BUILD_EPOCH;
     DEBUG ((
-      DEBUG_VERBOSE,
+      DEBUG_INFO,
       "LibGetTime: %s non volatile variable was not found - Using compilation time epoch.\n",
       mEpochVariableName
       ));
+
+    EfiSetVariable (
+      (CHAR16 *)mEpochVariableName,
+      &gEfiCallerIdGuid,
+      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+      sizeof (EpochSeconds),
+      &EpochSeconds
+      );
   }
   Counter = GetPerformanceCounter ();
   EpochSeconds += DivU64x64Remainder (Counter, Freq, &Remainder);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] EmbeddedPkg: Only print LibGetTime message about compile time epoch once
  2021-03-05 16:11 [PATCH 1/1] EmbeddedPkg: Only print LibGetTime message about compile time epoch once Rebecca Cran
@ 2021-03-05 16:12 ` Ard Biesheuvel
  2021-03-08 12:45   ` Leif Lindholm
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2021-03-05 16:12 UTC (permalink / raw)
  To: Rebecca Cran; +Cc: devel, Leif Lindholm, Ard Biesheuvel, Samer El-Haj-Mahmoud

On Fri, 5 Mar 2021 at 17:11, Rebecca Cran <rebecca@nuviainc.com> wrote:
>
> The message "LibGetTime: RtcEpochSeconds non volatile variable was not
> found - Using compilation time epoch." can be printed a very large
> number of times, causing log files to become excessively large. This is
> because the RtcEpochSeconds variable only gets set if LibSetTime is
> called, for example by running 'time 12:00' in the UEFI Shell.
>
> Avoid this by setting RtcEpochSeconds to BUILD_EPOCH (EpochSeconds)
> after printing the message. It's set to a volatile variable so the
> message will be displayed on future boots and not hidden.
>
> Commit 44ae214591e58af468eacb7b873eaa0bc187c4fa reduced the verbosity of
> the message to DEBUG_VERBOSE. Revert it back to DEBUG_INFO so it's more
> prominent now that it doesn't get printed so frequently.
>
> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>

Acked-by: Ard Biesheuvel <ardb@kernel.org>

> ---
>  EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
> index 4210708cff36..de6fbb40e61b 100644
> --- a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
> +++ b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
> @@ -88,10 +88,18 @@ LibGetTime (
>      //
>      EpochSeconds = BUILD_EPOCH;
>      DEBUG ((
> -      DEBUG_VERBOSE,
> +      DEBUG_INFO,
>        "LibGetTime: %s non volatile variable was not found - Using compilation time epoch.\n",
>        mEpochVariableName
>        ));
> +
> +    EfiSetVariable (
> +      (CHAR16 *)mEpochVariableName,
> +      &gEfiCallerIdGuid,
> +      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
> +      sizeof (EpochSeconds),
> +      &EpochSeconds
> +      );
>    }
>    Counter = GetPerformanceCounter ();
>    EpochSeconds += DivU64x64Remainder (Counter, Freq, &Remainder);
> --
> 2.26.2
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] EmbeddedPkg: Only print LibGetTime message about compile time epoch once
  2021-03-05 16:12 ` Ard Biesheuvel
@ 2021-03-08 12:45   ` Leif Lindholm
  0 siblings, 0 replies; 3+ messages in thread
From: Leif Lindholm @ 2021-03-08 12:45 UTC (permalink / raw)
  To: Rebecca Cran, Ard Biesheuvel; +Cc: devel, Ard Biesheuvel, Samer El-Haj-Mahmoud

On Fri, Mar 05, 2021 at 17:12:46 +0100, Ard Biesheuvel wrote:
> On Fri, 5 Mar 2021 at 17:11, Rebecca Cran <rebecca@nuviainc.com> wrote:
> >
> > The message "LibGetTime: RtcEpochSeconds non volatile variable was not
> > found - Using compilation time epoch." can be printed a very large
> > number of times, causing log files to become excessively large. This is
> > because the RtcEpochSeconds variable only gets set if LibSetTime is
> > called, for example by running 'time 12:00' in the UEFI Shell.
> >
> > Avoid this by setting RtcEpochSeconds to BUILD_EPOCH (EpochSeconds)
> > after printing the message. It's set to a volatile variable so the
> > message will be displayed on future boots and not hidden.
> >
> > Commit 44ae214591e58af468eacb7b873eaa0bc187c4fa reduced the verbosity of
> > the message to DEBUG_VERBOSE. Revert it back to DEBUG_INFO so it's more
> > prominent now that it doesn't get printed so frequently.
> >
> > Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> 
> Acked-by: Ard Biesheuvel <ardb@kernel.org>

Reviewed-by: Leif Lindholm <leif@nuviainc.com>

Pushed as 94fa95c8746c.

Thanks!

> > ---
> >  EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
> > index 4210708cff36..de6fbb40e61b 100644
> > --- a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
> > +++ b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
> > @@ -88,10 +88,18 @@ LibGetTime (
> >      //
> >      EpochSeconds = BUILD_EPOCH;
> >      DEBUG ((
> > -      DEBUG_VERBOSE,
> > +      DEBUG_INFO,
> >        "LibGetTime: %s non volatile variable was not found - Using compilation time epoch.\n",
> >        mEpochVariableName
> >        ));
> > +
> > +    EfiSetVariable (
> > +      (CHAR16 *)mEpochVariableName,
> > +      &gEfiCallerIdGuid,
> > +      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
> > +      sizeof (EpochSeconds),
> > +      &EpochSeconds
> > +      );
> >    }
> >    Counter = GetPerformanceCounter ();
> >    EpochSeconds += DivU64x64Remainder (Counter, Freq, &Remainder);
> > --
> > 2.26.2
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-08 12:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-05 16:11 [PATCH 1/1] EmbeddedPkg: Only print LibGetTime message about compile time epoch once Rebecca Cran
2021-03-05 16:12 ` Ard Biesheuvel
2021-03-08 12:45   ` Leif Lindholm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox