Received: from list by lists.gnu.org with archive (Exim 4.71) id 1WoxJV-0002bO-Uj for mharc-qemu-trivial@gnu.org; Mon, 26 May 2014 11:59:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoxJK-0002Jj-RA for qemu-trivial@nongnu.org; Mon, 26 May 2014 11:59:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoxJB-0003ce-K6 for qemu-trivial@nongnu.org; Mon, 26 May 2014 11:59:38 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:201:233:1::3]:47278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoxIq-0003W3-DE; Mon, 26 May 2014 11:59:08 -0400 Received: from blackfin.pond.sub.org (p5B328AAB.dip0.t-ipconnect.de [91.50.138.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by oxygen.pond.sub.org (Postfix) with ESMTPSA id 8429A24897; Mon, 26 May 2014 17:59:04 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CC0ED30403AF; Mon, 26 May 2014 17:59:03 +0200 (CEST) From: Markus Armbruster To: Kevin Wolf References: <1401068643-28655-1-git-send-email-tamlokveer@gmail.com> <20140526123922.GF10187@stefanha-thinkpad.redhat.com> <87k398twfd.fsf@blackfin.pond.sub.org> <20140526151624.GB3813@noname.str.redhat.com> Date: Mon, 26 May 2014 17:59:03 +0200 In-Reply-To: <20140526151624.GB3813@noname.str.redhat.com> (Kevin Wolf's message of "Mon, 26 May 2014 17:16:24 +0200") Message-ID: <87vbssr0oo.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:4f8:201:233:1::3 Cc: peter.crosthwaite@xilinx.com, qemu-trivial@nongnu.org, Stefan Hajnoczi , mjt@tls.msk.ru, Le Tan , qemu-devel@nongnu.org, jan.kiszka@web.de, stefanha@redhat.com, afaerber@suse.de Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v4] block: replace fprintf(stderr, ...) with error_report() X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 May 2014 15:59:48 -0000 Kevin Wolf writes: > Am 26.05.2014 um 17:02 hat Markus Armbruster geschrieben: >> Stefan Hajnoczi writes: >> >> > On Mon, May 26, 2014 at 09:44:03AM +0800, Le Tan wrote: >> >> Replace fprintf(stderr,...) with error_report() in files block/*, block.c, >> >> block-migration.c and blockdev.c. The trailing "\n"s of the @fmt argument >> >> have been removed because @fmt of error_report() should not >> >> contain newline. >> >> >> >> Signed-off-by: Le Tan >> >> --- >> >> block-migration.c | 6 +-- >> >> block.c | 4 +- >> >> block/qcow2-refcount.c | 115 +++++++++++++++++++++--------------------- >> >> block/qcow2.c | 16 +++--- >> >> block/raw-posix.c | 8 ++- >> >> block/raw-win32.c | 6 +-- >> >> block/ssh.c | 2 +- >> >> block/vdi.c | 14 +++--- >> >> block/vmdk.c | 15 +++--- >> >> block/vpc.c | 4 +- >> >> block/vvfat.c | 129 >> >> ++++++++++++++++++++++++------------------------ >> >> blockdev.c | 6 +-- >> >> 12 files changed, 159 insertions(+), 166 deletions(-) >> > >> > There is one thing that worries me about this: >> > >> > error_report() assumes that the QEMU global mutex is held in order to >> > access the "current monitor". >> >> Global variable cur_mon, non-null while we're executing a monitor >> command. > > The important part here is that it's indeed global and not thread-local. > >> > This is problematic for code in the read/write/flush path (like qcow2 >> > refcount allocation) since it can be invoked from a virtio-blk >> > data-plane thread (where the QEMU global mutex is not held). >> >> error_report() reports to the current monitor when "in monitor context", >> i.e. while executing a monitor command, i.e. while cur_mon isn't null. >> >> Can we ever be in monitor context (cur_mon not null) without holding the >> global mutex? > > The right question is: Can a thread (= the main loop thread) ever be in > monitor context while another thread (= dataplane thread) is executing > block driver code and doesn't hold the global mutex? > > If I understand dataplane correctly, the whole point of it is that the > answer to this is yes. Well, the answer used to be "no". Once upon a time because there was just a single thread, later on because only one thread ever executed "interesting" code. I'm *not* saying this should remain the case. I'm trying to find out what needs to be done around cur_mon when we break the assumption behind it. Would making cur_mon thread-local suffice?