|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH RFC v3 1/3] time: add "NOW() good" indicator
printk_start_of_line() checks for a value of 0 right now. In order to be
able to have NOW() return at least monotonically increasing values, that
needs replacing by an explicit indicator.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Arm and RISC-V may want to consider whether their initial get_cycles()
can't be moved yet earlier, such that the indicator also can be set
yet earlier.
---
v3: New.
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -145,6 +145,7 @@ void __init preinit_xen_time(void)
panic("Timer: Cannot initialize platform timer\n");
boot_count = get_cycles();
+ NOW_good = true;
}
static void __init init_dt_xen_time(void)
--- a/xen/arch/riscv/time.c
+++ b/xen/arch/riscv/time.c
@@ -87,6 +87,7 @@ void __init preinit_xen_time(void)
panic("%s: ACPI isn't supported\n", __func__);
boot_clock_cycles = get_cycles();
+ NOW_good = true;
/* set_xen_timer must have been set by sbi_init() already */
ASSERT(set_xen_timer);
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -2657,6 +2657,7 @@ void __init early_time_init(void)
set_time_scale(&t->tsc_scale, tmp);
t->stamp.local_tsc = boot_tsc_stamp;
+ NOW_good = true;
init_percpu_time();
--- a/xen/common/time.c
+++ b/xen/common/time.c
@@ -22,6 +22,8 @@
#include <asm/div64.h>
#include <asm/domain.h>
+bool __ro_after_init NOW_good;
+
/* Nonzero if YEAR is a leap year (every 4 years,
except every 100th isn't, and every 400th is). */
#define __isleap(year) \
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -975,11 +975,10 @@ static void printk_start_of_line(const c
}
/* fall through */
case TSM_BOOT:
- sec = NOW();
- nsec = do_div(sec, 1000000000);
-
- if ( sec | nsec )
+ if ( NOW_good )
{
+ sec = NOW();
+ nsec = do_div(sec, 1000000000);
snprintf(tstr, sizeof(tstr), "[%5"PRIu64".%06"PRIu64"] ",
sec, nsec / 1000);
break;
--- a/xen/include/xen/time.h
+++ b/xen/include/xen/time.h
@@ -63,6 +63,12 @@ struct tm wallclock_time(uint64_t *ns);
/* Chosen so (NOW() + delta) wont overflow without an uptime of 200 years */
#define STIME_DELTA_MAX ((s_time_t)((uint64_t)~0ULL>>2))
+/*
+ * Indicator that the value returned by NOW() is good (earlier invocations may
+ * return zero or very small, merely monotonically increasing values).
+ */
+extern bool NOW_good;
+
/* Explicitly OR with 1 just in case version number gets out of sync. */
#define version_update_begin(v) (((v) + 1) | 1)
#define version_update_end(v) ((v) + 1)
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |