wiki:DVFS

Dynamic Voltage and Frequency Scaling (DVFS)

Modern processors allow their core clocks to be scaled in order to trade-off performance vs power or simple to save power when performance is not needed. This is referred to as 'Dynamic Frequency Scaling'. In some cases processors also allow you to scale the core voltages down when using lower clock-speeds which is referred to as 'Dynamic Voltage Scaling'.

The following Gateworks product families support DVFS:

  • Malibu (CN9130)
    • supports frequency scaling between 550Mhz 733MHz 1.1GHz and 2.2GHz
  • Venice (i.MX8)
    • supports frequency scaling between 1.6GHz and 1.2GHz
  • Ventana (i.MX6)
    • supports frequency and voltage scaling between 996Mhz, 792Mhz and 396MHz for Industrial temp IMX6Q and 792MHz, 396MHz for Industrial temp IMX6DL

Linux Kernel DVFS API

The linux kernel provides a DVFS framework that allows each CPU core to have a min/max frequency and a governor that governs it. A sysfs API exists which is used by the cpufreq-utils package.

The /sys/devices/system/cpu/cpufreq/ directory will exist if you have hardware that supports dynamic frequency control and a cpufreq driver. That directory will have one or more policy nodes (ie policy0) which itself has the following nodes:

  • scaling_governor - get/set the governor
  • scaling_available_governors - get the available governors
  • scaling_available_frequencies - get the available frequencies
  • cpuinfo_cur_freq - get/set the current freq
  • cpuinfo_max_freq - get/set the max freq
  • cpuinfo_min_freq - get/set the min freq
  • scaling_setspeed - set the current freq (if using the userspace governor)
  • affected_cpus - which cpu's are affected together

It is possible to have a system that groups cores into different policies.

Governors

Governors are kernel models that can drive CPU core frequency/voltage operating points based on an algorithm. Currently the following governors exist:

  • performance - sets the frequency statically to the highest available CPU frequency
  • powersave - sets the frequency statically to the lowest available CPU frequency
  • userspace - set the frequency from a userspace program
  • ondemand - adjust based on utilization
  • conservative - adjust based on utilization but be a bit more conservative by adjusting gradually

Examples

Here are some examples of using DVFS:

  • show affected cpu's for policy0:
    cat /sys/devices/system/cpu/cpufreq/policy0/related_cpus
    
  • show governor for cpu0:
    cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    
  • show the governor for policy0:
    cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
    
  • show available frequencies (in MHz) for policy0
    cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
    
  • set 'conservative' governor for a good mix of power-saving and performance
    echo conservative > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
    
  • set to lowest power mode using the 'powersave' governor:
    echo powersave > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
    
  • set to highest performance mode using the 'performance' governor:
    echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
    
  • set 'userspace' governer because perhaps you have a script that wants to adjust it manually based on your own criteria over time:
    echo userspace > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
    echo 396000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed
    echo 792000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed
    echo 996000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed
    
Last modified 21 months ago Last modified on 03/28/2023 08:28:10 PM
Note: See TracWiki for help on using the wiki.