ia64/xen-unstable

changeset 1378:b996311d6c69

bitkeeper revision 1.904 (40a359e2w2OMbG-v-Q3bBA8dXOcCyg)

aborted attempt at using smp_call_function for implementing scheduler pause in shadow clean.
Code might be useful to someone else, though.
author iap10@labyrinth.cl.cam.ac.uk
date Thu May 13 11:20:02 2004 +0000 (2004-05-13)
parents acc04d188782
children e8e20ed30675
files xen/common/shadow.c xen/include/xen/shadow.h
line diff
     1.1 --- a/xen/common/shadow.c	Thu May 13 10:51:36 2004 +0000
     1.2 +++ b/xen/common/shadow.c	Thu May 13 11:20:02 2004 +0000
     1.3 @@ -170,9 +170,6 @@ int shadow_mode_enable( struct task_stru
     1.4      struct shadow_status **fptr;
     1.5      int i;
     1.6  
     1.7 -    spin_lock_init(&m->shadow_lock);
     1.8 -    spin_lock(&m->shadow_lock);
     1.9 -
    1.10      m->shadow_mode = mode;
    1.11   
    1.12      // allocate hashtable
    1.13 @@ -186,8 +183,10 @@ int shadow_mode_enable( struct task_stru
    1.14  
    1.15  
    1.16      // allocate space for first lot of extra nodes
    1.17 -    m->shadow_ht_extras = kmalloc( sizeof(void*) + (shadow_ht_extra_size * 
    1.18 -                                                    sizeof(struct shadow_status)), GFP_KERNEL );
    1.19 +    m->shadow_ht_extras = kmalloc( sizeof(void*) + 
    1.20 +				   (shadow_ht_extra_size * 
    1.21 +				    sizeof(struct shadow_status)),
    1.22 +				   GFP_KERNEL );
    1.23  
    1.24      if( ! m->shadow_ht_extras )
    1.25          goto nomem;
    1.26 @@ -222,14 +221,11 @@ int shadow_mode_enable( struct task_stru
    1.27          memset(m->shadow_dirty_bitmap,0,m->shadow_dirty_bitmap_size/8);
    1.28      }
    1.29  
    1.30 -    spin_unlock(&m->shadow_lock);
    1.31 -
    1.32      // call shadow_mk_pagetable
    1.33 -    shadow_mk_pagetable( m );
    1.34 +    __shadow_mk_pagetable( m );
    1.35      return 0;
    1.36  
    1.37   nomem:
    1.38 -    spin_unlock(&m->shadow_lock);
    1.39      return -ENOMEM;
    1.40  }
    1.41  
    1.42 @@ -238,10 +234,8 @@ void shadow_mode_disable( struct task_st
    1.43      struct mm_struct *m = &p->mm;
    1.44      struct shadow_status *next;
    1.45  
    1.46 -    spin_lock(&m->shadow_lock);
    1.47      __free_shadow_table( m );
    1.48      m->shadow_mode = 0;
    1.49 -    spin_unlock(&m->shadow_lock);
    1.50  
    1.51      SH_LOG("freed tables count=%d l1=%d l2=%d",
    1.52             m->shadow_page_count, perfc_value(shadow_l1_pages), perfc_value(shadow_l2_pages));
    1.53 @@ -285,9 +279,6 @@ static int shadow_mode_table_op( struct 
    1.54          return -EINVAL;
    1.55      }
    1.56     
    1.57 -
    1.58 -    spin_lock(&m->shadow_lock);
    1.59 -
    1.60      SH_VLOG("shadow mode table op %08lx %08lx count %d",pagetable_val( m->pagetable),pagetable_val(m->shadow_table), m->shadow_page_count);
    1.61  
    1.62      shadow_audit(m,1);
    1.63 @@ -348,16 +339,14 @@ static int shadow_mode_table_op( struct 
    1.64  
    1.65  out:
    1.66  
    1.67 -    spin_unlock(&m->shadow_lock);
    1.68 -
    1.69      SH_VLOG("shadow mode table op : page count %d", m->shadow_page_count);
    1.70  
    1.71      shadow_audit(m,1);
    1.72  
    1.73      // call shadow_mk_pagetable
    1.74 -    shadow_mk_pagetable( m );
    1.75 +    __shadow_mk_pagetable( m );
    1.76  
    1.77 -	return rc;
    1.78 +    return rc;
    1.79  }
    1.80  
    1.81  int shadow_mode_control( struct task_struct *p, dom0_shadow_control_t *sc )
    1.82 @@ -380,25 +369,31 @@ int shadow_mode_control( struct task_str
    1.83         Oh, and let's hope someone doesn't repin the CPU while we're here.
    1.84         Also, prey someone else doesn't do this in another domain.
    1.85         At least there's only one dom0 at the moment...
    1.86 +
    1.87       */
    1.88 -printk("SMC\n");
    1.89 +
    1.90 +printk("XXX\n");
    1.91 +    spin_lock(&p->mm.shadow_lock);
    1.92 +
    1.93 +printk("SMC irq=%d\n",local_irq_is_enabled());
    1.94      spin_lock( &cpu_stall_lock );		
    1.95      cpu = p->processor;
    1.96 -printk("got %d %d\n",cpu, current->processor );
    1.97 +printk("got target cpu=%d this cpu=%d\n",cpu, current->processor );
    1.98      if ( cpu != current->processor )
    1.99      {
   1.100 -printk("CPU %d %d\n",cpu, current->processor );
   1.101  	static void cpu_stall(void * data)
   1.102  	{
   1.103  	    if ( current->processor == (int) data )
   1.104  	    {
   1.105 -		printk("Stall %d\n",(int)data);
   1.106 +		printk("Stall cpu=%d is locked %d irq=%d\n",(int)data,spin_is_locked(&cpu_stall_lock),local_irq_is_enabled());
   1.107  		spin_lock( &cpu_stall_lock );
   1.108 +		printk("release\n");
   1.109  		spin_unlock( &cpu_stall_lock );
   1.110  	    }
   1.111  	}
   1.112 -
   1.113 +printk("before\n");
   1.114  	smp_call_function(cpu_stall, (void*)cpu, 1, 0); // don't wait!
   1.115 +printk("after\n");
   1.116      }
   1.117  
   1.118      if ( p->mm.shadow_mode && cmd == DOM0_SHADOW_CONTROL_OP_OFF )
   1.119 @@ -417,7 +412,9 @@ printk("CPU %d %d\n",cpu, current->proce
   1.120      } 
   1.121      else if ( p->mm.shadow_mode && cmd >= DOM0_SHADOW_CONTROL_OP_FLUSH && cmd<=DOM0_SHADOW_CONTROL_OP_CLEAN )
   1.122      {
   1.123 +printk("+");
   1.124          rc = shadow_mode_table_op(p, sc);
   1.125 +printk("=");
   1.126      }
   1.127      else
   1.128      {
   1.129 @@ -425,7 +422,10 @@ printk("CPU %d %d\n",cpu, current->proce
   1.130      }
   1.131  
   1.132      spin_unlock( &cpu_stall_lock );
   1.133 -printk("SMC-\n");
   1.134 +printk("SMC- %d\n",rc);
   1.135 +
   1.136 +    spin_unlock(&p->mm.shadow_lock);
   1.137 +
   1.138      return rc;
   1.139  }
   1.140  
   1.141 @@ -549,6 +549,8 @@ int shadow_fault( unsigned long va, long
   1.142      unsigned long gpte, spte;
   1.143      struct mm_struct *m = &current->mm;
   1.144  
   1.145 +    // we know interrupts are always on entry to the page fault handler 
   1.146 +
   1.147      SH_VVLOG("shadow_fault( va=%08lx, code=%ld )", va, error_code );
   1.148  
   1.149      check_pagetable( current, current->mm.pagetable, "pre-sf" );
     2.1 --- a/xen/include/xen/shadow.h	Thu May 13 10:51:36 2004 +0000
     2.2 +++ b/xen/include/xen/shadow.h	Thu May 13 11:20:02 2004 +0000
     2.3 @@ -528,23 +528,30 @@ static inline void set_shadow_status( st
     2.4  	return;
     2.5  }
     2.6  
     2.7 -static inline void shadow_mk_pagetable( struct mm_struct *mm )
     2.8 +static inline void __shadow_mk_pagetable( struct mm_struct *mm )
     2.9  {
    2.10  	unsigned long gpfn, spfn=0;
    2.11  
    2.12 +	gpfn =  pagetable_val(mm->pagetable) >> PAGE_SHIFT;
    2.13 +		
    2.14 +	if ( unlikely((spfn=__shadow_status(mm, gpfn)) == 0 ) )
    2.15 +	{
    2.16 +		spfn = shadow_l2_table(mm, gpfn );
    2.17 +	}      
    2.18 +	mm->shadow_table = mk_pagetable(spfn<<PAGE_SHIFT);
    2.19 +}
    2.20 +
    2.21 +static inline void shadow_mk_pagetable( struct mm_struct *mm )
    2.22 +{
    2.23  	SH_VVLOG("shadow_mk_pagetable( gptbase=%08lx, mode=%d )",
    2.24  			 pagetable_val(mm->pagetable), mm->shadow_mode );
    2.25  
    2.26  	if ( unlikely(mm->shadow_mode) )
    2.27  	{
    2.28 -		gpfn =  pagetable_val(mm->pagetable) >> PAGE_SHIFT;
    2.29 -		
    2.30          spin_lock(&mm->shadow_lock);
    2.31 -		if ( unlikely((spfn=__shadow_status(mm, gpfn)) == 0 ) )
    2.32 -		{
    2.33 -			spfn = shadow_l2_table(mm, gpfn );
    2.34 -		}      
    2.35 -		mm->shadow_table = mk_pagetable(spfn<<PAGE_SHIFT);
    2.36 +
    2.37 +		__shadow_mk_pagetable( mm );
    2.38 +
    2.39          spin_unlock(&mm->shadow_lock);		
    2.40  	}
    2.41  
    2.42 @@ -555,7 +562,6 @@ static inline void shadow_mk_pagetable( 
    2.43  }
    2.44  
    2.45  
    2.46 -
    2.47  #if SHADOW_DEBUG
    2.48  extern int check_pagetable(struct mm_struct *m, pagetable_t pt, char *s);
    2.49  #else