frno7 / linux

Linux 2.2, 2.6, 3.x, 4.x and 5.x kernels for the PlayStation 2.
Other
86 stars 5 forks source link

Enable the R5900 performance counter hardware #26

Open frno7 opened 5 years ago

frno7 commented 5 years ago

The R5900 performance counter hardware provides the means for gathering statistical information about the internal events of the CPU and the pipeline during program execution. The statistics gathered during program execution aid in tuning the performance of hardware and software systems based on the processor.

See section 9 in the TX79 manual.

See also #6.

Ravenslofty commented 5 years ago

The performance counter hardware is pretty easy to set up, actually. I've written bare-metal assembly programs to do it. It'd have to be hooked up to perf though, I think.

frno7 commented 5 years ago

Wiring the performance counter into the perf command sounds like an excellent idea!

A note of caution though. I have noticed that perf consumes a significant amount of memory, at least in its default configuration, and so if possible parts of it may need to be disabled for it to fit within the limits of 32 MiB of total system RAM. That in addition to the actual thing that one wants to measure, of course. :grin:

I have put some effort into making the R5900 Linux kernel port more modular to reduce its memory footprint to a minimum, if one so desires. The BIOS code has been removed as it is no longer used. Also, as described in #10, the text console mode does not need to use any system RAM for its frame buffer.

The Linux kernel has a rich set of instrumentation tools too. eBPF seems to be the latest craze for kernel analysis and it even has a MIPS JIT compiler.