tracepoint: fix bad trace value in trace_kvm_exit()
PATCH 1/1 tracepoint: fix bad trace value in trace_kvm_exit()
After enabling KVM event tracing, almost all of trace_kvm_exit()'s printk shows
"kvm_exit: IRQ: ..."
even if the actual exception_type is NOT IRQ. More specifically, trace_kvm_exit() is defined in virt/kvm/arm/trace.h by TRACE_EVENT.
This slight problem may have existed after commit e6753f23d961 ("tracepoint: Make rcuidle tracepoint callers use SRCU"). There are two variables in trace_kvm_exit() and __DO_TRACE() which have the same name, *idx*. Thus the actual value of *idx* will be overwritten when tracing. Fix it by adding a simple prefix.
--- include/linux/tracepoint.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/tracepoint.h +3 -3
@@ -166,7 +166,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)struct tracepoint_func *it_func_ptr; \void *it_func; \void *__data; \ - int __maybe_unused idx = 0; \ + int __maybe_unused __idx = 0; \ \if (!(cond)) \return ; \
@@ -182,7 +182,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)* doesn't work from the idle path. \ */ \if (rcuidle) { \ - idx =srcu_read_lock_notrace (&tracepoint_srcu); \ + __idx =srcu_read_lock_notrace (&tracepoint_srcu);\rcu_irq_enter_irqson (); \ } \ \
@@ -198,7 +198,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) \if (rcuidle) { \rcu_irq_exit_irqson (); \ -srcu_read_unlock_notrace (&tracepoint_srcu, idx);\ +srcu_read_unlock_notrace (&tracepoint_srcu, __idx);\ } \ \preempt_enable_notrace (); \
Signature · 1 line
1.8.3.1
Steven Rostedt
maintainerQuoted 5 lines · On Wed, 28 Nov 2018 03:35:23 +0000 Zenghui Yu <[email protected]> wrote:
After enabling KVM event tracing, almost all of trace_kvm_exit()'s printk shows
"kvm_exit: IRQ: ..."
Quoted 8 lines
even if the actual
exception_typeis NOT IRQ. More specifically,trace_kvm_exit()is defined invirt/kvm/arm/trace.hbyTRACE_EVENT.This slight problem may have existed after commit
e6753f23d961("tracepoint: Make rcuidle tracepoint callers use SRCU"). There are two variables intrace_kvm_exit()and__DO_TRACE()which have the same name, *idx*. Thus the actual value of *idx* will be overwritten when tracing. Fix it by adding a simple prefix.
Nice catch! I'll apply it tomorrow and start testing it then.
Thanks!
-- Steve
Quoted 40 lines
Signed-off-by Zenghui Yu <[email protected]>Cc Joel Fernandes <[email protected]>Cc Wang Haibin <[email protected]>--- include/linux/tracepoint.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)include/linux/tracepoint.h +3
-3@@ -166,7 +166,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)struct tracepoint_func *it_func_ptr; \void *it_func; \void *__data; \ - int __maybe_unused idx = 0; \ + int __maybe_unused __idx = 0; \ \if (!(cond)) \return ; \@@ -182,7 +182,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)* doesn't work from the idle path. \ */ \if (rcuidle) { \ - idx =srcu_read_lock_notrace (&tracepoint_srcu); \ + __idx =srcu_read_lock_notrace (&tracepoint_srcu);\rcu_irq_enter_irqson (); \ } \ \@@ -198,7 +198,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) \if (rcuidle) { \rcu_irq_exit_irqson (); \ -srcu_read_unlock_notrace (&tracepoint_srcu, idx);\ +srcu_read_unlock_notrace (&tracepoint_srcu, __idx);\ } \ \preempt_enable_notrace (); \
Quoted 11 lines · Steven Rostedt
Quoted 8 lines · On Wed, 28 Nov 2018 03:35:23 +0000 Zenghui Yu <[email protected]> wrote:
After enabling KVM event tracing, almost all of trace_kvm_exit()'s printk shows
"kvm_exit: IRQ: ..."even if the actual
exception_typeis NOT IRQ. More specifically,trace_kvm_exit()is defined invirt/kvm/arm/trace.hbyTRACE_EVENT.
Quoted 7 lines
Quoted 5 lines
This slight problem may have existed after commit
e6753f23d961("tracepoint: Make rcuidle tracepoint callers use SRCU"). There are two variables intrace_kvm_exit()and__DO_TRACE()which have the same name, *idx*. Thus the actual value of *idx* will be overwritten when tracing. Fix it by adding a simple prefix.Nice catch! I'll apply it tomorrow and start testing it then.
Thanks Steven!
Zenghui
Quoted 49 lines
Thanks!
-- Steve
Quoted 32 lines
Signed-off-by Zenghui Yu <[email protected]>Cc Joel Fernandes <[email protected]>Cc Wang Haibin <[email protected]>--- include/linux/tracepoint.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)include/linux/tracepoint.h +2
-2@@ -166,7 +166,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)struct tracepoint_func *it_func_ptr; \void *it_func; \void *__data; \ - int __maybe_unused idx = 0; \ + int __maybe_unused __idx = 0; \ \if (!(cond)) \return ; \@@ -182,7 +182,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)* doesn't work from the idle path. \ */ \if (rcuidle) { \ - idx =srcu_read_lock_notrace (&tracepoint_srcu); \ + __idx =srcu_read_lock_notrace (&tracepoint_srcu);\rcu_irq_enter_irqson (); \ } \ \include/linux/tracepoint.h static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) · line 204
Quoted 8 lines
include/linux/tracepoint.h +1
-1@@ -198,7 +198,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) \if (rcuidle) { \rcu_irq_exit_irqson (); \ -srcu_read_unlock_notrace (&tracepoint_srcu, idx);\ +srcu_read_unlock_notrace (&tracepoint_srcu, __idx);\ } \ \preempt_enable_notrace (); \.
Steven Rostedt
maintainerQuoted 18 lines · On Thu, 29 Nov 2018 10:21:55 +0800 Zenghui Yu <[email protected]> wrote:
Quoted 17 lines · Steven Rostedt
Quoted 13 lines · On Wed, 28 Nov 2018 03:35:23 +0000 Zenghui Yu <[email protected]> wrote:
After enabling KVM event tracing, almost all of trace_kvm_exit()'s printk shows
"kvm_exit: IRQ: ..."even if the actual
exception_typeis NOT IRQ. More specifically,trace_kvm_exit()is defined invirt/kvm/arm/trace.hbyTRACE_EVENT.This slight problem may have existed after commit
e6753f23d961("tracepoint: Make rcuidle tracepoint callers use SRCU"). There are two variables intrace_kvm_exit()and__DO_TRACE()which have the same name, *idx*. Thus the actual value of *idx* will be overwritten when tracing. Fix it by adding a simple prefix.
Quoted 4 lines
Quoted 1 line
Nice catch! I'll apply it tomorrow and start testing it then.
Thanks Steven!
FYI, I renamed your subject to:
tracepoint: Use __idx instead of idx in DO_TRACE macro to make it unique
to make the name more specific to the fix and not the symptom.
Thanks!
-- Steve
Joel Fernandes
Reviewed-byQuoted 26 lines · Steven Rostedt
Quoted 18 lines · On Thu, 29 Nov 2018 10:21:55 +0800 Zenghui Yu <[email protected]> wrote:
Quoted 17 lines · Steven Rostedt
Quoted 13 lines · On Wed, 28 Nov 2018 03:35:23 +0000 Zenghui Yu <[email protected]> wrote:
After enabling KVM event tracing, almost all of trace_kvm_exit()'s printk shows
"kvm_exit: IRQ: ..."even if the actual
exception_typeis NOT IRQ. More specifically,trace_kvm_exit()is defined invirt/kvm/arm/trace.hbyTRACE_EVENT.This slight problem may have existed after commit
e6753f23d961("tracepoint: Make rcuidle tracepoint callers use SRCU"). There are two variables intrace_kvm_exit()and__DO_TRACE()which have the same name, *idx*. Thus the actual value of *idx* will be overwritten when tracing. Fix it by adding a simple prefix.Quoted 4 lines
Quoted 1 line
Nice catch! I'll apply it tomorrow and start testing it then.
Thanks Steven!
Quoted 7 lines
FYI, I renamed your subject to:
tracepoint: Use
__idxinstead of idx inDO_TRACEmacro to make it uniqueto make the name more specific to the fix and not the symptom.
Thanks!
Thanks!
- Joel