[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 00/50] tcg plugin support

From: Alex Bennée
Subject: Re: [Qemu-devel] [PATCH v3 00/50] tcg plugin support
Date: Mon, 01 Jul 2019 17:51:02 +0100
User-agent: mu4e 1.3.2; emacs 26.1

Pranith Kumar <address@hidden> writes:

> On Fri, Jun 21, 2019 at 1:21 AM Alex Bennée <address@hidden> wrote:
>> > * Register and memory read/write API
>> >
>> >   It would be great to have register and memory read/write API i.e., 
>> > ability
>> >   to read/write to registers/memory from within the callback. This gives 
>> > the
>> >   plugin ability to do system introspection. (Not sure if the current 
>> > patchset
>> >   implements this already).
>> Not currently. The trick is to have something flexible enough without
>> exposing internals. I guess we could consider the gdb register
>> enumeration or maybe hook into stuff declared as
>> tcg_global_mem_new_i[64|32]. That won't get every "register" but it
>> should certainly cover the main general purpose ones. Things like SVE
>> and AdvSIMD vector registers wouldn't be seen though.
> I guess general registers could be a good starting point. We can then
> implement arch specific register access APIs.
>> > * Register callbacks
>> >
>> >   A callback needs to be invoked whenever a specified registers is read or
>> >   written to.
>> Again tricky as not every register read/write is obvious from TCG -
>> vector registers tweaked from helpers would be a good example.
>> >
>> > * Where do new plugins live in the tree?
>> >
>> >   The current source files in plugins (api, core etc.,) I think are better 
>> > if
>> >   moved to tcg/plugins/.  The various plugins we write would then live in 
>> > the
>> >   plugins/ folder instead of the current tests/plugin/ folder.
>> The example plugins are really just toys for experimenting with the API
>> - I don't see too much problem with them being in tests. However the
>> howvec plugin is very guest architecture specific so we could consider a
>> bit more of a hierarchy. Maybe these should all live in tests/tcg?
> So where do you want 'real' plugins to live in the tree? It would be
> good to think about the structure for those.

I don't see whats wrong with tests/plugins for this. For the upstream
point of view they are there to test and exercise the plugin code.

>> >
>> > * Timer interrupts
>> >
>> >   What I observed is that the system execution is affected by what you do 
>> > in
>> >   the callbacks because of timer interrupts. For example, if you spend 
>> > time in
>> >   the memory callback doing a bit of processing and writing to a file, you
>> >   will see more timer interrupt instructions. One solution to this would 
>> > be to
>> >   use 'icount', but it does not work that well. I think we need to do
>> >   something similar to what gdb does in debug mode. How would you handle 
>> > MTTCG
>> >   guests in that case?
>> icount is going to be the best you can get for deterministic time -
>> other efforts to pause/restart virtual time going in and out of plugins
>> are just going to add a lot of overhead.
> I wonder why using icount is not working in this case. Are there any
> timers that fire non-deterministically even when icount is used?

Shouldn't be. What sort of problems are you seeing?

>> Remember QEMU doesn't even try to be a cycle accurate emulation so
>> expecting to get reasonable timing information out of these plugins is a
>> stretch. Maybe I should make that clearer in the design document?
> It is less about being cycle accurate and more about being
> deterministic. For example, when tracing using plugins+callbacks, you
> will see a lot more interrupt code in the trace than when if you
> execute without tracing. How do we get them to be more similar?
> Another idea would be to provide an API for the plugin to generate the
> timer interrupt. This allows the plugin to generate regular interrupts
> irrespective of what is being done in the callbacks.

I don't think allowing plugins to change behaviour of the code is
something we want to consider - at least for v1.

>> The gdb behaviour is just a massive hack. When single-stepping in GDB we
>> prevent timer IRQs from being delivered - they have still fired and are
>> pending and will execute as soon as you hit continue.
>> >   Another approach would be to offload callback generation to a separate
>> >   plugin thread. The main thread will copy data required by a callback and
>> >   invoke the callback asynchronously (std::async in C++ if you are
>> >   familiar).
>> This would complicate things - the current iteration I'm working on
>> drops the haddr cb in favour of dynamically resolving the vaddr in the
>> callback. But that approach is only valid during the callback before
>> something else potentially pollutes the TLB.
>> >
>> > * Starting and stopping callback generation
>> >
>> >   It would be great if we have a mechanism to dynamically start/stop 
>> > callbacks
>> >   when a sequence of code (magic instruction) is executed. This would be
>> >   useful to annotate region-of-interest (ROI) in benchmarks to
>> > generate callbacks.
>> Well we have that now. At each TB generation event the callback is free to 
>> register
>> as many or few callbacks as it likes dynamically.
> But how does the plugin know that the TB being generated is the first
> TB in the ROI?

It has to track the information - I assume by a combination of looking
at addresses or looking through the instruction patterns.

> Similarly the plugin needs to know the then end of ROI has been reached.
> Also, please note that there can be multiple ROIs. It would be good to
> know if we can assign ids to each ROI for the plugin.

This all sounds like stuff the plugin can do for itself. What else does
it need to know from QEMU?

Alex Bennée

reply via email to

[Prev in Thread] Current Thread [Next in Thread]