ia64/linux-2.6.18-xen.hg

changeset 446:c48f54365060

netfront accel: Fix request_module/modprobe deadlock

There would seem to be a potential deadlock in the netfront accelerator
plugin support. When the configured accelerator changes in xenstore,
netfront tries to load the new plugin using request_module(). It does
this from a workqueue work item. request_module() will invoke
modprobe which in some circumstances (I'm not sure exactly what - I've
not managed to reproduce it myself) seems to try to flush the
workqueue, and so it deadlocks. This patch fixes the problem by
giving the accel watch work item its own workqueue, and so modprobe
can successfully flush the system-wide one.

Signed-off-by Kieran Mansley <kmansley@solarflare.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Feb 27 13:14:18 2008 +0000 (2008-02-27)
parents 43de9d7c3c63
children 7c04748ed275 439fda3ac269
files drivers/xen/netfront/accel.c
line diff
     1.1 --- a/drivers/xen/netfront/accel.c	Tue Feb 26 17:59:18 2008 +0000
     1.2 +++ b/drivers/xen/netfront/accel.c	Wed Feb 27 13:14:18 2008 +0000
     1.3 @@ -60,6 +60,9 @@ static struct list_head accelerators_lis
     1.4  /* Lock to protect access to accelerators_list */
     1.5  static spinlock_t accelerators_lock;
     1.6  
     1.7 +/* Workqueue to process acceleration configuration changes */
     1.8 +struct workqueue_struct *accel_watch_workqueue;
     1.9 +
    1.10  /* Mutex to prevent concurrent loads and suspends, etc. */
    1.11  DEFINE_MUTEX(accelerator_mutex);
    1.12  
    1.13 @@ -67,6 +70,8 @@ void netif_init_accel(void)
    1.14  {
    1.15  	INIT_LIST_HEAD(&accelerators_list);
    1.16  	spin_lock_init(&accelerators_lock);
    1.17 +
    1.18 +	accel_watch_workqueue = create_workqueue("accel_watch");
    1.19  }
    1.20  
    1.21  void netif_exit_accel(void)
    1.22 @@ -74,6 +79,9 @@ void netif_exit_accel(void)
    1.23  	struct netfront_accelerator *accelerator, *tmp;
    1.24  	unsigned long flags;
    1.25  
    1.26 +	flush_workqueue(accel_watch_workqueue);
    1.27 +	destroy_workqueue(accel_watch_workqueue);
    1.28 +
    1.29  	spin_lock_irqsave(&accelerators_lock, flags);
    1.30  
    1.31  	list_for_each_entry_safe(accelerator, tmp, &accelerators_list, link) {
    1.32 @@ -156,7 +164,7 @@ static void accel_watch_changed(struct x
    1.33  	struct netfront_accel_vif_state *vif_state = 
    1.34  		container_of(watch, struct netfront_accel_vif_state,
    1.35  			     accel_watch);
    1.36 -	schedule_work(&vif_state->accel_work);
    1.37 +	queue_work(accel_watch_workqueue, &vif_state->accel_work);
    1.38  }
    1.39  
    1.40  
    1.41 @@ -191,7 +199,7 @@ void netfront_accelerator_remove_watch(s
    1.42  		kfree(vif_state->accel_watch.node);
    1.43  		vif_state->accel_watch.node = NULL;
    1.44  
    1.45 -		flush_scheduled_work();
    1.46 +		flush_workqueue(accel_watch_workqueue);
    1.47  
    1.48  		/* Clean up any state left from watch */
    1.49  		if (vif_state->accel_frontend != NULL) {