The commit is pushed to "branch-rh10-6.12.0-55.13.1.2.x.vz10-ovz" and will
appear at [email protected]:openvz/vzkernel.git
after rh10-6.12.0-55.13.1.2.21.vz10
------>
commit 6f133010a39b5a3bd5e0b7103bb9a34515c2ff8f
Author: Aleksei Oladko <[email protected]>
Date: Tue Nov 25 16:40:31 2025 +0000
ve/printk: Add deferred version for scheduler-safe logging
Introduce ve_printk_deferred() that uses LOGLEVEL_SCHED to defer console
output, preventing deadlocks when called from scheduler contexts where
up() cannot be invoked.
The function mirrors ve_printk() logic but uses vprintk_emit() with
LOGLEVEL_SCHED instead of vprintk(), ensuring console output is offloaded
to kthreads rather than printed directly.
https://virtuozzo.atlassian.net/browse/VSTOR-119876
Signed-off-by: Aleksei Oladko <[email protected]>
Reviewed-by: Pavel Tikhomirov <[email protected]>
Feature: printk: per-CT virtualization
---
include/linux/printk.h | 8 ++++++++
kernel/printk/printk.c | 28 ++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index d74ad6f389870..8bbf98d43b939 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -169,6 +169,9 @@ int _printk(const char *fmt, ...);
asmlinkage __printf(2, 3) __cold
int ve_printk(int dst, const char *fmt, ...);
+asmlinkage __printf(2, 3) __cold
+int ve_printk_deferred(int dst, const char *fmt, ...);
+
struct ve_struct;
int ve_log_init(struct ve_struct *ve);
void ve_log_destroy(struct ve_struct *ve);
@@ -237,6 +240,11 @@ int ve_printk(int dst, const char *s, ...)
{
return 0;
}
+static inline __printf(2, 3) __cold
+int ve_printk_deferred(int dst, const char *s, ...)
+{
+ return 0;
+}
static inline
int ve_log_init(struct ve_struct *ve)
{
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f8e32b5fad0d7..68d82ff5a1fa3 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2558,6 +2558,34 @@ asmlinkage int ve_printk(int dst, const char *fmt, ...)
}
EXPORT_SYMBOL(ve_printk);
+static asmlinkage int ve_vprintk_deferred(int dst, const char *fmt, va_list
args)
+{
+ va_list args2;
+ int r = 0;
+
+ va_copy(args2, args);
+ if (ve_is_super(get_exec_env()) || (dst & VE0_LOG))
+ r = vprintk_emit(0, LOGLEVEL_SCHED, NULL, fmt, args);
+ if (!ve_is_super(get_exec_env()) && (dst & VE_LOG))
+ r = ve_vprintk_emit(0, LOGLEVEL_SCHED, NULL, fmt, args2);
+ va_end(args2);
+
+ return r;
+}
+
+asmlinkage int ve_printk_deferred(int dst, const char *fmt, ...)
+{
+ va_list args;
+ int r;
+
+ va_start(args, fmt);
+ r = ve_vprintk_deferred(dst, fmt, args);
+ va_end(args);
+
+ return r;
+}
+EXPORT_SYMBOL(ve_printk_deferred);
+
static asmlinkage int ve_log_vprintk(struct ve_struct *ve, const char *fmt,
va_list args)
{
int r = 0;
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel