[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
- [Qemu-devel] [RFC v2 02/38] tcg/README: fix typo s/afterwise/afterwards/, (continued)
- [Qemu-devel] [RFC v2 02/38] tcg/README: fix typo s/afterwise/afterwards/, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 03/38] cpu: introduce cpu_in_exclusive_work_context(), Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 01/38] trace: expand mem_info:size_shift to 3 bits, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 04/38] translate-all: use cpu_in_exclusive_work_context() in tb_flush, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 05/38] plugin: add user-facing API, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 11/38] tcg: add tcg_gen_st_ptr, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 07/38] queue: add QTAILQ_REMOVE_SEVERAL, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 12/38] tcg: add MO_HADDR to TCGMemOp, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 06/38] plugin: add core code, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 09/38] cputlb: introduce get_page_addr_code_hostp, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 23/38] target/ppc: fetch code with translator_ld, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 16/38] translate-all: notify plugin code of tb_flush, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 14/38] atomic_template: add inline trace/plugin helpers, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 17/38] *-user: notify plugin of exit, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 13/38] atomic_template: fix indentation in GEN_ATOMIC_HELPER, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 18/38] *-user: plugin syscalls, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 15/38] tcg: let plugins instrument memory accesses, Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 24/38] target/sh4: fetch code with translator_ld (WIP), Emilio G. Cota, 2018/12/09
- [Qemu-devel] [RFC v2 21/38] translator: add translator_ld{ub, sw, uw, l, q}, Emilio G. Cota, 2018/12/09