15630257fSFerruh Yigit.. SPDX-License-Identifier: BSD-3-Clause 25630257fSFerruh Yigit Copyright(c) 2010-2014 Intel Corporation. 3fc1f2750SBernard Iremonger 4fc1f2750SBernard IremongerPower Management 5fc1f2750SBernard Iremonger================ 6fc1f2750SBernard Iremonger 748624fd9SSiobhan ButlerThe DPDK Power Management feature allows users space applications to save power 8fc1f2750SBernard Iremongerby dynamically adjusting CPU frequency or entering into different C-States. 9fc1f2750SBernard Iremonger 10fc1f2750SBernard Iremonger* Adjusting the CPU frequency dynamically according to the utilization of RX queue. 11fc1f2750SBernard Iremonger 12fc1f2750SBernard Iremonger* Entering into different deeper C-States according to the adaptive algorithms to speculate 13fc1f2750SBernard Iremonger brief periods of time suspending the application if no packets are received. 14fc1f2750SBernard Iremonger 15fc1f2750SBernard IremongerThe interfaces for adjusting the operating CPU frequency are in the power management library. 16fc1f2750SBernard IremongerC-State control is implemented in applications according to the different use cases. 17fc1f2750SBernard Iremonger 18fc1f2750SBernard IremongerCPU Frequency Scaling 19fc1f2750SBernard Iremonger--------------------- 20fc1f2750SBernard Iremonger 21fc1f2750SBernard IremongerThe Linux kernel provides a cpufreq module for CPU frequency scaling for each lcore. 22fc1f2750SBernard IremongerFor example, for cpuX, /sys/devices/system/cpu/cpuX/cpufreq/ has the following sys files for frequency scaling: 23fc1f2750SBernard Iremonger 24fc1f2750SBernard Iremonger* affected_cpus 25fc1f2750SBernard Iremonger 26fc1f2750SBernard Iremonger* bios_limit 27fc1f2750SBernard Iremonger 28fc1f2750SBernard Iremonger* cpuinfo_cur_freq 29fc1f2750SBernard Iremonger 30fc1f2750SBernard Iremonger* cpuinfo_max_freq 31fc1f2750SBernard Iremonger 32fc1f2750SBernard Iremonger* cpuinfo_min_freq 33fc1f2750SBernard Iremonger 34fc1f2750SBernard Iremonger* cpuinfo_transition_latency 35fc1f2750SBernard Iremonger 36fc1f2750SBernard Iremonger* related_cpus 37fc1f2750SBernard Iremonger 38fc1f2750SBernard Iremonger* scaling_available_frequencies 39fc1f2750SBernard Iremonger 40fc1f2750SBernard Iremonger* scaling_available_governors 41fc1f2750SBernard Iremonger 42fc1f2750SBernard Iremonger* scaling_cur_freq 43fc1f2750SBernard Iremonger 44fc1f2750SBernard Iremonger* scaling_driver 45fc1f2750SBernard Iremonger 46fc1f2750SBernard Iremonger* scaling_governor 47fc1f2750SBernard Iremonger 48fc1f2750SBernard Iremonger* scaling_max_freq 49fc1f2750SBernard Iremonger 50fc1f2750SBernard Iremonger* scaling_min_freq 51fc1f2750SBernard Iremonger 52fc1f2750SBernard Iremonger* scaling_setspeed 53fc1f2750SBernard Iremonger 5448624fd9SSiobhan ButlerIn the DPDK, scaling_governor is configured in user space. 55fc1f2750SBernard IremongerThen, a user space application can prompt the kernel by writing scaling_setspeed to adjust the CPU frequency 56fc1f2750SBernard Iremongeraccording to the strategies defined by the user space application. 57fc1f2750SBernard Iremonger 58fc1f2750SBernard IremongerCore-load Throttling through C-States 59fc1f2750SBernard Iremonger------------------------------------- 60fc1f2750SBernard Iremonger 61fc1f2750SBernard IremongerCore state can be altered by speculative sleeps whenever the specified lcore has nothing to do. 6248624fd9SSiobhan ButlerIn the DPDK, if no packet is received after polling, 63fc1f2750SBernard Iremongerspeculative sleeps can be triggered according the strategies defined by the user space application. 64fc1f2750SBernard Iremonger 6594608a0fSDavid HuntPer-core Turbo Boost 6694608a0fSDavid Hunt-------------------- 6794608a0fSDavid Hunt 6894608a0fSDavid HuntIndividual cores can be allowed to enter a Turbo Boost state on a per-core 6994608a0fSDavid Huntbasis. This is achieved by enabling Turbo Boost Technology in the BIOS, then 7094608a0fSDavid Huntlooping through the relevant cores and enabling/disabling Turbo Boost on each 7194608a0fSDavid Huntcore. 7294608a0fSDavid Hunt 73d9e71f52SDavid HuntUse of Power Library in a Hyper-Threaded Environment 74d9e71f52SDavid Hunt---------------------------------------------------- 75d9e71f52SDavid Hunt 76d9e71f52SDavid HuntIn the case where the power library is in use on a system with Hyper-Threading enabled, 77d9e71f52SDavid Huntthe frequency on the physical core is set to the highest frequency of the Hyper-Thread siblings. 78d9e71f52SDavid HuntSo even though an application may request a scale down, the core frequency will 79d9e71f52SDavid Huntremain at the highest frequency until all Hyper-Threads on that core request a scale down. 80d9e71f52SDavid Hunt 81fc1f2750SBernard IremongerAPI Overview of the Power Library 82fc1f2750SBernard Iremonger--------------------------------- 83fc1f2750SBernard Iremonger 84fc1f2750SBernard IremongerThe main methods exported by power library are for CPU frequency scaling and include the following: 85fc1f2750SBernard Iremonger 86fc1f2750SBernard Iremonger* **Freq up**: Prompt the kernel to scale up the frequency of the specific lcore. 87fc1f2750SBernard Iremonger 88fc1f2750SBernard Iremonger* **Freq down**: Prompt the kernel to scale down the frequency of the specific lcore. 89fc1f2750SBernard Iremonger 90fc1f2750SBernard Iremonger* **Freq max**: Prompt the kernel to scale up the frequency of the specific lcore to the maximum. 91fc1f2750SBernard Iremonger 92fc1f2750SBernard Iremonger* **Freq min**: Prompt the kernel to scale down the frequency of the specific lcore to the minimum. 93fc1f2750SBernard Iremonger 94fc1f2750SBernard Iremonger* **Get available freqs**: Read the available frequencies of the specific lcore from the sys file. 95fc1f2750SBernard Iremonger 96fc1f2750SBernard Iremonger* **Freq get**: Get the current frequency of the specific lcore. 97fc1f2750SBernard Iremonger 98fc1f2750SBernard Iremonger* **Freq set**: Prompt the kernel to set the frequency for the specific lcore. 99fc1f2750SBernard Iremonger 10094608a0fSDavid Hunt* **Enable turbo**: Prompt the kernel to enable Turbo Boost for the specific lcore. 10194608a0fSDavid Hunt 10294608a0fSDavid Hunt* **Disable turbo**: Prompt the kernel to disable Turbo Boost for the specific lcore. 10394608a0fSDavid Hunt 104fc1f2750SBernard IremongerUser Cases 105fc1f2750SBernard Iremonger---------- 106fc1f2750SBernard Iremonger 107fc1f2750SBernard IremongerThe power management mechanism is used to save power when performing L3 forwarding. 108fc1f2750SBernard Iremonger 109450f0791SLiang Ma 110682a6454SLiang MaEthernet PMD Power Management API 111682a6454SLiang Ma--------------------------------- 112682a6454SLiang Ma 113682a6454SLiang MaAbstract 114682a6454SLiang Ma~~~~~~~~ 115682a6454SLiang Ma 1165dff9a72SAnatoly BurakovExisting power management mechanisms require developers to change application 1175dff9a72SAnatoly Burakovdesign or change code to make use of it. The PMD power management API provides a 1185dff9a72SAnatoly Burakovconvenient alternative by utilizing Ethernet PMD RX callbacks, and triggering 1195dff9a72SAnatoly Burakovpower saving whenever empty poll count reaches a certain number. 120682a6454SLiang Ma 1215dff9a72SAnatoly Burakov* Monitor 1225dff9a72SAnatoly Burakov This power saving scheme will put the CPU into optimized power state and 1235dff9a72SAnatoly Burakov monitor the Ethernet PMD RX descriptor address, waking the CPU up whenever 1245dff9a72SAnatoly Burakov there's new traffic. Support for this scheme may not be available on all 1255dff9a72SAnatoly Burakov platforms, and further limitations may apply (see below). 126682a6454SLiang Ma 1275dff9a72SAnatoly Burakov* Pause 1285dff9a72SAnatoly Burakov This power saving scheme will avoid busy polling by either entering 1295dff9a72SAnatoly Burakov power-optimized sleep state with ``rte_power_pause()`` function, or, if it's 1305dff9a72SAnatoly Burakov not supported by the underlying platform, use ``rte_pause()``. 131682a6454SLiang Ma 1325dff9a72SAnatoly Burakov* Frequency scaling 1335dff9a72SAnatoly Burakov This power saving scheme will use ``librte_power`` library functionality to 1345dff9a72SAnatoly Burakov scale the core frequency up/down depending on traffic volume. 1357580f973SDavid Hunt The reaction time of the frequency scaling mode is longer 1367580f973SDavid Hunt than the pause and monitor mode. 137682a6454SLiang Ma 1385dff9a72SAnatoly BurakovThe "monitor" mode is only supported in the following configurations and scenarios: 139682a6454SLiang Ma 1405dff9a72SAnatoly Burakov* On Linux* x86_64, `rte_power_monitor()` requires WAITPKG instruction set being 141f53fe635SAnatoly Burakov supported by the CPU, while `rte_power_monitor_multi()` requires WAITPKG and 142f53fe635SAnatoly Burakov RTM instruction sets being supported by the CPU. RTM instruction set may also 143f53fe635SAnatoly Burakov require booting the Linux with `tsx=on` command line parameter. Please refer 144f53fe635SAnatoly Burakov to your platform documentation for further information. 1455dff9a72SAnatoly Burakov 1465dff9a72SAnatoly Burakov* If ``rte_cpu_get_intrinsics_support()`` function indicates that 147f53fe635SAnatoly Burakov ``rte_power_monitor_multi()`` function is supported by the platform, then 148f53fe635SAnatoly Burakov monitoring multiple Ethernet Rx queues for traffic will be supported. 149f53fe635SAnatoly Burakov 150f53fe635SAnatoly Burakov* If ``rte_cpu_get_intrinsics_support()`` function indicates that only 1515dff9a72SAnatoly Burakov ``rte_power_monitor()`` is supported by the platform, then monitoring will be 1525dff9a72SAnatoly Burakov limited to a mapping of 1 core 1 queue (thus, each Rx queue will have to be 1535dff9a72SAnatoly Burakov monitored from a different lcore). 1545dff9a72SAnatoly Burakov 155f53fe635SAnatoly Burakov* If ``rte_cpu_get_intrinsics_support()`` function indicates that neither of the 156f53fe635SAnatoly Burakov two monitoring functions are supported, then monitor mode will not be supported. 1575dff9a72SAnatoly Burakov 1585dff9a72SAnatoly Burakov* Not all Ethernet drivers support monitoring, even if the underlying 1595dff9a72SAnatoly Burakov platform may support the necessary CPU instructions. Please refer to 1605dff9a72SAnatoly Burakov :doc:`../nics/overview` for more information. 1615dff9a72SAnatoly Burakov 162682a6454SLiang Ma 163682a6454SLiang MaAPI Overview for Ethernet PMD Power Management 164682a6454SLiang Ma~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 165682a6454SLiang Ma 166682a6454SLiang Ma* **Queue Enable**: Enable specific power scheme for certain queue/port/core. 167682a6454SLiang Ma 168682a6454SLiang Ma* **Queue Disable**: Disable power scheme for certain queue/port/core. 169682a6454SLiang Ma 1709e9e945bSKevin Laatz* **Get Emptypoll Max**: Get the configured number of empty polls to wait before 1719e9e945bSKevin Laatz entering sleep state. 1729e9e945bSKevin Laatz 1739e9e945bSKevin Laatz* **Set Emptypoll Max**: Set the number of empty polls to wait before entering 1749e9e945bSKevin Laatz sleep state. 1759e9e945bSKevin Laatz 1764a8fbc28SKevin Laatz* **Get Pause Duration**: Get the configured duration (microseconds) to be used 1774a8fbc28SKevin Laatz in the Pause callback. 1784a8fbc28SKevin Laatz 1794a8fbc28SKevin Laatz* **Set Pause Duration**: Set the duration of the pause (microseconds) used in 1804a8fbc28SKevin Laatz the Pause mode callback. 1814a8fbc28SKevin Laatz 18242651168SKevin Laatz* **Get Scaling Min Freq**: Get the configured minimum frequency (kHz) to be used 18342651168SKevin Laatz in Frequency Scaling mode. 18442651168SKevin Laatz 18542651168SKevin Laatz* **Set Scaling Min Freq**: Set the minimum frequency (kHz) to be used in Frequency 18642651168SKevin Laatz Scaling mode. 18742651168SKevin Laatz 18842651168SKevin Laatz* **Get Scaling Max Freq**: Get the configured maximum frequency (kHz) to be used 18942651168SKevin Laatz in Frequency Scaling mode. 19042651168SKevin Laatz 19142651168SKevin Laatz* **Set Scaling Max Freq**: Set the maximum frequency (kHz) to be used in Frequency 19242651168SKevin Laatz Scaling mode. 19342651168SKevin Laatz 194*ebe99d35SSivaprasad TummalaUncore API 195*ebe99d35SSivaprasad Tummala---------- 19660b8a661STadhg Kearney 19760b8a661STadhg KearneyAbstract 19860b8a661STadhg Kearney~~~~~~~~ 19960b8a661STadhg Kearney 20060b8a661STadhg KearneyUncore is a term used by Intel to describe the functions of a microprocessor 20160b8a661STadhg Kearneythat are not in the core, but which must be closely connected to the core 20260b8a661STadhg Kearneyto achieve high performance: L3 cache, on-die memory controller, etc. 20360b8a661STadhg KearneySignificant power savings can be achieved by reducing the uncore frequency 20460b8a661STadhg Kearneyto its lowest value. 20560b8a661STadhg Kearney 20660b8a661STadhg KearneyThe Linux kernel provides the driver "intel-uncore-frequency" 20760b8a661STadhg Kearneyto control the uncore frequency limits for x86 platform. 20860b8a661STadhg KearneyThe driver is available from kernel version 5.6 and above. 20960b8a661STadhg KearneyAlso CONFIG_INTEL_UNCORE_FREQ_CONTROL will need to be enabled in the kernel, 21060b8a661STadhg Kearneywhich was added in 5.6. 21160b8a661STadhg KearneyThis manipulates the context of MSR 0x620, 21260b8a661STadhg Kearneywhich sets min/max of the uncore for the SKU. 21360b8a661STadhg Kearney 214*ebe99d35SSivaprasad TummalaUncore API Overview 215*ebe99d35SSivaprasad Tummala~~~~~~~~~~~~~~~~~~~ 21660b8a661STadhg Kearney 217*ebe99d35SSivaprasad TummalaOverview of each function in the Uncore API, 21860b8a661STadhg Kearneywith explanation of what they do. 21960b8a661STadhg KearneyEach function should not be called in the fast path. 22060b8a661STadhg Kearney 22160b8a661STadhg KearneyUncore Power Init 22260b8a661STadhg Kearney Initialize uncore power, populate frequency array 22360b8a661STadhg Kearney and record original min & max for die on pkg. 22460b8a661STadhg Kearney 22560b8a661STadhg KearneyUncore Power Exit 22660b8a661STadhg Kearney Exit uncore power, restoring original min & max for die on pkg. 22760b8a661STadhg Kearney 22860b8a661STadhg KearneyGet Uncore Power Freq 22960b8a661STadhg Kearney Get current uncore freq index for die on pkg. 23060b8a661STadhg Kearney 23160b8a661STadhg KearneySet Uncore Power Freq 23260b8a661STadhg Kearney Set min & max uncore freq index for die on pkg 23360b8a661STadhg Kearney to specified index value (min and max will be the same). 23460b8a661STadhg Kearney 23560b8a661STadhg KearneyUncore Power Max 23660b8a661STadhg Kearney Set min & max uncore freq to maximum frequency index for die on pkg 23760b8a661STadhg Kearney (min and max will be the same). 23860b8a661STadhg Kearney 23960b8a661STadhg KearneyUncore Power Min 24060b8a661STadhg Kearney Set min & max uncore freq to minimum frequency index for die on pkg 24160b8a661STadhg Kearney (min and max will be the same). 24260b8a661STadhg Kearney 24360b8a661STadhg KearneyGet Num Freqs 24460b8a661STadhg Kearney Get the number of frequencies in the index array. 24560b8a661STadhg Kearney 24660b8a661STadhg KearneyGet Num Pkgs 24760b8a661STadhg Kearney Get the number of packages (CPU's) on the system. 24860b8a661STadhg Kearney 24960b8a661STadhg KearneyGet Num Dies 25060b8a661STadhg Kearney Get the number of die's on a given package. 25160b8a661STadhg Kearney 252fc1f2750SBernard IremongerReferences 253fc1f2750SBernard Iremonger---------- 254fc1f2750SBernard Iremonger 255fa77f80fSDavid Hunt* The :doc:`../sample_app_ug/l3_forward_power_man` 256fa77f80fSDavid Hunt chapter in the :doc:`../sample_app_ug/index` section. 257fc1f2750SBernard Iremonger 258fa77f80fSDavid Hunt* The :doc:`../sample_app_ug/vm_power_management` 259fa77f80fSDavid Hunt chapter in the :doc:`../sample_app_ug/index` section. 2605dff9a72SAnatoly Burakov 2615dff9a72SAnatoly Burakov* The :doc:`../nics/overview` chapter in the :doc:`../nics/index` section 262