xen: lift hypercall_cancel_continuation to sched.h
PATCH 1/1 xen: lift hypercall_cancel_continuation to sched.h
The function is the same on both x86 and arm. Lift it to sched.h to save a function call, make it take a pointer to vcpu to avoid resolving current every time it gets called.
Take the chance to change its callers to only use one current in code.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
--- xen/arch/arm/domain.c | 5 ----- xen/arch/x86/hypercall.c | 5 ----- xen/arch/x86/x86_64/compat/mm.c | 5 +++-- xen/common/multicall.c | 7 ++++--- xen/include/xen/sched.h | 6 +++++- 5 files changed, 12 insertions(+), 16 deletions(-)
xen/arch/arm/domain.c +0 -5
@@ -365,11 +365,6 @@ void sync_vcpu_execstate(struct vcpu *v) __arg; \ }) -void hypercall_cancel_continuation (void ) -{ - current->hcall_preempted = false; -} -unsigned long hypercall_create_continuation (unsigned int op,const char *format, ...) {
xen/arch/x86/hypercall.c +0 -5
@@ -86,11 +86,6 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] = __arg; \ }) -void hypercall_cancel_continuation (void ) -{ - current->hcall_preempted = false; -} -unsigned long hypercall_create_continuation (unsigned int op,const char *format, ...) {
xen/arch/x86/x86_64/compat/mm.c +3 -2
@@ -53,6 +53,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)compat_pfn_t mfn;unsigned int i;int rc =0 ; +struct vcpu *curr = current;switch ( cmd ) {
@@ -124,7 +125,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if (__copy_to_guest (arg, &cmp,1 ) ) {if ( rc == __HYPERVISOR_memory_op ) -hypercall_cancel_continuation (); +hypercall_cancel_continuation (curr); rc = -EFAULT ; }
@@ -133,7 +134,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)case XENMEM_machphys_mapping: { -struct domain *d = current->domain; +struct domain *d = curr->domain;struct compat_machphys_mapping mapping = { .v_start =MACH2PHYS_COMPAT_VIRT_START (d), .v_end =MACH2PHYS_COMPAT_VIRT_END ,
xen/common/multicall.c +4 -3
@@ -36,7 +36,8 @@ ret_t do_multicall( XEN_GUEST_HANDLE_PARAM(multicall_entry_t) call_list, uint32_t nr_calls) { -struct mc_state *mcs = ¤t->mc_state; +struct vcpu *curr = current; +struct mc_state *mcs = &curr->mc_state;uint32_t i;int rc =0 ;enum mc_disposition disp = mc_continue;
@@ -86,7 +87,7 @@ do_multicall(else if (unlikely (__copy_field_to_guest (call_list, &mcs->call, result)) ) rc = -EFAULT ; -else if ( current->hcall_preempted ) +else if ( curr->hcall_preempted ) {/* Translate sub-call continuation to guest layout */ xlat_multicall_entry (mcs);
@@ -95,7 +96,7 @@ do_multicall(if (likely (!__copy_to_guest (call_list, &mcs->call,1 )) ) goto preempted;else -hypercall_cancel_continuation (); +hypercall_cancel_continuation (curr); rc = -EFAULT ; }else
xen/include/xen/sched.h +5 -1
@@ -705,7 +705,11 @@ extern void (*dead_idle) (void);*/ unsigned long hypercall_create_continuation (unsigned int op,const char *format, ...); -void hypercall_cancel_continuation (void ); + +static inline void hypercall_cancel_continuation (struct vcpu *v) +{ + v->hcall_preempted = false; +}/* * For long-running operations that must be in hypercall context, check
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Hi Wei,
Quoted 4 lines · Wei Liu
The function is the same on both x86 and arm. Lift it to
sched.hto save a function call, make it take a pointer to vcpu to avoid resolving current every time it gets called.
Quoted 8 lines
Take the chance to change its callers to only use one current in code.
Signed-off-by Wei Liu <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
For ARM bits:
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 14.08.17 at 17:46, <[email protected]> wrote:
xen/arch/x86/x86_64/compat/mm.c +2
-1@@ -53,6 +53,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)compat_pfn_t mfn;unsigned int i;int rc =0 ; +struct vcpu *curr = current;switch ( cmd ) {@@ -124,7 +125,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if (__copy_to_guest (arg, &cmp,1 ) ) {if ( rc == __HYPERVISOR_memory_op ) -hypercall_cancel_continuation (); +hypercall_cancel_continuation (curr); rc = -EFAULT ; }
xen/arch/x86/x86_64/compat/mm.c int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 140
Quoted 8 lines
xen/arch/x86/x86_64/compat/mm.c +1
-1@@ -133,7 +134,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)case XENMEM_machphys_mapping: { -struct domain *d = current->domain; +struct domain *d = curr->domain;struct compat_machphys_mapping mapping = { .v_start =MACH2PHYS_COMPAT_VIRT_START (d), .v_end =MACH2PHYS_COMPAT_VIRT_END ,
I don't think the local variable is really useful here - it's two entirely distinct and uncommon paths which need it, yet you calculate unconditionally now. With the variable dropped
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel