Skip to content

Commit

Permalink
power: add traffic pattern aware power control
Browse files Browse the repository at this point in the history
1. Abstract

For packet processing workloads such as DPDK polling is continuous.
This means CPU cores always show 100% busy independent of how much work
those cores are doing. It is critical to accurately determine how busy
a core is hugely important for the following reasons:

   * No indication of overload conditions.

   * User does not know how much real load is on a system, resulting
     in wasted energy as no power management is utilized.

Compared to the original l3fwd-power design, instead of going to sleep
after detecting an empty poll, the new mechanism just lowers the core
frequency. As a result, the application does not stop polling the device,
which leads to improved handling of bursts of traffic.

When the system become busy, the empty poll mechanism can also increase the
core frequency (including turbo) to do best effort for intensive traffic.
This gives us more flexible and balanced traffic awareness over the
standard l3fwd-power application.

2. Proposed solution

The proposed solution focuses on how many times empty polls are executed.
The less the number of empty polls, means current core is busy with
processing workload, therefore, the higher frequency is needed. The high
empty poll number indicates the current core not doing any real work
therefore, we can lower the frequency to safe power.

In the current implementation, each core has 1 empty-poll counter which
assume 1 core is dedicated to 1 queue. This will need to be expanded in the
future to support multiple queues per core.

2.1 Power state definition:

	LOW:  Not currently used, reserved for future use.

	MED:  the frequency is used to process modest traffic workload.

	HIGH: the frequency is used to process busy traffic workload.

2.2 There are two phases to establish the power management system:

	a.Initialization/Training phase. The training phase is necessary
	  in order to figure out the system polling baseline numbers from
	  idle to busy. The highest poll count will be during idle, where
	  all polls are empty. These poll counts will be different between
	  systems due to the many possible processor micro-arch, cache
	  and device configurations, hence the training phase.
	  In the training phase, traffic is blocked so the training
	  algorithm can average the empty-poll numbers for the LOW, MED and
	  HIGH  power states in order to create a baseline.
	  The core's counter are collected every 10ms, and the Training
	  phase will take 2 seconds.
	  Training is disabled as default configuration. The default
	  parameter is applied. Sample App still can trigger training
	  if that's needed. Once the training phase has been executed once on
	  a system, the application can then be started with the relevant
	  thresholds provided on the command line, allowing the application
	  to start passing start traffic immediately

	b.Normal phase. Traffic starts immediately based on the default
	  thresholds, or based on the user supplied thresholds via the
	  command line parameters. The run-time poll counts are compared with
	  the baseline and the decision will be taken to move to MED power
	  state or HIGH power state. The counters are calculated every 10ms.

3. Proposed  API

1.  rte_power_empty_poll_stat_init(struct ep_params **eptr,
		uint8_t *freq_tlb, struct ep_policy *policy);
which is used to initialize the power management system.
 
2.  rte_power_empty_poll_stat_free(void);
which is used to free the resource hold by power management system.
 
3.  rte_power_empty_poll_stat_update(unsigned int lcore_id);
which is used to update specific core empty poll counter, not thread safe
 
4.  rte_power_poll_stat_update(unsigned int lcore_id, uint8_t nb_pkt);
which is used to update specific core valid poll counter, not thread safe
 
5.  rte_power_empty_poll_stat_fetch(unsigned int lcore_id);
which is used to get specific core empty poll counter.
 
6.  rte_power_poll_stat_fetch(unsigned int lcore_id);
which is used to get specific core valid poll counter.

7.  rte_empty_poll_detection(struct rte_timer *tim, void *arg);
which is used to detect empty poll state changes then take action.

Signed-off-by: Liang Ma <liang.j.ma@intel.com>
Reviewed-by: Lei Yao <lei.a.yao@intel.com>
Acked-by: David Hunt <david.hunt@intel.com>
  • Loading branch information
Liang Ma authored and tmonjalo committed Oct 25, 2018
1 parent c7d93df commit 450f079
Show file tree
Hide file tree
Showing 7 changed files with 883 additions and 4 deletions.
86 changes: 86 additions & 0 deletions doc/guides/prog_guide/power_man.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,92 @@ User Cases

The power management mechanism is used to save power when performing L3 forwarding.


Empty Poll API
--------------

Abstract
~~~~~~~~

For packet processing workloads such as DPDK polling is continuous.
This means CPU cores always show 100% busy independent of how much work
those cores are doing. It is critical to accurately determine how busy
a core is hugely important for the following reasons:

* No indication of overload conditions
* User does not know how much real load is on a system, resulting
in wasted energy as no power management is utilized

