kvm/arm: Standardize kvm exit reason field
PATCH 3/3 kvm/arm: Standardize kvm exit reason field
This standardizes kvm exit reason field name by replacing "esr_ec" with "exit_reason".
--- virt/kvm/arm/trace.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
virt/kvm/arm/trace.h +8 -6
@@ -27,25 +27,27 @@ TRACE_EVENT(kvm_entry, );TRACE_EVENT (kvm_exit, - TP_PROTO(int ret, unsigned int esr_ec, unsigned long vcpu_pc), -TP_ARGS (ret, esr_ec, vcpu_pc), + TP_PROTO(int ret, unsigned int exit_reason, unsigned long vcpu_pc), +TP_ARGS (ret, exit_reason, vcpu_pc),TP_STRUCT__entry ( __field( int, ret ) - __field( unsigned int, esr_ec ) + __field( unsigned int, exit_reason ) __field( unsigned long, vcpu_pc ) ),TP_fast_assign ( __entry->ret = ARM_EXCEPTION_CODE(ret); - __entry->esr_ec = ARM_EXCEPTION_IS_TRAP(ret) ? esr_ec : 0; + __entry->exit_reason = + ARM_EXCEPTION_IS_TRAP(ret) ? exit_reason: 0; __entry->vcpu_pc = vcpu_pc; ),TP_printk ("%s: HSR_EC: 0x%04x (%s), PC: 0x%08lx" ,__print_symbolic (__entry->ret, kvm_arm_exception_type), - __entry->esr_ec, -__print_symbolic (__entry->esr_ec, kvm_arm_exception_class), + __entry->exit_reason, +__print_symbolic (__entry->exit_reason, + kvm_arm_exception_class), __entry->vcpu_pc) );
Signature · 1 line
2.23.0
Hi Gavin,
Quoted 15 lines · Gavin Shan
This standardizes kvm exit reason field name by replacing "
esr_ec" with "exit_reason".Signed-off-by Gavin Shan <[email protected]>--- virt/kvm/arm/trace.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)virt/kvm/arm/trace.h +0
-0@@ -27,25 +27,27 @@ TRACE_EVENT(kvm_entry, );
virt/kvm/arm/trace.h TRACE_EVENT(kvm_entry, · line 35
Quoted 10 lines
virt/kvm/arm/trace.h +3
-3TRACE_EVENT(kvm_exit, - TP_PROTO(int ret, unsigned int esr_ec, unsigned long vcpu_pc), - TP_ARGS(ret, esr_ec, vcpu_pc), + TP_PROTO(int ret, unsigned int exit_reason, unsigned long vcpu_pc), + TP_ARGS(ret, exit_reason, vcpu_pc), TP_STRUCT__entry( __field( int, ret ) - __field( unsigned int, esr_ec ) + __field( unsigned int, exit_reason )
I don't think the two are the same thing. The exit reason should be exactly that: why has the guest exited (exception, host interrupt, trap).
What we're reporting here is the exception class, which doesn't apply to interrupts, for example (hence the 0 down below, which we treat as a catch-all).
Quoted 10 lines
virt/kvm/arm/trace.h +2
-1__field( unsigned long, vcpu_pc ) ),TP_fast_assign ( __entry->ret = ARM_EXCEPTION_CODE(ret); - __entry->esr_ec =ARM_EXCEPTION_IS_TRAP (ret) ? esr_ec :0 ; + __entry->exit_reason = +ARM_EXCEPTION_IS_TRAP (ret) ? exit_reason:0 ; __entry->vcpu_pc = vcpu_pc; ),
virt/kvm/arm/trace.h TRACE_EVENT(kvm_entry, · line 52
Quoted 10 lines
virt/kvm/arm/trace.h +3
-2TP_printk ("%s: HSR_EC: 0x%04x (%s), PC: 0x%08lx" ,__print_symbolic (__entry->ret, kvm_arm_exception_type), - __entry->esr_ec, -__print_symbolic (__entry->esr_ec, kvm_arm_exception_class), + __entry->exit_reason, +__print_symbolic (__entry->exit_reason, + kvm_arm_exception_class), __entry->vcpu_pc) );
The last thing is whether such a change is an ABI change or not. I've been very reluctant to change any of this for that reason.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Quoted 30 lines · Marc Zyngier
Quoted 21 lines · Gavin Shan
This standardizes kvm exit reason field name by replacing "
esr_ec" with "exit_reason".Signed-off-by Gavin Shan <[email protected]>---
virt/kvm/arm/trace.h | 14 ++++++++------1 file changed, 8 insertions(+), 6 deletions(-)virt/kvm/arm/trace.h +2
-2@@ -27,25 +27,27 @@ TRACE_EVENT(kvm_entry, ); TRACE_EVENT(kvm_exit, - TP_PROTO(int ret, unsigned int esr_ec, unsigned long vcpu_pc), - TP_ARGS(ret, esr_ec, vcpu_pc), + TP_PROTO(int ret, unsigned int exit_reason, unsigned long vcpu_pc), + TP_ARGS(ret, exit_reason, vcpu_pc),Quoted 4 lines
TP_STRUCT__entry(
__field( int, ret )-__field( unsigned int, esr_ec )+__field( unsigned int, exit_reason )I don't think the two are the same thing. The exit reason should be exactly that: why has the guest exited (exception, host interrupt, trap).
Quoted 4 lines
What we're reporting here is the exception class, which doesn't apply to interrupts, for example (hence the 0 down below, which we treat as a catch-all).
Marc, thanks a lot for your reply. Yeah, the combination (ret and esr_ec) is complete to indicate the exit reasons if I'm understanding correctly.
The exit reasons seen by kvm_stat is exactly the ESR_EL1[EC]. It's declared by marcro AARCH64_EXIT_REASONS in tools/kvm/kvm_stat/kvm_stat. So it's precise and complete from perspective of kvm_stat.
For the patch itself, it standardizes the filter name by renaming "esr_ec" to "exit_reason", no functional changes introduced and I think it would be fine.
Quoted 21 lines
Quoted 11 lines
__field( unsigned long, vcpu_pc )),TP_fast_assign(
__entry->ret =ARM_EXCEPTION_CODE(ret); -__entry->esr_ec=ARM_EXCEPTION_IS_TRAP(ret)?esr_ec: 0; +__entry->exit_reason=
+ARM_EXCEPTION_IS_TRAP(ret)?exit_reason: 0; __entry->vcpu_pc =vcpu_pc;
),Quoted 9 lines
TP_printk("%s:
HSR_EC: 0x%04x (%s), PC: 0x%08lx",__print_symbolic(__entry->ret, kvm_arm_exception_type), -__entry->esr_ec,
-__print_symbolic(__entry->esr_ec, kvm_arm_exception_class), +__entry->exit_reason,
+ __print_symbolic(__entry->exit_reason,
+kvm_arm_exception_class),__entry->vcpu_pc)
);
Quoted 3 lines
The last thing is whether such a change is an ABI change or not. I've been very reluctant to change any of this for that reason.
Yeah, I think it is ABI change unfortunately, but I'm not sure how many applications are using this filter. However, the fixed filter name ("exit_reason") is beneficial in long run. The application needn't distinguish architects to provide different tracepoint filters at least.
Regards,
Gavin
Hi Gavin,
Quoted 38 lines · Gavin Shan
Quoted 23 lines · Marc Zyngier
Quoted 22 lines · Gavin Shan
This standardizes kvm exit reason field name by replacing "
esr_ec" with "exit_reason".Signed-off-by Gavin Shan <[email protected]>---
virt/kvm/arm/trace.h | 14 ++++++++------1 file changed, 8 insertions(+), 6 deletions(-)virt/kvm/arm/trace.h +2
-2@@ -27,25 +27,27 @@ TRACE_EVENT(kvm_entry, ); TRACE_EVENT(kvm_exit, - TP_PROTO(int ret, unsigned int esr_ec, unsigned long vcpu_pc), - TP_ARGS(ret, esr_ec, vcpu_pc), + TP_PROTO(int ret, unsigned int exit_reason, unsigned long vcpu_pc), + TP_ARGS(ret, exit_reason, vcpu_pc),Quoted 10 lines
Quoted 4 lines
TP_STRUCT__entry(
__field( int, ret )-__field( unsigned int, esr_ec )+__field( unsigned int, exit_reason )I don't think the two are the same thing. The exit reason should be exactly that: why has the guest exited (exception, host interrupt, trap). What we're reporting here is the exception class, which doesn't apply to interrupts, for example (hence the 0 down below, which we treat as a catch-all).
Marc, thanks a lot for your reply. Yeah, the combination (ret and
esr_ec) is complete to indicate the exit reasons if I'm understanding correctly.
Quoted 8 lines
The exit reasons seen by
kvm_statis exactly the ESR_EL1[EC]. It's declared by marcroAARCH64_EXIT_REASONSintools/kvm/kvm_stat/kvm_stat. So it's precise
and complete from perspective ofkvm_stat.For the patch itself, it standardizes the filter name by renaming "
esr_ec" to "exit_reason", no functional changes introduced and I think it would be fine.
It may not be a functional change, but it is a semantic change. To me, 'exit_reason' means something, and esr_ec something entirely different.
But the real blocker is below.
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
__field( unsigned long, vcpu_pc )),TP_fast_assign(
__entry->ret =ARM_EXCEPTION_CODE(ret); -__entry->esr_ec=ARM_EXCEPTION_IS_TRAP(ret)?esr_ec: 0; +__entry->exit_reason=
+ARM_EXCEPTION_IS_TRAP(ret)?exit_reason: 0; __entry->vcpu_pc =vcpu_pc;
),TP_printk("%s:
HSR_EC: 0x%04x (%s), PC: 0x%08lx",__print_symbolic(__entry->ret, kvm_arm_exception_type), -__entry->esr_ec,
-__print_symbolic(__entry->esr_ec, kvm_arm_exception_class),
+__entry->exit_reason,
+ __print_symbolic(__entry->exit_reason,
+kvm_arm_exception_class),__entry->vcpu_pc)
);
Quoted 6 lines
Quoted 3 lines
The last thing is whether such a change is an ABI change or not. I've been very reluctant to change any of this for that reason.
Yeah, I think it is ABI change unfortunately, but I'm not sure how many applications are using this filter.
Nobody can tell. The problem is that someone will write a script that parses this trace point based on an older kernel release (such as what the distros are shipping today), and two years from now will shout at you (and me) for having broken their toy.
Quoted 3 lines
However, the fixed filter name ("
exit_reason") is beneficial in long run. The application needn't distinguish architects to provide different tracepoint filters at least.
Well, you certainly need to understand the actual semantic behind the fields if you want to draw any meaningful conclusion. Otherwise, all you need is to measure the frequency of such event.
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Quoted 43 lines · Marc Zyngier
Quoted 42 lines · Gavin Shan
Quoted 22 lines · Marc Zyngier
Quoted 21 lines · Gavin Shan
This standardizes kvm exit reason field name by replacing "
esr_ec" with "exit_reason".Signed-off-by Gavin Shan <[email protected]>---
virt/kvm/arm/trace.h | 14 ++++++++------1 file changed, 8 insertions(+), 6 deletions(-)virt/kvm/arm/trace.h +2
-2@@ -27,25 +27,27 @@ TRACE_EVENT(kvm_entry, ); TRACE_EVENT(kvm_exit, - TP_PROTO(int ret, unsigned int esr_ec, unsigned long vcpu_pc), - TP_ARGS(ret, esr_ec, vcpu_pc), + TP_PROTO(int ret, unsigned int exit_reason, unsigned long vcpu_pc), + TP_ARGS(ret, exit_reason, vcpu_pc),Quoted 10 lines
Quoted 4 lines
TP_STRUCT__entry(
__field( int, ret )-__field( unsigned int, esr_ec )+__field( unsigned int, exit_reason )I don't think the two are the same thing. The exit reason should be exactly that: why has the guest exited (exception, host interrupt, trap). What we're reporting here is the exception class, which doesn't apply to interrupts, for example (hence the 0 down below, which we treat as a catch-all).
Marc, thanks a lot for your reply. Yeah, the combination (ret and
esr_ec) is complete to indicate the exit reasons if I'm understanding correctly.The exit reasons seen by
kvm_statis exactly the ESR_EL1[EC]. It's declared by marcroAARCH64_EXIT_REASONSintools/kvm/kvm_stat/kvm_stat. So it's precise
and complete from perspective ofkvm_stat.
Quoted 9 lines
Quoted 3 lines
For the patch itself, it standardizes the filter name by renaming "
esr_ec" to "exit_reason", no functional changes introduced and I think it would be fine.It may not be a functional change, but it is a semantic change. To me, '
exit_reason' means something, andesr_ecsomething entirely different.But the real blocker is below.
Agree.
Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 11 lines
__field( unsigned long, vcpu_pc )),TP_fast_assign(
__entry->ret =ARM_EXCEPTION_CODE(ret); -__entry->esr_ec=ARM_EXCEPTION_IS_TRAP(ret)?esr_ec: 0; +__entry->exit_reason=
+ARM_EXCEPTION_IS_TRAP(ret)?exit_reason: 0; __entry->vcpu_pc =vcpu_pc;
),Quoted 9 lines
TP_printk("%s:
HSR_EC: 0x%04x (%s), PC: 0x%08lx",__print_symbolic(__entry->ret, kvm_arm_exception_type), -__entry->esr_ec,
-__print_symbolic(__entry->esr_ec, kvm_arm_exception_class), +__entry->exit_reason,
+ __print_symbolic(__entry->exit_reason,
+kvm_arm_exception_class),__entry->vcpu_pc)
);The last thing is whether such a change is an ABI change or not. I've been very reluctant to change any of this for that reason.
Quoted 8 lines
Quoted 2 lines
Yeah, I think it is ABI change unfortunately, but I'm not sure how many applications are using this filter.
Nobody can tell. The problem is that someone will write a script that parses this trace point based on an older kernel release (such as what the distros are shipping today), and two years from now will shout at you (and me) for having broken their toy.
Ah, it's not good :)
Quoted 8 lines
Quoted 3 lines
However, the fixed filter name ("
exit_reason") is beneficial in long run. The application needn't distinguish architects to provide different tracepoint filters at least.Well, you certainly need to understand the actual semantic behind the fields if you want to draw any meaningful conclusion. Otherwise, all you need is to measure the frequency of such event.
Well, I would like to receive Vitaly's comments here. Vitaly, it seems it's more realistic to fix the issue from kvm_stat side according to the comments given by Marc?
Thanks,
Gavin
Quoted 12 lines · Gavin Shan
Quoted 10 lines · Marc Zyngier
Quoted 3 lines · Gavin Shan
Yeah, I think it is ABI change unfortunately, but I'm not sure how many applications are using this filter.
Nobody can tell. The problem is that someone will write a script that parses this trace point based on an older kernel release (such as what the distros are shipping today), and two years from now will shout at you (and me) for having broken their toy.
Quoted 4 lines
Well, I would like to receive Vitaly's comments here. Vitaly, it seems it's more realistic to fix the issue from
kvm_statside according to the comments given by Marc?
Sure, if we decide to treat tracepoints as ABI then fixing users is likely the way to go. Personally, I think that we should have certain freedom with them and consider only tools which live in linux.git when making changes (and changing the tool to match in the same patch series is OK from this PoV, no need to support all possible versions of the tool).
Also, we can be a bit more conservative and in this particular case instead of renaming fields just add 'exit_reason' to all architectures where it's missing. For ARM, 'esr_ec' will then stay with what it is and 'exit_reason' may contain something different (like the information why the guest exited actually). But I don't know much about ARM specifics and I'm not sure how feasible the suggestion would be.
Signature · 1 line
Vitaly
Quoted 19 lines · Vitaly Kuznetsov
Quoted 12 lines · Gavin Shan
Quoted 10 lines · Marc Zyngier
Quoted 3 lines · Gavin Shan
Yeah, I think it is ABI change unfortunately, but I'm not sure how many applications are using this filter.
Nobody can tell. The problem is that someone will write a script that parses this trace point based on an older kernel release (such as what the distros are shipping today), and two years from now will shout at you (and me) for having broken their toy.
Quoted 4 lines
Well, I would like to receive Vitaly's comments here. Vitaly, it seems it's more realistic to fix the issue from
kvm_statside according to the comments given by Marc?
Quoted 6 lines
Sure, if we decide to treat tracepoints as ABI then fixing users is likely the way to go. Personally, I think that we should have certain freedom with them and consider only tools which live in linux.git when making changes (and changing the tool to match in the same patch series is OK from this PoV, no need to support all possible versions of the tool).
So far, the approach has been a pretty conservative one, and there was countless discussions (including a pretty heated one at KS two years ago, see [1] which did set the tone for the whole of the discussion).
So as far as I have something to say about this, we're not renaming fields in existing tracepoints.
Quoted 6 lines
Also, we can be a bit more conservative and in this particular case instead of renaming fields just add '
exit_reason' to all architectures where it's missing. For ARM, 'esr_ec' will then stay with what it is and 'exit_reason' may contain something different (like the information why the guest exited actually). But I don't know much about ARM specifics and I'm not sure how feasible the suggestion would be.
It should be possible to /extend/ tracepoints without breaking compatibility, and I don't have any issue with that. This could either report the unmodified 'ret' value, or something more synthetic. It really depends on what you want this information for.
M.
[1] https://lwn.net/Articles/737532/
Signature · 1 line
Jazz is not dead. It just smells funny...
Quoted 41 lines · Marc Zyngier
Quoted 19 lines · Vitaly Kuznetsov
Quoted 12 lines · Gavin Shan
Quoted 10 lines · Marc Zyngier
Quoted 3 lines · Gavin Shan
Yeah, I think it is ABI change unfortunately, but I'm not sure how many applications are using this filter.
Nobody can tell. The problem is that someone will write a script that parses this trace point based on an older kernel release (such as what the distros are shipping today), and two years from now will shout at you (and me) for having broken their toy.
Quoted 4 lines
Well, I would like to receive Vitaly's comments here. Vitaly, it seems it's more realistic to fix the issue from
kvm_statside according to the comments given by Marc?Quoted 6 lines
Sure, if we decide to treat tracepoints as ABI then fixing users is likely the way to go. Personally, I think that we should have certain freedom with them and consider only tools which live in linux.git when making changes (and changing the tool to match in the same patch series is OK from this PoV, no need to support all possible versions of the tool).
So far, the approach has been a pretty conservative one, and there was countless discussions (including a pretty heated one at KS two years ago, see [1] which did set the tone for the whole of the discussion).
So as far as I have something to say about this, we're not renaming fields in existing tracepoints.
Quoted 6 lines
Also, we can be a bit more conservative and in this particular case instead of renaming fields just add '
exit_reason' to all architectures where it's missing. For ARM, 'esr_ec' will then stay with what it is and 'exit_reason' may contain something different (like the information why the guest exited actually). But I don't know much about ARM specifics and I'm not sure how feasible the suggestion would be.
Quoted 9 lines
It should be possible to /extend/ tracepoints without breaking compatibility, and I don't have any issue with that. This could either report the unmodified 'ret' value, or something more synthetic. It really depends on what you want this information for.
M.
The extension means to add a new field "exit_reason" for aarch64. We can't delete or rename the existing fields in order to keep the compatibility. Also, the newly added field ("exit_reason") will carry duplicated information that have been carried by "ret" and "esr_ec". I guess it's going to make the interface ugly. So I personally prefer to fix the issue from "kvm_stat" and I'm going to post a v2 patch for this shortly.
Thanks again to Vitaly and Marc for your comments :)
Regards,
Gavin
Paolo Bonzini
maintainerQuoted 10 lines · Vitaly Kuznetsov
Quoted 4 lines
Well, I would like to receive Vitaly's comments here. Vitaly, it seems it's more realistic to fix the issue from
kvm_statside according to the comments given by Marc?Sure, if we decide to treat tracepoints as ABI then fixing users is likely the way to go. Personally, I think that we should have certain freedom with them and consider only tools which live in linux.git when making changes (and changing the tool to match in the same patch series is OK from this PoV, no need to support all possible versions of the tool).
I'd agree with that, plus trace-cmd since it has a KVM plugin, especially since KVM has for example debugfs stats unlike other subsystems (and we're tracing debugfs stats as stable userspace API, and planning to move them somewhere out of debugfs). But I wouldn't complain either if architecture maintainers feel differently.
Paolo
Quoted 6 lines
Also, we can be a bit more conservative and in this particular case instead of renaming fields just add '
exit_reason' to all architectures where it's missing. For ARM, 'esr_ec' will then stay with what it is and 'exit_reason' may contain something different (like the information why the guest exited actually). But I don't know much about ARM specifics and I'm not sure how feasible the suggestion would be.