x86/domctl: Don't pause the whole domain if only getting vcpu state
PATCH 1/1 x86/domctl: Don't pause the whole domain if only getting vcpu state
This patch adds the hvm_save_one_cpu_ctxt() function, called for the XEN_DOMCTL_gethvmcontext_partial domctl.
It optimizes by only pausing the vcpu, and no longer the whole domain.
--- xen/arch/x86/domctl.c | 20 +++++ xen/arch/x86/hvm/hvm.c | 194 ++++++++++++++++++++++-------------------- xen/include/asm-x86/hvm/hvm.h | 2 + 3 files changed, 122 insertions(+), 94 deletions(-)
xen/arch/x86/domctl.c +20 -0
@@ -625,6 +625,26 @@ long arch_do_domctl( !is_hvm_domain(d) )break ; +if ( domctl->u.hvmcontext_partial.type ==HVM_SAVE_CODE (CPU ) && + domctl->u.hvmcontext_partial.instance < d->max_vcpus ) + { +struct vcpu *v = d->vcpu[domctl->u.hvmcontext_partial.instance]; +struct hvm_hw_cpu ctx; + +vcpu_pause (v); + +hvm_save_one_cpu_ctxt (v, &ctx); + +vcpu_unpause (v); + +if (copy_to_guest (domctl->u.hvmcontext_partial.buffer, + (void *)&ctx,sizeof (ctx)) ) + ret = -EFAULT ; +else + ret =0 ; +break ; + } +domain_pause (d); ret = hvm_save_one(d, domctl->u.hvmcontext_partial.type, domctl->u.hvmcontext_partial.instance,
xen/arch/x86/hvm/hvm.c +100 -94
210 lines not on this page · raw message
xen/include/asm-x86/hvm/hvm.h +2 -0
@@ -609,6 +609,8 @@ static inline bool altp2m_vcpu_emulate_ve(struct vcpu *v)return false; } +void hvm_save_one_cpu_ctxt (struct vcpu *v,struct hvm_hw_cpu *ctxt); +/* Check CR4/EFER values */ const char *hvm_efer_valid (const struct vcpu *v,uint64_t value,signed int cr0_pg);
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
xen/arch/x86/domctl.c long arch_do_domctl( · line 629
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 12.09.17 at 15:53, <[email protected]> wrote:
xen/arch/x86/domctl.c +2
-0@@ -625,6 +625,26 @@ long arch_do_domctl( !is_hvm_domain(d) )break ; +if ( domctl->u.hvmcontext_partial.type ==HVM_SAVE_CODE (CPU ) && + domctl->u.hvmcontext_partial.instance < d->max_vcpus )
I have to admit that I'm not in favor of such special casing, even less so without any code comment saying why this is so special. What if someone else wanted some other piece of vCPU state without pausing the entire domain? Wouldn't it be possible to generalize this to cover all such state elements?
xen/arch/x86/domctl.c long arch_do_domctl( · line 641
Quoted 12 lines
xen/arch/x86/domctl.c +12
-0+ { +struct vcpu *v = d->vcpu[domctl->u.hvmcontext_partial.instance]; +struct hvm_hw_cpu ctx; + +vcpu_pause (v); + +hvm_save_one_cpu_ctxt (v, &ctx); + +vcpu_unpause (v); + +if (copy_to_guest (domctl->u.hvmcontext_partial.buffer, + (void *)&ctx,sizeof (ctx)) )
Indentation.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 12.09.17 at 15:53, <[email protected]> wrote:
xen/arch/x86/domctl.c +0
-0@@ -625,6 +625,26 @@ long arch_do_domctl( !is_hvm_domain(d) )break ;
Quoted 8 lines
xen/arch/x86/domctl.c long arch_do_domctl( · line 629
Quoted 2 lines
xen/arch/x86/domctl.c +2
-0+if ( domctl->u.hvmcontext_partial.type ==HVM_SAVE_CODE (CPU ) && + domctl->u.hvmcontext_partial.instance < d->max_vcpus )I have to admit that I'm not in favor of such special casing, even less so without any code comment saying why this is so special. What if someone else wanted some other piece of vCPU state without pausing the entire domain? Wouldn't it be possible to generalize this to cover all such state elements?
There's no reason why all the other cases where this would the possible shouldn't be optimized. What has made this one stand out for us is that we're using it a lot with introspection, and the optimization counts.
But judging by the code reorganization (the addition of hvm_save_one_cpu_ctxt()), the changes would need to be done on a one-by-one case anyway (different queries may require different ways of chaging the code).
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 18 lines
Quoted 1 line
Quoted 1 line
Razvan Cojocaru <[email protected]> 09/18/17 7:05 PM >>>
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 12.09.17 at 15:53, <[email protected]> wrote:
xen/arch/x86/domctl.c +0
-0@@ -625,6 +625,26 @@ long arch_do_domctl( !is_hvm_domain(d) )break ;Quoted 8 lines
xen/arch/x86/domctl.c long arch_do_domctl( · line 629
Quoted 2 lines
xen/arch/x86/domctl.c +2
-0+if ( domctl->u.hvmcontext_partial.type ==HVM_SAVE_CODE (CPU ) && + domctl->u.hvmcontext_partial.instance < d->max_vcpus )I have to admit that I'm not in favor of such special casing, even less so without any code comment saying why this is so special. What if someone else wanted some other piece of vCPU state without pausing the entire domain? Wouldn't it be possible to generalize this to cover all such state elements?
Quoted 8 lines
There's no reason why all the other cases where this would the possible shouldn't be optimized. What has made this one stand out for us is that we're using it a lot with introspection, and the optimization counts.
But judging by the code reorganization (the addition of
hvm_save_one_cpu_ctxt()), the changes would need to be done on a one-by-one case anyway (different queries may require different ways of chaging the code).
But this function addition is precisely what I'd like to avoid in favor of an extension to the existing mechanism using the registered function pointers.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 39 lines · Jan Beulich
Quoted 34 lines
Quoted 5 lines
Quoted 5 lines
Razvan Cojocaru <[email protected]> 09/18/17 7:05 PM
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines · On 12.09.17 at 15:53, <[email protected]> wrote:
xen/arch/x86/domctl.c +1
-0@@ -625,6 +625,26 @@ long arch_do_domctl( !is_hvm_domain(d) )break ; + if ( domctl->u.hvmcontext_partial.type ==
HVM_SAVE_CODE(CPU)&&
+domctl->u.hvmcontext_partial.instance< d-Quoted 7 lines
Quoted 1 line
Quoted 1 line
max_vcpus)I have to admit that I'm not in favor of such special casing, even
less so without any code comment saying why this is so special. What if someone else wanted some other piece of vCPU state without pausing the entire domain? Wouldn't it be possible to generalize this to cover all such state elements?There's no reason why all the other cases where this would the possible
shouldn't be optimized. What has made this one stand out for us is that
we're using it a lot with introspection, and the optimization counts.Quoted 5 lines
But judging by the code reorganization (the addition of
hvm_save_one_cpu_ctxt()), the changes would need to be done on a one-by-one case anyway (different queries may require different ways of
chaging the code).
Quoted 5 lines
But this function addition is precisely what I'd like to avoid in favor of
an extension to the existing mechanism using the registered function pointers.
What will be a suitable extend of the current call back system?
Regards,
Alex
________________________
This email was scanned by Bitdefender
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 33 lines
Quoted 1 line
Quoted 1 line · On 19.09.17 at 17:28, <[email protected]> wrote:
Quoted 31 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line
Razvan Cojocaru <[email protected]> 09/18/17 7:05 PM
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 12.09.17 at 15:53, <[email protected]> wrote:
xen/arch/x86/domctl.c +1
-0@@ -625,6 +625,26 @@ long arch_do_domctl( !is_hvm_domain(d) )break ; + if ( domctl->u.hvmcontext_partial.type ==
HVM_SAVE_CODE(CPU)&&
+domctl->u.hvmcontext_partial.instance< d-Quoted 7 lines
Quoted 1 line
Quoted 1 line
max_vcpus)I have to admit that I'm not in favor of such special casing, even
less so without any code comment saying why this is so special. What if someone else wanted some other piece of vCPU state without pausing the entire domain? Wouldn't it be possible to generalize this to cover all such state elements?There's no reason why all the other cases where this would the possible
shouldn't be optimized. What has made this one stand out for us is that
we're using it a lot with introspection, and the optimization counts.But judging by the code reorganization (the addition of
hvm_save_one_cpu_ctxt()), the changes would need to be done on a one-by-one case anyway (different queries may require different ways of
chaging the code).
Quoted 6 lines
Quoted 5 lines
But this function addition is precisely what I'd like to avoid in favor of
an extension to the existing mechanism using the registered function pointers.What will be a suitable extend of the current call back system?
I'm not sure what you expect as an answer here. Something following the current model, but skipping everything that's not per-vCPU, and for everything being per-vCPU handling just the single vCPU of interest.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel