DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
To: <david.hunt@intel.com>, <anatoly.burakov@intel.com>,
	<thomas@monjalon.net>, <ferruh.yigit@amd.com>,
	<david.marchand@redhat.com>
Cc: <dev@dpdk.org>
Subject: [RFC PATCH 2/2] test/power: fix power library with --lcores
Date: Wed, 24 Jul 2024 13:03:36 +0000	[thread overview]
Message-ID: <20240724130336.1076462-2-sivaprasad.tummala@amd.com> (raw)
In-Reply-To: <20240724130336.1076462-1-sivaprasad.tummala@amd.com>

When user request to use lcores mapped to different physical
cores using --lcores eal option, power application accesses
incorrect cpu sysfs attribute for checking current frequency

The patch fixes the cpu_id based on the lcore and cpu mappings.

Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
---
 app/test/test_power_cpufreq.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index 619b2811c6..63d13614df 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -9,6 +9,7 @@
 #include <string.h>
 #include <inttypes.h>
 #include <rte_cycles.h>
+#include <rte_lcore.h>
 
 #include "test.h"
 
@@ -46,9 +47,10 @@ test_power_caps(void)
 
 static uint32_t total_freq_num;
 static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];
+static uint32_t cpu_id;
 
 static int
-check_cur_freq(unsigned int lcore_id, uint32_t idx, bool turbo)
+check_cur_freq(__rte_unused unsigned int lcore_id, uint32_t idx, bool turbo)
 {
 #define TEST_POWER_CONVERT_TO_DECIMAL 10
 #define MAX_LOOP 100
@@ -62,13 +64,13 @@ check_cur_freq(unsigned int lcore_id, uint32_t idx, bool turbo)
 	int i;
 
 	if (snprintf(fullpath, sizeof(fullpath),
-		TEST_POWER_SYSFILE_CPUINFO_FREQ, lcore_id) < 0) {
+		TEST_POWER_SYSFILE_CPUINFO_FREQ, cpu_id) < 0) {
 		return 0;
 	}
 	f = fopen(fullpath, "r");
 	if (f == NULL) {
 		if (snprintf(fullpath, sizeof(fullpath),
-			TEST_POWER_SYSFILE_SCALING_FREQ, lcore_id) < 0) {
+			TEST_POWER_SYSFILE_SCALING_FREQ, cpu_id) < 0) {
 			return 0;
 		}
 		f = fopen(fullpath, "r");
@@ -497,6 +499,20 @@ test_power_cpufreq(void)
 {
 	int ret = -1;
 	enum power_management_env env;
+	rte_cpuset_t lcore_cpus;
+
+	lcore_cpus = rte_lcore_cpuset(TEST_POWER_LCORE_ID);
+	if (CPU_COUNT(&lcore_cpus) != 1) {
+		printf("Power management doesn't support "
+				"lcore %u mapping to %u cpus\n",
+				TEST_POWER_LCORE_ID,
+				CPU_COUNT(&lcore_cpus));
+		return TEST_SKIPPED;
+	}
+	for (cpu_id = 0; cpu_id < CPU_SETSIZE; cpu_id++) {
+		if (CPU_ISSET(cpu_id, &lcore_cpus))
+			break;
+	}
 
 	/* Test initialisation of a valid lcore */
 	ret = rte_power_init(TEST_POWER_LCORE_ID);
-- 
2.34.1


  reply	other threads:[~2024-07-24 13:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-24 13:03 [RFC PATCH 1/2] power: " Sivaprasad Tummala
2024-07-24 13:03 ` Sivaprasad Tummala [this message]
2024-07-24 14:38 ` Stephen Hemminger
2024-07-24 14:39 ` Stephen Hemminger
2024-08-26 13:43   ` Tummala, Sivaprasad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240724130336.1076462-2-sivaprasad.tummala@amd.com \
    --to=sivaprasad.tummala@amd.com \
    --cc=anatoly.burakov@intel.com \
    --cc=david.hunt@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).