All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [next] KVM: lapic: allow setting apic debug dynamically
@ 2019-05-07  6:37 Yi Wang
  2019-05-08 21:59 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: Yi Wang @ 2019-05-07  6:37 UTC (permalink / raw)
  To: pbonzini; +Cc: rkrcmar, tglx, mingo, bp, hpa, x86, kvm, linux-kernel, wang.yi59

There are many functions invoke apic_debug(), which is defined
as a null function by default, and that's incovenient for debuging
lapic.

This patch allows setting apic debug according to add a apic_dbg
parameter of kvm.

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
---
 arch/x86/kvm/lapic.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 9bf70cf..4d8f10f 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -54,8 +54,13 @@
 #define PRIu64 "u"
 #define PRIo64 "o"
 
+static int apic_dbg;
+module_param(apic_dbg, bool, 0644);
+
 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
-#define apic_debug(fmt, arg...) do {} while (0)
+#define apic_debug(fmt, arg...) do {  if (apic_dbg)   \
+	printk(KERN_DEBUG fmt, ##arg);    \
+} while (0)
 
 /* 14 is the version for Xeon and Pentium 8.4.8*/
 #define APIC_VERSION			(0x14UL | ((KVM_APIC_LVT_NUM - 1) << 16))
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [next] KVM: lapic: allow setting apic debug dynamically
  2019-05-07  6:37 [PATCH] [next] KVM: lapic: allow setting apic debug dynamically Yi Wang
@ 2019-05-08 21:59 ` Sean Christopherson
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2019-05-08 21:59 UTC (permalink / raw)
  To: Yi Wang; +Cc: pbonzini, rkrcmar, tglx, mingo, bp, hpa, x86, kvm, linux-kernel

On Tue, May 07, 2019 at 02:37:33PM +0800, Yi Wang wrote:
> There are many functions invoke apic_debug(), which is defined
> as a null function by default, and that's incovenient for debuging
> lapic.
> 
> This patch allows setting apic debug according to add a apic_dbg
> parameter of kvm.
> 
> Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
> ---
>  arch/x86/kvm/lapic.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 9bf70cf..4d8f10f 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -54,8 +54,13 @@
>  #define PRIu64 "u"
>  #define PRIo64 "o"
>  
> +static int apic_dbg;

s/int/bool to get this to compile.  And module params of this nature
should be tagged __read_mostly.

> +module_param(apic_dbg, bool, 0644);
> +
>  /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
> -#define apic_debug(fmt, arg...) do {} while (0)
> +#define apic_debug(fmt, arg...) do {  if (apic_dbg)   \
> +	printk(KERN_DEBUG fmt, ##arg);    \
> +} while (0)

I don't think we want to do this unless there is a very, very strong
argument to do so.  The reason debug messages like this are #ifdef'd
out is because they add conditional branches all over the place and
measurably increase the code size.  E.g.: this patch would increase
KVM's code footprint by 1100+ bytes:

 [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 2] .text             PROGBITS        0000000000000000 000070 04c282 00  AX  0   0 16

vs.

  [ 2] .text             PROGBITS        0000000000000000 000070 04c6d2 00  AX  0   0 16


>  
>  /* 14 is the version for Xeon and Pentium 8.4.8*/
>  #define APIC_VERSION			(0x14UL | ((KVM_APIC_LVT_NUM - 1) << 16))
> -- 
> 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-08 21:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-07  6:37 [PATCH] [next] KVM: lapic: allow setting apic debug dynamically Yi Wang
2019-05-08 21:59 ` Sean Christopherson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.