ia64/linux-2.6.18-xen.hg

changeset 609:8a3dc4fdb478

linux/evtchn: Add memory barriers to evtchn ring accesses.

Xenstore infrequently hangs up on IA64.
Actually the xenstored is still alive but no response from
xenstore-XXX commands.

After tracking down, I've found that evtchn_read() infrequently
returns a wrong evtchn port number and evtchn_write() never
unmask the exact port.

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>

Yes, updates of the ring_prod and ring_cons are separately protected
by different locks/mutexes, but the data communication between
producer and consumer is lock-free. Barriers are needed.

Acked-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jul 22 11:59:42 2008 +0100 (2008-07-22)
parents 905f275ed4d8
children c4b12c90de0e 3bcc901cbd7a
files drivers/xen/evtchn/evtchn.c
line diff
     1.1 --- a/drivers/xen/evtchn/evtchn.c	Mon Jul 21 09:51:36 2008 +0100
     1.2 +++ b/drivers/xen/evtchn/evtchn.c	Tue Jul 22 11:59:42 2008 +0100
     1.3 @@ -84,6 +84,7 @@ void evtchn_device_upcall(int port)
     1.4  	if ((u = port_user[port]) != NULL) {
     1.5  		if ((u->ring_prod - u->ring_cons) < EVTCHN_RING_SIZE) {
     1.6  			u->ring[EVTCHN_RING_MASK(u->ring_prod)] = port;
     1.7 +			wmb(); /* Ensure ring contents visible */
     1.8  			if (u->ring_cons == u->ring_prod++) {
     1.9  				wake_up_interruptible(&u->evtchn_wait);
    1.10  				kill_fasync(&u->evtchn_async_queue,
    1.11 @@ -180,6 +181,7 @@ static ssize_t evtchn_read(struct file *
    1.12  	}
    1.13  
    1.14  	rc = -EFAULT;
    1.15 +	rmb(); /* Ensure that we see the port before we copy it. */
    1.16  	if (copy_to_user(buf, &u->ring[EVTCHN_RING_MASK(c)], bytes1) ||
    1.17  	    ((bytes2 != 0) &&
    1.18  	     copy_to_user(&buf[bytes1], &u->ring[0], bytes2)))