Function Tracing - Function Tracing - 57368

uProf User Guide

Document_ID
57368
Release_Date
2025-06-09
Revision
5.1 English

Function tracing in Linux is used to monitor and analyze the execution of functions. It provides insights into the functions called by an application and functions' execution time. Function tracing introduces an additional overhead, which results in longer profiling times for an application.

Prerequisites

  1. Linux kernel 4.15 or later is required.
  2. From the AMDuProf installed directory, run the script AMDuProfSetup.sh with root access.
    sudo ./AMDuProfSetup.sh

If you install AMD uProf using DEB installer, the script is run by the installer and the info about eBPF (Extended Berkeley Packet Filter) support on the host and function tracing support is provided.

Data Collection

GUI

To launch the AMDuProf GUI, go to Home > Welcome page.
  1. Click Profile an Application on the Welcome page.
  2. Provide application path, application options, working directory, and environment variables, if any. Click Next.
  3. From Custom Configs, select Function Tracing.
  4. Provide the functions to trace. Set Threshold, if required.
  5. Click Profile to start the profiling.

CLI

  • Function Tracing
    AMDuProfCLI collect --trace func --func <module:pattern> -o <output-dir> <application>
  • Trace functions of size 256 bytes or more
    AMDuProfCLI collect --trace func --func <module:pattern> --func-size 256 -o <output-dir> <application>
  • Trace functions with threshold of 50000 ns
    AMDuProfCLI collect --trace func --func <module:pattern> --func-threshold 50000 -o <output-dir> <application>
  • Trace kernel functions
    AMDuProfCLI collect --trace func --func kernel:vfs_* -o <output-dir> <application>

After the profile data collection is complete, a session directory will be generated. Use session directory to generate the csv report (or) to import the session in GUI.

Refer Table 1 for all supported options.

Example
[amd@uprof-ethanolx5 bin]$ ./AMDuProfCLI collect --trace func --func /tmp/ScimarkStable:* -o /tmp/ /tmp/ScimarkStable 
……… 
Profiling (data collection) completed 
Generated data files path: /tmp/AMDuProf-ScimarkStable-CpuTrace_Sep-06-2024_03-38-23

Here, the generated session directory is /tmp/AMDuProf-ScimarkStable-CpuTrace_Sep-06-2024_03-38-23 .

Options

Table 1. Function Tracing Options
Option Description
--func-threshold <value> By default, function threshold value set to 1000000 ns. If you want to trace functions execution time less than default threshold, use this option to set function threshold value.
--func-size <size> By default, AMDuProf traces functions of size 128 bytes, if you want to trace functions of size more than or equals to 128 bytes, use this option to set the function size.
--func <module:function- pattern>

Specify functions to trace from the library or executable:

  • Function-pattern can be a function name or partial name ending with '*' or only '*' to trace all the functions of a module.
  • Module can be a library or executable.
  • To trace kernel functions, specify the module as “kernel”.
Note: It is recommended to provide the absolute/full path of a module.
--exclude-func <module:function- pattern>

Specify functions to exclude from the library or executable:

  • Function-pattern can be a function name or partial name ending with '*' or only '*' to trace all the functions of a module.
  • Module can be a library or executable.
  • To exclude the kernel functions, use the module as “kernel”.
Note: It is recommended to provide the absolute path of a module.

Analyze the Data

CLI

An example of the function summary report section in the .csv report file is as follows. It provides the function count, total time (function and its children), min and max function self-time and total self-time.
Figure 1. Function Tracing - Function Summary Report

GUI

If data is collected using CLI, then use Import Session to import the session into GUI to analyze data in GUI.
Figure 2. Function Tracing - Function Count Summary Report

Limitations

  • System wide data collection is not supported by function tracing.
  • Function tracing is not supported for non-ELF executable.
  • Function tracing is not supported when a shared library loaded using dlopen().
  • Analyzing 32-bit applications is not supported.
  • The total time is not accurate for recursive functions.