qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Aaron Lindsay OS <aaron@os.amperecomputing.com>
Cc: "robert.foley@futurewei.com" <robert.foley@futurewei.com>,
	"cota@braap.org" <cota@braap.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"peter.puhov@futurewei.com" <peter.puhov@futurewei.com>
Subject: Re: [PATCH  v6 37/54] plugin: expand the plugin_init function to include an info block
Date: Fri, 18 Oct 2019 16:54:34 +0100	[thread overview]
Message-ID: <87wod2nj5x.fsf@linaro.org> (raw)
In-Reply-To: <20191018153214.GE42857@RDU-FVFX20TUHV2H>


Aaron Lindsay OS <aaron@os.amperecomputing.com> writes:

> On Oct 17 14:15, Alex Bennée wrote:
>> This provides a limited amount of info to plugins about the guest
>> system that will allow them to make some additional decisions on
>> setup.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>
>> ---
>> v6
>>   - split and move to pre example plugins
>>   - checkpatch fixes
>> ---
>>  include/qemu/qemu-plugin.h | 26 ++++++++++++++++++++++++--
>>  plugins/loader.c           | 23 +++++++++++++++++++----
>>  2 files changed, 43 insertions(+), 6 deletions(-)
>>
>> diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
>> index c213d1dd19..784f1dfc3d 100644
>> --- a/include/qemu/qemu-plugin.h
>> +++ b/include/qemu/qemu-plugin.h
>> @@ -38,9 +38,27 @@
>>
>>  typedef uint64_t qemu_plugin_id_t;
>>
>> +typedef struct {
>> +    /* string describing architecture */
>
> Might be worth noting that this is set to the value of TARGET_NAME qemu
> was built with, and pointing to documentation about the possible values
> it may hold.

OK.

>> +    const char *target_name;
>> +    /* is this a full system emulation? */
>> +    bool system_emulation;
>
> It seems that 'system_emulation' is meant primarily in opposition to
> user-mode. I'm wondering if this could/should this be an enum of the
> execution mode being used to allow for future expansion? Or, if your
> intention here is mostly to allow the user to detect when the *_vcpus
> variables are valid, could it be renamed or commented differently to
> make that link more clear?

The only other operating mode that's ever been mooted is softmmu-user
(and no implementation has been done so far). Even then I don't think
that is a distinction that should be reported to the plugin as we are
trying not to leak implementation details.

But yes the practical upshot is for system emulation you at least have
sort of bounded size for how many threads you may have running.

>
>> +    union {
>> +        /*
>> +         * smp_vcpus may change if vCPUs can be hot-plugged, max_vcpus
>> +         * is the system-wide limit.
>> +         */
>> +        struct {
>> +            int smp_vcpus;
>> +            int max_vcpus;
>> +        } system;
>> +    };
>> +} qemu_info_t;
>
> [...]
>
>> @@ -241,11 +245,22 @@ static void plugin_desc_free(struct qemu_plugin_desc *desc)
>>  int qemu_plugin_load_list(QemuPluginList *head)
>>  {
>>      struct qemu_plugin_desc *desc, *next;
>> +    g_autofree qemu_info_t *info = g_new0(qemu_info_t, 1);
>> +
>> +    info->target_name = TARGET_NAME;
>> +#ifndef CONFIG_USER_ONLY
>> +    MachineState *ms = MACHINE(qdev_get_machine());
>> +    info->system_emulation = true;
>> +    info->system.smp_vcpus = ms->smp.cpus;
>> +    info->system.max_vcpus = ms->smp.max_cpus;
>> +#else
>> +    info->system_emulation = false;
>
> Thinking "out loud" here - I wonder if it would be helpful to set the
> *_vcpus variables even for user mode here. It might allow unconditional
> allocation of "per-cpu" structures that the plugin might need - without
> first needing to check whether the *_vcpus variables were valid.

but what too? It would certainly be wrong because any user-space process
could create (and destroy) thousands of threads.

We could consider just asking plugins to deal with threads with their
own __thread variables but in that case we'd need to expose some sort of
thread exit/cleanup method so they can collect data from threads and
safely place it somewhere else - but I suspect that is a hairy
programming model to impose on plugins.

So far all the example plugins have just used locks to serialise things
and it's not been too bad. I guess we could do with an example that
tries to use this information to get an idea of how grungy the interface
is. Perhaps exposing the vCPUs at this point is pointless and we should
just stick to TARGET_NAME for now?

>
> -Aaron


--
Alex Bennée


  reply	other threads:[~2019-10-18 15:58 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 13:15 [PATCH for 4.2 v6 00/54] Support for TCG plugins Alex Bennée
2019-10-17 13:15 ` [PATCH v6 01/54] trace: expand mem_info:size_shift to 4 bits Alex Bennée
2019-10-17 13:15 ` [PATCH v6 02/54] trace: add mmu_index to mem_info Alex Bennée
2019-10-17 13:15 ` [PATCH v6 03/54] cpu: introduce cpu_in_exclusive_context() Alex Bennée
2019-10-17 13:15 ` [PATCH v6 04/54] translate-all: use cpu_in_exclusive_work_context() in tb_flush Alex Bennée
2019-10-17 13:15 ` [PATCH v6 05/54] docs/devel: add plugins.rst design document Alex Bennée
2019-10-17 13:15 ` [PATCH v6 06/54] plugin: add user-facing API Alex Bennée
2019-10-17 13:15 ` [PATCH v6 07/54] plugin: add core code Alex Bennée
2019-10-17 13:15 ` [PATCH v6 08/54] plugin: add implementation of the api Alex Bennée
2019-10-17 13:15 ` [PATCH v6 09/54] queue: add QTAILQ_REMOVE_SEVERAL Alex Bennée
2019-10-17 13:15 ` [PATCH v6 10/54] cputlb: document get_page_addr_code Alex Bennée
2019-10-17 13:15 ` [PATCH v6 11/54] cputlb: introduce get_page_addr_code_hostp Alex Bennée
2019-10-17 13:15 ` [PATCH v6 12/54] tcg: add tcg_gen_st_ptr Alex Bennée
2019-10-17 13:15 ` [PATCH v6 13/54] plugin-gen: add module for TCG-related code Alex Bennée
2019-10-17 13:15 ` [PATCH v6 14/54] atomic_template: add inline trace/plugin helpers Alex Bennée
2019-10-17 13:15 ` [PATCH v6 15/54] tcg: let plugins instrument virtual memory accesses Alex Bennée
2019-10-17 13:15 ` [PATCH v6 16/54] plugins: implement helpers for resolving hwaddr Alex Bennée
2019-10-17 13:15 ` [PATCH v6 17/54] translate-all: notify plugin code of tb_flush Alex Bennée
2019-10-17 13:15 ` [PATCH v6 18/54] *-user: notify plugin of exit Alex Bennée
2019-10-17 13:15 ` [PATCH v6 19/54] *-user: plugin syscalls Alex Bennée
2019-10-17 13:15 ` [PATCH v6 20/54] cpu: hook plugin vcpu events Alex Bennée
2019-10-17 13:15 ` [PATCH v6 21/54] plugin-gen: add plugin_insn_append Alex Bennée
2019-10-17 13:15 ` [PATCH v6 22/54] translator: add translator_ld{ub,sw,uw,l,q} Alex Bennée
2019-10-17 13:15 ` [PATCH v6 23/54] target/arm: fetch code with translator_ld Alex Bennée
2019-10-17 13:15 ` [PATCH v6 24/54] target/ppc: " Alex Bennée
2019-10-17 13:15 ` [PATCH v6 25/54] target/sh4: " Alex Bennée
2019-10-17 13:15 ` [PATCH v6 26/54] target/i386: " Alex Bennée
2019-10-17 13:15 ` [PATCH v6 27/54] target/hppa: " Alex Bennée
2019-10-17 13:15 ` [PATCH v6 28/54] target/m68k: " Alex Bennée
2019-10-17 13:15 ` [PATCH v6 29/54] target/alpha: " Alex Bennée
2019-10-17 13:15 ` [PATCH v6 30/54] target/riscv: " Alex Bennée
2019-10-17 13:15 ` [PATCH v6 31/54] target/sparc: " Alex Bennée
2019-10-17 13:15 ` [PATCH v6 32/54] target/xtensa: " Alex Bennée
2019-10-17 13:15 ` [PATCH v6 33/54] target/openrisc: " Alex Bennée
2019-10-17 13:15 ` [PATCH v6 34/54] translator: inject instrumentation from plugins Alex Bennée
2019-10-17 13:15 ` [PATCH v6 35/54] configure: add --enable-plugins Alex Bennée
2019-10-17 13:15 ` [PATCH v6 36/54] plugin: add API symbols to qemu-plugins.symbols Alex Bennée
2019-10-17 13:15 ` [PATCH v6 37/54] plugin: expand the plugin_init function to include an info block Alex Bennée
2019-10-18 15:32   ` Aaron Lindsay OS
2019-10-18 15:54     ` Alex Bennée [this message]
2019-10-22 14:04       ` Aaron Lindsay OS
2019-10-24 13:09         ` Alex Bennée
2019-10-17 13:15 ` [PATCH v6 38/54] plugin: add qemu_plugin_insn_disas helper Alex Bennée
2019-10-17 13:16 ` [PATCH v6 39/54] plugin: add qemu_plugin_outs helper Alex Bennée
2019-10-22 14:07   ` Aaron Lindsay OS
2019-10-17 13:16 ` [PATCH v6 40/54] vl: support -plugin option Alex Bennée
2019-10-17 13:16 ` [PATCH v6 41/54] linux-user: " Alex Bennée
2019-10-17 13:16 ` [PATCH v6 42/54] tests/plugin: add sample plugins Alex Bennée
2019-10-17 13:16 ` [PATCH v6 43/54] tests/tcg/Makefile.target: fix path to config-host.mak Alex Bennée
2019-10-17 13:16 ` [PATCH v6 44/54] tests/tcg: set QEMU_OPTS for all cris runs Alex Bennée
2019-10-17 13:16 ` [PATCH v6 45/54] tests/tcg: move "virtual" tests to EXTRA_TESTS Alex Bennée
2019-10-17 13:16 ` [PATCH v6 46/54] tests/tcg: drop test-i386-fprem from TESTS when not SLOW Alex Bennée
2019-10-17 13:16 ` [PATCH v6 47/54] tests/tcg: enable plugin testing Alex Bennée
2019-10-17 13:16 ` [PATCH v6 48/54] tests/plugin: add a hotblocks plugin Alex Bennée
2019-10-17 13:16 ` [PATCH v6 49/54] tests/plugin: add instruction execution breakdown Alex Bennée
2019-10-17 13:16 ` [PATCH v6 50/54] tests/plugin: add hotpages to analyse memory access patterns Alex Bennée
2019-10-17 13:16 ` [PATCH v6 51/54] accel/stubs: reduce headers from tcg-stub Alex Bennée
2019-10-17 13:16 ` [PATCH v6 52/54] include/exec: wrap cpu_ldst.h in CONFIG_TCG Alex Bennée
2019-10-17 13:16 ` [PATCH v6 53/54] .travis.yml: add --enable-plugins tests Alex Bennée
2019-10-17 13:16 ` [PATCH v6 54/54] scripts/checkpatch.pl: don't complain about (foo, /* empty */) Alex Bennée
2019-10-22 14:12   ` Aaron Lindsay OS
2019-10-17 19:25 ` [PATCH for 4.2 v6 00/54] Support for TCG plugins no-reply
2019-10-18  7:07 ` no-reply
2019-10-18 17:43 ` no-reply
2019-10-22 11:37 ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wod2nj5x.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=aaron@os.amperecomputing.com \
    --cc=cota@braap.org \
    --cc=peter.puhov@futurewei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=robert.foley@futurewei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).