qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC v2 06/38] plugin: add core code


From: Emilio G. Cota
Subject: Re: [Qemu-devel] [RFC v2 06/38] plugin: add core code
Date: Mon, 10 Dec 2018 12:40:31 -0500
User-agent: Mutt/1.9.4 (2018-02-28)

On Mon, Dec 10, 2018 at 14:37:25 +0300, Pavel Dovgalyuk wrote:
> > From: Emilio G. Cota [mailto:address@hidden
(snip)
> > +struct qemu_plugin_dyn_cb_arr {
> > +    struct qemu_plugin_dyn_cb *data;
> > +    size_t n;
> > +    size_t capacity;
> > +};
> > +
> 
> Why not list or something dynamic?

Performance. Registering of dynamic callbacks can happen
very frequently (e.g. several times per instruction
translated), so we avoid malloc/free churn by keeping
an array of callback requests that we reuse across
translated TB's. The hierarchy is:

struct qemu_plugin_tb {
        insns[n_insns_in_the_tb] {
                dyn_cb_arr[various types];
        }
}

Each array has a "capacity" field so that we only ever expand
the arrays. This ensures that the amortized cost of
adding callbacks is negligible.

> Is the indexing required?

No, this is done just for performance.

> Can you add the comments for the data structures and functions?
> It is very hard to seek through the whole patch to get the details about them.

I had some comments but then the code evolved quickly and the
comments were outdated, which led to confusion. So I removed
most of them.

To understand the code I recommend you to go through one
of the examples and then follow the API calls, first through
plugin.c and then to plugin-gen.c where the instrumentation
is injected (based on the contents of the dyn_cb arrays).

Please ask further questions if anything is unclear.

Thanks,

                Emilio



reply via email to

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