<div dir="ltr"><div>Thank you for the comment, Kazu.</div><div dir="ltr">On Tue, Jan 18, 2022 at 2:26 PM HAGIO KAZUHITO(萩尾 一仁) <<a href="mailto:k-hagio-ab@nec.com">k-hagio-ab@nec.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Lianbo,<br>
<br>
-----Original Message-----<br>
> The "boot_date" is initialized conditionally in the cmd_log(), which may<br>
> display incorrect "boot_date" value with the following command before<br>
> running the "log -T" command:<br>
> <br>
> crash> help -k | grep date<br>
>           date: Wed Dec 22 13:39:29 IST 2021<br>
>      boot_date: Thu Jan  1 05:30:00 IST 1970<br>
>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br>
<br>
The "help -k" prints internal variables for debugging and it's merely<br>
uninitialized, so personally I don't think this is a bug, but I agree that<br>
the current behavior is not friendly and initializing it during startup<br>
will be helpful.<br>
<br></blockquote><div>Yes, you are right.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> The calculation of "boot_date" depends on the HZ value, and the HZ will<br>
> be calculated in task_init() at the latest, so let's move it here.<br>
<br>
Hmm, initializing the boot_date in task_init() looks a bit strange to me,<br></blockquote><div> </div><div>Me too.</div><div>But anyway, as mentioned above, the calculation of HZ is in task_init(), at least crash can get an expected behavior there.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
but possibly the HZ can be set in machdep_init(POST_GDB), so it's fine..<br>
<br>
> <br>
> Fixes: c86250bce29f ("Introduction of the "log -T" option...")<br>
<br>
Could you please remove this Fixes: tag?<br>
<br></blockquote><div>Sure. Thanks.</div><div>Lianbo</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Without this,<br>
Acked-by: Kazuhito Hagio <<a href="mailto:k-hagio-ab@nec.com" target="_blank">k-hagio-ab@nec.com</a>><br>
<br>
Thanks,<br>
Kazu<br>
<br>
> Signed-off-by: Lianbo Jiang <<a href="mailto:lijiang@redhat.com" target="_blank">lijiang@redhat.com</a>><br>
> ---<br>
>  kernel.c | 18 +++---------------<br>
>  task.c   | 10 ++++++++++<br>
>  2 files changed, 13 insertions(+), 15 deletions(-)<br>
> <br>
> diff --git a/kernel.c b/kernel.c<br>
> index 36c57ed501ad..094fe9b2efad 100644<br>
> --- a/kernel.c<br>
> +++ b/kernel.c<br>
> @@ -5025,21 +5025,9 @@ cmd_log(void)<br>
>          if (argerrs)<br>
>                  cmd_usage(pc->curcmd, SYNOPSIS);<br>
> <br>
> -     if (msg_flags & SHOW_LOG_CTIME) {<br>
> -             if (pc->flags & MINIMAL_MODE) {<br>
> -                     error(WARNING, "the option '-T' is not available in minimal mode\n");<br>
> -                     return;<br>
> -             }<br>
> -<br>
> -             if (kt->boot_date.tv_sec == 0) {<br>
> -                     ulonglong uptime_jiffies;<br>
> -                     ulong  uptime_sec;<br>
> -<br>
> -                     get_uptime(NULL, &uptime_jiffies);<br>
> -                     uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;<br>
> -                     kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;<br>
> -                     kt->boot_date.tv_nsec = 0;<br>
> -             }<br>
> +     if (msg_flags & SHOW_LOG_CTIME && pc->flags & MINIMAL_MODE) {<br>
> +             error(WARNING, "the option '-T' is not available in minimal mode\n");<br>
> +             return;<br>
>       }<br>
> <br>
>       if (msg_flags & SHOW_LOG_AUDIT) {<br>
> diff --git a/task.c b/task.c<br>
> index 76e184ae70b1..263a8344dd94 100644<br>
> --- a/task.c<br>
> +++ b/task.c<br>
> @@ -692,6 +692,16 @@ task_init(void)<br>
> <br>
>       stack_overflow_check_init();<br>
> <br>
> +     if (machdep->hz) {<br>
> +             ulonglong uptime_jiffies;<br>
> +             ulong  uptime_sec;<br>
> +<br>
> +             get_uptime(NULL, &uptime_jiffies);<br>
> +             uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;<br>
> +             kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;<br>
> +             kt->boot_date.tv_nsec = 0;<br>
> +     }<br>
> +<br>
>       tt->flags |= TASK_INIT_DONE;<br>
>  }<br>
> <br>
> --<br>
> 2.20.1<br>
<br>
</blockquote></div></div>