direct-io.hg

changeset 12471:cf98903ebb22

[XEN] Scheduling hypercalls defer entry to the scheduler to softirq
context.

This avoids entering the scheduler with outstanding multicall state
and also happens to simplify the x86 entry protocol to the scheduler
hypercall (since we do not need to preset the return code).

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Nov 16 18:28:05 2006 +0000 (2006-11-16)
parents 5f7b5e5ca14b
children 73ef90055339
files xen/arch/ia64/vmx/vmx_support.c xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_64/entry.S xen/common/domain.c xen/common/schedule.c
line diff
     1.1 --- a/xen/arch/ia64/vmx/vmx_support.c	Thu Nov 16 17:07:23 2006 +0000
     1.2 +++ b/xen/arch/ia64/vmx/vmx_support.c	Thu Nov 16 18:28:05 2006 +0000
     1.3 @@ -95,8 +95,7 @@ void vmx_send_assist_req(struct vcpu *v)
     1.4              break;
     1.5          }
     1.6  
     1.7 -        /* I want to call __enter_scheduler() only */
     1.8 -        do_sched_op_compat(SCHEDOP_yield, 0);
     1.9 +        raise_softirq(SCHEDULE_SOFTIRQ);
    1.10          mb();
    1.11      }
    1.12  
     2.1 --- a/xen/arch/x86/x86_32/entry.S	Thu Nov 16 17:07:23 2006 +0000
     2.2 +++ b/xen/arch/x86/x86_32/entry.S	Thu Nov 16 18:28:05 2006 +0000
     2.3 @@ -597,20 +597,6 @@ ENTRY(setup_vm86_frame)
     2.4          addl $16,%esp
     2.5          ret
     2.6  
     2.7 -do_arch_sched_op_compat:
     2.8 -        # Ensure we return success even if we return via schedule_tail()
     2.9 -        xorl %eax,%eax
    2.10 -        GET_GUEST_REGS(%ecx)
    2.11 -        movl %eax,UREGS_eax(%ecx)
    2.12 -        jmp  do_sched_op_compat
    2.13 -
    2.14 -do_arch_sched_op:
    2.15 -        # Ensure we return success even if we return via schedule_tail()
    2.16 -        xorl %eax,%eax
    2.17 -        GET_GUEST_REGS(%ecx)
    2.18 -        movl %eax,UREGS_eax(%ecx)
    2.19 -        jmp  do_sched_op
    2.20 -
    2.21  .data
    2.22  
    2.23  ENTRY(exception_table)
    2.24 @@ -642,7 +628,7 @@ ENTRY(hypercall_table)
    2.25          .long do_stack_switch
    2.26          .long do_set_callbacks
    2.27          .long do_fpu_taskswitch     /*  5 */
    2.28 -        .long do_arch_sched_op_compat
    2.29 +        .long do_sched_op_compat
    2.30          .long do_platform_op
    2.31          .long do_set_debugreg
    2.32          .long do_get_debugreg
    2.33 @@ -665,7 +651,7 @@ ENTRY(hypercall_table)
    2.34          .long do_mmuext_op
    2.35          .long do_acm_op
    2.36          .long do_nmi_op
    2.37 -        .long do_arch_sched_op
    2.38 +        .long do_sched_op
    2.39          .long do_callback_op        /* 30 */
    2.40          .long do_xenoprof_op
    2.41          .long do_event_channel_op
    2.42 @@ -684,7 +670,7 @@ ENTRY(hypercall_args_table)
    2.43          .byte 2 /* do_stack_switch      */
    2.44          .byte 4 /* do_set_callbacks     */
    2.45          .byte 1 /* do_fpu_taskswitch    */  /*  5 */
    2.46 -        .byte 2 /* do_arch_sched_op_compat */
    2.47 +        .byte 2 /* do_sched_op_compat   */
    2.48          .byte 1 /* do_platform_op       */
    2.49          .byte 2 /* do_set_debugreg      */
    2.50          .byte 1 /* do_get_debugreg      */
    2.51 @@ -707,7 +693,7 @@ ENTRY(hypercall_args_table)
    2.52          .byte 4 /* do_mmuext_op         */
    2.53          .byte 1 /* do_acm_op            */
    2.54          .byte 2 /* do_nmi_op            */
    2.55 -        .byte 2 /* do_arch_sched_op     */
    2.56 +        .byte 2 /* do_sched_op          */
    2.57          .byte 2 /* do_callback_op       */  /* 30 */
    2.58          .byte 2 /* do_xenoprof_op       */
    2.59          .byte 2 /* do_event_channel_op  */
     3.1 --- a/xen/arch/x86/x86_64/entry.S	Thu Nov 16 17:07:23 2006 +0000
     3.2 +++ b/xen/arch/x86/x86_64/entry.S	Thu Nov 16 18:28:05 2006 +0000
     3.3 @@ -497,20 +497,6 @@ nmi_in_hypervisor_mode:
     3.4          call  do_nmi
     3.5          jmp   ret_from_intr
     3.6  
     3.7 -do_arch_sched_op_compat:
     3.8 -        # Ensure we return success even if we return via schedule_tail()
     3.9 -        xorl  %eax,%eax
    3.10 -        GET_GUEST_REGS(%r10)
    3.11 -        movq  %rax,UREGS_rax(%r10)
    3.12 -        jmp   do_sched_op_compat
    3.13 -
    3.14 -do_arch_sched_op:
    3.15 -        # Ensure we return success even if we return via schedule_tail()
    3.16 -        xorl  %eax,%eax
    3.17 -        GET_GUEST_REGS(%r10)
    3.18 -        movq  %rax,UREGS_rax(%r10)
    3.19 -        jmp   do_sched_op
    3.20 -
    3.21  .data
    3.22  
    3.23  ENTRY(exception_table)
    3.24 @@ -542,7 +528,7 @@ ENTRY(hypercall_table)
    3.25          .quad do_stack_switch
    3.26          .quad do_set_callbacks
    3.27          .quad do_fpu_taskswitch     /*  5 */
    3.28 -        .quad do_arch_sched_op_compat
    3.29 +        .quad do_sched_op_compat
    3.30          .quad do_platform_op
    3.31          .quad do_set_debugreg
    3.32          .quad do_get_debugreg
    3.33 @@ -565,7 +551,7 @@ ENTRY(hypercall_table)
    3.34          .quad do_mmuext_op
    3.35          .quad do_acm_op
    3.36          .quad do_nmi_op
    3.37 -        .quad do_arch_sched_op
    3.38 +        .quad do_sched_op
    3.39          .quad do_callback_op        /* 30 */
    3.40          .quad do_xenoprof_op
    3.41          .quad do_event_channel_op
    3.42 @@ -584,8 +570,8 @@ ENTRY(hypercall_args_table)
    3.43          .byte 2 /* do_stack_switch      */
    3.44          .byte 3 /* do_set_callbacks     */
    3.45          .byte 1 /* do_fpu_taskswitch    */  /*  5 */
    3.46 -        .byte 2 /* do_arch_sched_op_compat */
    3.47 -        .byte 1 /* do_platform_op           */
    3.48 +        .byte 2 /* do_sched_op_compat   */
    3.49 +        .byte 1 /* do_platform_op       */
    3.50          .byte 2 /* do_set_debugreg      */
    3.51          .byte 1 /* do_get_debugreg      */
    3.52          .byte 2 /* do_update_descriptor */  /* 10 */
    3.53 @@ -607,7 +593,7 @@ ENTRY(hypercall_args_table)
    3.54          .byte 4 /* do_mmuext_op         */
    3.55          .byte 1 /* do_acm_op            */
    3.56          .byte 2 /* do_nmi_op            */
    3.57 -        .byte 2 /* do_arch_sched_op     */
    3.58 +        .byte 2 /* do_sched_op          */
    3.59          .byte 2 /* do_callback_op       */  /* 30 */
    3.60          .byte 2 /* do_xenoprof_op       */
    3.61          .byte 2 /* do_event_channel_op  */
     4.1 --- a/xen/common/domain.c	Thu Nov 16 17:07:23 2006 +0000
     4.2 +++ b/xen/common/domain.c	Thu Nov 16 18:28:05 2006 +0000
     4.3 @@ -258,8 +258,18 @@ void __domain_crash_synchronous(void)
     4.4  {
     4.5      __domain_crash(current->domain);
     4.6  
     4.7 -    /* Flush multicall state before dying. */
     4.8 -    this_cpu(mc_state).flags = 0;
     4.9 +    /*
    4.10 +     * Flush multicall state before dying if a multicall is in progress.
    4.11 +     * This shouldn't be necessary, but some architectures are calling
    4.12 +     * domain_crash_synchronous() when they really shouldn't (i.e., from
    4.13 +     * within hypercall context).
    4.14 +     */
    4.15 +    if ( this_cpu(mc_state).flags != 0 )
    4.16 +    {
    4.17 +        dprintk(XENLOG_ERR,
    4.18 +                "FIXME: synchronous domain crash during a multicall!\n");
    4.19 +        this_cpu(mc_state).flags = 0;
    4.20 +    }
    4.21  
    4.22      for ( ; ; )
    4.23          do_softirq();
     5.1 --- a/xen/common/schedule.c	Thu Nov 16 17:07:23 2006 +0000
     5.2 +++ b/xen/common/schedule.c	Thu Nov 16 18:28:05 2006 +0000
     5.3 @@ -60,8 +60,6 @@ static struct scheduler *schedulers[] = 
     5.4      NULL
     5.5  };
     5.6  
     5.7 -static void __enter_scheduler(void);
     5.8 -
     5.9  static struct scheduler ops;
    5.10  
    5.11  #define SCHED_OP(fn, ...)                                 \
    5.12 @@ -270,7 +268,7 @@ static long do_block(void)
    5.13      else
    5.14      {
    5.15          TRACE_2D(TRC_SCHED_BLOCK, v->domain->domain_id, v->vcpu_id);
    5.16 -        __enter_scheduler();
    5.17 +        raise_softirq(SCHEDULE_SOFTIRQ);
    5.18      }
    5.19  
    5.20      return 0;
    5.21 @@ -315,9 +313,9 @@ static long do_poll(struct sched_poll *s
    5.22          set_timer(&v->poll_timer, sched_poll->timeout);
    5.23  
    5.24      TRACE_2D(TRC_SCHED_BLOCK, v->domain->domain_id, v->vcpu_id);
    5.25 -    __enter_scheduler();
    5.26 +    raise_softirq(SCHEDULE_SOFTIRQ);
    5.27  
    5.28 -    stop_timer(&v->poll_timer);
    5.29 +    return 0;
    5.30  
    5.31   out:
    5.32      clear_bit(_VCPUF_polling, &v->vcpu_flags);
    5.33 @@ -329,7 +327,7 @@ static long do_poll(struct sched_poll *s
    5.34  static long do_yield(void)
    5.35  {
    5.36      TRACE_2D(TRC_SCHED_YIELD, current->domain->domain_id, current->vcpu_id);
    5.37 -    __enter_scheduler();
    5.38 +    raise_softirq(SCHEDULE_SOFTIRQ);
    5.39      return 0;
    5.40  }
    5.41  
    5.42 @@ -540,7 +538,7 @@ long sched_adjust(struct domain *d, stru
    5.43   * - deschedule the current domain (scheduler independent).
    5.44   * - pick a new domain (scheduler dependent).
    5.45   */
    5.46 -static void __enter_scheduler(void)
    5.47 +static void schedule(void)
    5.48  {
    5.49      struct vcpu          *prev = current, *next = NULL;
    5.50      s_time_t              now = NOW();
    5.51 @@ -549,6 +547,7 @@ static void __enter_scheduler(void)
    5.52      s32                   r_time;     /* time for new dom to run */
    5.53  
    5.54      ASSERT(!in_irq());
    5.55 +    ASSERT(this_cpu(mc_state).flags == 0);
    5.56  
    5.57      perfc_incrc(sched_run);
    5.58  
    5.59 @@ -679,7 +678,7 @@ void __init scheduler_init(void)
    5.60  {
    5.61      int i;
    5.62  
    5.63 -    open_softirq(SCHEDULE_SOFTIRQ, __enter_scheduler);
    5.64 +    open_softirq(SCHEDULE_SOFTIRQ, schedule);
    5.65  
    5.66      for_each_cpu ( i )
    5.67      {