[PULL 07/21] KVM: PPC: Book3S HV: Convert ICS mutex lock to spin lock

2015-04-21 Thread Alexander Graf
From: Suresh Warrier Replaces the ICS mutex lock with a spin lock since we will be porting these routines to real mode. Note that we need to disable interrupts before we take the lock in anticipation of the fact that on the guest side, we are running in the context of a hard irq and interrupts

[PULL 1/3] KVM: PPC: Book3S HV: Fix spinlock/mutex ordering issue in kvmppc_set_lpcr()

2015-03-25 Thread Alexander Graf
From: Paul Mackerras Currently, kvmppc_set_lpcr() has a spinlock around the whole function, and inside that does mutex_lock(&kvm->lock). It is not permitted to take a mutex while holding a spinlock, because the mutex_lock might call schedule(). In addition, this causes lockdep to warn

[PATCH 09/23] KVM: PPC: Book3S HV: Convert ICS mutex lock to spin lock

2015-03-20 Thread Paul Mackerras
From: Suresh Warrier Replaces the ICS mutex lock with a spin lock since we will be porting these routines to real mode. Note that we need to disable interrupts before we take the lock in anticipation of the fact that on the guest side, we are running in the context of a hard irq and interrupts

[PATCH 01/23] KVM: PPC: Book3S HV: Fix spinlock/mutex ordering issue in kvmppc_set_lpcr()

2015-03-20 Thread Paul Mackerras
Currently, kvmppc_set_lpcr() has a spinlock around the whole function, and inside that does mutex_lock(&kvm->lock). It is not permitted to take a mutex while holding a spinlock, because the mutex_lock might call schedule(). In addition, this causes lockdep to warn about a lock orderin

[PATCH/RFC 16/21] KVM: s390: no need to hold the kvm->mutex for floating interrupts

