Last edited one month ago

How to measure the DDR throughput

Applicable for STM32MP13x lines, STM32MP15x lines, STM32MP21x lines, STM32MP23x lines, STM32MP25x 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 (frequency, bursts length and word length are automatically detected on our platforms):

python3 /usr/bin/stm32_ddr_pmu.py
Found ddr frequency of 533.0 MHz
Usage:
 python stm32_ddr_pmu.py -f <perf_file> [-d <ddr_freq>] [-w <word_length>] [-l <burst_length>]
   -h: print this help
   -d ddr_freq: DDR frequency in MHz (533.0 MHz by default)
   -w word_length: width in bytes of DDR bus (4 by default)
   -l burst_length: length in cycles of DDR burst (8 by default)
   -f perf_file: text file containing the output of a perf stat command
       MP1: perf stat -e stm32_ddr_pmu/perf_op_is_rd/,\
                         stm32_ddr_pmu/perf_op_is_wr/,\
                         stm32_ddr_pmu/time_cnt/ -C 0 -o <perf_file> <command>

       MP2: perf stat -e stm32_ddr_pmu/dfi_is_rd/,\
                         stm32_ddr_pmu/dfi_is_wr/,\
                         stm32_ddr_pmu/dfi_is_rda/,\
                         stm32_ddr_pmu/dfi_is_wra/,\
                         stm32_ddr_pmu/dfi_is_mwra/,\
                         stm32_ddr_pmu/dfi_is_mwr/,\
                         stm32_ddr_pmu/time_cnt/ -C 0 -o <perf_file> <command>

The script considers bursts of 8 words with 4 bytes per word.
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 on a MP2 board.

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

perf stat -e stm32_ddr_pmu/dfi_is_rd/,\
                      stm32_ddr_pmu/dfi_is_wr/,\
                      stm32_ddr_pmu/dfi_is_rda/,\
                      stm32_ddr_pmu/dfi_is_wra/,\
                      stm32_ddr_pmu/dfi_is_mwra/,\
                      stm32_ddr_pmu/dfi_is_mwr/,\
                      stm32_ddr_pmu/time_cnt/ -C 0 -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 @ 800 MHz)

4. References[edit | edit source]