[v3,2/2] l3fwd-power: fix updating performance lcore parameters
diff mbox series

Message ID 7774ac413dcbe1e13c0029dd77ab7b467eb2c005.1594722597.git.anatoly.burakov@intel.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • [v3,1/2] power: fix power management env detection
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/travis-robot warning Travis build: failed
ci/checkpatch success coding style OK

Commit Message

Burakov, Anatoly July 14, 2020, 10:30 a.m. UTC
When perf-config option is specified, we are calling into the power
library even though it may not necessarily be enabled. It is
questionable whether perf-config option is even applicable to non-power
library modes, but for now, fix it just by avoiding calling into the
power library if it wasn't initialized, and assume that every lcore is
high performance core.

Fixes: e0194feb322c ("examples/l3fwd-power: add interrupt-only mode")

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: David Hunt <david.hunt@intel.com>
---
 examples/l3fwd-power/perf_core.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/examples/l3fwd-power/perf_core.c b/examples/l3fwd-power/perf_core.c
index 0a294dfcc8..4705967ea2 100644
--- a/examples/l3fwd-power/perf_core.c
+++ b/examples/l3fwd-power/perf_core.c
@@ -28,12 +28,27 @@  struct perf_lcore_params {
 static struct perf_lcore_params prf_lc_prms[MAX_LCORE_PARAMS];
 static uint16_t nb_prf_lc_prms;
 
+static int
+is_hp_core(unsigned int lcore)
+{
+	struct rte_power_core_capabilities caps;
+	int ret;
+
+	/* do we have power management enabled? */
+	if (rte_power_get_env() == PM_ENV_NOT_SET) {
+		/* there's no power management, so just mark it as high perf */
+		return 1;
+	}
+	ret = rte_power_get_capabilities(lcore, &caps);
+	return ret == 0 && caps.turbo;
+}
+
 int
 update_lcore_params(void)
 {
 	uint8_t non_perf_lcores[RTE_MAX_LCORE];
 	uint16_t nb_non_perf_lcores = 0;
-	int i, j, ret;
+	int i, j;
 
 	/* if perf-config option was not used do nothing */
 	if (nb_prf_lc_prms == 0)
@@ -42,13 +57,9 @@  update_lcore_params(void)
 	/* if high-perf-cores option was not used query every available core */
 	if (nb_hp_lcores == 0) {
 		for (i = 0; i < RTE_MAX_LCORE; i++) {
-			if (rte_lcore_is_enabled(i)) {
-				struct rte_power_core_capabilities caps;
-				ret = rte_power_get_capabilities(i, &caps);
-				if (ret == 0 && caps.turbo) {
-					hp_lcores[nb_hp_lcores] = i;
-					nb_hp_lcores++;
-				}
+			if (rte_lcore_is_enabled(i) && is_hp_core(i)) {
+				hp_lcores[nb_hp_lcores] = i;
+				nb_hp_lcores++;
 			}
 		}
 	}