[PATCH 0/5] stop collection of instruction usage statistics

Bruno Larsen (billionai) posted 5 patches 2 years, 10 months ago
Failed in applying to current master (apply log)
hmp-commands-info.hx   | 13 --------
hw/core/cpu.c          |  9 ------
include/hw/core/cpu.h  | 12 --------
monitor/misc.c         | 11 -------
target/ppc/cpu.h       |  1 -
target/ppc/cpu_init.c  |  3 --
target/ppc/translate.c | 69 +++---------------------------------------
7 files changed, 5 insertions(+), 113 deletions(-)
[PATCH 0/5] stop collection of instruction usage statistics
Posted by Bruno Larsen (billionai) 2 years, 10 months ago
Based-on: <20210525115355.8254-1-bruno.larsen@eldorado.org.br>

The functionality of counting how many instructions were being executed and
being able to show it through the monitor, although neat, was only
supported by ppc, and now that it is migrating to use decodetree (at
least partially), those statistics won't be used anymore. Therefore,
this patch removes that functinality completely.

This series was suggested by Richard Henderson

Bruno Larsen (billionai) (5):
  target/ppc: fixed GEN_OPCODE behavior when PPC_DUMP_CPU is set
  target/ppc: remove ppc_cpu_dump_statistics
  target/ppc: removed mentions to DO_PPC_STATISTICS
  monitor: removed cpustats command
  hw/core/cpu: removed cpu_dump_statistics function

 hmp-commands-info.hx   | 13 --------
 hw/core/cpu.c          |  9 ------
 include/hw/core/cpu.h  | 12 --------
 monitor/misc.c         | 11 -------
 target/ppc/cpu.h       |  1 -
 target/ppc/cpu_init.c  |  3 --
 target/ppc/translate.c | 69 +++---------------------------------------
 7 files changed, 5 insertions(+), 113 deletions(-)

-- 
2.17.1


Re: [PATCH 0/5] stop collection of instruction usage statistics
Posted by Alex Bennée 2 years, 10 months ago
"Bruno Larsen (billionai)" <bruno.larsen@eldorado.org.br> writes:

> Based-on: <20210525115355.8254-1-bruno.larsen@eldorado.org.br>
>
> The functionality of counting how many instructions were being executed and
> being able to show it through the monitor, although neat, was only
> supported by ppc, and now that it is migrating to use decodetree (at
> least partially), those statistics won't be used anymore. Therefore,
> this patch removes that functinality completely.

I have no particular comment to make about the PPC stuff but with the
common translator loop we have hooks across all converted front ends to
identify the start of each instruction. It's needed for the TCG plugin
instrumentation and we could in theory use it for more integrated stats
across the board.

Out of interest what was the main aim of this code - a view of total
executed instructions or something more detailed like a breakdown of
types and ops?

>
> This series was suggested by Richard Henderson
>
> Bruno Larsen (billionai) (5):
>   target/ppc: fixed GEN_OPCODE behavior when PPC_DUMP_CPU is set
>   target/ppc: remove ppc_cpu_dump_statistics
>   target/ppc: removed mentions to DO_PPC_STATISTICS
>   monitor: removed cpustats command
>   hw/core/cpu: removed cpu_dump_statistics function
>
>  hmp-commands-info.hx   | 13 --------
>  hw/core/cpu.c          |  9 ------
>  include/hw/core/cpu.h  | 12 --------
>  monitor/misc.c         | 11 -------
>  target/ppc/cpu.h       |  1 -
>  target/ppc/cpu_init.c  |  3 --
>  target/ppc/translate.c | 69 +++---------------------------------------
>  7 files changed, 5 insertions(+), 113 deletions(-)


-- 
Alex Bennée

RE: [PATCH 0/5] stop collection of instruction usage statistics
Posted by Luis Fernando Fujita Pires 2 years, 10 months ago
From: Alex Bennée <alex.bennee@linaro.org>
> I have no particular comment to make about the PPC stuff but with the common
> translator loop we have hooks across all converted front ends to identify the
> start of each instruction. It's needed for the TCG plugin instrumentation and we
> could in theory use it for more integrated stats across the board.
> 
> Out of interest what was the main aim of this code - a view of total executed
> instructions or something more detailed like a breakdown of types and ops?

The legacy instruction decoding logic in the PPC implementation uses a table that maps opcode patterns (based on different parts of the instructions) to handlers that actually implement each instruction. 
The code that is being removed would list how many times each specific handler was invoked, so it had more information than just the total count of executed instructions.

That being said, the code probably wasn't being used for a while now, as it didn't even compile.

