Last edited one year ago

How to measure the DDR throughput

Applicable for STM32MP13x lines, STM32MP15x lines

1. Article purpose[edit | edit source]

This article explains how to measure the overall DDR throughput generated during a Linux® user space command execution.

2. Measurement flow[edit | edit source]

The DDR throughput measurement is done via counters provided by the DDRPERFM internal peripheral and controlled by stm32_ddr_pmu[1] performance monitoring unit driver that is registered to the Linux kernel perf framework.

From user land side, the perf tool is used to interact with the perf framework in order to record given events (such as stm32_ddr_pmu) during a command execution.

Once recorded, the stm32_ddr_pmu.py Python script is used to compute the corresponding DDR throughputs.

Launching this script without any parameter returns the usage information:

 python3 /usr/bin/stm32_ddr_pmu.py
Usage:
  python stm32_ddr_pmu.py [-d <ddr_freq>] -f <perf_file>
    -d ddr_freq: DDR frequency in MHz (533 MHz by default)
    -f perf_file: text file containing the output of
        perf stat -e stm32_ddr_pmu/read_cnt/,stm32_ddr_pmu/time_cnt/,stm32_ddr_pmu/write_cnt/ -a -o <perf_file> <command>
Info white.png Information
The stm32_ddr_pmu driver is compiled as a kernel module (stm32_ddr_pmu.ko) that may not be automatically probed at startup. If 'lsmod' command does not show this module, then make sure that ddrperfm node is enabled in the device tree and run the command 'modprobe stm32_ddr_pmu' to get it properly loaded.

3. Example[edit | edit source]

Let us see how to measure the DDR throughput generated during the 'sleep 1' command execution.

First, record the counters into 'perf.txt' file, providing the command to launch as parameter:

 perf stat -e stm32_ddr_pmu/read_cnt/,stm32_ddr_pmu/time_cnt/,stm32_ddr_pmu/write_cnt/ -a -o perf.txt sleep 1

Then, run the Python script to convert the result in throughput values:

 python3 /usr/bin/stm32_ddr_pmu.py -f perf.txt
R = 8 MB/s, W = 2 MB/s, R&W = 9 MB/s (DDR @ 533 MHz)

These low figures are due to the fact that the measurement was done with Weston stopped.

4. References[edit | edit source]