diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-21 15:54:12 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-21 15:54:12 -0400 |
| commit | 888a6f77e0418b049f83d37547c209b904d30af4 (patch) | |
| tree | 42cdb9f781d2177e6b380e69a66a27ec7705f51f /drivers | |
| parent | 31b7eab27a314b153d8fa07ba9e9ec00a98141e1 (diff) | |
| parent | 6506cf6ce68d78a5470a8360c965dafe8e4b78e3 (diff) | |
Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (52 commits)
sched: fix RCU lockdep splat from task_group()
rcu: using ACCESS_ONCE() to observe the jiffies_stall/rnp->qsmask value
sched: suppress RCU lockdep splat in task_fork_fair
net: suppress RCU lockdep false positive in sock_update_classid
rcu: move check from rcu_dereference_bh to rcu_read_lock_bh_held
rcu: Add advice to PROVE_RCU_REPEATEDLY kernel config parameter
rcu: Add tracing data to support queueing models
rcu: fix sparse errors in rcutorture.c
rcu: only one evaluation of arg in rcu_dereference_check() unless sparse
kernel: Remove undead ifdef CONFIG_DEBUG_LOCK_ALLOC
rcu: fix _oddness handling of verbose stall warnings
rcu: performance fixes to TINY_PREEMPT_RCU callback checking
rcu: upgrade stallwarn.txt documentation for CPU-bound RT processes
vhost: add __rcu annotations
rcu: add comment stating that list_empty() applies to RCU-protected lists
rcu: apply TINY_PREEMPT_RCU read-side speedup to TREE_PREEMPT_RCU
rcu: combine duplicate code, courtesy of CONFIG_PREEMPT_RCU
rcu: Upgrade srcu_read_lock() docbook about SRCU grace periods
rcu: document ways of stalling updates in low-memory situations
rcu: repair code-duplication FIXMEs
...
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/input/evdev.c | 2 | ||||
| -rw-r--r-- | drivers/vhost/net.c | 16 | ||||
| -rw-r--r-- | drivers/vhost/vhost.c | 22 | ||||
| -rw-r--r-- | drivers/vhost/vhost.h | 10 |
4 files changed, 36 insertions, 14 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 9ddafc30f432..af9ee313c10b 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
| @@ -28,7 +28,7 @@ struct evdev { | |||
| 28 | int minor; | 28 | int minor; |
| 29 | struct input_handle handle; | 29 | struct input_handle handle; |
| 30 | wait_queue_head_t wait; | 30 | wait_queue_head_t wait; |
| 31 | struct evdev_client *grab; | 31 | struct evdev_client __rcu *grab; |
| 32 | struct list_head client_list; | 32 | struct list_head client_list; |
| 33 | spinlock_t client_lock; /* protects client_list */ | 33 | spinlock_t client_lock; /* protects client_list */ |
| 34 | struct mutex mutex; | 34 | struct mutex mutex; |
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 7c8008225ee3..17927b1f9334 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c | |||
| @@ -127,7 +127,10 @@ static void handle_tx(struct vhost_net *net) | |||
| 127 | size_t len, total_len = 0; | 127 | size_t len, total_len = 0; |
| 128 | int err, wmem; | 128 | int err, wmem; |
| 129 | size_t hdr_size; | 129 | size_t hdr_size; |
| 130 | struct socket *sock = rcu_dereference(vq->private_data); | 130 | struct socket *sock; |
| 131 | |||
| 132 | sock = rcu_dereference_check(vq->private_data, | ||
| 133 | lockdep_is_held(&vq->mutex)); | ||
| 131 | if (!sock) | 134 | if (!sock) |
| 132 | return; | 135 | return; |
| 133 | 136 | ||
| @@ -582,7 +585,10 @@ static void vhost_net_disable_vq(struct vhost_net *n, | |||
| 582 | static void vhost_net_enable_vq(struct vhost_net *n, | 585 | static void vhost_net_enable_vq(struct vhost_net *n, |
| 583 | struct vhost_virtqueue *vq) | 586 | struct vhost_virtqueue *vq) |
| 584 | { | 587 | { |
| 585 | struct socket *sock = vq->private_data; | 588 | struct socket *sock; |
| 589 | |||
| 590 | sock = rcu_dereference_protected(vq->private_data, | ||
| 591 | lockdep_is_held(&vq->mutex)); | ||
| 586 | if (!sock) | 592 | if (!sock) |
| 587 | return; | 593 | return; |
| 588 | if (vq == n->vqs + VHOST_NET_VQ_TX) { | 594 | if (vq == n->vqs + VHOST_NET_VQ_TX) { |
| @@ -598,7 +604,8 @@ static struct socket *vhost_net_stop_vq(struct vhost_net *n, | |||
| 598 | struct socket *sock; | 604 | struct socket *sock; |
| 599 | 605 | ||
| 600 | mutex_lock(&vq->mutex); | 606 | mutex_lock(&vq->mutex); |
| 601 | sock = vq->private_data; | 607 | sock = rcu_dereference_protected(vq->private_data, |
| 608 | lockdep_is_held(&vq->mutex)); | ||
| 602 | vhost_net_disable_vq(n, vq); | 609 | vhost_net_disable_vq(n, vq); |
| 603 | rcu_assign_pointer(vq->private_data, NULL); | 610 | rcu_assign_pointer(vq->private_data, NULL); |
| 604 | mutex_unlock(&vq->mutex); | 611 | mutex_unlock(&vq->mutex); |
| @@ -736,7 +743,8 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd) | |||
| 736 | } | 743 | } |
| 737 | 744 | ||
| 738 | /* start polling new socket */ | 745 | /* start polling new socket */ |
| 739 | oldsock = vq->private_data; | 746 | oldsock = rcu_dereference_protected(vq->private_data, |
| 747 | lockdep_is_held(&vq->mutex)); | ||
| 740 | if (sock != oldsock) { | 748 | if (sock != oldsock) { |
| 741 | vhost_net_disable_vq(n, vq); | 749 | vhost_net_disable_vq(n, vq); |
| 742 | rcu_assign_pointer(vq->private_data, sock); | 750 | rcu_assign_pointer(vq->private_data, sock); |
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index dd3d6f7406f8..8b5a1b33d0fe 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c | |||
| @@ -320,7 +320,7 @@ long vhost_dev_reset_owner(struct vhost_dev *dev) | |||
| 320 | vhost_dev_cleanup(dev); | 320 | vhost_dev_cleanup(dev); |
| 321 | 321 | ||
| 322 | memory->nregions = 0; | 322 | memory->nregions = 0; |
| 323 | dev->memory = memory; | 323 | RCU_INIT_POINTER(dev->memory, memory); |
| 324 | return 0; | 324 | return 0; |
| 325 | } | 325 | } |
| 326 | 326 | ||
| @@ -352,8 +352,9 @@ void vhost_dev_cleanup(struct vhost_dev *dev) | |||
| 352 | fput(dev->log_file); | 352 | fput(dev->log_file); |
| 353 | dev->log_file = NULL; | 353 | dev->log_file = NULL; |
| 354 | /* No one will access memory at this point */ | 354 | /* No one will access memory at this point */ |
| 355 | kfree(dev->memory); | 355 | kfree(rcu_dereference_protected(dev->memory, |
| 356 | dev->memory = NULL; | 356 | lockdep_is_held(&dev->mutex))); |
| 357 | RCU_INIT_POINTER(dev->memory, NULL); | ||
| 357 | if (dev->mm) | 358 | if (dev->mm) |
| 358 | mmput(dev->mm); | 359 | mmput(dev->mm); |
| 359 | dev->mm = NULL; | 360 | dev->mm = NULL; |
| @@ -440,14 +441,22 @@ static int vq_access_ok(unsigned int num, | |||
| 440 | /* Caller should have device mutex but not vq mutex */ | 441 | /* Caller should have device mutex but not vq mutex */ |
| 441 | int vhost_log_access_ok(struct vhost_dev *dev) | 442 | int vhost_log_access_ok(struct vhost_dev *dev) |
| 442 | { | 443 | { |
| 443 | return memory_access_ok(dev, dev->memory, 1); | 444 | struct vhost_memory *mp; |
| 445 | |||
| 446 | mp = rcu_dereference_protected(dev->memory, | ||
| 447 | lockdep_is_held(&dev->mutex)); | ||
| 448 | return memory_access_ok(dev, mp, 1); | ||
| 444 | } | 449 | } |
| 445 | 450 | ||
| 446 | /* Verify access for write logging. */ | 451 | /* Verify access for write logging. */ |
| 447 | /* Caller should have vq mutex and device mutex */ | 452 | /* Caller should have vq mutex and device mutex */ |
| 448 | static int vq_log_access_ok(struct vhost_virtqueue *vq, void __user *log_base) | 453 | static int vq_log_access_ok(struct vhost_virtqueue *vq, void __user *log_base) |
| 449 | { | 454 | { |
| 450 | return vq_memory_access_ok(log_base, vq->dev->memory, | 455 | struct vhost_memory *mp; |
| 456 | |||
| 457 | mp = rcu_dereference_protected(vq->dev->memory, | ||
| 458 | lockdep_is_held(&vq->mutex)); | ||
| 459 | return vq_memory_access_ok(log_base, mp, | ||
| 451 | vhost_has_feature(vq->dev, VHOST_F_LOG_ALL)) && | 460 | vhost_has_feature(vq->dev, VHOST_F_LOG_ALL)) && |
| 452 | (!vq->log_used || log_access_ok(log_base, vq->log_addr, | 461 | (!vq->log_used || log_access_ok(log_base, vq->log_addr, |
| 453 | sizeof *vq->used + | 462 | sizeof *vq->used + |
| @@ -487,7 +496,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) | |||
| 487 | kfree(newmem); | 496 | kfree(newmem); |
| 488 | return -EFAULT; | 497 | return -EFAULT; |
| 489 | } | 498 | } |
| 490 | oldmem = d->memory; | 499 | oldmem = rcu_dereference_protected(d->memory, |
| 500 | lockdep_is_held(&d->mutex)); | ||
| 491 | rcu_assign_pointer(d->memory, newmem); | 501 | rcu_assign_pointer(d->memory, newmem); |
| 492 | synchronize_rcu(); | 502 | synchronize_rcu(); |
| 493 | kfree(oldmem); | 503 | kfree(oldmem); |
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index afd77295971c..af3c11ded5fd 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h | |||
| @@ -106,7 +106,7 @@ struct vhost_virtqueue { | |||
| 106 | * vhost_work execution acts instead of rcu_read_lock() and the end of | 106 | * vhost_work execution acts instead of rcu_read_lock() and the end of |
| 107 | * vhost_work execution acts instead of rcu_read_lock(). | 107 | * vhost_work execution acts instead of rcu_read_lock(). |
| 108 | * Writers use virtqueue mutex. */ | 108 | * Writers use virtqueue mutex. */ |
| 109 | void *private_data; | 109 | void __rcu *private_data; |
| 110 | /* Log write descriptors */ | 110 | /* Log write descriptors */ |
| 111 | void __user *log_base; | 111 | void __user *log_base; |
| 112 | struct vhost_log log[VHOST_NET_MAX_SG]; | 112 | struct vhost_log log[VHOST_NET_MAX_SG]; |
| @@ -116,7 +116,7 @@ struct vhost_dev { | |||
| 116 | /* Readers use RCU to access memory table pointer | 116 | /* Readers use RCU to access memory table pointer |
| 117 | * log base pointer and features. | 117 | * log base pointer and features. |
| 118 | * Writers use mutex below.*/ | 118 | * Writers use mutex below.*/ |
| 119 | struct vhost_memory *memory; | 119 | struct vhost_memory __rcu *memory; |
| 120 | struct mm_struct *mm; | 120 | struct mm_struct *mm; |
| 121 | struct mutex mutex; | 121 | struct mutex mutex; |
| 122 | unsigned acked_features; | 122 | unsigned acked_features; |
| @@ -173,7 +173,11 @@ enum { | |||
| 173 | 173 | ||
| 174 | static inline int vhost_has_feature(struct vhost_dev *dev, int bit) | 174 | static inline int vhost_has_feature(struct vhost_dev *dev, int bit) |
| 175 | { | 175 | { |
| 176 | unsigned acked_features = rcu_dereference(dev->acked_features); | 176 | unsigned acked_features; |
| 177 | |||
| 178 | acked_features = | ||
| 179 | rcu_dereference_index_check(dev->acked_features, | ||
| 180 | lockdep_is_held(&dev->mutex)); | ||
| 177 | return acked_features & (1 << bit); | 181 | return acked_features & (1 << bit); |
| 178 | } | 182 | } |
| 179 | 183 | ||
