15630257fSFerruh Yigit.. SPDX-License-Identifier: BSD-3-Clause 25630257fSFerruh Yigit Copyright(c) 2010-2014 Intel Corporation. 3c75f4e6aSPablo de Lara 430d3aa86SDavid HuntVirtual Machine Power Management Application 530d3aa86SDavid Hunt============================================ 6c75f4e6aSPablo de Lara 730d3aa86SDavid HuntApplications running in virtual environments have an abstract view of 830d3aa86SDavid Huntthe underlying hardware on the host. Specifically, applications cannot 930d3aa86SDavid Huntsee the binding of virtual components to physical hardware. When looking 1030d3aa86SDavid Huntat CPU resourcing, the pinning of Virtual CPUs (vCPUs) to Physical CPUs 1130d3aa86SDavid Hunt(pCPUs) on the host is not apparent to an application and this pinning 1230d3aa86SDavid Huntmay change over time. In addition, operating systems on Virtual Machines 1330d3aa86SDavid Hunt(VMs) do not have the ability to govern their own power policy. The 1430d3aa86SDavid HuntMachine Specific Registers (MSRs) for enabling P-state transitions are 1530d3aa86SDavid Huntnot exposed to the operating systems running on the VMs. 16c75f4e6aSPablo de Lara 1730d3aa86SDavid HuntThe solution demonstrated in this sample application shows an example of 1830d3aa86SDavid Hunthow a DPDK application can indicate its processing requirements using 1930d3aa86SDavid HuntVM-local only information (vCPU/lcore, and so on) to a host resident VM 2030d3aa86SDavid HuntPower Manager. The VM Power Manager is responsible for: 21c75f4e6aSPablo de Lara 2230d3aa86SDavid Hunt- **Accepting requests for frequency changes for a vCPU** 2330d3aa86SDavid Hunt- **Translating the vCPU to a pCPU using libvirt** 2430d3aa86SDavid Hunt- **Performing the change in frequency** 25c75f4e6aSPablo de Lara 2630d3aa86SDavid HuntThis application demonstrates the following features: 27c75f4e6aSPablo de Lara 2830d3aa86SDavid Hunt- **The handling of VM application requests to change frequency.** 2930d3aa86SDavid Hunt VM applications can request frequency changes for a vCPU. The VM 3030d3aa86SDavid Hunt Power Management Application uses libvirt to translate that 3130d3aa86SDavid Hunt virtual CPU (vCPU) request to a physical CPU (pCPU) request and 3230d3aa86SDavid Hunt performs the frequency change. 33c75f4e6aSPablo de Lara 3430d3aa86SDavid Hunt- **The acceptance of power management policies from VM applications.** 3530d3aa86SDavid Hunt A VM application can send a policy to the host application. The 3630d3aa86SDavid Hunt policy contains rules that define the power management behaviour 3730d3aa86SDavid Hunt of the VM. The host application then applies the rules of the 3830d3aa86SDavid Hunt policy independent of the VM application. For example, the 3930d3aa86SDavid Hunt policy can contain time-of-day information for busy/quiet 4030d3aa86SDavid Hunt periods, and the host application can scale up/down the relevant 4130d3aa86SDavid Hunt cores when required. See :ref:`sending_policy` for information on 4230d3aa86SDavid Hunt setting policy values. 43c75f4e6aSPablo de Lara 4430d3aa86SDavid Hunt- **Out-of-band monitoring of workloads using core hardware event counters.** 4530d3aa86SDavid Hunt The host application can manage power for an application by looking 4630d3aa86SDavid Hunt at the event counters of the cores and taking action based on the 4730d3aa86SDavid Hunt branch miss/hit ratio. See :ref:`enabling_out_of_band`. 48c75f4e6aSPablo de Lara 4930d3aa86SDavid Hunt **Note**: This functionality also applies in non-virtualised environments. 5050ac590fSDavid Hunt 5130d3aa86SDavid HuntIn addition to the ``librte_power`` library used on the host, the 5230d3aa86SDavid Huntapplication uses a special version of ``librte_power`` on each VM, which 5330d3aa86SDavid Huntdirects frequency changes and policies to the host monitor rather than 5430d3aa86SDavid Huntthe APCI ``cpufreq`` ``sysfs`` interface used on the host in non-virtualised 5530d3aa86SDavid Huntenvironments. 56c75f4e6aSPablo de Lara 574a22e6eeSJohn McNamara.. _figure_vm_power_mgr_highlevel: 58c75f4e6aSPablo de Lara 594a22e6eeSJohn McNamara.. figure:: img/vm_power_mgr_highlevel.* 60c75f4e6aSPablo de Lara 614a22e6eeSJohn McNamara Highlevel Solution 624a22e6eeSJohn McNamara 6330d3aa86SDavid HuntIn the above diagram, the DPDK Applications are shown running in 6430d3aa86SDavid Huntvirtual machines, and the VM Power Monitor application is shown running 6530d3aa86SDavid Huntin the host. 66c75f4e6aSPablo de Lara 6730d3aa86SDavid Hunt**DPDK VM Application** 68c75f4e6aSPablo de Lara 6930d3aa86SDavid Hunt- Reuse ``librte_power`` interface, but uses an implementation that 7030d3aa86SDavid Hunt forwards frequency requests to the host using a ``virtio-serial`` channel 7130d3aa86SDavid Hunt- Each lcore has exclusive access to a single channel 7230d3aa86SDavid Hunt- Sample application reuses ``l3fwd_power`` 7330d3aa86SDavid Hunt- A CLI for changing frequency from within a VM is also included 74c75f4e6aSPablo de Lara 7530d3aa86SDavid Hunt**VM Power Monitor** 76c75f4e6aSPablo de Lara 7730d3aa86SDavid Hunt- Accepts VM commands over ``virtio-serial`` endpoints, monitored 7830d3aa86SDavid Hunt using ``epoll`` 7930d3aa86SDavid Hunt- Commands include the virtual core to be modified, using ``libvirt`` to get 8030d3aa86SDavid Hunt the physical core mapping 8130d3aa86SDavid Hunt- Uses ``librte_power`` to affect frequency changes using Linux userspace 8230d3aa86SDavid Hunt power governor (``acpi_cpufreq`` OR ``intel_pstate`` driver) 8330d3aa86SDavid Hunt- CLI: For adding VM channels to monitor, inspecting and changing channel 8430d3aa86SDavid Hunt state, manually altering CPU frequency. Also allows for the changings 8530d3aa86SDavid Hunt of vCPU to pCPU pinning 8630d3aa86SDavid Hunt 8730d3aa86SDavid HuntSample Application Architecture Overview 8830d3aa86SDavid Hunt---------------------------------------- 8930d3aa86SDavid Hunt 9030d3aa86SDavid HuntThe VM power management solution employs ``qemu-kvm`` to provide 9130d3aa86SDavid Huntcommunications channels between the host and VMs in the form of a 9230d3aa86SDavid Hunt``virtio-serial`` connection that appears as a para-virtualised serial 9330d3aa86SDavid Huntdevice on a VM and can be configured to use various backends on the 9430d3aa86SDavid Hunthost. For this example, the configuration of each ``virtio-serial`` endpoint 9530d3aa86SDavid Hunton the host as an ``AF_UNIX`` file socket, supporting poll/select and 9630d3aa86SDavid Hunt``epoll`` for event notification. In this example, each channel endpoint on 9730d3aa86SDavid Huntthe host is monitored for ``EPOLLIN`` events using ``epoll``. Each channel 9830d3aa86SDavid Huntis specified as ``qemu-kvm`` arguments or as ``libvirt`` XML for each VM, 9930d3aa86SDavid Huntwhere each VM can have several channels up to a maximum of 64 per VM. In this 10030d3aa86SDavid Huntexample, each DPDK lcore on a VM has exclusive access to a channel. 10130d3aa86SDavid Hunt 10230d3aa86SDavid HuntTo enable frequency changes from within a VM, the VM forwards a 10330d3aa86SDavid Hunt``librte_power`` request over the ``virtio-serial`` channel to the host. Each 10430d3aa86SDavid Huntrequest contains the vCPU and power command (scale up/down/min/max). The 10530d3aa86SDavid HuntAPI for the host ``librte_power`` and guest ``librte_power`` is consistent 10630d3aa86SDavid Huntacross environments, with the selection of VM or host implementation 10730d3aa86SDavid Huntdetermined automatically at runtime based on the environment. On 10830d3aa86SDavid Huntreceiving a request, the host translates the vCPU to a pCPU using the 10930d3aa86SDavid Huntlibvirt API before forwarding it to the host ``librte_power``. 11030d3aa86SDavid Hunt 111c75f4e6aSPablo de Lara 1124a22e6eeSJohn McNamara.. _figure_vm_power_mgr_vm_request_seq: 113c75f4e6aSPablo de Lara 1144a22e6eeSJohn McNamara.. figure:: img/vm_power_mgr_vm_request_seq.* 115c75f4e6aSPablo de Lara 11630d3aa86SDavid HuntIn addition to the ability to send power management requests to the 11730d3aa86SDavid Hunthost, a VM can send a power management policy to the host. In some 11830d3aa86SDavid Huntcases, using a power management policy is a preferred option because it 11930d3aa86SDavid Huntcan eliminate possible latency issues that can occur when sending power 12030d3aa86SDavid Huntmanagement requests. Once the VM sends the policy to the host, the VM no 12130d3aa86SDavid Huntlonger needs to worry about power management, because the host now 12230d3aa86SDavid Huntmanages the power for the VM based on the policy. The policy can specify 12330d3aa86SDavid Huntpower behavior that is based on incoming traffic rates or time-of-day 12430d3aa86SDavid Huntpower adjustment (busy/quiet hour power adjustment for example). See 12530d3aa86SDavid Hunt:ref:`sending_policy` for more information. 1264a22e6eeSJohn McNamara 12730d3aa86SDavid HuntOne method of power management is to sense how busy a core is when 12830d3aa86SDavid Huntprocessing packets and adjusting power accordingly. One technique for 12930d3aa86SDavid Huntdoing this is to monitor the ratio of the branch miss to branch hits 13030d3aa86SDavid Huntcounters and scale the core power accordingly. This technique is based 13130d3aa86SDavid Hunton the premise that when a core is not processing packets, the ratio of 13230d3aa86SDavid Huntbranch misses to branch hits is very low, but when the core is 13330d3aa86SDavid Huntprocessing packets, it is measurably higher. The implementation of this 13430d3aa86SDavid Huntcapability is as a policy of type ``BRANCH_RATIO``. 13530d3aa86SDavid HuntSee :ref:`sending_policy` for more information on using the 13630d3aa86SDavid HuntBRANCH_RATIO policy option. 13730d3aa86SDavid Hunt 13830d3aa86SDavid HuntA JSON interface enables the specification of power management requests 13930d3aa86SDavid Huntand policies in JSON format. The JSON interfaces provide a more 14030d3aa86SDavid Huntconvenient and more easily interpreted interface for the specification 14130d3aa86SDavid Huntof requests and policies. See :ref:`power_man_requests` for more information. 142c75f4e6aSPablo de Lara 143c75f4e6aSPablo de LaraPerformance Considerations 144c75f4e6aSPablo de Lara~~~~~~~~~~~~~~~~~~~~~~~~~~ 145c75f4e6aSPablo de Lara 14630d3aa86SDavid HuntWhile the Haswell microarchitecture allows for independent power control 14730d3aa86SDavid Huntfor each core, earlier microarchitectures do not offer such fine-grained 14830d3aa86SDavid Huntcontrol. When deploying on pre-Haswell platforms, greater care must be 14930d3aa86SDavid Hunttaken when selecting which cores are assigned to a VM, for example, a 15030d3aa86SDavid Huntcore does not scale down in frequency until all of its siblings are 15130d3aa86SDavid Huntsimilarly scaled down. 152c75f4e6aSPablo de Lara 153c75f4e6aSPablo de LaraConfiguration 154c75f4e6aSPablo de Lara------------- 155c75f4e6aSPablo de Lara 156c75f4e6aSPablo de LaraBIOS 157c75f4e6aSPablo de Lara~~~~ 158c75f4e6aSPablo de Lara 15930d3aa86SDavid HuntTo use the power management features of the DPDK, you must enable 16030d3aa86SDavid HuntEnhanced Intel SpeedStep® Technology in the platform BIOS. Otherwise, 16130d3aa86SDavid Huntthe ``sys`` file folder ``/sys/devices/system/cpu/cpu0/cpufreq`` does not 16230d3aa86SDavid Huntexist, and you cannot use CPU frequency-based power management. Refer to the 16330d3aa86SDavid Huntrelevant BIOS documentation to determine how to access these settings. 164c75f4e6aSPablo de Lara 165c75f4e6aSPablo de LaraHost Operating System 166c75f4e6aSPablo de Lara~~~~~~~~~~~~~~~~~~~~~ 167c75f4e6aSPablo de Lara 16830d3aa86SDavid HuntThe DPDK Power Management library can use either the ``acpi_cpufreq`` or 16930d3aa86SDavid Huntthe ``intel_pstate`` kernel driver for the management of core frequencies. In 17030d3aa86SDavid Huntmany cases, the ``intel_pstate`` driver is the default power management 17130d3aa86SDavid Huntenvironment. 172b7eaf5bbSDavid Hunt 17330d3aa86SDavid HuntShould the ``acpi-cpufreq driver`` be required, the ``intel_pstate`` 17430d3aa86SDavid Huntmodule must be disabled, and the ``acpi-cpufreq`` module loaded in its place. 175b7eaf5bbSDavid Hunt 17630d3aa86SDavid HuntTo disable the ``intel_pstate`` driver, add the following to the ``grub`` 17730d3aa86SDavid HuntLinux command line: 178c75f4e6aSPablo de Lara 17930d3aa86SDavid Hunt ``intel_pstate=disable`` 180c75f4e6aSPablo de Lara 18130d3aa86SDavid HuntOn reboot, load the ``acpi_cpufreq`` module: 182c75f4e6aSPablo de Lara 18330d3aa86SDavid Hunt ``modprobe acpi_cpufreq`` 184c75f4e6aSPablo de Lara 185c75f4e6aSPablo de LaraHypervisor Channel Configuration 186c75f4e6aSPablo de Lara~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 187c75f4e6aSPablo de Lara 18830d3aa86SDavid HuntConfigure ``virtio-serial`` channels using ``libvirt`` XML. 18930d3aa86SDavid HuntThe XML structure is as follows: 190c75f4e6aSPablo de Lara 19130d3aa86SDavid Hunt.. code-block:: XML 192c75f4e6aSPablo de Lara 193c75f4e6aSPablo de Lara <name>{vm_name}</name> 194c75f4e6aSPablo de Lara <controller type='virtio-serial' index='0'> 195c75f4e6aSPablo de Lara <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> 196c75f4e6aSPablo de Lara </controller> 197c75f4e6aSPablo de Lara <channel type='unix'> 198c75f4e6aSPablo de Lara <source mode='bind' path='/tmp/powermonitor/{vm_name}.{channel_num}'/> 1993ec02f9cSJohn McNamara <target type='virtio' name='virtio.serial.port.poweragent.{vm_channel_num}'/> 200c75f4e6aSPablo de Lara <address type='virtio-serial' controller='0' bus='0' port='{N}'/> 201c75f4e6aSPablo de Lara </channel> 202c75f4e6aSPablo de Lara 20330d3aa86SDavid HuntWhere a single controller of type ``virtio-serial`` is created, up to 32 20430d3aa86SDavid Huntchannels can be associated with a single controller, and multiple 20530d3aa86SDavid Huntcontrollers can be specified. The convention is to use the name of the 20630d3aa86SDavid HuntVM in the host path ``{vm_name}`` and to increment ``{channel_num}`` for each 20730d3aa86SDavid Huntchannel. Likewise, the port value ``{N}`` must be incremented for each 20830d3aa86SDavid Huntchannel. 209c75f4e6aSPablo de Lara 21030d3aa86SDavid HuntOn the host, for each channel to appear in the path, ensure the creation 21130d3aa86SDavid Huntof the ``/tmp/powermonitor/`` directory and the assignment of ``qemu`` 21230d3aa86SDavid Huntpermissions: 213c75f4e6aSPablo de Lara 214c75f4e6aSPablo de Lara.. code-block:: console 215c75f4e6aSPablo de Lara 216c75f4e6aSPablo de Lara mkdir /tmp/powermonitor/ 217c75f4e6aSPablo de Lara chown qemu:qemu /tmp/powermonitor 218c75f4e6aSPablo de Lara 21930d3aa86SDavid HuntNote that files and directories in ``/tmp`` are generally removed when 22030d3aa86SDavid Huntrebooting the host and you may need to perform the previous steps after 22130d3aa86SDavid Hunteach reboot. 222c75f4e6aSPablo de Lara 22330d3aa86SDavid HuntThe serial device as it appears on a VM is configured with the target 22430d3aa86SDavid Huntelement attribute name and must be in the form: 22530d3aa86SDavid Hunt``virtio.serial.port.poweragent.{vm_channel_num}``, where 22630d3aa86SDavid Hunt``vm_channel_num`` is typically the lcore channel to be used in 22730d3aa86SDavid HuntDPDK VM applications. 228c75f4e6aSPablo de Lara 22930d3aa86SDavid HuntEach channel on a VM is present at: 23030d3aa86SDavid Hunt 23130d3aa86SDavid Hunt``/dev/virtio-ports/virtio.serial.port.poweragent.{vm_channel_num}`` 232c75f4e6aSPablo de Lara 233c75f4e6aSPablo de LaraCompiling and Running the Host Application 234c75f4e6aSPablo de Lara------------------------------------------ 235c75f4e6aSPablo de Lara 23630d3aa86SDavid HuntCompiling the Host Application 23730d3aa86SDavid Hunt~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 238c75f4e6aSPablo de Lara 2394f823975SThomas MonjalonFor information on compiling the DPDK and sample applications, 24050ac590fSDavid Huntsee :doc:`compiling`. 2417cacb056SHerakliusz Lipiec 24230d3aa86SDavid HuntThe application is located in the ``vm_power_manager`` subdirectory. 243c75f4e6aSPablo de Lara 244e0130788SDavid HuntTo build just the ``vm_power_manager`` application using ``make``: 24550ac590fSDavid Hunt 24650ac590fSDavid Hunt.. code-block:: console 24750ac590fSDavid Hunt 248e2a94f9aSCiara Power cd dpdk/examples/vm_power_manager/ 24950ac590fSDavid Hunt make 25050ac590fSDavid Hunt 251e2a94f9aSCiara PowerThe resulting binary is ``dpdk/build/examples/vm_power_manager``. 252e0130788SDavid Hunt 25330d3aa86SDavid HuntTo build just the ``vm_power_manager`` application using ``meson``/``ninja``: 254e0130788SDavid Hunt 255e0130788SDavid Hunt.. code-block:: console 256e0130788SDavid Hunt 257e2a94f9aSCiara Power cd dpdk 258*e24b8ad4SStephen Hemminger meson setup build 259e0130788SDavid Hunt cd build 260e0130788SDavid Hunt ninja 261e0130788SDavid Hunt meson configure -Dexamples=vm_power_manager 262e0130788SDavid Hunt ninja 263e0130788SDavid Hunt 264e2a94f9aSCiara PowerThe resulting binary is ``dpdk/build/examples/dpdk-vm_power_manager``. 265e0130788SDavid Hunt 26630d3aa86SDavid HuntRunning the Host Application 26730d3aa86SDavid Hunt~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 268c75f4e6aSPablo de Lara 26930d3aa86SDavid HuntThe application does not have any specific command line options other 27030d3aa86SDavid Huntthan the EAL options: 271c75f4e6aSPablo de Lara 272c75f4e6aSPablo de Lara.. code-block:: console 273c75f4e6aSPablo de Lara 274e2a94f9aSCiara Power ./<build_dir>/examples/dpdk-vm_power_mgr [EAL options] 275c75f4e6aSPablo de Lara 27630d3aa86SDavid HuntThe application requires exactly two cores to run. One core for the CLI 27730d3aa86SDavid Huntand the other for the channel endpoint monitor. For example, to run on 27830d3aa86SDavid Huntcores 0 and 1 on a system with four memory channels, issue the command: 279c75f4e6aSPablo de Lara 280c75f4e6aSPablo de Lara.. code-block:: console 281c75f4e6aSPablo de Lara 282e2a94f9aSCiara Power ./<build_dir>/examples/dpdk-vm_power_mgr -l 0-1 -n 4 283c75f4e6aSPablo de Lara 28430d3aa86SDavid HuntAfter successful initialization, the VM Power Manager CLI prompt appears: 285c75f4e6aSPablo de Lara 286c75f4e6aSPablo de Lara.. code-block:: console 287c75f4e6aSPablo de Lara 288c75f4e6aSPablo de Lara vm_power> 289c75f4e6aSPablo de Lara 29030d3aa86SDavid HuntNow, it is possible to add virtual machines to the VM Power Manager: 291c75f4e6aSPablo de Lara 292c75f4e6aSPablo de Lara.. code-block:: console 293c75f4e6aSPablo de Lara 294c75f4e6aSPablo de Lara vm_power> add_vm {vm_name} 295c75f4e6aSPablo de Lara 29630d3aa86SDavid HuntWhen a ``{vm_name}`` is specified with the ``add_vm`` command, a lookup is 29730d3aa86SDavid Huntperformed with ``libvirt`` to ensure that the VM exists. ``{vm_name}`` is a 29830d3aa86SDavid Huntunique identifier to associate channels with a particular VM and for 29930d3aa86SDavid Huntexecuting operations on a VM within the CLI. VMs do not have to be 30030d3aa86SDavid Huntrunning to add them. 301c75f4e6aSPablo de Lara 30230d3aa86SDavid HuntIt is possible to issue several commands from the CLI to manage VMs. 303c75f4e6aSPablo de Lara 30430d3aa86SDavid HuntRemove the virtual machine identified by ``{vm_name}`` from the VM Power 30530d3aa86SDavid HuntManager using the command: 306c75f4e6aSPablo de Lara 307c75f4e6aSPablo de Lara.. code-block:: console 308c75f4e6aSPablo de Lara 309c75f4e6aSPablo de Lara rm_vm {vm_name} 310c75f4e6aSPablo de Lara 31130d3aa86SDavid HuntAdd communication channels for the specified VM using the following 31230d3aa86SDavid Huntcommand. The ``virtio`` channels must be enabled in the VM configuration 31330d3aa86SDavid Hunt(``qemu/libvirt``) and the associated VM must be active. ``{list}`` is a 31430d3aa86SDavid Huntcomma-separated list of channel numbers to add. Specifying the keyword 31530d3aa86SDavid Hunt``all`` attempts to add all channels for the VM: 316c75f4e6aSPablo de Lara 317c75f4e6aSPablo de Lara.. code-block:: console 318c75f4e6aSPablo de Lara 319c75f4e6aSPablo de Lara set_pcpu {vm_name} {vcpu} {pcpu} 320c75f4e6aSPablo de Lara 321f433878aSDavid Hunt Enable query of physical core information from a VM: 322f433878aSDavid Hunt 323f433878aSDavid Hunt.. code-block:: console 324f433878aSDavid Hunt 325f433878aSDavid Hunt set_query {vm_name} enable|disable 326f433878aSDavid Hunt 327c75f4e6aSPablo de LaraManual control and inspection can also be carried in relation CPU frequency scaling: 328c75f4e6aSPablo de Lara 329c75f4e6aSPablo de Lara Get the current frequency for each core specified in the mask: 330c75f4e6aSPablo de Lara 331c75f4e6aSPablo de Lara.. code-block:: console 332c75f4e6aSPablo de Lara 333c75f4e6aSPablo de Lara show_cpu_freq_mask {mask} 334c75f4e6aSPablo de Lara 335c75f4e6aSPablo de Lara Set the current frequency for the cores specified in {core_mask} by scaling each up/down/min/max: 336c75f4e6aSPablo de Lara 337c75f4e6aSPablo de Lara.. code-block:: console 338c75f4e6aSPablo de Lara 33930d3aa86SDavid Hunt add_channels {vm_name} {list}|all 34030d3aa86SDavid Hunt 34130d3aa86SDavid HuntEnable or disable the communication channels in ``{list}`` (comma-separated) 34230d3aa86SDavid Huntfor the specified VM. Alternatively, replace ``list`` with the keyword 34330d3aa86SDavid Hunt``all``. Disabled channels receive packets on the host. However, the commands 34430d3aa86SDavid Huntthey specify are ignored. Set the status to enabled to begin processing 34530d3aa86SDavid Huntrequests again: 34630d3aa86SDavid Hunt 34730d3aa86SDavid Hunt.. code-block:: console 34830d3aa86SDavid Hunt 34930d3aa86SDavid Hunt set_channel_status {vm_name} {list}|all enabled|disabled 35030d3aa86SDavid Hunt 35130d3aa86SDavid HuntPrint to the CLI information on the specified VM. The information lists 35230d3aa86SDavid Huntthe number of vCPUs, the pinning to pCPU(s) as a bit mask, along with 35330d3aa86SDavid Huntany communication channels associated with each VM, and the status of 35430d3aa86SDavid Hunteach channel: 35530d3aa86SDavid Hunt 35630d3aa86SDavid Hunt.. code-block:: console 35730d3aa86SDavid Hunt 35830d3aa86SDavid Hunt show_vm {vm_name} 35930d3aa86SDavid Hunt 36030d3aa86SDavid HuntSet the binding of a virtual CPU on a VM with name ``{vm_name}`` to the 36130d3aa86SDavid Huntphysical CPU mask: 36230d3aa86SDavid Hunt 36330d3aa86SDavid Hunt.. code-block:: console 36430d3aa86SDavid Hunt 36530d3aa86SDavid Hunt set_pcpu_mask {vm_name} {vcpu} {pcpu} 36630d3aa86SDavid Hunt 36730d3aa86SDavid HuntSet the binding of the virtual CPU on the VM to the physical CPU: 36830d3aa86SDavid Hunt 36930d3aa86SDavid Hunt .. code-block:: console 37030d3aa86SDavid Hunt 37130d3aa86SDavid Hunt set_pcpu {vm_name} {vcpu} {pcpu} 37230d3aa86SDavid Hunt 37330d3aa86SDavid HuntIt is also possible to perform manual control and inspection in relation 37430d3aa86SDavid Huntto CPU frequency scaling. 37530d3aa86SDavid Hunt 37630d3aa86SDavid HuntGet the current frequency for each core specified in the mask: 37730d3aa86SDavid Hunt 37830d3aa86SDavid Hunt.. code-block:: console 37930d3aa86SDavid Hunt 38030d3aa86SDavid Hunt show_cpu_freq_mask {mask} 38130d3aa86SDavid Hunt 38230d3aa86SDavid HuntSet the current frequency for the cores specified in ``{core_mask}`` by 38330d3aa86SDavid Huntscaling each up/down/min/max: 38430d3aa86SDavid Hunt 38530d3aa86SDavid Hunt.. code-block:: console 38630d3aa86SDavid Hunt 387c75f4e6aSPablo de Lara set_cpu_freq {core_mask} up|down|min|max 388c75f4e6aSPablo de Lara 389c75f4e6aSPablo de LaraGet the current frequency for the specified core: 390c75f4e6aSPablo de Lara 391c75f4e6aSPablo de Lara.. code-block:: console 392c75f4e6aSPablo de Lara 393c75f4e6aSPablo de Lara show_cpu_freq {core_num} 394c75f4e6aSPablo de Lara 395c75f4e6aSPablo de LaraSet the current frequency for the specified core by scaling up/down/min/max: 396c75f4e6aSPablo de Lara 397c75f4e6aSPablo de Lara.. code-block:: console 398c75f4e6aSPablo de Lara 399c75f4e6aSPablo de Lara set_cpu_freq {core_num} up|down|min|max 400c75f4e6aSPablo de Lara 40130d3aa86SDavid Hunt.. _enabling_out_of_band: 40250ac590fSDavid Hunt 40330d3aa86SDavid HuntCommand Line Options for Enabling Out-of-band Branch Ratio Monitoring 40430d3aa86SDavid Hunt~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 40550ac590fSDavid Hunt 40630d3aa86SDavid HuntThere are a couple of command line parameters for enabling the out-of-band 40730d3aa86SDavid Huntmonitoring of branch ratios on cores doing busy polling using PMDs as 408d7decefcSThomas Monjalondescribed below: 40950ac590fSDavid Hunt 41095f648ffSRory Sexton``--core-branch-ratio {list of cores}:{branch ratio for listed cores}`` 411d7decefcSThomas Monjalon Specify the list of cores to monitor the ratio of branch misses 412d7decefcSThomas Monjalon to branch hits. A tightly-polling PMD thread has a very low 413d7decefcSThomas Monjalon branch ratio, therefore the core frequency scales down to the 414d7decefcSThomas Monjalon minimum allowed value. On receiving packets, the code path changes, 415d7decefcSThomas Monjalon causing the branch ratio to increase. When the ratio goes above 416d7decefcSThomas Monjalon the ratio threshold, the core frequency scales up to the maximum 41795f648ffSRory Sexton allowed value. The specified branch-ratio is a floating point number 41895f648ffSRory Sexton that identifies the threshold at which to scale up or down for the 41995f648ffSRory Sexton elements of the core-list. If not included the default branch ratio of 42095f648ffSRory Sexton 0.01 but will need adjustment for different workloads 42150ac590fSDavid Hunt 42295f648ffSRory Sexton This parameter can be used multiple times for different sets of cores. 4233cb46d40SRory Sexton The branch ratio mechanism can also be useful for non-PMD cores and 4243cb46d40SRory Sexton hyper-threaded environments where C-States are disabled. 425a63504a9SDavid Hunt 426a63504a9SDavid Hunt 427c75f4e6aSPablo de LaraCompiling and Running the Guest Applications 428c75f4e6aSPablo de Lara-------------------------------------------- 429c75f4e6aSPablo de Lara 43030d3aa86SDavid HuntIt is possible to use the ``l3fwd-power`` application (for example) with the 43130d3aa86SDavid Hunt``vm_power_manager``. 432c75f4e6aSPablo de Lara 43330d3aa86SDavid HuntThe distribution also provides a guest CLI for validating the setup. 434c75f4e6aSPablo de Lara 43530d3aa86SDavid HuntFor both ``l3fwd-power`` and the guest CLI, the host application must use 43630d3aa86SDavid Huntthe ``add_channels`` command to monitor the channels for the VM. To do this, 43730d3aa86SDavid Huntissue the following commands in the host application: 43850ac590fSDavid Hunt 43950ac590fSDavid Hunt.. code-block:: console 44050ac590fSDavid Hunt 44150ac590fSDavid Hunt vm_power> add_vm vmname 44250ac590fSDavid Hunt vm_power> add_channels vmname all 44350ac590fSDavid Hunt vm_power> set_channel_status vmname all enabled 44450ac590fSDavid Hunt vm_power> show_vm vmname 44550ac590fSDavid Hunt 44630d3aa86SDavid HuntCompiling the Guest Application 44730d3aa86SDavid Hunt~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 448c75f4e6aSPablo de Lara 44930d3aa86SDavid HuntFor information on compiling DPDK and the sample applications in general, 45050ac590fSDavid Huntsee :doc:`compiling`. 45150ac590fSDavid Hunt 45230d3aa86SDavid HuntFor compiling and running the ``l3fwd-power`` sample application, see 45330d3aa86SDavid Hunt:doc:`l3_forward_power_man`. 45450ac590fSDavid Hunt 45530d3aa86SDavid HuntThe application is in the ``guest_cli`` subdirectory under ``vm_power_manager``. 45650ac590fSDavid Hunt 45730d3aa86SDavid HuntTo build just the ``guest_vm_power_manager`` application using ``make``, issue 45830d3aa86SDavid Huntthe following commands: 45950ac590fSDavid Hunt 46050ac590fSDavid Hunt.. code-block:: console 46150ac590fSDavid Hunt 462e2a94f9aSCiara Power cd dpdk/examples/vm_power_manager/guest_cli/ 46350ac590fSDavid Hunt make 464c75f4e6aSPablo de Lara 465e2a94f9aSCiara PowerThe resulting binary is ``dpdk/build/examples/guest_cli``. 466e0130788SDavid Hunt 46730d3aa86SDavid Hunt**Note**: This sample application conditionally links in the Jansson JSON 46830d3aa86SDavid Huntlibrary. Consequently, if you are using a multilib or cross-compile 46930d3aa86SDavid Huntenvironment, you may need to set the ``PKG_CONFIG_LIBDIR`` environmental 47030d3aa86SDavid Huntvariable to point to the relevant ``pkgconfig`` folder so that the correct 47130d3aa86SDavid Huntlibrary is linked in. 4723f04e13aSDavid Hunt 4733f04e13aSDavid HuntFor example, if you are building for a 32-bit target, you could find the 47430d3aa86SDavid Huntcorrect directory using the following find command: 4753f04e13aSDavid Hunt 4763f04e13aSDavid Hunt.. code-block:: console 4773f04e13aSDavid Hunt 4783f04e13aSDavid Hunt # find /usr -type d -name pkgconfig 4793f04e13aSDavid Hunt /usr/lib/i386-linux-gnu/pkgconfig 4803f04e13aSDavid Hunt /usr/lib/x86_64-linux-gnu/pkgconfig 4813f04e13aSDavid Hunt 4823f04e13aSDavid HuntThen use: 4833f04e13aSDavid Hunt 4843f04e13aSDavid Hunt.. code-block:: console 4853f04e13aSDavid Hunt 4863f04e13aSDavid Hunt export PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig 4873f04e13aSDavid Hunt 48830d3aa86SDavid HuntYou then use the ``make`` command as normal, which should find the 32-bit 48930d3aa86SDavid Huntversion of the library, if it installed. If not, the application builds 49030d3aa86SDavid Huntwithout the JSON interface functionality. 4913f04e13aSDavid Hunt 49230d3aa86SDavid HuntTo build just the ``vm_power_manager`` application using ``meson``/``ninja``: 493e0130788SDavid Hunt 494e0130788SDavid Hunt.. code-block:: console 495e0130788SDavid Hunt 496e2a94f9aSCiara Power cd dpdk 497*e24b8ad4SStephen Hemminger meson setup build 498e0130788SDavid Hunt cd build 499e0130788SDavid Hunt ninja 500e0130788SDavid Hunt meson configure -Dexamples=vm_power_manager/guest_cli 501e0130788SDavid Hunt ninja 502e0130788SDavid Hunt 503e2a94f9aSCiara PowerThe resulting binary is ``dpdk/build/examples/guest_cli``. 504e0130788SDavid Hunt 50530d3aa86SDavid HuntRunning the Guest Application 50630d3aa86SDavid Hunt~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 507c75f4e6aSPablo de Lara 50830d3aa86SDavid HuntThe standard EAL command line parameters are necessary: 509c75f4e6aSPablo de Lara 510c75f4e6aSPablo de Lara.. code-block:: console 511c75f4e6aSPablo de Lara 512e2a94f9aSCiara Power ./<build_dir>/examples/dpdk-vm_power_mgr [EAL options] -- [guest options] 513c75f4e6aSPablo de Lara 51430d3aa86SDavid HuntThe guest example uses a channel for each lcore enabled. For example, to 51530d3aa86SDavid Huntrun on cores 0, 1, 2 and 3: 516c75f4e6aSPablo de Lara 517c75f4e6aSPablo de Lara.. code-block:: console 518c75f4e6aSPablo de Lara 519e2a94f9aSCiara Power ./<build_dir>/examples/dpdk-guest_vm_power_mgr -l 0-3 52050ac590fSDavid Hunt 52130d3aa86SDavid Hunt.. _sending_policy: 52250ac590fSDavid Hunt 52330d3aa86SDavid HuntCommand Line Options Available When Sending a Policy to the Host 52430d3aa86SDavid Hunt~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 52550ac590fSDavid Hunt 52630d3aa86SDavid HuntOptionally, there are several command line options for a user who needs 527d7decefcSThomas Monjalonto send a power policy to the host application: 52850ac590fSDavid Hunt 529d7decefcSThomas Monjalon``--vm-name {name of guest vm}`` 530d7decefcSThomas Monjalon Allows the user to change the virtual machine name 531d7decefcSThomas Monjalon passed down to the host application using the power policy. 532d7decefcSThomas Monjalon The default is ubuntu2. 53350ac590fSDavid Hunt 534d7decefcSThomas Monjalon``--vcpu-list {list vm cores}`` 535d7decefcSThomas Monjalon A comma-separated list of cores in the VM that the user 536d7decefcSThomas Monjalon wants the host application to monitor. 537d7decefcSThomas Monjalon The list of cores in any VM starts at zero, 538d7decefcSThomas Monjalon and the host application maps these to the physical cores 539d7decefcSThomas Monjalon once the policy passes down to the host. 540d7decefcSThomas Monjalon Valid syntax includes individual cores 2,3,4, 541d7decefcSThomas Monjalon a range of cores 2-4, or a combination of both 1,3,5-7. 54250ac590fSDavid Hunt 543d7decefcSThomas Monjalon``--busy-hours {list of busy hours}`` 544d7decefcSThomas Monjalon A comma-separated list of hours in which to set the core 545d7decefcSThomas Monjalon frequency to the maximum. 546d7decefcSThomas Monjalon Valid syntax includes individual hours 2,3,4, 547d7decefcSThomas Monjalon a range of hours 2-4, or a combination of both 1,3,5-7. 548d7decefcSThomas Monjalon Valid hour values are 0 to 23. 54950ac590fSDavid Hunt 550d7decefcSThomas Monjalon``--quiet-hours {list of quiet hours}`` 551d7decefcSThomas Monjalon A comma-separated list of hours in which to set the core frequency 552d7decefcSThomas Monjalon to minimum. Valid syntax includes individual hours 2,3,4, 553d7decefcSThomas Monjalon a range of hours 2-4, or a combination of both 1,3,5-7. 554d7decefcSThomas Monjalon Valid hour values are 0 to 23. 55550ac590fSDavid Hunt 556d7decefcSThomas Monjalon``--policy {policy type}`` 557d7decefcSThomas Monjalon The type of policy. This can be one of the following values: 55850ac590fSDavid Hunt 559d7decefcSThomas Monjalon - TRAFFIC - Based on incoming traffic rates on the NIC. 560d7decefcSThomas Monjalon - TIME - Uses a busy/quiet hours policy. 561d7decefcSThomas Monjalon - BRANCH_RATIO - Uses branch ratio counters to determine core busyness. 562d7decefcSThomas Monjalon - WORKLOAD - Sets the frequency to low, medium or high 563d7decefcSThomas Monjalon based on the received policy setting. 56450ac590fSDavid Hunt 565d7decefcSThomas Monjalon **Note**: Not all policy types need all parameters. 566d7decefcSThomas Monjalon For example, BRANCH_RATIO only needs the vcpu-list parameter. 56750ac590fSDavid Hunt 56830d3aa86SDavid HuntAfter successful initialization, the VM Power Manager Guest CLI prompt 56930d3aa86SDavid Huntappears: 570c75f4e6aSPablo de Lara 571c75f4e6aSPablo de Lara.. code-block:: console 572c75f4e6aSPablo de Lara 573c75f4e6aSPablo de Lara vm_power(guest)> 574c75f4e6aSPablo de Lara 57530d3aa86SDavid HuntTo change the frequency of an lcore, use a ``set_cpu_freq`` command similar 57630d3aa86SDavid Huntto the following: 577c75f4e6aSPablo de Lara 578c75f4e6aSPablo de Lara.. code-block:: console 579c75f4e6aSPablo de Lara 580c75f4e6aSPablo de Lara set_cpu_freq {core_num} up|down|min|max 58150ac590fSDavid Hunt 58230d3aa86SDavid Huntwhere, ``{core_num}`` is the lcore and channel to change frequency by 58330d3aa86SDavid Huntscaling up/down/min/max. 58430d3aa86SDavid Hunt 58530d3aa86SDavid HuntTo start an application, configure the power policy, and send it to the 58630d3aa86SDavid Hunthost, use a command like the following: 58730d3aa86SDavid Hunt 58830d3aa86SDavid Hunt.. code-block:: console 58930d3aa86SDavid Hunt 590e2a94f9aSCiara Power ./<build_dir>/examples/dpdk-guest_vm_power_mgr -l 0-3 -n 4 -- --vm-name=ubuntu --policy=BRANCH_RATIO --vcpu-list=2-4 59130d3aa86SDavid Hunt 59230d3aa86SDavid HuntOnce the VM Power Manager Guest CLI appears, issuing the 'send_policy now' command 59330d3aa86SDavid Huntwill send the policy to the host: 59430d3aa86SDavid Hunt 59530d3aa86SDavid Hunt.. code-block:: console 59630d3aa86SDavid Hunt 59730d3aa86SDavid Hunt send_policy now 59830d3aa86SDavid Hunt 59930d3aa86SDavid HuntOnce the policy is sent to the host, the host application takes over the power monitoring 60030d3aa86SDavid Huntof the specified cores in the policy. 60130d3aa86SDavid Hunt 60230d3aa86SDavid Hunt.. _power_man_requests: 60330d3aa86SDavid Hunt 60430d3aa86SDavid HuntJSON Interface for Power Management Requests and Policies 60530d3aa86SDavid Hunt--------------------------------------------------------- 60630d3aa86SDavid Hunt 60730d3aa86SDavid HuntIn addition to the command line interface for the host command, and a 60830d3aa86SDavid Hunt``virtio-serial`` interface for VM power policies, there is also a JSON 60930d3aa86SDavid Huntinterface through which power commands and policies can be sent. 61030d3aa86SDavid Hunt 61130d3aa86SDavid Hunt**Note**: This functionality adds a dependency on the Jansson library. 61230d3aa86SDavid HuntInstall the Jansson development package on the system to avail of the 61330d3aa86SDavid HuntJSON parsing functionality in the app. Issue the ``apt-get install 61430d3aa86SDavid Huntlibjansson-dev`` command to install the development package. The command 61530d3aa86SDavid Huntand package name may be different depending on your operating system. It 61630d3aa86SDavid Huntis worth noting that the app builds successfully if this package is not 61730d3aa86SDavid Huntpresent, but a warning displays during compilation, and the JSON parsing 61830d3aa86SDavid Huntfunctionality is not present in the app. 61930d3aa86SDavid Hunt 62030d3aa86SDavid HuntSend a request or policy to the VM Power Manager by simply opening a 62130d3aa86SDavid Huntfifo file at ``/tmp/powermonitor/fifo``, writing a JSON string to that file, 62230d3aa86SDavid Huntand closing the file. 62330d3aa86SDavid Hunt 62430d3aa86SDavid HuntThe JSON string can be a power management request or a policy, and takes 62530d3aa86SDavid Huntthe following format: 62630d3aa86SDavid Hunt 62730d3aa86SDavid Hunt.. code-block:: javascript 62830d3aa86SDavid Hunt 62930d3aa86SDavid Hunt {"packet_type": { 63030d3aa86SDavid Hunt "pair_1": value, 63130d3aa86SDavid Hunt "pair_2": value 63230d3aa86SDavid Hunt }} 63330d3aa86SDavid Hunt 63430d3aa86SDavid HuntThe ``packet_type`` header can contain one of two values, depending on 63530d3aa86SDavid Huntwhether a power management request or policy is being sent. The two 63630d3aa86SDavid Huntpossible values are ``instruction`` and ``policy`` and the expected name-value 63730d3aa86SDavid Huntpairs are different depending on which type is sent. 63830d3aa86SDavid Hunt 63930d3aa86SDavid HuntThe pairs are in the format of standard JSON name-value pairs. The value 64030d3aa86SDavid Hunttype varies between the different name-value pairs, and may be integers, 64130d3aa86SDavid Huntstrings, arrays, and so on. See :ref:`json_interface_ex` 64230d3aa86SDavid Huntfor examples of policies and instructions and 64330d3aa86SDavid Hunt:ref:`json_name_value_pair` for the supported names and value types. 64430d3aa86SDavid Hunt 64530d3aa86SDavid Hunt.. _json_interface_ex: 64630d3aa86SDavid Hunt 64730d3aa86SDavid HuntJSON Interface Examples 64830d3aa86SDavid Hunt~~~~~~~~~~~~~~~~~~~~~~~ 64930d3aa86SDavid Hunt 65030d3aa86SDavid HuntThe following is an example JSON string that creates a time-profile 65130d3aa86SDavid Huntpolicy. 65230d3aa86SDavid Hunt 65330d3aa86SDavid Hunt.. code-block:: JSON 65430d3aa86SDavid Hunt 65530d3aa86SDavid Hunt {"policy": { 65630d3aa86SDavid Hunt "name": "ubuntu", 65730d3aa86SDavid Hunt "command": "create", 65830d3aa86SDavid Hunt "policy_type": "TIME", 65930d3aa86SDavid Hunt "busy_hours":[ 17, 18, 19, 20, 21, 22, 23 ], 66030d3aa86SDavid Hunt "quiet_hours":[ 2, 3, 4, 5, 6 ], 66130d3aa86SDavid Hunt "core_list":[ 11 ] 66230d3aa86SDavid Hunt }} 66330d3aa86SDavid Hunt 66430d3aa86SDavid HuntThe following is an example JSON string that removes the named policy. 66530d3aa86SDavid Hunt 66630d3aa86SDavid Hunt.. code-block:: JSON 66730d3aa86SDavid Hunt 66830d3aa86SDavid Hunt {"policy": { 66930d3aa86SDavid Hunt "name": "ubuntu", 67030d3aa86SDavid Hunt "command": "destroy", 67130d3aa86SDavid Hunt }} 67230d3aa86SDavid Hunt 67330d3aa86SDavid HuntThe following is an example JSON string for a power management request. 67430d3aa86SDavid Hunt 67530d3aa86SDavid Hunt.. code-block:: JSON 67630d3aa86SDavid Hunt 67730d3aa86SDavid Hunt {"instruction": { 67830d3aa86SDavid Hunt "name": "ubuntu", 67930d3aa86SDavid Hunt "command": "power", 68030d3aa86SDavid Hunt "unit": "SCALE_MAX", 68130d3aa86SDavid Hunt "resource_id": 10 68230d3aa86SDavid Hunt }} 68330d3aa86SDavid Hunt 6847be78d02SJosh SorefTo query the available frequencies of an lcore, use the query_cpu_freq command. 685f433878aSDavid HuntWhere {core_num} is the lcore to query. 686f433878aSDavid HuntBefore using this command, please enable responses via the set_query command on the host. 687f433878aSDavid Hunt 688f433878aSDavid Hunt.. code-block:: console 689f433878aSDavid Hunt 690f433878aSDavid Hunt query_cpu_freq {core_num}|all 691f433878aSDavid Hunt 692f433878aSDavid HuntTo query the capabilities of an lcore, use the query_cpu_caps command. 693f433878aSDavid HuntWhere {core_num} is the lcore to query. 694f433878aSDavid HuntBefore using this command, please enable responses via the set_query command on the host. 695f433878aSDavid Hunt 696f433878aSDavid Hunt.. code-block:: console 697f433878aSDavid Hunt 698f433878aSDavid Hunt query_cpu_caps {core_num}|all 699f433878aSDavid Hunt 70050ac590fSDavid HuntTo start the application and configure the power policy, and send it to the host: 70150ac590fSDavid Hunt 70250ac590fSDavid Hunt.. code-block:: console 70350ac590fSDavid Hunt 704e2a94f9aSCiara Power ./<build_dir>/examples/dpdk-guest_vm_power_mgr -l 0-3 -n 4 -- --vm-name=ubuntu --policy=BRANCH_RATIO --vcpu-list=2-4 70550ac590fSDavid Hunt 70650ac590fSDavid HuntOnce the VM Power Manager Guest CLI appears, issuing the 'send_policy now' command 70750ac590fSDavid Huntwill send the policy to the host: 70850ac590fSDavid Hunt 70950ac590fSDavid Hunt.. code-block:: console 71050ac590fSDavid Hunt 71150ac590fSDavid Hunt send_policy now 71250ac590fSDavid Hunt 71350ac590fSDavid HuntOnce the policy is sent to the host, the host application takes over the power monitoring 71450ac590fSDavid Huntof the specified cores in the policy. 71530d3aa86SDavid Hunt 71630d3aa86SDavid Hunt.. _json_name_value_pair: 71730d3aa86SDavid Hunt 71830d3aa86SDavid HuntJSON Name-value Pairs 71930d3aa86SDavid Hunt~~~~~~~~~~~~~~~~~~~~~ 72030d3aa86SDavid Hunt 72130d3aa86SDavid HuntThe following are the name-value pairs supported by the JSON interface: 72230d3aa86SDavid Hunt 72330d3aa86SDavid Hunt- `avg_packet_thresh`_ 72430d3aa86SDavid Hunt- `busy_hours`_ 72530d3aa86SDavid Hunt- `command`_ 72630d3aa86SDavid Hunt- `core_list`_ 72730d3aa86SDavid Hunt- `mac_list`_ 72830d3aa86SDavid Hunt- `max_packet_thresh`_ 72930d3aa86SDavid Hunt- `name`_ 73030d3aa86SDavid Hunt- `policy_type`_ 73130d3aa86SDavid Hunt- `quiet_hours`_ 73230d3aa86SDavid Hunt- `resource_id`_ 73330d3aa86SDavid Hunt- `unit`_ 73430d3aa86SDavid Hunt- `workload`_ 73530d3aa86SDavid Hunt 73630d3aa86SDavid Huntavg_packet_thresh 73730d3aa86SDavid Hunt^^^^^^^^^^^^^^^^^ 73830d3aa86SDavid Hunt 739d7decefcSThomas MonjalonDescription 740d7decefcSThomas Monjalon The threshold below which the frequency is set to the minimum value 741d7decefcSThomas Monjalon for the TRAFFIC policy. 742d7decefcSThomas Monjalon If the traffic rate is above this value and below the maximum value, 743d7decefcSThomas Monjalon the frequency is set to medium. 744d7decefcSThomas MonjalonType 745d7decefcSThomas Monjalon integer 746d7decefcSThomas MonjalonValues 747d7decefcSThomas Monjalon The number of packets below which the TRAFFIC policy applies 748d7decefcSThomas Monjalon the minimum frequency, or the medium frequency 749d7decefcSThomas Monjalon if between the average and maximum thresholds. 750d7decefcSThomas MonjalonRequired 751d7decefcSThomas Monjalon Yes 752d7decefcSThomas MonjalonExample 753d7decefcSThomas Monjalon ``"avg_packet_thresh": 100000`` 75430d3aa86SDavid Hunt 75530d3aa86SDavid Huntbusy_hours 75630d3aa86SDavid Hunt^^^^^^^^^^ 75730d3aa86SDavid Hunt 758d7decefcSThomas MonjalonDescription 759d7decefcSThomas Monjalon The hours of the day in which we scale up the cores for busy times. 760d7decefcSThomas MonjalonType 761d7decefcSThomas Monjalon array of integers 762d7decefcSThomas MonjalonValues 763d7decefcSThomas Monjalon An array with a list of hour values (0-23). 764d7decefcSThomas MonjalonRequired 765d7decefcSThomas Monjalon For the TIME policy only. 766d7decefcSThomas MonjalonExample 767d7decefcSThomas Monjalon ``"busy_hours":[ 17, 18, 19, 20, 21, 22, 23 ]`` 76830d3aa86SDavid Hunt 76930d3aa86SDavid Huntcommand 77030d3aa86SDavid Hunt^^^^^^^ 77130d3aa86SDavid Hunt 772d7decefcSThomas MonjalonDescription 773d7decefcSThomas Monjalon The type of packet to send to the VM Power Manager. 774d7decefcSThomas Monjalon It is possible to create or destroy a policy or send a direct command 775d7decefcSThomas Monjalon to adjust the frequency of a core, 776d7decefcSThomas Monjalon as is possible on the command line interface. 777d7decefcSThomas MonjalonType 778d7decefcSThomas Monjalon string 779d7decefcSThomas MonjalonValues 780d7decefcSThomas Monjalon Possible values are: 78130d3aa86SDavid Hunt - CREATE: Create a new policy. 78230d3aa86SDavid Hunt - DESTROY: Remove an existing policy. 78330d3aa86SDavid Hunt - POWER: Send an immediate command, max, min, and so on. 784d7decefcSThomas MonjalonRequired 785d7decefcSThomas Monjalon Yes 786d7decefcSThomas MonjalonExample 787d7decefcSThomas Monjalon ``"command": "CREATE"`` 78830d3aa86SDavid Hunt 78930d3aa86SDavid Huntcore_list 79030d3aa86SDavid Hunt^^^^^^^^^ 79130d3aa86SDavid Hunt 792d7decefcSThomas MonjalonDescription 793d7decefcSThomas Monjalon The cores to which to apply a policy. 794d7decefcSThomas MonjalonType 795d7decefcSThomas Monjalon array of integers 796d7decefcSThomas MonjalonValues 797d7decefcSThomas Monjalon An array with a list of virtual CPUs. 798d7decefcSThomas MonjalonRequired 799d7decefcSThomas Monjalon For CREATE/DESTROY policy requests only. 800d7decefcSThomas MonjalonExample 801d7decefcSThomas Monjalon ``"core_list":[ 10, 11 ]`` 80230d3aa86SDavid Hunt 80330d3aa86SDavid Huntmac_list 80430d3aa86SDavid Hunt^^^^^^^^ 80530d3aa86SDavid Hunt 806d7decefcSThomas MonjalonDescription 807d7decefcSThomas Monjalon When the policy is of type TRAFFIC, 808d7decefcSThomas Monjalon it is necessary to specify the MAC addresses that the host must monitor. 809d7decefcSThomas MonjalonType 810d7decefcSThomas Monjalon array of strings 811d7decefcSThomas MonjalonValues 812d7decefcSThomas Monjalon An array with a list of MAC address strings. 813d7decefcSThomas MonjalonRequired 814d7decefcSThomas Monjalon For TRAFFIC policy types only. 815d7decefcSThomas MonjalonExample 816d7decefcSThomas Monjalon ``"mac_list":[ "de:ad:be:ef:01:01","de:ad:be:ef:01:02" ]`` 81730d3aa86SDavid Hunt 81830d3aa86SDavid Huntmax_packet_thresh 81930d3aa86SDavid Hunt^^^^^^^^^^^^^^^^^ 82030d3aa86SDavid Hunt 821d7decefcSThomas MonjalonDescription 822d7decefcSThomas Monjalon In a policy of type TRAFFIC, 823d7decefcSThomas Monjalon the threshold value above which the frequency is set to a maximum. 824d7decefcSThomas MonjalonType 825d7decefcSThomas Monjalon integer 826d7decefcSThomas MonjalonValues 827d7decefcSThomas Monjalon The number of packets per interval above which 828d7decefcSThomas Monjalon the TRAFFIC policy applies the maximum frequency. 829d7decefcSThomas MonjalonRequired 830d7decefcSThomas Monjalon For the TRAFFIC policy only. 831d7decefcSThomas MonjalonExample 832d7decefcSThomas Monjalon ``"max_packet_thresh": 500000`` 83330d3aa86SDavid Hunt 83430d3aa86SDavid Huntname 83530d3aa86SDavid Hunt^^^^ 83630d3aa86SDavid Hunt 837d7decefcSThomas MonjalonDescription 838d7decefcSThomas Monjalon The name of the VM or host. 839d7decefcSThomas Monjalon Allows the parser to associate the policy with the relevant VM or host OS. 840d7decefcSThomas MonjalonType 841d7decefcSThomas Monjalon string 842d7decefcSThomas MonjalonValues 843d7decefcSThomas Monjalon Any valid string. 844d7decefcSThomas MonjalonRequired 845d7decefcSThomas Monjalon Yes 846d7decefcSThomas MonjalonExample 847d7decefcSThomas Monjalon ``"name": "ubuntu2"`` 84830d3aa86SDavid Hunt 84930d3aa86SDavid Huntpolicy_type 85030d3aa86SDavid Hunt^^^^^^^^^^^ 85130d3aa86SDavid Hunt 852d7decefcSThomas MonjalonDescription 853d7decefcSThomas Monjalon The type of policy to apply. 854d7decefcSThomas Monjalon See the ``--policy`` option description for more information. 855d7decefcSThomas MonjalonType 856d7decefcSThomas Monjalon string 857d7decefcSThomas MonjalonValues 858d7decefcSThomas Monjalon Possible values are: 85930d3aa86SDavid Hunt 860d7decefcSThomas Monjalon - TIME: Time-of-day policy. 861d7decefcSThomas Monjalon Scale the frequencies of the relevant cores up/down 862d7decefcSThomas Monjalon depending on busy and quiet hours. 863d7decefcSThomas Monjalon - TRAFFIC: Use statistics from the NIC and scale up and down accordingly. 864d7decefcSThomas Monjalon - WORKLOAD: Determine how heavily loaded the cores are 865d7decefcSThomas Monjalon and scale up and down accordingly. 866d7decefcSThomas Monjalon - BRANCH_RATIO: An out-of-band policy that looks at the ratio 867d7decefcSThomas Monjalon between branch hits and misses on a core 868d7decefcSThomas Monjalon and uses that information to determine how much packet processing 869d7decefcSThomas Monjalon a core is doing. 87030d3aa86SDavid Hunt 871d7decefcSThomas MonjalonRequired 872d7decefcSThomas Monjalon For ``CREATE`` and ``DESTROY`` policy requests only. 873d7decefcSThomas MonjalonExample 874d7decefcSThomas Monjalon ``"policy_type": "TIME"`` 87530d3aa86SDavid Hunt 87630d3aa86SDavid Huntquiet_hours 87730d3aa86SDavid Hunt^^^^^^^^^^^ 87830d3aa86SDavid Hunt 879d7decefcSThomas MonjalonDescription 880d7decefcSThomas Monjalon The hours of the day to scale down the cores for quiet times. 881d7decefcSThomas MonjalonType 882d7decefcSThomas Monjalon array of integers 883d7decefcSThomas MonjalonValues 884d7decefcSThomas Monjalon An array with a list of hour numbers with values in the range 0 to 23. 885d7decefcSThomas MonjalonRequired 886d7decefcSThomas Monjalon For the TIME policy only. 887d7decefcSThomas MonjalonExample 888d7decefcSThomas Monjalon ``"quiet_hours":[ 2, 3, 4, 5, 6 ]`` 88930d3aa86SDavid Hunt 89030d3aa86SDavid Huntresource_id 89130d3aa86SDavid Hunt^^^^^^^^^^^ 89230d3aa86SDavid Hunt 893d7decefcSThomas MonjalonDescription 894d7decefcSThomas Monjalon The core to which to apply a power command. 895d7decefcSThomas MonjalonType 896d7decefcSThomas Monjalon integer 897d7decefcSThomas MonjalonValues 898d7decefcSThomas Monjalon A valid core ID for the VM or host OS. 899d7decefcSThomas MonjalonRequired 900d7decefcSThomas Monjalon For the ``POWER`` instruction only. 901d7decefcSThomas MonjalonExample 902d7decefcSThomas Monjalon ``"resource_id": 10`` 90330d3aa86SDavid Hunt 90430d3aa86SDavid Huntunit 90530d3aa86SDavid Hunt^^^^ 90630d3aa86SDavid Hunt 907d7decefcSThomas MonjalonDescription 908d7decefcSThomas Monjalon The type of power operation to apply in the command. 909d7decefcSThomas MonjalonType 910d7decefcSThomas Monjalon string 911d7decefcSThomas MonjalonValues 912d7decefcSThomas Monjalon - SCALE_MAX: Scale the frequency of this core to the maximum. 91330d3aa86SDavid Hunt - SCALE_MIN: Scale the frequency of this core to the minimum. 91430d3aa86SDavid Hunt - SCALE_UP: Scale up the frequency of this core. 91530d3aa86SDavid Hunt - SCALE_DOWN: Scale down the frequency of this core. 91630d3aa86SDavid Hunt - ENABLE_TURBO: Enable Intel® Turbo Boost Technology for this core. 91730d3aa86SDavid Hunt - DISABLE_TURBO: Disable Intel® Turbo Boost Technology for this core. 918d7decefcSThomas MonjalonRequired 919d7decefcSThomas Monjalon For the ``POWER`` instruction only. 920d7decefcSThomas MonjalonExample 921d7decefcSThomas Monjalon ``"unit": "SCALE_MAX"`` 92230d3aa86SDavid Hunt 92330d3aa86SDavid Huntworkload 92430d3aa86SDavid Hunt^^^^^^^^ 92530d3aa86SDavid Hunt 926d7decefcSThomas MonjalonDescription 927d7decefcSThomas Monjalon In a policy of type WORKLOAD, 928d7decefcSThomas Monjalon it is necessary to specify how heavy the workload is. 929d7decefcSThomas MonjalonType 930d7decefcSThomas Monjalon string 931d7decefcSThomas MonjalonValues 932d7decefcSThomas Monjalon - HIGH: Scale the frequency of this core to maximum. 93330d3aa86SDavid Hunt - MEDIUM: Scale the frequency of this core to minimum. 93430d3aa86SDavid Hunt - LOW: Scale up the frequency of this core. 935d7decefcSThomas MonjalonRequired 936d7decefcSThomas Monjalon For the ``WORKLOAD`` policy only. 937d7decefcSThomas MonjalonExample 938d7decefcSThomas Monjalon ``"workload": "MEDIUM"`` 939