2019-05-31 06:41:47

by Wanpeng Li

[permalink] [raw]
Subject: [PATCH v2 2/2] KVM: LAPIC: remove the trailing newline used in the fmt parameter of TP_printk

From: Wanpeng Li <[email protected]>

The trailing newlines will lead to extra newlines in the trace file
which looks like the following output, so remove it.

qemu-system-x86-15695 [002] ...1 15774.839240: kvm_hv_timer_state: vcpu_id 0 hv_timer 1

qemu-system-x86-15695 [002] ...1 15774.839309: kvm_hv_timer_state: vcpu_id 0 hv_timer 1

Cc: Paolo Bonzini <[email protected]>
Cc: Radim Krčmář <[email protected]>
Signed-off-by: Wanpeng Li <[email protected]>
---
arch/x86/kvm/trace.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index 4d47a26..b5c831e 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -1365,7 +1365,7 @@ TRACE_EVENT(kvm_hv_timer_state,
__entry->vcpu_id = vcpu_id;
__entry->hv_timer_in_use = hv_timer_in_use;
),
- TP_printk("vcpu_id %x hv_timer %x\n",
+ TP_printk("vcpu_id %x hv_timer %x",
__entry->vcpu_id,
__entry->hv_timer_in_use)
);
--
2.7.4


2019-05-31 18:59:39

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] KVM: LAPIC: remove the trailing newline used in the fmt parameter of TP_printk

On Fri, 2019-05-31 at 14:40 +0800, Wanpeng Li wrote:
> The trailing newlines will lead to extra newlines in the trace file
[]
> diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
[]
> @@ -1365,7 +1365,7 @@ TRACE_EVENT(kvm_hv_timer_state,
> __entry->vcpu_id = vcpu_id;
> __entry->hv_timer_in_use = hv_timer_in_use;
> ),
> - TP_printk("vcpu_id %x hv_timer %x\n",
> + TP_printk("vcpu_id %x hv_timer %x",
> __entry->vcpu_id,
> __entry->hv_timer_in_use)
> );

Not about the kvm subsystem, but generically there are
many of these that could be removed.

$ git grep -w TP_printk | grep '\\n' | wc -l
45

Also, aren't all TP_printk formats supposed to be single line?

If not, these are odd as well.

$ git grep -w TP_printk | grep '\\n[^"]'
include/trace/events/9p.h: TP_printk("clnt %lu %s(tag = %d)\n%.3x: %16ph\n%.3x: %16ph\n",
net/tipc/trace.h: TP_printk("%s\n%s", __get_str(header), __get_str(buf))
net/tipc/trace.h: TP_printk("%s\n%s", __get_str(header), __get_str(buf))
net/tipc/trace.h: TP_printk("<%u> %s\n%s%s", __entry->portid, __get_str(header),
net/tipc/trace.h: TP_printk("<%s> %s\n%s", __entry->name, __get_str(header),
net/tipc/trace.h: TP_printk("<%x> %s\n%s", __entry->addr, __get_str(header),

Perhaps the documentation files around these formats
Documentation/trace/events.rst
Documentation/trace/tracepoints.rst
could be improved as well.


2019-06-08 21:28:41

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] KVM: LAPIC: remove the trailing newline used in the fmt parameter of TP_printk

On Fri, 31 May 2019 11:57:04 -0700
Joe Perches <[email protected]> wrote:

> On Fri, 2019-05-31 at 14:40 +0800, Wanpeng Li wrote:
> > The trailing newlines will lead to extra newlines in the trace file
> []
> > diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
> []
> > @@ -1365,7 +1365,7 @@ TRACE_EVENT(kvm_hv_timer_state,
> > __entry->vcpu_id = vcpu_id;
> > __entry->hv_timer_in_use = hv_timer_in_use;
> > ),
> > - TP_printk("vcpu_id %x hv_timer %x\n",
> > + TP_printk("vcpu_id %x hv_timer %x",
> > __entry->vcpu_id,
> > __entry->hv_timer_in_use)
> > );
>
> Not about the kvm subsystem, but generically there are
> many of these that could be removed.
>
> $ git grep -w TP_printk | grep '\\n' | wc -l
> 45
>
> Also, aren't all TP_printk formats supposed to be single line?

Yeah they should be, otherwise it makes the trace look funny. We do
have some legitimate ones (stack traces for example), but really,
unless there's a good reason, it shouldn't have them.

>
> If not, these are odd as well.
>
> $ git grep -w TP_printk | grep '\\n[^"]'
> include/trace/events/9p.h: TP_printk("clnt %lu %s(tag = %d)\n%.3x: %16ph\n%.3x: %16ph\n",
> net/tipc/trace.h: TP_printk("%s\n%s", __get_str(header), __get_str(buf))
> net/tipc/trace.h: TP_printk("%s\n%s", __get_str(header), __get_str(buf))
> net/tipc/trace.h: TP_printk("<%u> %s\n%s%s", __entry->portid, __get_str(header),
> net/tipc/trace.h: TP_printk("<%s> %s\n%s", __entry->name, __get_str(header),
> net/tipc/trace.h: TP_printk("<%x> %s\n%s", __entry->addr, __get_str(header),
>
> Perhaps the documentation files around these formats
> Documentation/trace/events.rst
> Documentation/trace/tracepoints.rst
> could be improved as well.
>

Sure, like most documentation ;-)

-- Steve