Compared to the original l3fwd-power design, instead of going to sleep
after detecting an empty poll, the new mechanism just lowers the core frequency.
As a result, the application does not stop polling the device, which leads
to improved handling of bursts of traffic.

When the system become busy, the empty poll mechanism can also increase the core
frequency (including turbo) to do best effort for intensive traffic. This gives
us more flexible and balanced traffic awareness over the standard l3fwd-power
application.


Proposed Solution
~~~~~~~~~~~~~~~~~
The proposed solution focuses on how many times empty polls are executed.
The less the number of empty polls, means current core is busy with processing
workload, therefore, the higher frequency is needed. The high empty poll number
indicates the current core not doing any real work therefore, we can lower the
frequency to safe power.

In the current implementation, each core has 1 empty-poll counter which assume
1 core is dedicated to 1 queue. This will need to be expanded in the future to
support multiple queues per core.

Power state definition:
^^^^^^^^^^^^^^^^^^^^^^^

* LOW: Not currently used, reserved for future use.

* MED: the frequency is used to process modest traffic workload.

* HIGH: the frequency is used to process busy traffic workload.

There are two phases to establish the power management system:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Training phase. This phase is used to measure the optimal frequency
change thresholds for a given system. The thresholds will differ from
system to system due to differences in processor micro-architecture,
cache and device configurations.
In this phase, the user must ensure that no traffic can enter the
system so that counts can be measured for empty polls at low, medium
and high frequencies. Each frequency is measured for two seconds.
Once the training phase is complete, the threshold numbers are
displayed, and normal mode resumes, and traffic can be allowed into
the system. These threshold number can be used on the command line
when starting the application in normal mode to avoid re-training
every time.

* Normal phase. Every 10ms the run-time counters are compared
to the supplied threshold values, and the decision will be made
whether to move to a different power state (by adjusting the
frequency).

API Overview for Empty Poll Power Management
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* **State Init**: initialize the power management system.

* **State Free**: free the resource hold by power management system.

* **Update Empty Poll Counter**: update the empty poll counter.

* **Update Valid Poll Counter**: update the valid poll counter.

* **Set the Fequence Index**: update the power state/frequency mapping.

* **Detect empty poll state change**: empty poll state change detection algorithm then take action.

User Cases
----------
The mechanism can applied to any device which is based on polling. e.g. NIC, FPGA.

References
----------

Expand Down
10 changes: 10 additions & 0 deletions doc/guides/rel_notes/release_18_11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ New Features
collisions. In addition, the internal hashing algorithm was changed to use
partial-key hashing to improve memory efficiency and lookup performance.

* **Added Traffic Pattern Aware Power Control Library**

Added an experimental library. This extend Power Library and provide
empty_poll APIs. This feature measure how many times empty_poll are
executed per core, use the number of empty polls as a hint for system
power management.

See the :doc:`../prog_guide/power_man` section of the DPDK Programmers
Guide document for more information.

* **Added ability to switch queue deferred start flag on testpmd app.**

Added a console command to testpmd app, giving ability to switch
Expand Down
5 changes: 3 additions & 2 deletions lib/librte_power/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
LIB = librte_power.a

CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -fno-strict-aliasing
LDLIBS += -lrte_eal
LDLIBS += -lrte_eal -lrte_timer

EXPORT_MAP := rte_power_version.map

Expand All @@ -16,8 +16,9 @@ LIBABIVER := 1
# all source are stored in SRCS-y
SRCS-$(CONFIG_RTE_LIBRTE_POWER) := rte_power.c power_acpi_cpufreq.c
SRCS-$(CONFIG_RTE_LIBRTE_POWER) += power_kvm_vm.c guest_channel.c
SRCS-$(CONFIG_RTE_LIBRTE_POWER) += rte_power_empty_poll.c

# install this header file
SYMLINK-$(CONFIG_RTE_LIBRTE_POWER)-include := rte_power.h
SYMLINK-$(CONFIG_RTE_LIBRTE_POWER)-include := rte_power.h rte_power_empty_poll.h

include $(RTE_SDK)/mk/rte.lib.mk
6 changes: 4 additions & 2 deletions lib/librte_power/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ if host_machine.system() != 'linux'
build = false
endif
sources = files('rte_power.c', 'power_acpi_cpufreq.c',
'power_kvm_vm.c', 'guest_channel.c')
headers = files('rte_power.h')
'power_kvm_vm.c', 'guest_channel.c',
'rte_power_empty_poll.c')
headers = files('rte_power.h','rte_power_empty_poll.h')
deps += ['timer']
Loading

0 comments on commit 450f079

Please sign in to comment.