ia64/xen-unstable

changeset 6360:af9e3ae3a9b1

Add locking for gnttab_free_callback_list.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Aug 23 08:45:13 2005 +0000 (2005-08-23)
parents d13f5c7daddf
children 96f1f6c71089
files linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Tue Aug 23 08:41:18 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Tue Aug 23 08:45:13 2005 +0000
     1.3 @@ -51,6 +51,7 @@ static grant_ref_t gnttab_free_head;
     1.4  static grant_entry_t *shared;
     1.5  
     1.6  static struct gnttab_free_callback *gnttab_free_callback_list = NULL;
     1.7 +static spinlock_t gnttab_free_callback_list_lock = SPIN_LOCK_UNLOCKED;
     1.8  
     1.9  /*
    1.10   * Lock-free grant-entry allocator
    1.11 @@ -69,8 +70,11 @@ get_free_entry(
    1.12  
    1.13  static void do_free_callbacks(void)
    1.14  {
    1.15 -    struct gnttab_free_callback *callback = gnttab_free_callback_list, *next;
    1.16 +    struct gnttab_free_callback *callback, *next;
    1.17 +    spin_lock_irq(&gnttab_free_callback_list_lock);
    1.18 +    callback = gnttab_free_callback_list;
    1.19      gnttab_free_callback_list = NULL;
    1.20 +    spin_unlock_irq(&gnttab_free_callback_list_lock);
    1.21      while (callback) {
    1.22  	next = callback->next;
    1.23  	callback->next = NULL;
    1.24 @@ -86,8 +90,10 @@ put_free_entry(
    1.25      grant_ref_t fh, nfh = gnttab_free_head;
    1.26      do { gnttab_free_list[ref] = fh = nfh; wmb(); }
    1.27      while ( unlikely((nfh = cmpxchg(&gnttab_free_head, fh, ref)) != fh) );
    1.28 +    spin_lock_irq(&gnttab_free_callback_list_lock);
    1.29      if ( unlikely(gnttab_free_callback_list) )
    1.30  	do_free_callbacks();
    1.31 +    spin_unlock_irq(&gnttab_free_callback_list_lock);
    1.32  }
    1.33  
    1.34  /*
    1.35 @@ -274,8 +280,10 @@ gnttab_request_free_callback(struct gntt
    1.36  	return;
    1.37      callback->fn = fn;
    1.38      callback->arg = arg;
    1.39 +    spin_lock_irq(&gnttab_free_callback_list_lock);
    1.40      callback->next = gnttab_free_callback_list;
    1.41      gnttab_free_callback_list = callback;
    1.42 +    spin_unlock_irq(&gnttab_free_callback_list_lock);
    1.43  }
    1.44  
    1.45  /*