Recent generations of the Intel® Xeon® family processors allow Turbo Boost
to be enabled/disabled on a per-core basis.

This patch set introduces additional API calls to the librte_power library
to allow users to enable/disable Turbo Boost on particular cores.

Changes in patchset v2:
   * Removed wrmsr/rdmsr functions as they were very architecture specific.
     Now using the scaling_setspeed in the sys filesystem, as this is a more
     standard cross-platform method of changing frequencies (where available).
   * Removed patch that checks for particular models of CPU, as they are no
     longer needed with the above change.
   * Added APIs to the docs.

Additionally, the use of the library is demonstrated by additions to the
vm_power_manager example application, where the new commands have been
added to allow the turbo status of cores to be changed dynamically.

Extra message types have been added to the virtio-serial channels between the
guest_vm_power_manager app and the vm_power_manager apps to demonstrate
turbo change requests from a virtual machine. In this case, the guest will
send a request to the physical host, which in turn will change the state of
the turbo status.


Usage Example:
--------------

A VM has been created using 8 CPU cores, and 8 virtio-serial channels have
been created as per-core communications channels between the host and the VM.

See: http://www.dpdk.org/doc/guides/sample_app_ug/vm_power_management.html
for more information on setting up the vm_power applications.

In the vm_power_manager app on the host, we can query these channels:
vmpower> show_vm ubuntu2

VM: 'ubuntu2', status = ACTIVE
Channels 8
  [0]: /tmp/powermonitor/ubuntu2.0, status = CONNECTED
  [1]: /tmp/powermonitor/ubuntu2.1, status = CONNECTED
  [2]: /tmp/powermonitor/ubuntu2.2, status = CONNECTED
  [3]: /tmp/powermonitor/ubuntu2.3, status = CONNECTED
  [4]: /tmp/powermonitor/ubuntu2.4, status = CONNECTED
  [5]: /tmp/powermonitor/ubuntu2.5, status = CONNECTED
  [6]: /tmp/powermonitor/ubuntu2.6, status = CONNECTED
  [7]: /tmp/powermonitor/ubuntu2.7, status = CONNECTED
Virtual CPU(s): 8
  [0]: Physical CPU Mask 0x100000
  [1]: Physical CPU Mask 0x200000
  [2]: Physical CPU Mask 0x400000
  [3]: Physical CPU Mask 0x800000
  [4]: Physical CPU Mask 0x1000000
  [5]: Physical CPU Mask 0x2000000
  [6]: Physical CPU Mask 0x4000000
  [7]: Physical CPU Mask 0x8000000

Once the VM is up and running, if we exercise all the cores on the guest, we
can use turbostat on the host to see the frequencies of the guest cores. In
this example, it's cores 20-27:

      19       0    0.01    2500    2500
      20    2498  100.00    2500    2498
      21    2498  100.00    2500    2498
      22    2498  100.00    2500    2498
      23    2498  100.00    2500    2498
      24   *2498  100.00    2500    2498
      25    2498  100.00    2500    2498
      26    2498  100.00    2500    2498
      27    2498  100.00    2500    2498
      28       0    0.01    2032    2498

We can then issue a command in the vmpower app on the guest:

vmpower(guest)> set_cpu_freq 4 enable_turbo

This command will pass a message down through virtio-serial to the host, which
will enable turbo on core 24, the underlying physical core for the guest's
4th lcore_id. We can then see the change by running turbostat on the host:

      19       0    0.01    2500    2496
      20    2498  100.00    2500    2498
      21    2498  100.00    2500    2498
      22    2498  100.00    2500    2498
      23    2498  100.00    2500    2498
      24   *3297  100.00    3300    2498
      25    2498  100.00    2500    2498
      26    2498  100.00    2500    2498
      27    2498  100.00    2500    2498
      28       0    0.01    1016    2498

Core 24 is now running at 3300MHz, whereas the remainder are still running
at 2500MHz.

We can issue a similar command in the vm_power_manager running on the host
to disable turbo on that core, but this time we use the physical core id:

vmpower> set_cpu_freq 24 disable_turbo

and we see that turbo is now disabled on that core.

      19       0    0.00    2500    2495
      20    2499  100.00    2500    2499
      21    2499  100.00    2500    2499
      22    2499  100.00    2500    2499
      23    2499  100.00    2500    2499
      24   *2499  100.00    2500    2499
      25    2499  100.00    2500    2499
      26    2499  100.00    2500    2499
      27    2499  100.00    2500    2499
      28       0    0.01    1000    2499

[1/4] lib/librte_power: add turbo boost API
[2/4] examples/vm_power_manager: add per-core turbo
[3/4] examples/vm_power_cli_guest: add per-core turbo
[4/4] doc/power: add information on per-core turbo APIs

Reply via email to