xenalyze: Miscellaneous fixes
cover xenalyze: Miscellaneous fixes
None of these are critical; but they're also in a fairly low criticality part of the code. I'd be fine with either putting them in now or waiting until 4.19.
PATCH 1/5 xenalyze: Only accumulate data from one vmexit without a handler
If a vmentry/exit arc unexpectedly doesn't have a handler, we throw an error, and then log the information under HVM event 0; thus those particular traces within the vmexit reason will have stats gathered, and will show up with "(no handler)". This is useful in the event that there are unusual paths through the hypervisor which don't have trace points.
However, if there are more than one of these, then although we detect and warn that this is happening, we subsequently continue to stuff data about all exits into that one exit, even though we only show it in one place.
Instead, refator things to only allow a single exit reason to be accumulated into any given event.
Also put a comment explaining what's going on, and how to fix it.
---
Release justification: This is a bug fix; a minor one, but also in a non-critical part of the code.
--- tools/xentrace/xenalyze.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
tools/xentrace/xenalyze.c +26 -8
@@ -4652,6 +4652,19 @@ void hvm_generic_postprocess(struct hvm_data *h) ?"[clipped]" : h->exit_reason_name[h->exit_reason]); warned[h->exit_reason]=1 ; + +/* +* NB that we don't return here; the result will be that `evt` +* will be "0", and there will be a "(no handler)" entry for the +* given VMEXIT. +* +* This does mean that if two different exits have no HVM +* handlers, that only the first one will accumulate data; +* if accumulating a separate "(no handler)" data for more +* than one exit reason is needed, we'll have to make Yet +* Another Array. But for now, since we try to avoid +* it happening, just tolerate it. +*/ } }
@@ -4664,18 +4677,19 @@ void hvm_generic_postprocess(struct hvm_data *h) }if (opt.summary_info) { -update_cycles (&h->summary.generic[evt], - h->arc_cycles); -/* NB that h->exit_reason may be 0, so we offset by 1 */ if ( registered[evt] ) {static unsigned warned[HVM_EXIT_REASON_MAX ] = {0 }; -if ( registered[evt] != h->exit_reason+1 && !warned[h->exit_reason]) +if ( registered[evt] != h->exit_reason+1 ) { -fprintf (warn,"%s: HVM evt %lx in %x and %x!\n" , - __func__, evt, registered[evt]-1 , h->exit_reason); - warned[h->exit_reason]=1 ; +if ( !warned[h->exit_reason] ) + { +fprintf (warn,"%s: HVM evt %lx in %x and %x!\n" , + __func__, evt, registered[evt]-1 , h->exit_reason); + warned[h->exit_reason]=1 ; + } +return ; } }else
@@ -4686,7 +4700,11 @@ void hvm_generic_postprocess(struct hvm_data *h) __func__, ret); registered[evt]=h->exit_reason+1 ; } -/* HLT checked at hvm_vmexit_close() */ + +update_cycles (&h->summary.generic[evt], + h->arc_cycles); + +/* HLT checked at hvm_vmexit_close() */ } }
Signature · 1 line
2.25.1
Re: [PATCH for-4.18 1/5] xenalyze: Only accumulate data from one vmexit without a handler
Quoted 11 lines · George Dunlap
If a vmentry/exit arc unexpectedly doesn't have a handler, we throw an error, and then log the information under HVM event 0; thus those particular traces within the vmexit reason will have stats gathered, and will show up with "(no handler)". This is useful in the event that there are unusual paths through the hypervisor which don't have trace points.
However, if there are more than one of these, then although we detect and warn that this is happening, we subsequently continue to stuff data about all exits into that one exit, even though we only show it in one place.
Quoted 6 lines
Instead, refator things to only allow a single exit reason to be accumulated into any given event.
Also put a comment explaining what's going on, and how to fix it.
Signed-off-by George Dunlap <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 2/5 xenalyze: AMD's VMEXIT_VINTR doesn't need a trace record
In reply to George DunlapJust like Intel's PENDING_VIRT_INTR, AMD's VINTR doesn't need an HVM trace record. Expect that.
---
Release justification: This is a bug fix. It's a *very* small one, but then the code path is not very critical either.
--- tools/xentrace/xenalyze.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/xentrace/xenalyze.c +7 -0
@@ -4628,6 +4628,13 @@ void hvm_generic_postprocess(struct hvm_data *h)/* Some exits we don't expect a handler; just return */ if (opt.svm_mode) { +switch (h->exit_reason) + { +case VMEXIT_VINTR :/* Equivalent of PENDING_VIRT_INTR */ +return ; +default : +break ; + } }else {
Signature · 1 line
2.25.1
Re: [PATCH for-4.18 2/5] xenalyze: AMD's VMEXIT_VINTR doesn't need a trace record
Quoted 4 lines · George Dunlap
Just like Intel's
PENDING_VIRT_INTR, AMD's VINTR doesn't need an HVM trace record. Expect that.Signed-off-by George Dunlap <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 3/5 xenalyze: Don't expect an HVM_HANDLER trace for PAUSE vmexits
In reply to George DunlapNeither vmx nor svm trace anything, nor is there anything obvious worth tracing.
---
Release justification: This is a bug fix; a minor one, but also in a non-critical part of the code.
--- tools/xentrace/xenalyze.c | 2 ++ 1 file changed, 2 insertions(+)
tools/xentrace/xenalyze.c +2 -0
@@ -4631,6 +4631,7 @@ void hvm_generic_postprocess(struct hvm_data *h)switch (h->exit_reason) {case VMEXIT_VINTR :/* Equivalent of PENDING_VIRT_INTR */ +case VMEXIT_PAUSE :return ;default :break ;
@@ -4643,6 +4644,7 @@ void hvm_generic_postprocess(struct hvm_data *h)/* These just need us to go through the return path */ case EXIT_REASON_PENDING_VIRT_INTR :case EXIT_REASON_TPR_BELOW_THRESHOLD : +case EXIT_REASON_PAUSE_INSTRUCTION :/* Not much to log now; may need later */ case EXIT_REASON_WBINVD :return ;
Signature · 1 line
2.25.1
Re: [PATCH for-4.18 3/5] xenalyze: Don't expect an HVM_HANDLER trace for PAUSE vmexits
Quoted 4 lines · George Dunlap
Neither vmx nor svm trace anything, nor is there anything obvious worth tracing.
Signed-off-by George Dunlap <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 4/5 xenalyze: Fix interrupt EIP reporting
In reply to George DunlapEIP lists are generalized across several use cases. For many of them, it make sense to have a cycle per sample; but not really for interrupt EIP lists. For this reason, it normally just passes 0 as for the tsc value, which will in turn down at the bottom of update_cycles(), update only the summary.event_count, but nothing else.
The dump_eip() function attempted to handle this by calling the generic cycle print handler if the summary contained *any* cycles, and by collecting and printing its own stats, based solely on counts, if not.
Unfortunately, it used the wrong element for this: it collected the total from samples.count rather samples.event_count; in the case that there are no cycles, this will always be zero. It then divided by this zero value. This results in output that looked like this:
``` ffff89d29656 : 0 -nan% ffff89d298b6 : 0 -nan% ffff89d298c0 : 0 -nan% ```
It's better than nothing, but a lot less informative than one would like.
Use event_count rather than count for collecting the total, and the reporting when there are no cycles in the summary information. This results in output that looks like this:
``` ffff89d29656 : 2 1.21% ffff89d298b6 : 1 0.61% ffff89d298c0 : 1 0.61% ```
---
Rationale: This is a bug fix. It's a minor one, but it's also in a non-critical part of the code.
--- tools/xentrace/xenalyze.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/xentrace/xenalyze.c +3 -3
@@ -2866,7 +2866,7 @@ void dump_eip(struct eip_list_struct *head) {for (p=head; p; p=p->next) { - total += p->summary.count; + total += p->summary.event_count;N ++; }
@@ -2901,8 +2901,8 @@ void dump_eip(struct eip_list_struct *head) { p->eip, find_symbol(p->eip));printf (" %7d %5.2lf%%\n" , - p->summary.count, - ((double )p->summary.count*100 )/total); + p->summary.event_count, + ((double )p->summary.event_count*100 )/total); }
Signature · 1 line
2.25.1
Re: [PATCH for-4.18 4/5] xenalyze: Fix interrupt EIP reporting
Quoted 28 lines · George Dunlap
EIP lists are generalized across several use cases. For many of them, it make sense to have a cycle per sample; but not really for interrupt EIP lists. For this reason, it normally just passes 0 as for the tsc value, which will in turn down at the bottom of
update_cycles(), update only the summary.event_count, but nothing else.The
dump_eip()function attempted to handle this by calling the generic cycle print handler if the summary contained *any* cycles, and by collecting and printing its own stats, based solely on counts, if not.Unfortunately, it used the wrong element for this: it collected the total from samples.count rather samples.event_count; in the case that there are no cycles, this will always be zero. It then divided by this zero value. This results in output that looked like this:
``` ffff89d29656 : 0 -nan% ffff89d298b6 : 0 -nan% ffff89d298c0 : 0 -nan% ```It's better than nothing, but a lot less informative than one would like.
Use
event_countrather than count for collecting the total, and the reporting when there are no cycles in the summary information. This results in output that looks like this:
Quoted 7 lines
``` ffff89d29656 : 2 1.21% ffff89d298b6 : 1 0.61% ffff89d298c0 : 1 0.61% ```Signed-off-by George Dunlap <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 5/5 xenalyze: Reduce warnings about leaving a vcpu in INIT
In reply to George DunlapWe warn when we see data for a vcpu moving into a non-RUNNING state, just so that people know why we're ignoring it. On full traces, this happens only once. However, if the trace was limited to a subset of pcpus, then this will happen every time the domain in question is woken on that pcpu.
Add a 'delayed_init' flag to the vcpu struct to indicate when a vcpu has experienced a delayed init. Print a warning message once when entering the state, and once when leaving it.
---
Release justification: By removing extraneous output which makes the tool annoying to use, this could be considered a bug fix; a minor one, but also in a non-critical part of the code.
--- tools/xentrace/xenalyze.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
tools/xentrace/xenalyze.c +10 -3
@@ -1625,7 +1625,7 @@ struct vlapic_struct {struct vcpu_data {int vid;struct domain_data *d;/* up-pointer */ -unsigned activated:1 ; +unsigned activated:1 , delayed_init:1 ;int guest_paging_levels;
@@ -6979,10 +6979,17 @@ void vcpu_start(struct pcpu_info *p, struct vcpu_data *v,* bring a vcpu out of INIT until it's seen to be actually * running somewhere. */ if ( new_runstate !=RUNSTATE_RUNNING ) { -fprintf (warn,"First schedule for d%dv%d doesn't take us into a running state; leaving INIT\n" , - v->d->did, v->vid); +if ( !v->delayed_init ) { +fprintf (warn,"First schedule for d%dv%d doesn't take us into a running state; leaving in INIT\n" , + v->d->did, v->vid); + v->delayed_init =1 ; + }return ; + }else if ( v->delayed_init ) { +fprintf (warn,"d%dv%d RUNSTATE_RUNNING detected, leaving INIT" , + v->d->did, v->vid); + v->delayed_init =0 ; } tsc = ri_tsc;
Signature · 1 line
2.25.1
Re: [PATCH for-4.18 5/5] xenalyze: Reduce warnings about leaving a vcpu in INIT
Quoted 11 lines · George Dunlap
We warn when we see data for a vcpu moving into a non-RUNNING state, just so that people know why we're ignoring it. On full traces, this happens only once. However, if the trace was limited to a subset of pcpus, then this will happen every time the domain in question is woken on that pcpu.
Add a '
delayed_init' flag to the vcpu struct to indicate when a vcpu has experienced a delayed init. Print a warning message once when entering the state, and once when leaving it.Signed-off-by George Dunlap <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
Hi George,
Quoted 5 lines · George Dunlap
None of these are critical; but they're also in a fairly low criticality part of the code. I'd be fine with either putting them in now or waiting until 4.19.
I saw most of the patches are bugfix so I am fine with including them in 4.18, so if this series can get proper review before the release, please feel free to have:
Kind regards,
Henry