direct-io.hg

changeset 2515:b3eb75cf942b

bitkeeper revision 1.1159.79.15 (4151a1aaxwsNrL2Uz8ag9J-2-2nVwQ)

Don't use fake clockframe for interrupt delivery. Fixes all cpu time getting
accounted to the kernel and not to userspace programs.
author cl349@freefall.cl.cam.ac.uk
date Wed Sep 22 16:00:42 2004 +0000 (2004-09-22)
parents 669a7dd084ec
children bb7dd5c657d5
files netbsd-2.0-xen-sparse/sys/arch/xen/i386/hypervisor_machdep.c netbsd-2.0-xen-sparse/sys/arch/xen/i386/vector.S netbsd-2.0-xen-sparse/sys/arch/xen/include/evtchn.h netbsd-2.0-xen-sparse/sys/arch/xen/include/hypervisor.h netbsd-2.0-xen-sparse/sys/arch/xen/xen/clock.c netbsd-2.0-xen-sparse/sys/arch/xen/xen/evtchn.c
line diff
     1.1 --- a/netbsd-2.0-xen-sparse/sys/arch/xen/i386/hypervisor_machdep.c	Wed Sep 22 13:16:21 2004 +0000
     1.2 +++ b/netbsd-2.0-xen-sparse/sys/arch/xen/i386/hypervisor_machdep.c	Wed Sep 22 16:00:42 2004 +0000
     1.3 @@ -151,7 +151,7 @@ stipending()
     1.4  	return (ret);
     1.5  }
     1.6  
     1.7 -void do_hypervisor_callback(struct trapframe *regs)
     1.8 +void do_hypervisor_callback(struct intrframe *regs)
     1.9  {
    1.10  	uint32_t l1;
    1.11  	unsigned long l2;
     2.1 --- a/netbsd-2.0-xen-sparse/sys/arch/xen/i386/vector.S	Wed Sep 22 13:16:21 2004 +0000
     2.2 +++ b/netbsd-2.0-xen-sparse/sys/arch/xen/i386/vector.S	Wed Sep 22 16:00:42 2004 +0000
     2.3 @@ -1347,9 +1347,10 @@ ENTRY(hypervisor_callback)
     2.4          jb   11f
     2.5          cmpl $ecrit,%eax
     2.6          jb   critical_region_fixup
     2.7 -11:     push %esp
     2.8 +11:     pushl CPUVAR(ILEVEL)
     2.9 +        push %esp
    2.10          call do_hypervisor_callback
    2.11 -        add  $4,%esp
    2.12 +        add  $8,%esp
    2.13          movl HYPERVISOR_shared_info,%esi
    2.14          xorl %eax,%eax
    2.15          movb TF_CS(%esp),%cl
     3.1 --- a/netbsd-2.0-xen-sparse/sys/arch/xen/include/evtchn.h	Wed Sep 22 13:16:21 2004 +0000
     3.2 +++ b/netbsd-2.0-xen-sparse/sys/arch/xen/include/evtchn.h	Wed Sep 22 16:00:42 2004 +0000
     3.3 @@ -43,7 +43,7 @@ typedef int (*ev_handler_t)(void *);
     3.4  
     3.5  void events_default_setup(void);
     3.6  void init_events(void);
     3.7 -unsigned int do_event(int, struct trapframe *);
     3.8 +unsigned int do_event(int, struct intrframe *);
     3.9  int event_set_handler(int, ev_handler_t, void *, int);
    3.10  
    3.11  int bind_virq_to_irq(int);
     4.1 --- a/netbsd-2.0-xen-sparse/sys/arch/xen/include/hypervisor.h	Wed Sep 22 13:16:21 2004 +0000
     4.2 +++ b/netbsd-2.0-xen-sparse/sys/arch/xen/include/hypervisor.h	Wed Sep 22 16:00:42 2004 +0000
     4.3 @@ -83,7 +83,7 @@ extern union start_info_union start_info
     4.4  
     4.5  
     4.6  /* hypervisor.c */
     4.7 -void do_hypervisor_callback(struct trapframe *regs);
     4.8 +void do_hypervisor_callback(struct intrframe *regs);
     4.9  void hypervisor_notify_via_evtchn(unsigned int);
    4.10  void hypervisor_enable_irq(unsigned int);
    4.11  void hypervisor_disable_irq(unsigned int);
     5.1 --- a/netbsd-2.0-xen-sparse/sys/arch/xen/xen/clock.c	Wed Sep 22 13:16:21 2004 +0000
     5.2 +++ b/netbsd-2.0-xen-sparse/sys/arch/xen/xen/clock.c	Wed Sep 22 16:00:42 2004 +0000
     5.3 @@ -51,7 +51,7 @@
     5.4  
     5.5  #include "config_time.h"		/* for CONFIG_TIME */
     5.6  
     5.7 -static int xen_timer_handler(void *, struct trapframe *);
     5.8 +static int xen_timer_handler(void *, struct intrframe *);
     5.9  
    5.10  /* These are peridically updated in shared_info, and then copied here. */
    5.11  static uint64_t shadow_tsc_stamp;
    5.12 @@ -213,7 +213,7 @@ xen_initclocks()
    5.13  }
    5.14  
    5.15  static int
    5.16 -xen_timer_handler(void *arg, struct trapframe *regs)
    5.17 +xen_timer_handler(void *arg, struct intrframe *regs)
    5.18  {
    5.19  	int64_t delta;
    5.20  
    5.21 @@ -245,7 +245,7 @@ xen_timer_handler(void *arg, struct trap
    5.22  	delta = (int64_t)(shadow_system_time + get_tsc_offset_ns() -
    5.23  			  processed_system_time);
    5.24  	while (delta >= NS_PER_TICK) {
    5.25 -		hardclock((struct clockframe *)regs);
    5.26 +		hardclock(regs);
    5.27  		delta -= NS_PER_TICK;
    5.28  		processed_system_time += NS_PER_TICK;
    5.29  	}
     6.1 --- a/netbsd-2.0-xen-sparse/sys/arch/xen/xen/evtchn.c	Wed Sep 22 13:16:21 2004 +0000
     6.2 +++ b/netbsd-2.0-xen-sparse/sys/arch/xen/xen/evtchn.c	Wed Sep 22 16:00:42 2004 +0000
     6.3 @@ -123,9 +123,13 @@ init_events()
     6.4  }
     6.5  
     6.6  unsigned int
     6.7 -do_event(int irq, struct trapframe *regs)
     6.8 +do_event(int irq, struct intrframe *regs)
     6.9  {
    6.10  	struct cpu_info *ci;
    6.11 +	int ilevel;
    6.12 +	struct intrhand *ih;
    6.13 +	int	(*ih_fun)(void *, void *);
    6.14 +	extern struct uvmexp uvmexp;
    6.15  
    6.16  	if (irq >= NR_IRQS) {
    6.17  #ifdef DIAGNOSTIC
    6.18 @@ -144,15 +148,46 @@ do_event(int irq, struct trapframe *regs
    6.19  
    6.20  	hypervisor_acknowledge_irq(irq);
    6.21  	if (ci->ci_isources[irq] == NULL) {
    6.22 +		hypervisor_enable_irq(irq);
    6.23 +		return 0;
    6.24 +	}
    6.25 +	ilevel = ci->ci_ilevel;
    6.26 +	if (ci->ci_isources[irq]->is_maxlevel <= ilevel) {
    6.27 +		ci->ci_ipending |= 1 << irq;
    6.28 +		/* leave masked */
    6.29  		return 0;
    6.30  	}
    6.31 -	__asm__ __volatile__ (
    6.32 -		"   movl $1f,%%esi	;"
    6.33 -		"   jmp  *%%eax		;"
    6.34 -		"1:			"
    6.35 -		: : "a" (ci->ci_isources[irq]->is_recurse),
    6.36 -		"b" (ci->ci_ilevel)
    6.37 -		: "esi", "ecx", "edx", "memory");
    6.38 +	uvmexp.intrs++;
    6.39 +	ci->ci_isources[irq]->is_evcnt.ev_count++;
    6.40 +	ci->ci_ilevel = ci->ci_isources[irq]->is_maxlevel;
    6.41 +	/* sti */
    6.42 +	ci->ci_idepth++;
    6.43 +#ifdef MULTIPROCESSOR
    6.44 +	x86_intlock(regs);
    6.45 +#endif
    6.46 +	ih = ci->ci_isources[irq]->is_handlers;
    6.47 +	while (ih != NULL) {
    6.48 +		if (ih->ih_level <= ilevel) {
    6.49 +#ifdef MULTIPROCESSOR
    6.50 +			x86_intunlock(regs);
    6.51 +#endif
    6.52 +			ci->ci_ipending |= 1 << irq;
    6.53 +			/* leave masked */
    6.54 +			ci->ci_idepth--;
    6.55 +			splx(ilevel);
    6.56 +			return 0;
    6.57 +		}
    6.58 +		ci->ci_ilevel = ih->ih_level;
    6.59 +		ih_fun = (void *)ih->ih_fun;
    6.60 +		ih_fun(ih->ih_arg, regs);
    6.61 +		ih = ih->ih_next;
    6.62 +	}
    6.63 +#ifdef MULTIPROCESSOR
    6.64 +	x86_intunlock(regs);
    6.65 +#endif
    6.66 +	hypervisor_enable_irq(irq);
    6.67 +	ci->ci_idepth--;
    6.68 +	splx(ilevel);
    6.69  
    6.70  	if (0 && irq == 4)
    6.71  		printf("do_event %d done, ipending %08x\n", irq,