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 54138802A5 for ; Sun, 11 Oct 2026 22:54:21 +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 69BMrAro009407; Mon, 12 Oct 2026 01:53:11 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69BMrAro009407 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="GUK+vi5l" Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69BMqqPE009360 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 12 Oct 2026 01:52:52 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69BMqqPE009360 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4a009f82bedso10911315e9.0 for ; Sun, 11 Oct 2026 15:52:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvByHygGak1yKVVBnC8d6BSxno2idDjNeKaPMkKOn9DHbDvWCOjuvZkSoJD2x1FJMzMJksYOTPg==@openvz.org X-Gm-Message-State: AFq9FYL/zKW59ak1jsEPfrAcZUs/OSxNdDLo/Y9bi9YG4hE8uGYMQa7O mNx4/+JeRaDBHCraEObHZZwirM0dlNfjaDZ3b8B8aasQ8Imc1TyptUuaJ0o62y+Ju6ir27yA8Pu 9FeHd2q6jXr761wYCg3O0QD3YzwOBKijvkYXGXBLB38hAoQV4pfZxzw== X-Gm-Gg: AYBFou34YCdwuV4t3ceAHofgA7yVY/JDuFFP/y3mcntt6hTwr485US4Gwr43F1xWF/i 0hLabsoXBbZ1rBpMcYswaRfTtlq+29E4QYg/AM0BVRGVfrq7LeEdPG8olIhTB1Y+abkIvH9vMgM z8P+WNFaOcI0KPecdu0854XCSd1czMxuaeb6Yl8OqU/TWk+wXQophRoEnIkNgidaHdkA0QZIwny Y/TswyRINlqqkIjuCAHxjKpZ9EWPOmaJPwSiKH8tSHBhlLXUsihtXsY2S5Mejm1ZvHr8zxqx3Pj MrPzTc0F8unZ3GQTbN8aHkupRyaTjUUOeu++6Hb0iaVt2zdupNGmQmd848q4I3OOmjn9fvzYvQ9 aR0KuNqrYq5YVYTIGcFiuixeSaWSx X-Received: by 2002:a05:600c:6207:b0:49f:ff73:9971 with SMTP id 5b1f17b1804b1-4a18e4aff66mr140663855e9.18.1791759172264; Sun, 11 Oct 2026 15:52:52 -0700 (PDT) X-Received: by 2002:a05:600c:6207:b0:49f:ff73:9971 with SMTP id 5b1f17b1804b1-4a18e4aff66mr140663685e9.18.1791759171718; Sun, 11 Oct 2026 15:52:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791759171; cv=none; d=google.com; s=arc-20260327; b=bSqYcqUcByViQGZKGyqvQZDQ7XibfUc9i1Uskvx2kObsqQoNEdBeX6VSc6U+JKpWma 3VbI7ZWPdanLy6OTG1VhLAvLYSBvZ7SFLC8/lADsznCsGs51uftRUskGSCy24wzODU0B g1gLDY/TSz4JChu5RSjnsonZfgMNlwpU6ipqrSnvJx9gPOuTJ37tV9k6SDUrkSmNyZPY S8wCneksrUpJ7OVpTZ+h7rwfaaYKr82N3wxL0taSEdfrYrZ1oYOj789o1RMLZGbhcpP/ H3q+Q/vBlq2lvQrUudz18QE//IUTlGIJFP1trjnGk0bGXyBo6+8ZrtFu0qI5vFw+3lT2 E6wQ== 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=3WODhn6Yf8Q520h4ggAv2A7hAk5ZTIWisyTaI7hNbBA=; fh=eCOFrBZAqsL6jjT8ApulcBPCLrgIlXlNCEpSn7Ap5O8=; b=NvFkHVEhE+yoLICLjooiyO756XymMMN+dGNOAha9BXGYNld4y9bB7mjioQrjLJdQ51 aiPYXwWTJSIlL6bV9/aYcRhR3E4IKKn7pZ2ZpMflHoX9CFRmKM3s6+dxPxsmnwybDFOo 79ANAmCy5Fl907foXpQ7LpHa4fSNCgfH0NR0/ePpggnDhcstlKod45EGXSiz4SOaveb/ mpNIr5wYrfDX1KWcg4frIZ/eoeDJhpY91HBYvm3Uu5nCVSxhyWSJqhe72xQkQZanj0S+ rYVEfTuTcuhNXI9oVAwCTKrvmVldUbiOMZg7bfcg92h2r1LhbPBhMcyFSe5kx49DtK4a Txmg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=GUK+vi5l; 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-48dbf071815si14033075f8f.488.2026.10.11.15.52.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Oct 2026 15:52:51 -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=GUK+vi5l; 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=3WODhn6Yf8Q520h4ggAv2A7hAk5ZTIWisyTaI7hNbBA=; b=GUK+vi5lR/sl+7YMApw x3YyAh62rlpod0+bH77Id4p/2NMiZuZf1u2RaiyTqhwp2m4Q+b8WZwOFjlcpqdhwUzV38w0/K0xkq V2jHFXVFJk2lkVq4Oii6Nepk2dL7+O0YEw84NRberANe2RGLtChCZlYGy/t1ChpfFLiUCogqMHqlz X2PzJaQrjU8Frt2LvCTka0paeg8Sbcjytor3CBFzZwAX781X3/NQzD+CBe7AdYVJP4nM+VLYY4aCS S08MxnCiaYYmGr170BSb2NjGl5qVu7q14LKf4KZccvAoWsU8hWJJA52WAg8VtFjCoivyHjx4Xwtk1 pZ2ty8dHINbBxAA==; 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 1xG2M6-002SCD-0s; Mon, 12 Oct 2026 00:52:44 +0200 From: Vladimir Riabchun Date: Mon, 12 Oct 2026 00:52:31 +0200 MIME-Version: 1.0 Message-Id: <20261012-ve-printk-irq-v3-4-efc95fd5c78a@virtuozzo.com> References: <20261012-ve-printk-irq-v3-0-efc95fd5c78a@virtuozzo.com> In-Reply-To: <20261012-ve-printk-irq-v3-0-efc95fd5c78a@virtuozzo.com> To: vasileios.almpanis@virtuozzo.com, ptikhomirov@virtuozzo.com, Konstantin Khorenko X-Mailer: b4 0.14.3 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v3 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 | 2 ++ kernel/printk/printk.c | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index d00ac40d8401..10c2c15f9fb8 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -354,11 +354,13 @@ struct log_state { */ struct latched_seq clear_seq; struct printk_ringbuffer *prb; + struct ve_struct *owner_ve; }; 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 f0897de062a8..efe2d3069d7a 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -534,6 +534,9 @@ struct log_state init_log_state = { .val[1] = 0, }, .prb = &printk_rb_static, +#ifdef CONFIG_VE + .owner_ve = &ve0, +#endif }; /* kdump relies on some log_* symbols, let's make it happy */ @@ -698,12 +701,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 +734,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 +1432,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 +2327,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(); @@ -5292,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