From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 2C98A807FB for ; Tue, 6 Oct 2026 21:55:45 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 696LsSTE028173; Wed, 7 Oct 2026 00:54:29 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696LsSTE028173 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="kFsmqk41" Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 696LsAt8028123 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 7 Oct 2026 00:54:10 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696LsAt8028123 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48c50ed05abso2514911f8f.0 for ; Tue, 06 Oct 2026 14:54:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBz5skZrCQjLhm9CozhPyVEN3IcW/kwCAzOLHeljJRFCpqvi+z2X5+WmoNNgUYMMlYlowQjygA==@openvz.org X-Gm-Message-State: AFq9FYLG7wk+RvZ+SePQgAQJZD1G8kmV9p6d/sMySbCoUBJigx7pKq3A UCK9Ze7bJbE0I6ecXGqGg0xFRRLdYoo5jkBl1W+93XjKnmGQttqykWs3sSw1hECuB8Ye4Gky1+k lxJF/tqEZfHzFM6DBEaaJxRsZMNKDUmvVrMNCb2dMpdF+kKomMKCeJw== X-Gm-Gg: AYBFou1tXPnyKjV6vpz80FiGWjWZaqJTgPAO/ED7LWbepjFceEqk+PVJpURvTub38/g IoWj0ExHXdzXP3M2lU0tXEAAZ88gAyB338iW7GS1WnbepZoLhFzh/vDFltMhMsX3RrS0GaY5U8W NZQ5EdOp55/+SjOYvsilwqInNcX8eKPgoigveUFaiySMACjtCs+b07Cn0ETDrrTtLLVs8YOUpJl MlkyZ9uXgDbU43a80DuTnBGIA4wB/ENWRwMM7CJTV3f5WZ7uNnWN+E5+zJCJTnIfU6UFXSBLgpN 02ArdvNcrpcs59csnkXiCPUyTyMLjCpRSpB5XRXOI9Ib+pt2FFrlNFFXwioaO6YPLxZuGsOuHaw iaAXvEMgEPOPUNpLoyHscSB5rGd2Q X-Received: by 2002:a05:6000:46c3:b0:487:1687:197d with SMTP id ffacd0b85a97d-48c726ff41dmr836406f8f.6.1791323649809; Tue, 06 Oct 2026 14:54:09 -0700 (PDT) X-Received: by 2002:a05:6000:46c3:b0:487:1687:197d with SMTP id ffacd0b85a97d-48c726ff41dmr836388f8f.6.1791323649254; Tue, 06 Oct 2026 14:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791323649; cv=none; d=google.com; s=arc-20260327; b=TQz+1mJfUrZbz34rD1sB9g60xKu4/BqMgOYu1H8sDgVR7Tvnl52mh6zrXszEgb1rkF nQLA4Cqj334GDphP7NxaXezge0WXR5ayM6sSRZkMAtEpubPmaTXTYoyZCV2ZfSro+dhQ WMXhulzHkrjBrV7nAC7gyRlw3s4J/ZLg/olzNgSYvaPlwdQgK2m8eoKXZcNBDhq0AGR3 RJ7Z44jPw4SCSiMvddnBa+zlDhQzialFygmke3nrfWsmbB3oIcam2aJ259se6Z5chHbA R2bsJoAm0ybAqMgL2T+e3duhLPn/2gdxsWi/ZvI8frjNvO93ktQ5qvb+xj1+59kCrs2k EMow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=P8be3c2x8k4+IE+oYekHVW04TiIPs3KB8tA6TQ1lRKg=; fh=qxDc+R3aPG8cEdp5mmd3IFOllj1eLCwZHAcc+Tf/KXA=; b=KvxIJ48qTG1ZbtGzgRW2PVZ8w0wfb4chPe4+3f5ZzTvXWwR4VIMmLZNU8V94GftP0o JzV2nuM865ayb36TGEbwbEWIEAHjThRuWeq0jri9Y2VDM9MBP2a67FHreeRiviTSDCje HMNrurLt4kjvdGfmWMEz5SJtIZDa/vdnwkbrWVbaY/djUunWhryRXAmn+Q0NQKHaNrPG XP3OmfGmYKWbhKY4SsedIx8dEXab+ZrD3CSGCcHk+cs5r2NuXx9V8XgYkPeNLUgl9Gvi EZvGX6t1+OameUqfxwZ8zrAuvm3zAwcFAjkjqFtRAag7DcCCnoEaLy80gzRJJb6mnCly iRow==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=kFsmqk41; spf=pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vladimir.riabchun@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-48c724c110asi1242293f8f.502.2026.10.06.14.54.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 14:54:09 -0700 (PDT) Received-SPF: pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=kFsmqk41; spf=pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vladimir.riabchun@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Message-Id:Content-Type:MIME-Version:Subject:Date :From; bh=P8be3c2x8k4+IE+oYekHVW04TiIPs3KB8tA6TQ1lRKg=; b=kFsmqk41zfAR44lW0Q8 uifQeqE8EgXhj5Gr/7JSYBDPTGsu+huXaa9yP+TTI5nEu9tmWlMAs9Qto17CbxAsr4UZcqjzzKa61 o0I4FRm4WKBBVMwnbS0qG1wJMNY3GGcpQ006Y9/bkx5dH0k+AQe3EHmVnBauIPLWduWx7YX7OuMAR dGTLdVoywh6bkMf7nRYlcGq+Kg8KTABpFOqfRfmyxwAKHmB5b9RzGOGG9WsyCq0DApzp7VtgOTfQ6 tEvPQyCtVA67crADAFiacRGtBSPM9CitPJBQ6SHeZjNyR3mtujHs6Xu4B7gny2UYlXqF4fv576U87 29lgHdE0O+lCIbA==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=192.168.1.87) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1xED3f-004Dgb-24; Tue, 06 Oct 2026 23:53:58 +0200 From: Vladimir Riabchun Date: Tue, 06 Oct 2026 23:53:55 +0200 MIME-Version: 1.0 Message-Id: <20261006-ve-printk-irq-v2-4-db1dc4f6ed07@virtuozzo.com> References: <20261006-ve-printk-irq-v2-0-db1dc4f6ed07@virtuozzo.com> In-Reply-To: <20261006-ve-printk-irq-v2-0-db1dc4f6ed07@virtuozzo.com> To: vasileios.almpanis@virtuozzo.com, Konstantin Khorenko X-Mailer: b4 0.14.3 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v2 4/6] ve/printk: Fix time virtualization X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org The usage of get_exec_env() in ve_timens_add_boottime_ns can lead to time travels - a printk from IRQ might use container time for printing to host dmesg and vice versa. Do time adjustments on message submission in vprintk_store_log, there we know the final destination and VE, so we can get actual time namespace and offsets there. https://virtuozzo.atlassian.net/browse/VSTOR-146839 Feature: ve printk Signed-off-by: Vladimir Riabchun --- kernel/printk/internal.h | 4 ++++ kernel/printk/printk.c | 12 +++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index d00ac40d8401..d678718482ed 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -354,11 +354,15 @@ struct log_state { */ struct latched_seq clear_seq; struct printk_ringbuffer *prb; + struct ve_struct *owner_ve; }; +#define GET_VE_LOG(ve) ((struct log_state *) ve->log_state) + extern struct log_state init_log_state; struct log_state *ve_log_state(void); +struct log_state *__ve_log_state(struct ve_struct *ve); bool printk_get_next_message(struct log_state *log, struct printk_message *pmsg, u64 seq, diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index d5680fda32ca..cf4baacd22d8 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -534,6 +534,7 @@ struct log_state init_log_state = { .val[1] = 0, }, .prb = &printk_rb_static, + .owner_ve = &ve0, }; /* kdump relies on some log_* symbols, let's make it happy */ @@ -698,12 +699,12 @@ static void append_char(char **pp, char *e, char c) *(*pp)++ = c; } -static inline u64 ve_timens_add_boottime_ns(u64 nsec) +static inline u64 ve_timens_add_boottime_ns(u64 nsec, struct ve_struct *ve) { struct time_namespace *ve_time_ns; struct timens_offsets *ns_offsets; - ve_time_ns = ve_get_time_ns(get_exec_env()); + ve_time_ns = ve_get_time_ns(ve); if (unlikely(!ve_time_ns)) { /* container not yet started */ return nsec; @@ -731,8 +732,6 @@ static ssize_t info_print_ext_header(char *buf, size_t size, caller[0] = '\0'; #endif - /* shift the timestamp on the Container uptime value */ - ts_usec = ve_timens_add_boottime_ns(ts_usec); do_div(ts_usec, 1000); return scnprintf(buf, size, "%u,%llu,%llu,%c%s;", @@ -1431,9 +1430,6 @@ static size_t print_time(u64 ts, char *buf) { unsigned long rem_nsec; - /* shift the timestamp on the Container uptime value */ - ts = ve_timens_add_boottime_ns(ts); - rem_nsec = do_div(ts, 1000000000); return sprintf(buf, "[%5lu.%06lu]", @@ -2329,6 +2325,7 @@ static int vprintk_store_log(struct log_state *log, int facility, int level, * timestamp with respect to the caller. */ ts_nsec = local_clock(); + ts_nsec = ve_timens_add_boottime_ns(ts_nsec, log->owner_ve); caller_id = printk_caller_id(); @@ -5294,6 +5291,7 @@ int ve_log_init(struct ve_struct *ve) seqcount_latch_init(&log->clear_seq.latch); ve->log_state = log; + log->owner_ve = ve; return 0; } -- 2.52.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel