[PATCH 4/5] plugins: remove special casing for cpu->realized

Alex Bennée posted 5 patches 6 months ago
Maintainers: Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, "Alex Bennée" <alex.bennee@linaro.org>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Reinoud Zandijk <reinoud@netbsd.org>, Sunil Muthuswamy <sunilmut@microsoft.com>
[PATCH 4/5] plugins: remove special casing for cpu->realized
Posted by Alex Bennée 6 months ago
Now the condition variable is initialised early on we don't need to go
through hoops to avoid calling async_run_on_cpu.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 plugins/core.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/plugins/core.c b/plugins/core.c
index 0726bc7f25..badede28cf 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -65,11 +65,7 @@ static void plugin_cpu_update__locked(gpointer k, gpointer v, gpointer udata)
     CPUState *cpu = container_of(k, CPUState, cpu_index);
     run_on_cpu_data mask = RUN_ON_CPU_HOST_ULONG(*plugin.mask);
 
-    if (DEVICE(cpu)->realized) {
-        async_run_on_cpu(cpu, plugin_cpu_update__async, mask);
-    } else {
-        plugin_cpu_update__async(cpu, mask);
-    }
+    async_run_on_cpu(cpu, plugin_cpu_update__async, mask);
 }
 
 void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx,
-- 
2.39.2


Re: [PATCH 4/5] plugins: remove special casing for cpu->realized
Posted by Philippe Mathieu-Daudé 5 months, 4 weeks ago
On 30/5/24 21:42, Alex Bennée wrote:
> Now the condition variable is initialised early on we don't need to go
> through hoops to avoid calling async_run_on_cpu.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   plugins/core.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/plugins/core.c b/plugins/core.c
> index 0726bc7f25..badede28cf 100644
> --- a/plugins/core.c
> +++ b/plugins/core.c
> @@ -65,11 +65,7 @@ static void plugin_cpu_update__locked(gpointer k, gpointer v, gpointer udata)
>       CPUState *cpu = container_of(k, CPUState, cpu_index);
>       run_on_cpu_data mask = RUN_ON_CPU_HOST_ULONG(*plugin.mask);
>   
> -    if (DEVICE(cpu)->realized) {

We could assert() this to protect future refactors.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> -        async_run_on_cpu(cpu, plugin_cpu_update__async, mask);
> -    } else {
> -        plugin_cpu_update__async(cpu, mask);
> -    }
> +    async_run_on_cpu(cpu, plugin_cpu_update__async, mask);
>   }
>   
>   void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx,


Re: [PATCH 4/5] plugins: remove special casing for cpu->realized
Posted by Alex Bennée 5 months, 4 weeks ago
Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> On 30/5/24 21:42, Alex Bennée wrote:
>> Now the condition variable is initialised early on we don't need to go
>> through hoops to avoid calling async_run_on_cpu.
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>   plugins/core.c | 6 +-----
>>   1 file changed, 1 insertion(+), 5 deletions(-)
>> diff --git a/plugins/core.c b/plugins/core.c
>> index 0726bc7f25..badede28cf 100644
>> --- a/plugins/core.c
>> +++ b/plugins/core.c
>> @@ -65,11 +65,7 @@ static void plugin_cpu_update__locked(gpointer k, gpointer v, gpointer udata)
>>       CPUState *cpu = container_of(k, CPUState, cpu_index);
>>       run_on_cpu_data mask = RUN_ON_CPU_HOST_ULONG(*plugin.mask);
>>   -    if (DEVICE(cpu)->realized) {
>
> We could assert() this to protect future refactors.

No because the CPU can still not be realized but it will be able to
queue async work.

>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
>> -        async_run_on_cpu(cpu, plugin_cpu_update__async, mask);
>> -    } else {
>> -        plugin_cpu_update__async(cpu, mask);
>> -    }
>> +    async_run_on_cpu(cpu, plugin_cpu_update__async, mask);
>>   }
>>     void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx,

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH 4/5] plugins: remove special casing for cpu->realized
Posted by Philippe Mathieu-Daudé 5 months, 4 weeks ago
On 3/6/24 13:31, Philippe Mathieu-Daudé wrote:
> On 30/5/24 21:42, Alex Bennée wrote:
>> Now the condition variable is initialised early on we don't need to go
>> through hoops to avoid calling async_run_on_cpu.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>   plugins/core.c | 6 +-----
>>   1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/plugins/core.c b/plugins/core.c
>> index 0726bc7f25..badede28cf 100644
>> --- a/plugins/core.c
>> +++ b/plugins/core.c
>> @@ -65,11 +65,7 @@ static void plugin_cpu_update__locked(gpointer k, 
>> gpointer v, gpointer udata)
>>       CPUState *cpu = container_of(k, CPUState, cpu_index);
>>       run_on_cpu_data mask = RUN_ON_CPU_HOST_ULONG(*plugin.mask);
>> -    if (DEVICE(cpu)->realized) {
> 
> We could assert() this to protect future refactors.

(No we can't because vCPU can still be unrealized at this point).

> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
>> -        async_run_on_cpu(cpu, plugin_cpu_update__async, mask);
>> -    } else {
>> -        plugin_cpu_update__async(cpu, mask);
>> -    }
>> +    async_run_on_cpu(cpu, plugin_cpu_update__async, mask);
>>   }
>>   void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx,
> 


Re: [PATCH 4/5] plugins: remove special casing for cpu->realized
Posted by Pierrick Bouvier 6 months ago
On 5/30/24 12:42, Alex Bennée wrote:
> Now the condition variable is initialised early on we don't need to go
> through hoops to avoid calling async_run_on_cpu.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   plugins/core.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/plugins/core.c b/plugins/core.c
> index 0726bc7f25..badede28cf 100644
> --- a/plugins/core.c
> +++ b/plugins/core.c
> @@ -65,11 +65,7 @@ static void plugin_cpu_update__locked(gpointer k, gpointer v, gpointer udata)
>       CPUState *cpu = container_of(k, CPUState, cpu_index);
>       run_on_cpu_data mask = RUN_ON_CPU_HOST_ULONG(*plugin.mask);
>   
> -    if (DEVICE(cpu)->realized) {
> -        async_run_on_cpu(cpu, plugin_cpu_update__async, mask);
> -    } else {
> -        plugin_cpu_update__async(cpu, mask);
> -    }
> +    async_run_on_cpu(cpu, plugin_cpu_update__async, mask);
>   }
>   
>   void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx,

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>