Received: from eggs.gnu.org ([208.118.235.92]:46496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWXDw-0003d8-Rd for qemu-devel@nongnu.org; Sun, 28 Apr 2013 15:25:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWXDs-0001mt-OC for qemu-devel@nongnu.org; Sun, 28 Apr 2013 15:25:24 -0400 Received: from roura.ac.upc.edu ([147.83.33.10]:60018 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWXDs-0001mM-9P for qemu-devel@nongnu.org; Sun, 28 Apr 2013 15:25:20 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <20130421191129.8947.77964.stgit@fimbulvetr.bsc.es> <20130424111734.GB24635@stefanha-thinkpad.redhat.com> <871ua05dil.fsf@fimbulvetr.bsc.es> <20130425123900.GA8160@stefanha-thinkpad.redhat.com> <87wqrpsd1p.fsf@fimbulvetr.bsc.es> <20130426151026.GC7648@stefanha-thinkpad.redhat.com> Date: Sun, 28 Apr 2013 21:25:15 +0200 Message-ID: <87k3nmfof8.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC][PATCH v3 00/24] instrument: Let the user wrap/override specific event tracing routines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org Stefan Hajnoczi writes: > On Fri, Apr 26, 2013 at 02:15:46PM +0200, Llu=C3=ADs Vilanova wrote: >> Stefan Hajnoczi writes: >>=20 >> > On Wed, Apr 24, 2013 at 02:17:22PM +0200, Llu=C3=ADs Vilanova wrote: >> > Given that the group of users for this feature is so small while the >> > burden of supporting this is rather large, it seems like writing >> > instrumentation code straight in a QEMU source tree is the most powerf= ul >> > and viable solution. >>=20 >> Well, the tracing event instrumentation support itself is quite generic = and >> should be maintainable, and can enormously simplify the task for others = to use >> it in the future. >>=20 >> From my repository, the first three series (including this one) handle t= he >> infrastructure, which is mostly based on providing tracetool backends. >>=20 >> The 4th one adds some very generic events (vbbl_{before,after}, >> vinst_{before,after}, vmem) that should have no ties to the TCG implemen= tation. > They would be affected by things like real TCG vcpu threads (parallel > translation and execution) because now trace events will be invoked > simultaneously from multiple threads. Or heterogenous cores in QEMU > (ARM + DSP) where previously you could assume there is one target > architecture. Yes, my assumption was that the library is invoked on the vCPU's thread, so everything is performed on its context. For other non-guest tracing events,= you need to know what's going on in QEMU, and that's why events are not instrumentable by default. What I didn't yet get to implement is to safely unload an instrumentation library or change the callback for an event (e.g., ensure it is performed exclusively). As for the heterogeneous case, I thought it was still far, so I didn't give= it much thought. Most of the code in the base infrastructure is oblivious to t= he target. Once you need that, the affected target-specific routines would nee= d to be defined using something similar to the current function pointers in CPUS= tate when having a heterogeneous QEMU. >> The 5th one adds the backdoor we discussed long ago, which lets the gues= t code >> interact with the instrumentation library, so that they can coordinate (= AFAIR, >> Blue said that could come in handy during tests, for example). >>=20 >> The next ones probably are more controversial, as they start adding new >> interfaces available to the instrumentation libraries (as well as some e= xtra >> events). > I don't think this effort is maintainable. > The API would be great if QEMU was heavily focussed on instrumentation > and simulation research. It allows interesting analysis without diving > into the internals of QEMU. > The problem is it touches everything in QEMU because you should be able > to instrument everything. Who is going to maintain an API of this > scope? > The QEMU community has two large groups: TCG for emulation and KVM for > virtualization. The API doesn't offer them anything so they will not > keep it in mind when making changes. Ok, my bad. After the initial discussions that took place long ago I unders= tood there actually was some interest in having such functionality, although not= with all the public APIs I added. I have no problem in maintaining a separate branch for certain events and interfaces (some of which are currently quite crude and hackish in the final series), as long as the bases are upstream (e.g., instrumentation infrastructure, and the most basic abstract guest events). > This is why I think it makes more sense to focus on specific tools that > don't try to introduce stable APIs. i.e. a tool for instruction tracing > in TCG. I'm not sure what you mean by such a tool. What some patches do is, for exa= mple, call "trace_vbbl_begin" at the beginning of the main loop of "gen_intermediate_code_internal" of each target. The user does not instrume= nt calls to actual TCG routines (which know near to nothing about the guest semantics), but only the "vbbl_begin" event. In fact, while looking at all the targets I thought about unifying code by merging code generation of all targets using a single common header impleme= nting the main loop, with callbacks to target-specific code. But I thought that w= ould be too invasive to the project. I agree that all the public API could become a burden for a project only interested in functional emulation and virtualization, but as I said I thin= k the most basic parts of it could be landed, already providing a powerful infrastructure where further extension is up to the user. > Advanced users will have to modify the QEMU source. >> > Basically I think putting a stable API in place here isn't going to fl= y. >> > In terms of the tracing subsystem I don't mind, but I think it's a >> > question for the larger QEMU community. >>=20 >> What are you referring to as an API? The tracing events and their signat= ures? > The interface that dynamic instrumentation libraries use to interact > with QEMU. That means "stable" tracing events plus any operations that > libraries can perform (stop/stop vcpu, peek/poke memory, dirty bitmaps, > MMU, interrupts, etc). Not all events require being "stable", just a few that I established as "abstract" and relate to some very generic guest state (which in their most basic form can be boiled down to 5). As for the rest of the API and more controversial events, as I said I have no problem in maintaining a separate branch. Thanks, Lluis --=20 "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth