Jan Beulich
2007-Mar-26 14:54 UTC
[Xen-devel] [PATCH] linux: simplify and perform checking of multicall status
Signed-off-by: Jan Beulich <jbeulich@novell.com> Index: head-2007-03-19/arch/i386/mm/hypervisor.c ==================================================================--- head-2007-03-19.orig/arch/i386/mm/hypervisor.c 2007-03-23 16:21:22.000000000 +0100 +++ head-2007-03-19/arch/i386/mm/hypervisor.c 2007-03-23 16:30:29.000000000 +0100 @@ -303,7 +303,7 @@ int xen_create_contiguous_region( set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, INVALID_P2M_ENTRY); } - if (HYPERVISOR_multicall(cr_mcl, i)) + if (HYPERVISOR_multicall_check(cr_mcl, i, NULL)) BUG(); /* 2. Get a new contiguous memory extent. */ @@ -342,7 +342,7 @@ int xen_create_contiguous_region( cr_mcl[i - 1].args[MULTI_UVMFLAGS_INDEX] = order ? UVMF_TLB_FLUSH|UVMF_ALL : UVMF_INVLPG|UVMF_ALL; - if (HYPERVISOR_multicall(cr_mcl, i)) + if (HYPERVISOR_multicall_check(cr_mcl, i, NULL)) BUG(); if (success) @@ -400,7 +400,7 @@ void xen_destroy_contiguous_region(unsig INVALID_P2M_ENTRY); out_frames[i] = (__pa(vstart) >> PAGE_SHIFT) + i; } - if (HYPERVISOR_multicall(cr_mcl, i)) + if (HYPERVISOR_multicall_check(cr_mcl, i, NULL)) BUG(); /* 3. Do the exchange for non-contiguous MFNs. */ @@ -432,7 +432,7 @@ void xen_destroy_contiguous_region(unsig cr_mcl[i - 1].args[MULTI_UVMFLAGS_INDEX] = order ? UVMF_TLB_FLUSH|UVMF_ALL : UVMF_INVLPG|UVMF_ALL; - if (HYPERVISOR_multicall(cr_mcl, i)) + if (HYPERVISOR_multicall_check(cr_mcl, i, NULL)) BUG(); balloon_unlock(flags); Index: head-2007-03-19/drivers/xen/core/machine_kexec.c ==================================================================--- head-2007-03-19.orig/drivers/xen/core/machine_kexec.c 2007-03-23 16:21:22.000000000 +0100 +++ head-2007-03-19/drivers/xen/core/machine_kexec.c 2007-03-21 11:54:05.000000000 +0100 @@ -7,7 +7,6 @@ #include <xen/interface/kexec.h> #include <linux/mm.h> #include <linux/bootmem.h> -#include <asm/hypercall.h> extern void machine_kexec_setup_load_arg(xen_kexec_image_t *xki, struct kimage *image); Index: head-2007-03-19/drivers/xen/netback/netback.c ==================================================================--- head-2007-03-19.orig/drivers/xen/netback/netback.c 2007-03-23 16:21:22.000000000 +0100 +++ head-2007-03-19/drivers/xen/netback/netback.c 2007-03-23 11:54:05.000000000 +0100 @@ -615,8 +615,9 @@ static void net_rx_action(unsigned long BUG_ON(npo.mcl_prod > NET_RX_RING_SIZE+3); BUG_ON(npo.meta_prod > NET_RX_RING_SIZE); - ret = HYPERVISOR_multicall(npo.mcl, npo.mcl_prod); - BUG_ON(ret != 0); + ret = HYPERVISOR_multicall_check(npo.mcl, npo.mcl_prod, NULL); + BUG_ON(ret < 0); + WARN_ON(ret > 0); while ((skb = __skb_dequeue(&rxq)) != NULL) { nr_frags = *(int *)skb->cb; Index: head-2007-03-19/drivers/xen/netfront/netfront.c ==================================================================--- head-2007-03-19.orig/drivers/xen/netfront/netfront.c 2007-03-23 16:21:22.000000000 +0100 +++ head-2007-03-19/drivers/xen/netfront/netfront.c 2007-03-23 16:03:40.000000000 +0100 @@ -1579,7 +1579,8 @@ static void netif_release_rx_bufs(struct mcl->args[2] = 0; mcl->args[3] = DOMID_SELF; mcl++; - HYPERVISOR_multicall(np->rx_mcl, mcl - np->rx_mcl); + if (HYPERVISOR_multicall_check(np->rx_mcl, mcl - np->rx_mcl, NULL)) + BUG(); } } Index: head-2007-03-19/include/asm-i386/mach-xen/asm/hypercall.h ==================================================================--- head-2007-03-19.orig/include/asm-i386/mach-xen/asm/hypercall.h 2007-03-23 16:21:22.000000000 +0100 +++ head-2007-03-19/include/asm-i386/mach-xen/asm/hypercall.h 2007-03-21 11:54:05.000000000 +0100 @@ -238,7 +238,7 @@ HYPERVISOR_memory_op( static inline int HYPERVISOR_multicall( - void *call_list, int nr_calls) + multicall_entry_t *call_list, int nr_calls) { return _hypercall2(int, multicall, call_list, nr_calls); } Index: head-2007-03-19/include/asm-i386/mach-xen/asm/hypervisor.h ==================================================================--- head-2007-03-19.orig/include/asm-i386/mach-xen/asm/hypervisor.h 2007-03-23 16:21:22.000000000 +0100 +++ head-2007-03-19/include/asm-i386/mach-xen/asm/hypervisor.h 2007-03-21 11:54:05.000000000 +0100 @@ -122,7 +122,7 @@ void xen_destroy_contiguous_region( /* Turn jiffies into Xen system time. */ u64 jiffies_to_st(unsigned long jiffies); -#include <asm/hypercall.h> +#include <xen/hypercall.h> #if defined(CONFIG_X86_64) #define MULTI_UVMFLAGS_INDEX 2 Index: head-2007-03-19/include/asm-ia64/hypervisor.h ==================================================================--- head-2007-03-19.orig/include/asm-ia64/hypervisor.h +++ head-2007-03-19/include/asm-ia64/hypervisor.h @@ -55,7 +55,7 @@ void xen_destroy_contiguous_region( #include <xen/interface/event_channel.h> #include <xen/interface/physdev.h> #include <xen/interface/sched.h> -#include <asm/hypercall.h> +#include <xen/hypercall.h> #include <asm/ptrace.h> #include <asm/page.h> Index: head-2007-03-19/include/asm-x86_64/mach-xen/asm/hypercall.h ==================================================================--- head-2007-03-19.orig/include/asm-x86_64/mach-xen/asm/hypercall.h 2007-03-23 16:21:22.000000000 +0100 +++ head-2007-03-19/include/asm-x86_64/mach-xen/asm/hypercall.h 2007-03-21 11:54:05.000000000 +0100 @@ -241,7 +241,7 @@ HYPERVISOR_memory_op( static inline int HYPERVISOR_multicall( - void *call_list, int nr_calls) + multicall_entry_t *call_list, int nr_calls) { return _hypercall2(int, multicall, call_list, nr_calls); } Index: head-2007-03-19/include/xen/hvm.h ==================================================================--- head-2007-03-19.orig/include/xen/hvm.h 2007-03-23 16:21:22.000000000 +0100 +++ head-2007-03-19/include/xen/hvm.h 2007-03-21 11:54:05.000000000 +0100 @@ -3,7 +3,6 @@ #define XEN_HVM_H__ #include <xen/interface/hvm/params.h> -#include <asm/hypercall.h> static inline unsigned long hvm_get_parameter(int idx) { Index: head-2007-03-19/include/xen/hypercall.h ==================================================================--- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ head-2007-03-19/include/xen/hypercall.h 2007-03-23 16:25:06.000000000 +0100 @@ -0,0 +1,23 @@ +#ifndef __XEN_HYPERCALL_H__ +#define __XEN_HYPERCALL_H__ + +#include <asm/hypercall.h> + +static inline int +HYPERVISOR_multicall_check( + multicall_entry_t *call_list, int nr_calls, + const unsigned long *rc_list) +{ + int rc = HYPERVISOR_multicall(call_list, nr_calls); + + if (unlikely(rc == 0)) + return rc; + + for ( ; nr_calls > 0; --nr_calls, ++call_list) + if (unlikely(call_list->result != (rc_list ? *rc_list++ : 0))) + return nr_calls; + + return 0; +} + +#endif /* __XEN_HYPERCALL_H__ */ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2007-Apr-05 08:29 UTC
Re: [Xen-devel] [PATCH] linux: simplify and perform checking of multicall status
On 26/3/07 15:54, "Jan Beulich" <jbeulich@novell.com> wrote:> +static inline int > +HYPERVISOR_multicall_check( > + multicall_entry_t *call_list, int nr_calls, > + const unsigned long *rc_list) > +{ > + int rc = HYPERVISOR_multicall(call_list, nr_calls); > + > + if (unlikely(rc == 0)) > + return rc;ITYM unlikely(rc != 0)? -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jan Beulich
2007-Apr-05 09:00 UTC
Re: [Xen-devel] [PATCH] linux: simplify and perform checking of multicall status
>>> Keir Fraser <keir@xensource.com> 05.04.07 10:29 >>> >On 26/3/07 15:54, "Jan Beulich" <jbeulich@novell.com> wrote: > >> +static inline int >> +HYPERVISOR_multicall_check( >> + multicall_entry_t *call_list, int nr_calls, >> + const unsigned long *rc_list) >> +{ >> + int rc = HYPERVISOR_multicall(call_list, nr_calls); >> + >> + if (unlikely(rc == 0)) >> + return rc; > >ITYM unlikely(rc != 0)?Huh, indeed. And perhaps it should (give the rest of the function) even be if (unlikely(rc < 0)) return rc; BUG_ON(rc); (i.e. so that positive return values indicate the failed slot, negative ones indicate a failure of the multicall itself). Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2007-Apr-05 09:15 UTC
Re: [Xen-devel] [PATCH] linux: simplify and perform checking of multicall status
On 5/4/07 10:00, "Jan Beulich" <jbeulich@novell.com> wrote:> Huh, indeed. And perhaps it should (give the rest of the function) even > be > > if (unlikely(rc < 0)) > return rc; > BUG_ON(rc); > > (i.e. so that positive return values indicate the failed slot, negative ones > indicate a failure of the multicall itself).Makes sense. I''ll merge that in. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel