diff mbox series

[v2,18/18] contrib/plugins: avoid hanging program

Message ID 20240916085400.1046925-19-alex.bennee@linaro.org
State Superseded
Headers show
Series None | expand

Commit Message

Alex Bennée Sept. 16, 2024, 8:54 a.m. UTC
Although we asks for instructions per second we work in quanta and
that cannot be 0. Fail to load the plugin instead and report the
minimum IPS we can handle.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reported-by: Elisha Hollander <just4now666666@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 contrib/plugins/ips.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Pierrick Bouvier Sept. 18, 2024, 6:51 p.m. UTC | #1
On 9/16/24 01:54, Alex Bennée wrote:
> Although we asks for instructions per second we work in quanta and
> that cannot be 0. Fail to load the plugin instead and report the
> minimum IPS we can handle.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Reported-by: Elisha Hollander <just4now666666@gmail.com>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   contrib/plugins/ips.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c
> index 29fa556d0f..6f078689dc 100644
> --- a/contrib/plugins/ips.c
> +++ b/contrib/plugins/ips.c
> @@ -152,6 +152,11 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
>       vcpus = qemu_plugin_scoreboard_new(sizeof(vCPUTime));
>       max_insn_per_quantum = max_insn_per_second / NUM_TIME_UPDATE_PER_SEC;
>   
> +    if (max_insn_per_quantum == 0) {
> +        fprintf(stderr, "minimum of %d instructions per second needed\n", NUM_TIME_UPDATE_PER_SEC);
> +        return -1;
> +    }
> +
>       time_handle = qemu_plugin_request_time_control();
>       g_assert(time_handle);
>   

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

Patch

diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c
index 29fa556d0f..6f078689dc 100644
--- a/contrib/plugins/ips.c
+++ b/contrib/plugins/ips.c
@@ -152,6 +152,11 @@  QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
     vcpus = qemu_plugin_scoreboard_new(sizeof(vCPUTime));
     max_insn_per_quantum = max_insn_per_second / NUM_TIME_UPDATE_PER_SEC;
 
+    if (max_insn_per_quantum == 0) {
+        fprintf(stderr, "minimum of %d instructions per second needed\n", NUM_TIME_UPDATE_PER_SEC);
+        return -1;
+    }
+
     time_handle = qemu_plugin_request_time_control();
     g_assert(time_handle);