2015-01-15 Thread Christian Borntraeger
The kvm mutex was (probably) used to protect against cpu hotplug. The current code no longer needs to protect against that, as we only rely on CPU data structures that are guaranteed to be available if we can access the CPU. (e.g. vcpu_create will put the cpu in the array AFTER the cpu is ready

[PATCH v5 REPOST 1/6] hw_random: place mutex around read functions and buffers.

2014-12-08 Thread Amos Kong
From: Rusty Russell There's currently a big lock around everything, and it means that we can't query sysfs (eg /sys/devices/virtual/misc/hw_random/rng_current) while the rng is reading. This is a real problem when the rng is slow, or blocked (eg. virtio_rng with qemu's default /dev/random backen

[PATCH v5 1/6] hw_random: place mutex around read functions and buffers.

2014-12-05 Thread Amos Kong
From: Rusty Russell There's currently a big lock around everything, and it means that we can't query sysfs (eg /sys/devices/virtual/misc/hw_random/rng_current) while the rng is reading. This is a real problem when the rng is slow, or blocked (eg. virtio_rng with qemu's default /dev/random backen

[PATCH v4 1/6] hw_random: place mutex around read functions and buffers.

2014-11-03 Thread Amos Kong
From: Rusty Russell There's currently a big lock around everything, and it means that we can't query sysfs (eg /sys/devices/virtual/misc/hw_random/rng_current) while the rng is reading. This is a real problem when the rng is slow, or blocked (eg. virtio_rng with qemu's default /dev/random backen

[GIT PULL 1/9] KVM: s390: Make the simple ipte mutex specific to a VM instead of global

2014-10-28 Thread Christian Borntraeger
]; wait_queue_head_t ipte_wq; + int ipte_lock_count; + struct mutex ipte_mutex; spinlock_t start_stop_lock; struct kvm_s390_crypto crypto; }; diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c index 0f961a1..c1424e8 100644 --- a/arch/s390/kvm/gaccess.c +++ b/arch/s390/kvm

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-23 Thread Paolo Bonzini
Il 23/09/2014 10:06, Christian Borntraeger ha scritto: > Yes. Davids explanation also makes sense as a commit message. Paolo, > if you use David patch with a better description of the "why" I am > fine with this patch. Done, thanks everybody! Paolo -- To unsubscribe from this list: send the line

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-23 Thread Christian Borntraeger
On 09/23/2014 08:49 AM, Gleb Natapov wrote: > On Mon, Sep 22, 2014 at 09:29:19PM +0200, Paolo Bonzini wrote: >> Il 22/09/2014 21:20, Christian Borntraeger ha scritto: >>> "while using trinity to fuzz KVM, we noticed long stalls on invalid ioctls. >>> Lets bail out early on invalid ioctls". or simi

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread Gleb Natapov
On Mon, Sep 22, 2014 at 09:29:19PM +0200, Paolo Bonzini wrote: > Il 22/09/2014 21:20, Christian Borntraeger ha scritto: > > "while using trinity to fuzz KVM, we noticed long stalls on invalid ioctls. > > Lets bail out early on invalid ioctls". or similar? > > Okay. David, can you explain how you

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread Marcelo Tosatti
ngs with some generic > process inspection code that was probing all open file descriptors. > There's no reason non-kvm ioctls should have to wait for the vcpu > mutex to become available just to fail. OK then, please add the usecase to the changelog. -- To unsubscribe from this list

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread Marcelo Tosatti
ould not be executing vcpu ioctls/Should not be executing vcpu ioctls which take vcpu mutex/ -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread David Matlack
On 09/22, Marcelo Tosatti wrote: > On Fri, Sep 19, 2014 at 04:03:25PM -0700, David Matlack wrote: > > vcpu ioctls can hang the calling thread if issued while a vcpu is > > running. > > There is a mutex per-vcpu, so thats expected, OK... > > > If we know ioctl is g

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread Paolo Bonzini
Il 22/09/2014 22:08, Marcelo Tosatti ha scritto: > > This patch does not change functionality, it just makes invalid ioctls > > fail faster. > > Should not be executing vcpu ioctls without interrupt KVM_RUN in the > first place. This is not entirely true, there are a couple of asynchronous ioctls

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread Marcelo Tosatti
On Fri, Sep 19, 2014 at 04:03:25PM -0700, David Matlack wrote: > vcpu ioctls can hang the calling thread if issued while a vcpu is > running. There is a mutex per-vcpu, so thats expected, OK... > If we know ioctl is going to be rejected as invalid anyway, > we can fail before trying

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread David Matlack
y 2 more cycles for something that exited to > userspace - nobody would even notice. I am just disturbed by the fact that we > care about something that is not slow-path but broken beyond repair (why does > userspace call a non-KVM ioctl on a fd of a vcpu from a different thread > (ot

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread Paolo Bonzini
Il 22/09/2014 21:20, Christian Borntraeger ha scritto: > "while using trinity to fuzz KVM, we noticed long stalls on invalid ioctls. > Lets bail out early on invalid ioctls". or similar? Okay. David, can you explain how you found it so that I can make up my mind? Gleb and Marcelo, a fourth and

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread Christian Borntraeger
ust disturbed by the fact that we care about something that is not slow-path but broken beyond repair (why does userspace call a non-KVM ioctl on a fd of a vcpu from a different thread (otherwise the mutex would be free)? Please, can we have an explanation, e.g. something like "while using trini

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread David Matlack
,10 @@ bool kvm_is_mmio_pfn(pfn_t pfn) /* * Switches to specified vcpu, until a matching vcpu_put() */ -int vcpu_load(struct kvm_vcpu *vcpu) +static void __vcpu_load(struct kvm_vcpu *vcpu) { int cpu; - if (mutex_lock_killable(&vcpu->mutex)) - return -EINT

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread Paolo Bonzini
+ b/virt/kvm/kvm_main.c @@ -117,12 +117,10 @@ bool kvm_is_mmio_pfn(pfn_t pfn) /* * Switches to specified vcpu, until a matching vcpu_put() */ -int vcpu_load(struct kvm_vcpu *vcpu) +static void __vcpu_load(struct kvm_vcpu *vcpu) { int cpu; - if (mutex_lock_killable(

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread Christian Borntraeger
On 09/22/2014 12:50 PM, Paolo Bonzini wrote: > Il 20/09/2014 01:03, David Matlack ha scritto: >> vcpu ioctls can hang the calling thread if issued while a vcpu is >> running. If we know ioctl is going to be rejected as invalid anyway, >> we can fail before trying to take the v

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-22 Thread Paolo Bonzini
Il 20/09/2014 01:03, David Matlack ha scritto: > vcpu ioctls can hang the calling thread if issued while a vcpu is > running. If we know ioctl is going to be rejected as invalid anyway, > we can fail before trying to take the vcpu mutex. > > This patch does not change functionality

[PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-19 Thread David Matlack
vcpu ioctls can hang the calling thread if issued while a vcpu is running. If we know ioctl is going to be rejected as invalid anyway, we can fail before trying to take the vcpu mutex. This patch does not change functionality, it just makes invalid ioctls fail faster. Signed-off-by: David

[PATCH v2 1/6] hw_random: place mutex around read functions and buffers.

2014-09-18 Thread Amos Kong
From: Rusty Russell There's currently a big lock around everything, and it means that we can't query sysfs (eg /sys/devices/virtual/misc/hw_random/rng_current) while the rng is reading. This is a real problem when the rng is slow, or blocked (eg. virtio_rng with qemu's default /dev/random backen

[PATCH 1/5] hw_random: place mutex around read functions and buffers.

2014-09-17 Thread Rusty Russell
There's currently a big lock around everything, and it means that we can't query sysfs (eg /sys/devices/virtual/misc/hw_random/rng_current) while the rng is reading. This is a real problem when the rng is slow, or blocked (eg. virtio_rng with qemu's default /dev/random backend) This doesn't help

Re: [PATCH v2 1/3] virtio-rng cleanup: move some code out of mutex protection

2014-09-15 Thread Amos Kong
On Mon, Sep 15, 2014 at 06:13:20PM +0200, Michael Büsch wrote: > On Tue, 16 Sep 2014 00:02:27 +0800 > Amos Kong wrote: > > > It doesn't save too much cpu time as expected, just a cleanup. > > > > Signed-off-by: Amos Kong > > --- > > drivers/char/hw_random/core.c | 6 +++--- > > 1 file changed,

Re: [PATCH v2 1/3] virtio-rng cleanup: move some code out of mutex protection

2014-09-15 Thread Michael Büsch
On Tue, 16 Sep 2014 00:02:27 +0800 Amos Kong wrote: > It doesn't save too much cpu time as expected, just a cleanup. > > Signed-off-by: Amos Kong > --- > drivers/char/hw_random/core.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/char/hw_random/core.c

[PATCH v2 1/3] virtio-rng cleanup: move some code out of mutex protection

2014-09-15 Thread Amos Kong
It doesn't save too much cpu time as expected, just a cleanup. Signed-off-by: Amos Kong --- drivers/char/hw_random/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index aa30a25..c591d7e 100644 --- a/dr

Re: [PATCH 1/2] virtio-rng cleanup: move some code out of mutex protection

2014-09-10 Thread Amit Shah
On (Wed) 10 Sep 2014 [17:07:06], Amos Kong wrote: > It doesn't save too much cpu time as expected, just a cleanup. Frankly I won't bother with this. It doesn't completely remove all copying from the mutex, so it's not worthwhile. > Signed-off-by: Amos Kong >

[PATCH 1/2] virtio-rng cleanup: move some code out of mutex protection

2014-09-10 Thread Amos Kong
It doesn't save too much cpu time as expected, just a cleanup. Signed-off-by: Amos Kong --- drivers/char/hw_random/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index aa30a25..c591d7e 100644 --- a/dr

mutex

2014-09-09 Thread Amos Kong
kill dd process. We have some static variables (eg, current_rng, data_avail, etc) in hw_random/core.c, they are protected by rng_mutex. I try to workaround this issue by undelay(100) after mutex_unlock() in rng_dev_read(). This gives chance for hwrng_attr_*_show() to get mutex. This patch also c

[PATCH 2/3] vfio-pci: Use mutex around open, release, and remove

2014-07-16 Thread Alex Williamson
Serializing open/release allows us to fix a refcnt error if we fail to enable the device and lets us prevent devices from being unbound or opened, giving us an opportunity to do bus resets on release. No restriction added to serialize binding devices to vfio-pci while the mutex is held though

Re: [PATCH v2 10/10] mm, cma: use spinlock instead of mutex

2014-06-12 Thread Joonsoo Kim
On Thu, Jun 12, 2014 at 04:40:29PM +0900, Minchan Kim wrote: > On Thu, Jun 12, 2014 at 12:21:47PM +0900, Joonsoo Kim wrote: > > Currently, we should take the mutex for manipulating bitmap. > > This job may be really simple and short so we don't need to sleep > > if co

Re: [PATCH v2 10/10] mm, cma: use spinlock instead of mutex

2014-06-12 Thread Minchan Kim
On Thu, Jun 12, 2014 at 12:21:47PM +0900, Joonsoo Kim wrote: > Currently, we should take the mutex for manipulating bitmap. > This job may be really simple and short so we don't need to sleep > if contended. So I change it to spinlock. I'm not sure it would be good always. Ma

[PATCH v2 10/10] mm, cma: use spinlock instead of mutex

2014-06-11 Thread Joonsoo Kim
Currently, we should take the mutex for manipulating bitmap. This job may be really simple and short so we don't need to sleep if contended. So I change it to spinlock. Signed-off-by: Joonsoo Kim diff --git a/mm/cma.c b/mm/cma.c index 22a5b23..3085e8c 100644 --- a/mm/cma.c +++ b/mm/

Re: [PULL 2/2] vhost: replace rcu with mutex

2014-06-05 Thread Michael S. Tsirkin
ous > > > > > > > > What about using kfree_rcu() instead ? > > > > > > It would lead to unbound allocation from userspace. > > > > Look at how we did this in commit > > c3059477fce2d956a0bb3e04357324780c5d8eeb > > > > >

Re: [PULL 2/2] vhost: replace rcu with mutex

2014-06-04 Thread Michael S. Tsirkin
t; > It would lead to unbound allocation from userspace. > > Look at how we did this in commit > c3059477fce2d956a0bb3e04357324780c5d8eeb > > > > > > translate_desc() still uses rcu_read_lock(), its not clear if the mutex > > > is really held. > > &g

Re: [PULL 2/2] vhost: replace rcu with mutex

2014-06-04 Thread Michael S. Tsirkin
On Mon, Jun 02, 2014 at 02:58:00PM -0700, Eric Dumazet wrote: > On Tue, 2014-06-03 at 00:30 +0300, Michael S. Tsirkin wrote: > > All memory accesses are done under some VQ mutex. > > So lock/unlock all VQs is a faster equivalent of synchronize_rcu() > > for memory access cha

Re: [PULL 2/2] vhost: replace rcu with mutex

2014-06-03 Thread Paolo Bonzini
commit c3059477fce2d956a0bb3e04357324780c5d8eeb That would make VHOST_SET_MEMORY as slow as before (even though once every few times). translate_desc() still uses rcu_read_lock(), its not clear if the mutex is really held. Yes, vhost_get_vq_desc must be called with the vq mutex held. The

Re: [PULL 2/2] vhost: replace rcu with mutex

2014-06-03 Thread Eric Dumazet
t how we did this in commit c3059477fce2d956a0bb3e04357324780c5d8eeb > > > translate_desc() still uses rcu_read_lock(), its not clear if the mutex > > is really held. > > Yes, vhost_get_vq_desc must be called with the vq mutex held. > > The rcu_read_lock/unlock in translate_desc is unnecessary. Yep,

Re: [PULL 2/2] vhost: replace rcu with mutex

2014-06-03 Thread Paolo Bonzini
Il 03/06/2014 15:35, Vlad Yasevich ha scritto: > Yes, vhost_get_vq_desc must be called with the vq mutex held. > > The rcu_read_lock/unlock in translate_desc is unnecessary. If that's true, then does dev->memory really needs to be rcu protected? It appears to always be read un

Re: [PULL 2/2] vhost: replace rcu with mutex

2014-06-03 Thread Vlad Yasevich
On 06/03/2014 08:48 AM, Paolo Bonzini wrote: > Il 02/06/2014 23:58, Eric Dumazet ha scritto: >> This looks dubious >> >> What about using kfree_rcu() instead ? > > It would lead to unbound allocation from userspace. > >> translate_desc() still uses rcu_rea

Re: [PULL 2/2] vhost: replace rcu with mutex

2014-06-03 Thread Paolo Bonzini
Il 02/06/2014 23:58, Eric Dumazet ha scritto: This looks dubious What about using kfree_rcu() instead ? It would lead to unbound allocation from userspace. translate_desc() still uses rcu_read_lock(), its not clear if the mutex is really held. Yes, vhost_get_vq_desc must be called with

Re: [PULL 2/2] vhost: replace rcu with mutex

2014-06-02 Thread Eric Dumazet
On Tue, 2014-06-03 at 00:30 +0300, Michael S. Tsirkin wrote: > All memory accesses are done under some VQ mutex. > So lock/unlock all VQs is a faster equivalent of synchronize_rcu() > for memory access changes. > Some guests cause a lot of these changes, so it's helpful >

[PULL 2/2] vhost: replace rcu with mutex

2014-06-02 Thread Michael S. Tsirkin
All memory accesses are done under some VQ mutex. So lock/unlock all VQs is a faster equivalent of synchronize_rcu() for memory access changes. Some guests cause a lot of these changes, so it's helpful to make them faster. Reported-by: "Gonglei (Arei)" Signed-off-by: Mic

Re: [RFC 1/2] virtio_balloon: move balloon_lock mutex to callers

2013-05-10 Thread Luiz Capitulino
On Thu, 9 May 2013 18:03:09 -0300 Rafael Aquini wrote: > On Thu, May 09, 2013 at 10:53:48AM -0400, Luiz Capitulino wrote: > > This commit moves the balloon_lock mutex out of the fill_balloon() > > and leak_balloon() functions to their callers. > > > > The reason for t

Re: [RFC 1/2] virtio_balloon: move balloon_lock mutex to callers

2013-05-09 Thread Rafael Aquini
On Thu, May 09, 2013 at 10:53:48AM -0400, Luiz Capitulino wrote: > This commit moves the balloon_lock mutex out of the fill_balloon() > and leak_balloon() functions to their callers. > > The reason for this change is that the next commit will introduce > a shrinker callback for the

[RFC 1/2] virtio_balloon: move balloon_lock mutex to callers

2013-05-09 Thread Luiz Capitulino
This commit moves the balloon_lock mutex out of the fill_balloon() and leak_balloon() functions to their callers. The reason for this change is that the next commit will introduce a shrinker callback for the balloon driver, which will also call leak_balloon() but will require different locking

[PATCH 3/4] vhost-scsi: Always access vq->private_data under vq mutex

2013-05-06 Thread Asias He
@@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) int head, ret; u8 target; + mutex_lock(&vq->mutex); /* * We can handle the vq only after the endpoint is setup by calling the * VHOST_SCSI_SET_ENDPOINT ioctl. -* -* TODO

[PATCH 2/4] vhost-test: Always access vq->private_data under vq mutex

2013-05-06 Thread Asias He
(struct vhost_test *n) size_t len, total_len = 0; void *private; - private = rcu_dereference_check(vq->private_data, 1); - if (!private) - return; mutex_lock(&vq->mutex); + private = vq->private_data; +

[PATCH 1/4] vhost-net: Always access vq->private_data under vq mutex

2013-05-06 Thread Asias He
void handle_tx(struct vhost_net *net) struct vhost_net_ubuf_ref *uninitialized_var(ubufs); bool zcopy, zcopy_used; - /* TODO: check that we are running from vhost_worker? */ - sock = rcu_dereference_check(vq->private_data, 1); + mutex_lock(&vq->mutex); +

[PATCH v3 05/35] protect the ramlist with a separate mutex

2012-10-30 Thread Isaku Yamahata
From: Umesh Deshpande From: Umesh Deshpande Add the new mutex that protects shared state between ram_save_live and the iothread. If the iothread mutex has to be taken together with the ramlist mutex, the iothread shall always be _outside_. Signed-off-by: Paolo Bonzini Signed-off-by: Umesh

Re: [RFC 1/3] kvm tools: use mutex abstraction instead of pthread mutex

2012-10-24 Thread Pekka Enberg
On Wed, 24 Oct 2012, Sasha Levin wrote: > We already have something to wrap pthread with mutex_[init,lock,unlock] > calls. This patch creates a new struct mutex abstraction and moves > everything to work with it. > > Signed-off-by: Sasha Levin I applied this patch from the RFC

[RFC 1/3] kvm tools: use mutex abstraction instead of pthread mutex

2012-10-24 Thread Sasha Levin
We already have something to wrap pthread with mutex_[init,lock,unlock] calls. This patch creates a new struct mutex abstraction and moves everything to work with it. Signed-off-by: Sasha Levin --- tools/kvm/hw/serial.c | 10 +- tools/kvm/include/kvm/mutex.h | 22

Re: [PATCH] kvm: make processes waiting on vcpu mutex killable

2012-09-17 Thread Marcelo Tosatti
On Sun, Sep 16, 2012 at 11:50:30AM +0300, Michael S. Tsirkin wrote: > vcpu mutex can be held for unlimited time so > taking it with mutex_lock on an ioctl is wrong: > one process could be passed a vcpu fd and > call this ioctl on the vcpu used by another process, > it will then be u

[PATCH] kvm: make processes waiting on vcpu mutex killable

2012-09-16 Thread Michael S. Tsirkin
vcpu mutex can be held for unlimited time so taking it with mutex_lock on an ioctl is wrong: one process could be passed a vcpu fd and call this ioctl on the vcpu used by another process, it will then be unkillable until the owner exits. Call mutex_lock_killable instead and return status. Note

[PATCH 4/5] kvm tools: Fix ndev mutex and condition variable initialization

2011-10-31 Thread Asias He
This patch fixes the initialization of the following variables: ndev->io_tx_lock ndev->io_rx_lock ndev->io_tx_cond ndev->io_rx_cond Signed-off-by: Asias He --- tools/kvm/virtio/net.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/kvm/virtio/net.c

Re: [PATCH 3/5] Migration thread mutex

2011-08-29 Thread Marcelo Tosatti
On Sat, Aug 27, 2011 at 02:09:46PM -0400, Umesh Deshpande wrote: > This patch implements migrate_ram mutex, which protects the RAMBlock list > traversal in the migration thread during the transfer of a ram from their > addition/removal from the iothread. > > Note: Combination of

Re: [PATCH 3/5] Migration thread mutex

2011-08-29 Thread Umesh Deshpande
On 08/29/2011 05:04 AM, Stefan Hajnoczi wrote: On Sat, Aug 27, 2011 at 7:09 PM, Umesh Deshpande wrote: This patch implements migrate_ram mutex, which protects the RAMBlock list traversal in the migration thread during the transfer of a ram from their addition/removal from the iothread. Note

Re: [PATCH 3/5] Migration thread mutex

2011-08-29 Thread Stefan Hajnoczi
On Sat, Aug 27, 2011 at 7:09 PM, Umesh Deshpande wrote: > This patch implements migrate_ram mutex, which protects the RAMBlock list > traversal in the migration thread during the transfer of a ram from their > addition/removal from the iothread. > > Note: Combination of iot

[PATCH 3/5] Migration thread mutex

2011-08-27 Thread Umesh Deshpande
This patch implements migrate_ram mutex, which protects the RAMBlock list traversal in the migration thread during the transfer of a ram from their addition/removal from the iothread. Note: Combination of iothread mutex and migration thread mutex works as a rw-lock. Both mutexes are acquired

Re: [RFC PATCH v5 2/4] Migration thread mutex

2011-08-27 Thread Marcelo Tosatti
On Tue, Aug 23, 2011 at 11:12:48PM -0400, Umesh Deshpande wrote: > ramlist mutex is implemented to protect the RAMBlock list traversal in the > migration thread from their addition/removal from the iothread. > > Note: Combination of iothread mutex and migration thread mutex works as

[RFC PATCH v5 2/4] Migration thread mutex

2011-08-23 Thread Umesh Deshpande
ramlist mutex is implemented to protect the RAMBlock list traversal in the migration thread from their addition/removal from the iothread. Note: Combination of iothread mutex and migration thread mutex works as a rw-lock. Both mutexes are acquired while modifying the ram_list members or RAM block

Re: [RFC PATCH v4 2/5] ramlist mutex

2011-08-23 Thread Marcelo Tosatti
On Tue, Aug 23, 2011 at 01:41:48PM +0200, Paolo Bonzini wrote: > On 08/23/2011 11:17 AM, Marcelo Tosatti wrote: > >>>> >typedef struct RAMList { > >>>> > +QemuMutex mutex; > >>>> >uint8_t *phys

Re: [RFC PATCH v4 2/5] ramlist mutex

2011-08-23 Thread Paolo Bonzini
On 08/23/2011 11:17 AM, Marcelo Tosatti wrote: > >typedef struct RAMList { > > + QemuMutex mutex; > >uint8_t *phys_dirty; > >QLIST_HEAD(ram, RAMBlock) blocks; > >QLIST_HEAD(, RAMBlock) blocks_mru; > > A comment on w

Re: [RFC PATCH v4 2/5] ramlist mutex

2011-08-23 Thread Marcelo Tosatti
On Tue, Aug 23, 2011 at 06:15:33AM -0300, Marcelo Tosatti wrote: > On Tue, Aug 16, 2011 at 11:56:37PM -0400, Umesh Deshpande wrote: > > ramlist mutex is implemented to protect the RAMBlock list traversal in the > > migration thread from their addition/removal from the iothread. >

Re: [RFC PATCH v4 2/5] ramlist mutex

2011-08-23 Thread Marcelo Tosatti
On Tue, Aug 16, 2011 at 11:56:37PM -0400, Umesh Deshpande wrote: > ramlist mutex is implemented to protect the RAMBlock list traversal in the > migration thread from their addition/removal from the iothread. > > Signed-off-by: Umesh Deshpande > --- > cpu-all.h |

Re: [RFC PATCH v4 2/5] ramlist mutex

2011-08-21 Thread Paolo Bonzini
r the migration code. This way we don't have to acquire the mutex for block list traversals. I'm not sure... as I said, the MRU list is on a fast path and restricting it to that fast path keeps us honest. Also, the non-MRU list is almost never accessed outside the migration threa

Re: [RFC PATCH v4 2/5] ramlist mutex

2011-08-18 Thread Umesh Deshpande
ru order, whereas the sequence of blocks doesn't matter for the migration code. This way we don't have to acquire the mutex for block list traversals. - Umesh -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vge

Re: [RFC PATCH v4 2/5] ramlist mutex

2011-08-16 Thread Paolo Bonzini
On 08/16/2011 08:56 PM, Umesh Deshpande wrote: @@ -3001,8 +3016,10 @@ void qemu_ram_free_from_ptr(ram_addr_t addr) QLIST_FOREACH(block,&ram_list.blocks, next) { if (addr == block->offset) { +qemu_mutex_lock_ramlist(); QLIST_REMOVE(block, next);

[RFC PATCH v4 2/5] ramlist mutex

2011-08-16 Thread Umesh Deshpande
ramlist mutex is implemented to protect the RAMBlock list traversal in the migration thread from their addition/removal from the iothread. Signed-off-by: Umesh Deshpande --- cpu-all.h |2 ++ exec.c| 19 +++ qemu-common.h |2 ++ 3 files changed, 23

[PATCH 04/20] qemu-kvm: Use upstream mutex and conds

2011-05-27 Thread Jan Kiszka
This temporarily requires our own initialization service as we are still using the !IOTHREAD version of qemu_init_main_loop. Signed-off-by: Jan Kiszka --- cpus.c | 57 +++-- 1 files changed, 31 insertions(+), 26 deletions(-) diff --git a/cpu

[PATCH 3/6] kvm tools: Protect IRQ allocations by a mutex

2011-05-26 Thread Sasha Levin
Makes IRQ allocation for new devices thread-safe. Signed-off-by: Sasha Levin --- tools/kvm/irq.c | 20 +--- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/kvm/irq.c b/tools/kvm/irq.c index 15f4702..f92123d 100644 --- a/tools/kvm/irq.c +++ b/tools/kvm/irq.

Re: [PATCH] kvm tools: Fix pthread mutex error checks

2011-04-09 Thread Ingo Molnar
* Pekka Enberg wrote: > The pthread_mutex_{lock|unlock} functions return non-zero, not negative number > upon error. Fix that wrong assumption in the code. glibc/pthreads mutex API semantics are pretty silly IMO. I *think* it would be better to try to match the kernel API here, and p

[PATCH] kvm tools: Fix pthread mutex error checks

2011-04-09 Thread Pekka Enberg
serial8250_device *dev = &devices[0]; - if (pthread_mutex_lock(&dev->mutex) < 0) + if (pthread_mutex_lock(&dev->mutex) != 0) die("pthread_mutex_lock"); serial8250__receive(self, dev); @@ -133,7 +133,7 @@ void serial8250__in

[KVM-AUTOTEST PATCH 1/2] KVM test: rss.cpp: use critical section instead of mutex for text buffer access

2010-07-08 Thread Michael Goldish
); // Set size limit SendMessage(hTextBox, EM_LIMITTEXT, TEXTBOX_LIMIT, 0); -// Create mutex for text buffer access -hTextBufferMutex = CreateMutex(NULL, FALSE, NULL); +// Initialize critical section object for text buffer access +InitializeCriticalSection(&crit

[PATCH 39/40] KVM: avoid taking ioapic mutex for non-ioapic EOIs

2010-02-10 Thread Avi Kivity
When the guest acknowledges an interrupt, it sends an EOI message to the local apic, which broadcasts it to the ioapic. To handle the EOI, we need to take the ioapic mutex. On large guests, this causes a lot of contention on this mutex. Since large guests usually don't route interrupts vi

[PATCH 36/40] KVM: convert slots_lock to a mutex

2010-02-10 Thread Avi Kivity
struct file *filp, if (kvm->arch.vpit) r = 0; create_pit_unlock: - up_write(&kvm->slots_lock); + mutex_unlock(&kvm->slots_lock); break; case KVM_IRQ_LINE_STATUS: case KVM_I

Re: [PATCH] KVM: avoid taking ioapic mutex for non-ioapic EOIs

2009-12-29 Thread Marcelo Tosatti
Dec 28, 2009 at 02:08:30PM +0200, Avi Kivity wrote: >>>> >>>> >>>>> When the guest acknowledges an interrupt, it sends an EOI message to the >>>>> local >>>>> apic, which broadcasts it to the ioapic. To handle the EOI, w

Re: [PATCH] KVM: avoid taking ioapic mutex for non-ioapic EOIs

2009-12-29 Thread Avi Kivity
message to the local apic, which broadcasts it to the ioapic. To handle the EOI, we need to take the ioapic mutex. On large guests, this causes a lot of contention on this mutex. Since large guests usually don't route interrupts via the ioapic (they use msi instead), this is completely unnece

Re: [PATCH] KVM: avoid taking ioapic mutex for non-ioapic EOIs

2009-12-28 Thread Marcelo Tosatti
cal >>> apic, which broadcasts it to the ioapic. To handle the EOI, we need to take >>> the ioapic mutex. >>> >>> On large guests, this causes a lot of contention on this mutex. Since large >>> guests usually don't route interrupts via the ioapic (

Re: [PATCH] KVM: avoid taking ioapic mutex for non-ioapic EOIs

2009-12-28 Thread Avi Kivity
On 12/28/2009 10:37 PM, Marcelo Tosatti wrote: On Mon, Dec 28, 2009 at 02:08:30PM +0200, Avi Kivity wrote: When the guest acknowledges an interrupt, it sends an EOI message to the local apic, which broadcasts it to the ioapic. To handle the EOI, we need to take the ioapic mutex. On large

Re: [PATCH] KVM: avoid taking ioapic mutex for non-ioapic EOIs

2009-12-28 Thread Marcelo Tosatti
On Mon, Dec 28, 2009 at 02:08:30PM +0200, Avi Kivity wrote: > When the guest acknowledges an interrupt, it sends an EOI message to the local > apic, which broadcasts it to the ioapic. To handle the EOI, we need to take > the ioapic mutex. > > On large guests, this causes a lot o

[PATCH] KVM: avoid taking ioapic mutex for non-ioapic EOIs

2009-12-28 Thread Avi Kivity
When the guest acknowledges an interrupt, it sends an EOI message to the local apic, which broadcasts it to the ioapic. To handle the EOI, we need to take the ioapic mutex. On large guests, this causes a lot of contention on this mutex. Since large guests usually don't route interrupts vi

[patch 11/11] KVM: convert slots_lock to a mutex

2009-12-23 Thread Marcelo Tosatti
== --- kvm.orig/include/linux/kvm_host.h +++ kvm/include/linux/kvm_host.h @@ -161,7 +161,7 @@ struct kvm_memslots { struct kvm { spinlock_t mmu_lock; spinlock_t requests_lock; - struct rw_semaphore slots_lock; + struct mutex slots_lock; struct mm_struct *m

[patch 11/11] KVM: convert slots_lock to a mutex

2009-12-23 Thread Marcelo Tosatti
== --- kvm.orig/include/linux/kvm_host.h +++ kvm/include/linux/kvm_host.h @@ -161,7 +161,7 @@ struct kvm_memslots { struct kvm { spinlock_t mmu_lock; spinlock_t requests_lock; - struct rw_semaphore slots_lock; + struct mutex slots_lock; struct mm_struct *m

Re: [PATCH] qemu-kvm: Reenable iothread mutex wrappers on !CONFIG_KVM

2009-11-15 Thread Avi Kivity
On 11/12/2009 01:49 AM, Jan Kiszka wrote: Needed to avoid some missing symbols when KVM is disabled. Applied, thanks. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger

[PATCH] qemu-kvm: Reenable iothread mutex wrappers on !CONFIG_KVM

2009-11-11 Thread Jan Kiszka
Needed to avoid some missing symbols when KVM is disabled. Signed-off-by: Jan Kiszka --- vl.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/vl.c b/vl.c index 594ca34..6556075 100644 --- a/vl.c +++ b/vl.c @@ -3443,7 +3443,7 @@ void qemu_notify_event(void) } }

Re: [PATCH 8/8 v2] Change irq_lock from mutex to spinlock.

2009-08-12 Thread Gleb Natapov
On Wed, Aug 12, 2009 at 12:22:34PM +0300, Avi Kivity wrote: > On 08/12/2009 12:11 PM, Gleb Natapov wrote: >> On Wed, Aug 12, 2009 at 11:29:00AM +0300, Avi Kivity wrote: >> >>> On 08/11/2009 03:31 PM, Gleb Natapov wrote: >>> >>>> Change irq

Re: [PATCH 8/8 v2] Change irq_lock from mutex to spinlock.

2009-08-12 Thread Avi Kivity
On 08/12/2009 12:11 PM, Gleb Natapov wrote: On Wed, Aug 12, 2009 at 11:29:00AM +0300, Avi Kivity wrote: On 08/11/2009 03:31 PM, Gleb Natapov wrote: Change irq_lock from mutex to spinlock. We do not sleep while holding it. But why change? Isn't it more lightw

Re: [PATCH 8/8 v2] Change irq_lock from mutex to spinlock.

2009-08-12 Thread Gleb Natapov
On Wed, Aug 12, 2009 at 11:29:00AM +0300, Avi Kivity wrote: > On 08/11/2009 03:31 PM, Gleb Natapov wrote: >> Change irq_lock from mutex to spinlock. We do not sleep while holding >> it. >> > > But why change? > Isn't it more lightweight? For the remainin

Re: [PATCH 8/8 v2] Change irq_lock from mutex to spinlock.

2009-08-12 Thread Avi Kivity
On 08/11/2009 03:31 PM, Gleb Natapov wrote: Change irq_lock from mutex to spinlock. We do not sleep while holding it. But why change? The only motivation I can see is to allow injection from irqfd and interrupt contexts without requiring a tasklet/work. But that needs spin_lock_irqsave

[PATCH 8/8 v2] Change irq_lock from mutex to spinlock.

2009-08-11 Thread Gleb Natapov
Change irq_lock from mutex to spinlock. We do not sleep while holding it. Signed-off-by: Gleb Natapov --- include/linux/kvm_host.h |2 +- virt/kvm/irq_comm.c | 28 ++-- virt/kvm/kvm_main.c |2 +- 3 files changed, 16 insertions(+), 16 deletions

Re: [PATCH 6/6] kvm: qemu: virtio-net: drop mutex during tx tapfd write

2008-11-04 Thread Avi Kivity
Mark McLoughlin wrote: This allows the guest vcpu thread to exit while the I/O thread is churning away. + kvm_sleep_begin(); What if the nic is hot-unplugged here? len += qemu_sendv_packet(n->vc, out_sg, out_num); n is freed, no? + kvm_sleep_end(); -- error

[PATCH 6/6] kvm: qemu: virtio-net: drop mutex during tx tapfd write

2008-10-30 Thread Mark McLoughlin
This allows the guest vcpu thread to exit while the I/O thread is churning away. Signed-off-by: Mark McLoughlin <[EMAIL PROTECTED]> --- qemu/hw/virtio-net.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/qemu/hw/virtio-net.c b/qemu/hw/virtio-net.c index 0612f5f..aa1c107

[PATCH 12/12] kvm: qemu: Drop the mutex while reading from tapfd

2008-08-11 Thread Mark McLoughlin
The idea here is that with GSO, packets are much larger and we can allow the vcpu threads to e.g. process irq acks during the window where we're reading these packets from the tapfd. One known issue with this is that it triggers a subtle SMP race in the kernel's posix-timers and signalfd code. See

Re: [PATCH 8/9] kvm: qemu: Drop the mutex while reading from tapfd

2008-07-25 Thread Mark McLoughlin
s->fd, NULL, &sbuf, &f) >=0 ? sbuf.len : -1; > > #else > > > Maybe do it only when GSO is actually used by the guest/tap. > Otherwise it can cause some ctx trashing right? (Strange habit you have of "top commenting" on patches :-) I've been meaning t

Re: [PATCH 8/9] kvm: qemu: Drop the mutex while reading from tapfd

2008-07-24 Thread Dor Laor
Mark McLoughlin wrote: The idea here is that with GSO, packets are much larger and we can allow the vcpu threads to e.g. process irq acks during the window where we're reading these packets from the tapfd. Signed-off-by: Mark McLoughlin <[EMAIL PROTECTED]> --- qemu/vl.c |2 ++ 1 files chang

  1   2   >