Skip to contentSkip to conversation

RFC: [PATCH v1] KVM: Use trace_printk() for vcpu_unimpl() for performance reasons

PATCH Ilari Stenroth 1 participant 1 message Aug 10, 2014 KVM

lore
Share & tools
lore
#0 lore raw

vcpu_unimpl() is called to notify for example about unhandled wrmsr requests made by KVM guests. It used to call printk() but in certain setups printk() may cause severe performance impact thus replacing printk() with guaranteed to be buffered trace_printk() avoids this caveat.

---
 include/linux/kvm_host.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/kvm_host.h +8 -0
index a4c33b3..b79ce59 100644
@@ -24,6 +24,8 @@
 #include <linux/err.h>
 #include <linux/irqflags.h>
 #include <linux/context_tracking.h>
+#include <linux/kernel.h>
+#include <linux/kern_levels.h>
 #include <asm/signal.h>
 
 #include <linux/kvm.h>
@@ -408,9 +410,15 @@ struct kvm {
 	pr_info("kvm [%i]: " fmt, task_pid_nr(current), ## __VA_ARGS__)
 #define kvm_debug(fmt, ...) \
 	pr_debug("kvm [%i]: " fmt, task_pid_nr(current), ## __VA_ARGS__)
+#ifdef CONFIG_TRACING
+#define kvm_pr_unimpl(fmt, ...) \
+	trace_printk(pr_fmt("KERN_ERR kvm [%i]: " fmt), \
+			   task_tgid_nr(current), ## __VA_ARGS__)
+#else
 #define kvm_pr_unimpl(fmt, ...) \
 	pr_err_ratelimited("kvm [%i]: " fmt, \
 			   task_tgid_nr(current), ## __VA_ARGS__)
+#endif
 
 /* The guest did something we don't support. */
 #define vcpu_unimpl(vcpu, fmt, ...)					\
Signature · 1 line
2.0.4