From: Ingo Molnar Subject: Re: [PATCH 3/3] kvm tools: Make virtio-blk kvm__irq_line thread safe Date: Fri, 29 Apr 2011 08:44:33 +0200 Message-ID: <20110429064433.GB13893@elte.hu> References: <1304058985-13833-1-git-send-email-asias.hejun@gmail.com> <1304058985-13833-3-git-send-email-asias.hejun@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Pekka Enberg , Cyrill Gorcunov , Sasha Levin , Prasad Joshi , kvm@vger.kernel.org To: Asias He Return-path: Received: from mx2.mail.elte.hu ([157.181.151.9]:35726 "EHLO mx2.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751842Ab1D2Goi (ORCPT ); Fri, 29 Apr 2011 02:44:38 -0400 Content-Disposition: inline In-Reply-To: <1304058985-13833-3-git-send-email-asias.hejun@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: * Asias He wrote: > Signed-off-by: Asias He > --- > tools/kvm/virtio-blk.c | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/tools/kvm/virtio-blk.c b/tools/kvm/virtio-blk.c > index 3feabd0..ade6335 100644 > --- a/tools/kvm/virtio-blk.c > +++ b/tools/kvm/virtio-blk.c > @@ -159,7 +159,9 @@ static void virtio_blk_do_io(struct kvm *kvm, void *param) > while (virt_queue__available(vq)) > virtio_blk_do_io_request(kvm, vq); > > + mutex_lock(&blk_device.mutex); > kvm__irq_line(kvm, VIRTIO_BLK_IRQ, 1); > + mutex_unlock(&blk_device.mutex); Hm, this looks a bit strange (the mutex here protects only a kernel call - that cannot be right) and there's no explanation why it's needed. Why do VIRTIO_BLK_IRQ (== KVM_IRQ_LINE ioctl()) calls have to be covered by the mutex? A short blurb about expected behavior on SMP and locking rules at the top of virtio-blk.c would be nice. Thanks, Ingo