ia64/xen-unstable

changeset 204:0e45b167992d

bitkeeper revision 1.65 (3e536858YdNPGFSv3J35Fl8zAGLJjQ)

sched.h, xen_block.c, domain.c:
Now have per-domain IO completion queue.
author kaf24@labyrinth.cl.cam.ac.uk
date Wed Feb 19 11:19:52 2003 +0000 (2003-02-19)
parents 6cdebb6f9876
children 6ef50c70b315 ce5fb53e847b
files xen-2.4.16/common/domain.c xen-2.4.16/drivers/block/xen_block.c xen-2.4.16/include/xeno/sched.h
line diff
     1.1 --- a/xen-2.4.16/common/domain.c	Mon Feb 17 13:35:17 2003 +0000
     1.2 +++ b/xen-2.4.16/common/domain.c	Wed Feb 19 11:19:52 2003 +0000
     1.3 @@ -49,6 +49,9 @@ struct task_struct *do_newdomain(void)
     1.4      p->active_mm  = &p->mm;
     1.5      p->num_net_vifs = 0;
     1.6  
     1.7 +    INIT_LIST_HEAD(&p->io_done_queue);
     1.8 +    spin_lock_init(&p->io_done_queue_lock);
     1.9 +
    1.10      /*
    1.11       * KAF: Passing in newdomain struct to this function is gross!
    1.12       * Therefore, for now we just allocate the single blk_ring
     2.1 --- a/xen-2.4.16/drivers/block/xen_block.c	Mon Feb 17 13:35:17 2003 +0000
     2.2 +++ b/xen-2.4.16/drivers/block/xen_block.c	Wed Feb 19 11:19:52 2003 +0000
     2.3 @@ -36,10 +36,8 @@ blk_request_t blk_request_list[XEN_BLK_R
     2.4  
     2.5  struct list_head free_queue;          /* unused requests */
     2.6  struct list_head pending_queue;       /* waiting for hardware */
     2.7 -struct list_head io_done_queue;       /* request completed. send to guest os */
     2.8  spinlock_t free_queue_lock;
     2.9  spinlock_t pending_queue_lock;
    2.10 -spinlock_t io_done_queue_lock;
    2.11  
    2.12  /* some definitions */
    2.13  void dumpx (char *buffer, int count);
    2.14 @@ -63,36 +61,37 @@ void end_block_io_op(struct buffer_head 
    2.15      /* struct list_head *list;*/
    2.16      blk_request_t *blk_request = NULL;
    2.17      unsigned long flags; /* irq save */
    2.18 -    
    2.19 +    struct task_struct *p;
    2.20 +
    2.21      if (XEN_BLK_DEBUG)  
    2.22  	printk(XEN_BLK_DEBUG_LEVEL "XEN end_block_io_op,  bh: %lx\n",
    2.23  	       (unsigned long)bh);
    2.24      
    2.25      spin_lock_irqsave(&pending_queue_lock, flags);
    2.26 -    blk_request = (blk_request_t *)bh->b_xen_request;
    2.27 +    if ( (blk_request = (blk_request_t *)bh->b_xen_request) == NULL) 
    2.28 +        goto bad_interrupt;
    2.29 +    list_del(&blk_request->queue);
    2.30 +    spin_unlock(&pending_queue_lock);
    2.31      
    2.32 -    if (blk_request == NULL) {
    2.33 -	printk (KERN_ALERT
    2.34 -		"   block io interrupt received for unknown buffer [0x%lx]\n",
    2.35 -		(unsigned long) bh);
    2.36 -	spin_unlock_irqrestore(&pending_queue_lock, flags);
    2.37 -	BUG();
    2.38 -	return;
    2.39 -    }
    2.40 -    
    2.41 -    list_del(&blk_request->queue);
    2.42 -    spin_unlock_irqrestore(&pending_queue_lock, flags);
    2.43 -    
    2.44 -    spin_lock_irqsave(&io_done_queue_lock, flags);
    2.45 -    list_add_tail(&blk_request->queue, &io_done_queue);
    2.46 -    
    2.47 +    p = blk_request->domain;
    2.48 +
    2.49 +    spin_lock(&p->io_done_queue_lock);
    2.50 +    list_add_tail(&blk_request->queue, &p->io_done_queue);
    2.51      /* enqueue work for 'flush_blk_queue' handler */
    2.52 -    cpu_mask = mark_hyp_event(blk_request->domain, _HYP_EVENT_BLK_RX);
    2.53 -    spin_unlock_irqrestore(&io_done_queue_lock, flags);
    2.54 +    cpu_mask = mark_hyp_event(p, _HYP_EVENT_BLK_RX);
    2.55 +    spin_unlock_irqrestore(&p->io_done_queue_lock, flags);
    2.56      
    2.57      /* now kick the hypervisor */
    2.58      hyp_event_notify(cpu_mask); 
    2.59      return;
    2.60 +
    2.61 + bad_interrupt:
    2.62 +    printk (KERN_ALERT
    2.63 +            "   block io interrupt received for unknown buffer [0x%lx]\n",
    2.64 +            (unsigned long) bh);
    2.65 +    spin_unlock_irqrestore(&pending_queue_lock, flags);
    2.66 +    BUG();
    2.67 +    return;
    2.68  }
    2.69  
    2.70  /*
    2.71 @@ -104,23 +103,24 @@ void end_block_io_op(struct buffer_head 
    2.72  
    2.73  void flush_blk_queue(void)
    2.74  {
    2.75 +    struct task_struct *p = current;
    2.76      blk_request_t *blk_request;
    2.77      int position = 0;
    2.78      blk_ring_t *blk_ring;
    2.79      unsigned long flags;
    2.80      int loop;
    2.81      
    2.82 -    spin_lock_irqsave(&io_done_queue_lock, flags);
    2.83 -    clear_bit(_HYP_EVENT_BLK_RX, &current->hyp_events);
    2.84 +    spin_lock_irqsave(&p->io_done_queue_lock, flags);
    2.85 +    clear_bit(_HYP_EVENT_BLK_RX, &p->hyp_events);
    2.86      
    2.87 -    while (!list_empty(&io_done_queue)) {
    2.88 -
    2.89 -	blk_request = list_entry(io_done_queue.next, blk_request_t, queue);
    2.90 -	list_del (&blk_request->queue);
    2.91 -	spin_unlock_irqrestore(&io_done_queue_lock, flags);
    2.92 +    while ( !list_empty(&p->io_done_queue) )
    2.93 +    {
    2.94 +	blk_request = list_entry(p->io_done_queue.next, blk_request_t, queue);
    2.95 +	list_del(&blk_request->queue);
    2.96 +	spin_unlock_irqrestore(&p->io_done_queue_lock, flags);
    2.97  	
    2.98  	/* place on ring for guest os */ 
    2.99 -	blk_ring = blk_request->domain->blk_ring_base;
   2.100 +	blk_ring = p->blk_ring_base;
   2.101  	position = blk_ring->brx_prod;
   2.102  
   2.103  	if (XEN_BLK_DEBUG)  
   2.104 @@ -131,19 +131,19 @@ void flush_blk_queue(void)
   2.105  	blk_ring->brx_prod = BLK_RX_RING_INC(blk_ring->brx_prod);
   2.106  
   2.107  	/* notify appropriate guest os */
   2.108 -	set_bit(_EVENT_BLK_RX, &blk_request->domain->shared_info->events);
   2.109 +	set_bit(_EVENT_BLK_RX, &p->shared_info->events);
   2.110  	
   2.111  	/* free the buffer header allocated in do_block_io_op */
   2.112 -	if (blk_request->bh)
   2.113 +	if ( blk_request->bh )
   2.114  	    kfree(blk_request->bh); 
   2.115  
   2.116  	spin_lock_irqsave(&free_queue_lock, flags);
   2.117  	list_add_tail(&blk_request->queue, &free_queue);
   2.118  	spin_unlock_irqrestore(&free_queue_lock, flags);
   2.119  
   2.120 -	spin_lock_irqsave(&io_done_queue_lock, flags);
   2.121 +	spin_lock_irqsave(&p->io_done_queue_lock, flags);
   2.122      }
   2.123 -    spin_unlock_irqrestore(&io_done_queue_lock, flags);
   2.124 +    spin_unlock_irqrestore(&p->io_done_queue_lock, flags);
   2.125  
   2.126  
   2.127      /* XXX SMH: below is ugly and dangerous -- fix */
   2.128 @@ -160,15 +160,15 @@ void flush_blk_queue(void)
   2.129       * at domain 0 every time (although we might want to special
   2.130       * case domain 0);
   2.131       */
   2.132 -    for (loop = 0; loop < XEN_BLOCK_MAX_DOMAINS; loop++) {
   2.133 -
   2.134 +    for ( loop = 0; loop < XEN_BLOCK_MAX_DOMAINS; loop++ )
   2.135 +    {
   2.136  	int domain = pending_work & (1 << loop);
   2.137  
   2.138 -	if (domain) {
   2.139 -
   2.140 +	if ( domain ) 
   2.141 +        {
   2.142  	    struct task_struct *mytask = current;
   2.143  
   2.144 -	    while (mytask->domain != loop)
   2.145 +	    while ( mytask->domain != loop )
   2.146  		mytask = mytask->next_task;
   2.147  
   2.148  	    pending_work = pending_work & !(1 << loop);
   2.149 @@ -421,9 +421,13 @@ static void dump_blockq(u_char key, void
   2.150      dump_queue(&pending_queue, "PENDING QUEUE"); 
   2.151      spin_unlock_irqrestore(&pending_queue_lock, flags);
   2.152  
   2.153 +#if 0
   2.154      spin_lock_irqsave(&io_done_queue_lock, flags);
   2.155      dump_queue(&io_done_queue, "IO DONE QUEUE"); 
   2.156      spin_unlock_irqrestore(&io_done_queue_lock, flags);
   2.157 +#else
   2.158 +    printk("FIXME: IO_DONE_QUEUE IS NOW PER DOMAIN!!\n");
   2.159 +#endif
   2.160  
   2.161      return; 
   2.162  }
   2.163 @@ -443,11 +447,9 @@ void initialize_block_io (){
   2.164      
   2.165      INIT_LIST_HEAD(&free_queue);
   2.166      INIT_LIST_HEAD(&pending_queue);
   2.167 -    INIT_LIST_HEAD(&io_done_queue);
   2.168      
   2.169      spin_lock_init(&free_queue_lock);
   2.170      spin_lock_init(&pending_queue_lock);
   2.171 -    spin_lock_init(&io_done_queue_lock);
   2.172      
   2.173      for (loop = 0; loop < XEN_BLK_REQUEST_LIST_SIZE; loop++)
   2.174      {
     3.1 --- a/xen-2.4.16/include/xeno/sched.h	Mon Feb 17 13:35:17 2003 +0000
     3.2 +++ b/xen-2.4.16/include/xeno/sched.h	Wed Feb 19 11:19:52 2003 +0000
     3.3 @@ -70,13 +70,15 @@ struct task_struct {
     3.4      struct list_head pg_head;
     3.5      unsigned int tot_pages;
     3.6  
     3.7 -    /* Pointer to this guest's virtual interfaces. */
     3.8 -    /* network */
     3.9 +    /* Network I/O */
    3.10      net_ring_t *net_ring_base;
    3.11      net_vif_t *net_vif_list[MAX_GUEST_VIFS];
    3.12      int num_net_vifs;
    3.13 -    /* block io */
    3.14 +
    3.15 +    /* Block I/O */
    3.16      blk_ring_t *blk_ring_base;
    3.17 +    struct list_head io_done_queue;
    3.18 +    spinlock_t io_done_queue_lock;
    3.19  
    3.20      int has_cpu, policy, counter;
    3.21