qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
	"Alexandre Iooss" <erdnaxe@crans.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Mahmoud Mandour" <ma.mandourr@gmail.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH v3 07/17] plugins: implement inline operation relative to cpu_index
Date: Wed, 7 Feb 2024 10:01:58 +0400	[thread overview]
Message-ID: <1f483920-b99d-4d5c-9f9a-423f79986c23@linaro.org> (raw)
In-Reply-To: <1838c7f7-db41-4328-b75b-6b392f600bd2@linaro.org>

On 2/7/24 07:42, Richard Henderson wrote:
> On 2/6/24 19:24, Pierrick Bouvier wrote:
>> Instead of working on a fixed memory location, allow to address it based
>> on cpu_index, an element size and a given offset.
>> Result address: ptr + offset + cpu_index * element_size.
>>
>> With this, we can target a member in a struct array from a base pointer.
>>
>> Current semantic is not modified, thus inline operation still targets
>> always the same memory location.
>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>    plugins/plugin.h       |  2 +-
>>    accel/tcg/plugin-gen.c | 65 +++++++++++++++++++++++++++++++++++-------
>>    plugins/api.c          |  3 +-
>>    plugins/core.c         | 12 +++++---
>>    4 files changed, 65 insertions(+), 17 deletions(-)
>>
>> diff --git a/plugins/plugin.h b/plugins/plugin.h
>> index fd93a372803..77ed10689ca 100644
>> --- a/plugins/plugin.h
>> +++ b/plugins/plugin.h
>> @@ -100,7 +100,7 @@ void plugin_register_vcpu_mem_cb(GArray **arr,
>>                                     enum qemu_plugin_mem_rw rw,
>>                                     void *udata);
>>    
>> -void exec_inline_op(struct qemu_plugin_dyn_cb *cb);
>> +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index);
>>    
>>    int plugin_num_vcpus(void);
>>    
>> diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
>> index b37ce7683e6..68dee4c68d3 100644
>> --- a/accel/tcg/plugin-gen.c
>> +++ b/accel/tcg/plugin-gen.c
>> @@ -132,16 +132,28 @@ static void gen_empty_udata_cb_no_rwg(void)
>>     */
>>    static void gen_empty_inline_cb(void)
>>    {
>> +    TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
>> +    TCGv_ptr cpu_index_as_ptr = tcg_temp_ebb_new_ptr();
>>        TCGv_i64 val = tcg_temp_ebb_new_i64();
>>        TCGv_ptr ptr = tcg_temp_ebb_new_ptr();
>>    
>> +    tcg_gen_ld_i32(cpu_index, tcg_env,
>> +                   -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
>> +    /* pass an immediate != 0 so that it doesn't get optimized away */
>> +    tcg_gen_muli_i32(cpu_index, cpu_index, 0xdeadbeef);
> 
> You don't need a random immediate here.
> You can just as easily use
> 
>       tcg_gen_mul_i32(cpu_index, cpu_index, cpu_index);
> 
> with a similar comment about the true size being inserted later.
> 

Followed the tcg_gen_addi_i64 that was using this pattern in the same 
file. I'll change this to what you recommend.

> Otherwise,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> 
> r~


  reply	other threads:[~2024-02-07  6:02 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06  9:24 [PATCH v3 00/17] TCG Plugin inline operation enhancement Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 01/17] plugins: remove previous n_vcpus functions from API Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 02/17] plugins: add qemu_plugin_num_vcpus function Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 03/17] plugins: fix order of init/idle/resume callback Pierrick Bouvier
2024-02-07  2:59   ` Richard Henderson
2024-02-06  9:24 ` [PATCH v3 04/17] cpu: call plugin init hook asynchronously Pierrick Bouvier
2024-02-07  3:00   ` Richard Henderson
2024-02-06  9:24 ` [PATCH v3 05/17] plugins: scoreboard API Pierrick Bouvier
2024-02-07  3:21   ` Richard Henderson
2024-02-07  5:59     ` Pierrick Bouvier
2024-02-11  0:41       ` Richard Henderson
2024-02-11 14:26         ` Pierrick Bouvier
2024-02-11 19:13           ` Richard Henderson
2024-02-12  6:24             ` Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 06/17] docs/devel: plugins can trigger a tb flush Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 07/17] plugins: implement inline operation relative to cpu_index Pierrick Bouvier
2024-02-07  3:42   ` Richard Henderson
2024-02-07  6:01     ` Pierrick Bouvier [this message]
2024-02-06  9:24 ` [PATCH v3 08/17] plugins: add inline operation per vcpu Pierrick Bouvier
2024-02-07  3:45   ` Richard Henderson
2024-02-07  6:05     ` Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 09/17] tests/plugin: add test plugin for inline operations Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 10/17] tests/plugin/mem: migrate to new per_vcpu API Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 11/17] tests/plugin/insn: " Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 12/17] tests/plugin/bb: " Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 13/17] contrib/plugins/hotblocks: " Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 14/17] contrib/plugins/howvec: " Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 15/17] plugins: remove non per_vcpu inline operation from API Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 16/17] plugins: cleanup codepath for previous inline operation Pierrick Bouvier
2024-02-06  9:24 ` [PATCH v3 17/17] MAINTAINERS: Add myself as reviewer for TCG Plugins Pierrick Bouvier
2024-02-07 15:45 ` [PATCH v3 00/17] TCG Plugin inline operation enhancement Alex Bennée
2024-02-07 16:06   ` Alex Bennée
2024-02-07 18:21     ` Pierrick Bouvier

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=1f483920-b99d-4d5c-9f9a-423f79986c23@linaro.org \
    --to=pierrick.bouvier@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=eduardo@habkost.net \
    --cc=erdnaxe@crans.org \
    --cc=ma.mandourr@gmail.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=wangyanan55@huawei.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).