Measuring CPU Utilization in Linux

This topic describes two methods, the ftrace and top tools, for measuring CPU utilization of workloads that run in NVIDIA DRIVE® OS Linux.

Guidelines

These are the guidelines:

  • Workload should be executed for a minimum of 60 seconds when you collect utilization data.
  • It is important to collect idle system utilization for the duration of experiment and use it as a baseline for comparison.
    • Total idle utilization should be subtracted from the workload utilization for precise results.
  • For runtime CPU utilization measurements, begin the trace collection/measurement tool after the initialization is complete and stop the tracing before the application has exited.

Tool Comparison

This table summarizes the benefits and drawbacks of each method based on the tool used.

Tool Benefits Drawbacks
ftrace

(Recommended)

  • It provides fine-grained information of per-thread CPU utilization.
  • It does not provide a breakdown of the system CPU utilization.
  • It requires multiple steps and post-processing before a report is generated.
  • It cannot be used if kernel is built without debugfs (possible in production/release versions).
top
  • It is a simple method that requires no additional scripts or post-processing.
  • It gives quick insight into a workload's CPU utilization.
  • With the right options, it can also provide reasonable thread-level data.
  • Single decimal point precision for %CPU column can lead to under-counting of utilization.
  • Ensure that the correct set of options are used.
Note: You can also consider the mpstat and tegrastats tools; however, both tools provide processor-level reports, which are not useful for fine-grained, thread-level utilization.