From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 1/5] Protect irq_sources_bitmap by kvm->lock instead of kvm->irq_lock Date: Mon, 13 Jul 2009 18:19:44 +0300 Message-ID: <20090713151944.GL23086@redhat.com> References: <1247476355-27284-1-git-send-email-gleb@redhat.com> <1247476355-27284-2-git-send-email-gleb@redhat.com> <4A5B44AE.4000407@gmail.com> <20090713143941.GT28046@redhat.com> <4A5B4CDC.1000806@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, avi@redhat.com, mtosatti@redhat.com To: Gregory Haskins Return-path: Received: from mx2.redhat.com ([66.187.237.31]:42821 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756194AbZGMPTr (ORCPT ); Mon, 13 Jul 2009 11:19:47 -0400 Content-Disposition: inline In-Reply-To: <4A5B4CDC.1000806@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Jul 13, 2009 at 11:03:56AM -0400, Gregory Haskins wrote: > Gleb Natapov wrote: > > On Mon, Jul 13, 2009 at 10:29:02AM -0400, Gregory Haskins wrote: > > > >> Gleb Natapov wrote: > >> > >>> diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c > >>> index 6c57e46..ce8fcd3 100644 > >>> --- a/virt/kvm/irq_comm.c > >>> +++ b/virt/kvm/irq_comm.c > >>> @@ -210,7 +210,8 @@ int kvm_request_irq_source_id(struct kvm *kvm) > >>> unsigned long *bitmap = &kvm->arch.irq_sources_bitmap; > >>> int irq_source_id; > >>> > >>> - mutex_lock(&kvm->irq_lock); > >>> + WARN_ON(!mutex_is_locked(&kvm->lock)); > >>> > >>> > >> Shouldn't this be fatal? (e.g. BUG_ON). I know the usage between > >> BUG/WARN is controversial, but it seems to me that something is > >> completely broken if you expect it to be locked and its not. Might as > >> well fail the system, IMO. > >> > >> > > Well I don't really care but we have WARN_ON() in the code currently. > > > > Well, that is perhaps unfortunate, but not relevant. I am not reviewing > those patches ;) > > > Besides the chances are good that even without locking around this > > function nothing will break, so why kill host kernel? > > > > The question to ask is: Is it legal to continue to run if the mutex is > found unlocked? If not, the offending caller should be found/fixed as > early as possible IMO, and an oops should be sufficient to do so. I > think WARN_ON tends to gets overused/abused, so lets not perpetuate it > simply because of precedence. > I will have to end this particular thread about WARN_ON by stating that Avi told me to put it there. I'll let him decide. -- Gleb.