--
Luis Pires
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br>
Departamento de Computação Embarcada
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>

Re: [PATCH 0/5] stop collection of instruction usage statistics
Posted by Alex Bennée 2 years, 10 months ago
Luis Fernando Fujita Pires <luis.pires@eldorado.org.br> writes:

> From: Alex Bennée <alex.bennee@linaro.org>
>> I have no particular comment to make about the PPC stuff but with the common
>> translator loop we have hooks across all converted front ends to identify the
>> start of each instruction. It's needed for the TCG plugin instrumentation and we
>> could in theory use it for more integrated stats across the board.
>> 
>> Out of interest what was the main aim of this code - a view of total executed
>> instructions or something more detailed like a breakdown of types and ops?
>
> The legacy instruction decoding logic in the PPC implementation uses a
> table that maps opcode patterns (based on different parts of the
> instructions) to handlers that actually implement each instruction.
> The code that is being removed would list how many times each specific handler was invoked, so it had more information than just the total count of executed instructions.
>
> That being said, the code probably wasn't being used for a while now,
> as it didn't even compile.

Ahh OK. If you wanted to you could probably re-create that information
using the howvec plugin (see contrib/plugins/howvec) if the decode
tables where added for PPC.

-- 
Alex Bennée

RE: [PATCH 0/5] stop collection of instruction usage statistics
Posted by Luis Fernando Fujita Pires 2 years, 10 months ago
From: Alex Bennée <alex.bennee@linaro.org>
> Ahh OK. If you wanted to you could probably re-create that information using
> the howvec plugin (see contrib/plugins/howvec) if the decode tables where
> added for PPC.

Interesting. I hadn't looked at the plugin mechanism before. In this hypothetical case, if we wanted to get the execution count for each instruction, we could also automatically generate the instruction decoding code based on decodetree. Then it would work for any architecture that uses decodetree.

I just realized that the ppc code wasn't counting instruction executions, but translations. A slightly modified version of howvec would also take care of that by counting the instructions directly in vcpu_tb_trans(), without even registering execution callbacks. Again, all hypothetical - but neat. :)

--
Luis Pires
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br>
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>

Re: [PATCH 0/5] stop collection of instruction usage statistics
Posted by Bruno Piazera Larsen 2 years, 10 months ago
On 27/05/2021 10:57, Alex Bennée wrote:
> "Bruno Larsen (billionai)" <bruno.larsen@eldorado.org.br> writes:
>
>> Based-on: <20210525115355.8254-1-bruno.larsen@eldorado.org.br>
>>
>> The functionality of counting how many instructions were being executed and
>> being able to show it through the monitor, although neat, was only
>> supported by ppc, and now that it is migrating to use decodetree (at
>> least partially), those statistics won't be used anymore. Therefore,
>> this patch removes that functinality completely.
> I have no particular comment to make about the PPC stuff but with the
> common translator loop we have hooks across all converted front ends to
> identify the start of each instruction. It's needed for the TCG plugin
> instrumentation and we could in theory use it for more integrated stats
> across the board.
>
> Out of interest what was the main aim of this code - a view of total
> executed instructions or something more detailed like a breakdown of
> types and ops?

I'm pretty new to qemu, so I'm not sure what the original intent was, 
but what it did was count how many times the handler of the instruction 
was called, so you knew how many times each individual opcode was used. 
At least, that's what I think it should do, since the code doesn't even 
compile anymore for me to check

>
>> This series was suggested by Richard Henderson
>>
>> Bruno Larsen (billionai) (5):
>>    target/ppc: fixed GEN_OPCODE behavior when PPC_DUMP_CPU is set
>>    target/ppc: remove ppc_cpu_dump_statistics
>>    target/ppc: removed mentions to DO_PPC_STATISTICS
>>    monitor: removed cpustats command
>>    hw/core/cpu: removed cpu_dump_statistics function
>>
>>   hmp-commands-info.hx   | 13 --------
>>   hw/core/cpu.c          |  9 ------
>>   include/hw/core/cpu.h  | 12 --------
>>   monitor/misc.c         | 11 -------
>>   target/ppc/cpu.h       |  1 -
>>   target/ppc/cpu_init.c  |  3 --
>>   target/ppc/translate.c | 69 +++---------------------------------------
>>   7 files changed, 5 insertions(+), 113 deletions(-)
>
-- 
Bruno Piazera Larsen
Instituto de Pesquisas ELDORADO 
<https://www.eldorado.org.br/?utm_campaign=assinatura_de_e-mail&utm_medium=email&utm_source=RD+Station>
Departamento Computação Embarcada
Analista de Software Trainee
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>