[Devel] [PATCH RHEL7 COMMIT] syslog: Virtualize timestamps in the data reported
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Feb 6 20:17:31 MSK 2023
The commit is pushed to "branch-rh7-3.10.0-1160.83.1.vz7.194.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.83.1.vz7.194.2
------>
commit b44b2f8707da076195b74f804d84c65e6b8fc05e
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date: Thu Feb 2 22:52:32 2023 +0300
syslog: Virtualize timestamps in the data reported
Internally log messages contain the timestamps relative to the Host boot
time, while Container could start much later than the Host boots and the
timestamps should be shifted accordingly.
Otherwise syslog() syscall reports incorrect timestamps.
https://jira.sw.ru/browse/PSBM-145263
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
Acked-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
kernel/printk.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/printk.c b/kernel/printk.c
index 27221d15590a..747383d21569 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -960,11 +960,18 @@ module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
static size_t print_time(u64 ts, char *buf)
{
+ struct ve_struct *ve;
unsigned long rem_nsec;
if (!printk_time)
return 0;
+ /* shift the timestamp on the Container uptime value */
+ ve = get_exec_env();
+ if (!ve_is_super(ve)) {
+ ts -= ve->real_start_timespec.tv_sec * NSEC_PER_SEC;
+ ts -= ve->real_start_timespec.tv_nsec;
+ }
rem_nsec = do_div(ts, 1000000000);
if (!buf)
More information about the Devel
mailing list