[Qemu-devel] [PATCH] monitor: Check whether TCG is enabled before running the "info jit" code

Thomas Huth posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1493179907-22516-1-git-send-email-thuth@redhat.com
Test checkpatch passed
Test docker passed
Test s390x passed
monitor.c | 5 +++++
1 file changed, 5 insertions(+)
[Qemu-devel] [PATCH] monitor: Check whether TCG is enabled before running the "info jit" code
Posted by Thomas Huth 7 years ago
The "info jit" command currently aborts on Mac OS X with the message
"qemu_mutex_lock: Invalid argument" when running with "-M accel=qtest".
We should only call into the TCG code here if TCG has really been
enabled and initialized.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 monitor.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/monitor.c b/monitor.c
index be282ec..3e0979d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1086,6 +1086,11 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
 
 static void hmp_info_jit(Monitor *mon, const QDict *qdict)
 {
+    if (!tcg_enabled()) {
+        error_report("JIT information is only available with accel=tcg");
+        return;
+    }
+
     dump_exec_info((FILE *)mon, monitor_fprintf);
     dump_drift_info((FILE *)mon, monitor_fprintf);
 }
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH] monitor: Check whether TCG is enabled before running the "info jit" code
Posted by Dr. David Alan Gilbert 7 years ago
* Thomas Huth (thuth@redhat.com) wrote:
> The "info jit" command currently aborts on Mac OS X with the message
> "qemu_mutex_lock: Invalid argument" when running with "-M accel=qtest".
> We should only call into the TCG code here if TCG has really been
> enabled and initialized.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  monitor.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/monitor.c b/monitor.c
> index be282ec..3e0979d 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1086,6 +1086,11 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
>  
>  static void hmp_info_jit(Monitor *mon, const QDict *qdict)
>  {
> +    if (!tcg_enabled()) {
> +        error_report("JIT information is only available with accel=tcg");
> +        return;
> +    }
> +
>      dump_exec_info((FILE *)mon, monitor_fprintf);
>      dump_drift_info((FILE *)mon, monitor_fprintf);
>  }

so tcg_enabled checks tcg_ctx.code_gen_buffer != NULL
code_gen_buffer is set by code_gen_alloc
code_gen_alloc does a qemu_mutex_init of tb_lock
and the previous problem was an uninitialised tb_lock.

So:
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>


Peter: Does this fix the hmp test for you?

Dave

> -- 
> 1.8.3.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Re: [Qemu-devel] [PATCH] monitor: Check whether TCG is enabled before running the "info jit" code
Posted by Peter Maydell 7 years ago
On 26 April 2017 at 09:18, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> * Thomas Huth (thuth@redhat.com) wrote:
>> The "info jit" command currently aborts on Mac OS X with the message
>> "qemu_mutex_lock: Invalid argument" when running with "-M accel=qtest".
>> We should only call into the TCG code here if TCG has really been
>> enabled and initialized.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>  monitor.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/monitor.c b/monitor.c
>> index be282ec..3e0979d 100644
>> --- a/monitor.c
>> +++ b/monitor.c
>> @@ -1086,6 +1086,11 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
>>
>>  static void hmp_info_jit(Monitor *mon, const QDict *qdict)
>>  {
>> +    if (!tcg_enabled()) {
>> +        error_report("JIT information is only available with accel=tcg");
>> +        return;
>> +    }
>> +
>>      dump_exec_info((FILE *)mon, monitor_fprintf);
>>      dump_drift_info((FILE *)mon, monitor_fprintf);
>>  }
>
> so tcg_enabled checks tcg_ctx.code_gen_buffer != NULL
> code_gen_buffer is set by code_gen_alloc
> code_gen_alloc does a qemu_mutex_init of tb_lock
> and the previous problem was an uninitialised tb_lock.
>
> So:
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>
>
> Peter: Does this fix the hmp test for you?

Yes, it does.

Tested-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM

Re: [Qemu-devel] [PATCH] monitor: Check whether TCG is enabled before running the "info jit" code
Posted by Dr. David Alan Gilbert 7 years ago
* Peter Maydell (peter.maydell@linaro.org) wrote:
> On 26 April 2017 at 09:18, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> > * Thomas Huth (thuth@redhat.com) wrote:
> >> The "info jit" command currently aborts on Mac OS X with the message
> >> "qemu_mutex_lock: Invalid argument" when running with "-M accel=qtest".
> >> We should only call into the TCG code here if TCG has really been
> >> enabled and initialized.
> >>
> >> Signed-off-by: Thomas Huth <thuth@redhat.com>
> >> ---
> >>  monitor.c | 5 +++++
> >>  1 file changed, 5 insertions(+)
> >>
> >> diff --git a/monitor.c b/monitor.c
> >> index be282ec..3e0979d 100644
> >> --- a/monitor.c
> >> +++ b/monitor.c
> >> @@ -1086,6 +1086,11 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
> >>
> >>  static void hmp_info_jit(Monitor *mon, const QDict *qdict)
> >>  {
> >> +    if (!tcg_enabled()) {
> >> +        error_report("JIT information is only available with accel=tcg");
> >> +        return;
> >> +    }
> >> +
> >>      dump_exec_info((FILE *)mon, monitor_fprintf);
> >>      dump_drift_info((FILE *)mon, monitor_fprintf);
> >>  }
> >
> > so tcg_enabled checks tcg_ctx.code_gen_buffer != NULL
> > code_gen_buffer is set by code_gen_alloc
> > code_gen_alloc does a qemu_mutex_init of tb_lock
> > and the previous problem was an uninitialised tb_lock.
> >
> > So:
> > Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> >
> >
> > Peter: Does this fix the hmp test for you?
> 
> Yes, it does.
> 
> Tested-by: Peter Maydell <peter.maydell@linaro.org>

OK, I'll cook a new version of the HMP pull later with this in it.

Dave

> -- PMM
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK