From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ilari Stenroth Subject: RFC: [PATCH v1] KVM: Use trace_printk() for vcpu_unimpl() for performance reasons Date: Sun, 10 Aug 2014 17:35:17 +0300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org Return-path: Received: from plane.gmane.org ([80.91.229.3]:41939 "EHLO plane.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750986AbaHJPKH (ORCPT ); Sun, 10 Aug 2014 11:10:07 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XGUl2-0003BF-Mq for kvm@vger.kernel.org; Sun, 10 Aug 2014 17:10:04 +0200 Received: from gw.stenroth.fi ([188.127.202.98]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 Aug 2014 17:10:04 +0200 Received: from ilari.stenroth by gw.stenroth.fi with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 Aug 2014 17:10:04 +0200 Sender: kvm-owner@vger.kernel.org List-ID: 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. Signed-off-by: Ilari Stenroth --- include/linux/kvm_host.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index a4c33b3..b79ce59 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include @@ -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, ...) \ -- 2.0.4