Skip to contentSkip to conversation

Fix session topology test for powerpc and add utility function to get cpuinfo entries

PATCH In review Athira Rajeev 5 participants 10 messages May 5, 2022 – May 10, 2022 perf events

lore
Share & tools
lore
#0 lore raw

v2 cover Fix session topology test for powerpc and add utility function to get cpuinfo entries

The session topology test fails in powerpc pSeries platform. Test logs:
<<>>
Session topology : FAILED!
<<>>

This test uses cpu topology information and in powerpc, some of the topology info is restricted in environment like virtualized platform. Hence this test needs to be skipped in pSeries platform for powerpc. The information about platform is available in /proc/cpuinfo.

Patch 1 adds generic utility function in "util/header.c" to read /proc/cpuinfo for any entry. Though the testcase fix needs value from "platform" entry, making this as a generic function to return value for any entry from the /proc/cpuinfo file which can be used commonly in future usecases.

Patch 2 uses the newly added utility function to look for platform and skip the test in pSeries platform for powerpc.

Athira Rajeev (2):
tools/perf: Add utility function to read /proc/cpuinfo for any field tools/perf/tests: Fix session topology test to skip the test in guest
environment

Changelog:
V1 -> v2:
Addressed review comments from Kajol.
Use "strim" to remove space from string. Also use "feof" to check for EOF instead of using new variable "ret".

 tools/perf/tests/topology.c | 17 ++++++++++++
 tools/perf/util/header.c    | 53 +++++++++++++++++++++++++++++++++++++
 tools/perf/util/header.h    |  1 +
 3 files changed, 71 insertions(+)
Signature · 1 line
2.35.1
#1 lore raw

PATCH v2 1/2 tools/perf: Add utility function to read /proc/cpuinfo for any field

/proc/cpuinfo provides information about type of processor, number of CPU's etc. Reading /proc/cpuinfo file outputs useful information by field name like cpu, platform, model (depending on architecture) and its value separated by colon.

Add new utility function "cpuinfo_field" in "util/header.c" which accepts field name as input string to search in /proc/cpuinfo content. This returns the first matching value as resulting string. Example, calling the function "cpuinfo_field(platform)" in powerpc returns the platform value. This can be used to fetch processor information from "cpuinfo" by other utilities/testcases.

---
 tools/perf/util/header.c | 53 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/header.h |  1 +
 2 files changed, 54 insertions(+)
tools/perf/util/header.c +53 -0
index a27132e5a5ef..f08857f96606 100644
@@ -983,6 +983,59 @@ static int write_dir_format(struct feat_fd *ff,
 	return do_write(ff, &data->dir.version, sizeof(data->dir.version));
 }
 
+/*
+ * Return entry from /proc/cpuinfo
+ * indicated by "search" parameter.
+ */
+char *cpuinfo_field(const char *search)
+{
+	FILE *file;
+	char *buf = NULL;
+	char *copy_buf = NULL, *p;
+	size_t len = 0;
+
+	if (!search)
+		return NULL;
+
+	file = fopen("/proc/cpuinfo", "r");
+	if (!file)
+		return NULL;
+
+	while (getline(&buf, &len, file) > 0) {
+		if (!strncmp(buf, search, strlen(search)))
+			break;
+	}
+
+	if (feof(file))
+		goto done;
+
+	/*
+	 * Trim the new line and separate
+	 * value for search field from ":"
+	 * in cpuinfo line output.
+	 * Example output line:
+	 * platform : <value>
+	 */
+	copy_buf = buf;
+	p = strchr(copy_buf, ':');
+
+	/* Go to string after ":" */
+	copy_buf = p + 1;
+	p = strchr(copy_buf, '\n');
+	if (p)
+		*p = '\0';
+
+	/* Copy the filtered string after removing space to buf */
+	strcpy(buf, strim(copy_buf));
+
+	fclose(file);
+	return buf;
+
+done:
+	free(buf);
+	fclose(file);
+	return NULL;
+}
 /*
  * Check whether a CPU is online
  *
tools/perf/util/header.h +1 -0
index 0eb4bc29a5a4..b0f754364bd4 100644
@@ -166,4 +166,5 @@ int get_cpuid(char *buffer, size_t sz);
 
 char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused);
 int strcmp_cpuid_str(const char *s1, const char *s2);
+char *cpuinfo_field(const char *search);
 #endif /* __PERF_HEADER_H */
Signature · 1 line
2.35.1
#2 lore raw

Re: [PATCH V2 1/2] tools/perf: Add utility function to read /proc/cpuinfo for any field

Em Thu, May 05, 2022 at 03:09:59PM +0530, Athira Rajeev escreveu:

Quoted 36 lines

/proc/cpuinfo provides information about type of processor, number of CPU's etc. Reading /proc/cpuinfo file outputs useful information by field name like cpu, platform, model (depending on architecture) and its value separated by colon.

Add new utility function "cpuinfo_field" in "util/header.c" which accepts field name as input string to search in /proc/cpuinfo content. This returns the first matching value as resulting string. Example, calling the function "cpuinfo_field(platform)" in powerpc returns the platform value. This can be used to fetch processor information from "cpuinfo" by other utilities/testcases.

---
 tools/perf/util/header.c | 53 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/header.h |  1 +
 2 files changed, 54 insertions(+)
tools/perf/util/header.c +10 -0
index a27132e5a5ef..f08857f96606 100644
@@ -983,6 +983,59 @@ static int write_dir_format(struct feat_fd *ff,
 	return do_write(ff, &data->dir.version, sizeof(data->dir.version));
 }
 
+/*
+ * Return entry from /proc/cpuinfo
+ * indicated by "search" parameter.
+ */
+char *cpuinfo_field(const char *search)
+{
+	FILE *file;
+	char *buf = NULL;
+	char *copy_buf = NULL, *p;
+	size_t len = 0;

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1005

Quoted 10 lines
tools/perf/util/header.c +10 -0
+
+	if (!search)
+		return NULL;
+
+	file = fopen("/proc/cpuinfo", "r");
+	if (!file)
+		return NULL;
+
+	while (getline(&buf, &len, file) > 0) {
+		if (!strncmp(buf, search, strlen(search)))

Can you save the search string lenght in a variable and use it instead of calling strlen() for the same buffer for each line in /proc/cpuinfo?

Quoted 5 lines
tools/perf/util/header.c +5 -0
+			break;
+	}
+
+	if (feof(file))
+		goto done;

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1020

Quoted 10 lines
tools/perf/util/header.c +10 -0
+
+	/*
+	 * Trim the new line and separate
+	 * value for search field from ":"
+	 * in cpuinfo line output.
+	 * Example output line:
+	 * platform : <value>
+	 */
+	copy_buf = buf;
+	p = strchr(copy_buf, ':');

So you assume that this will always be there, right? Shouldn't we not assume that and check if p is NULL and bail out instead?

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1024

Quoted 4 lines
tools/perf/util/header.c +4 -0
+
+	/* Go to string after ":" */
+	copy_buf = p + 1;
+	p = strchr(copy_buf, '\n');

Ditto.

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1034

Quoted 10 lines
tools/perf/util/header.c +10 -0
+	if (p)
+		*p = '\0';
+
+	/* Copy the filtered string after removing space to buf */
+	strcpy(buf, strim(copy_buf));
+
+	fclose(file);
+	return buf;
+
+done:

Please rename this goto label to "not_found", "done" isn't intention revealing.

Quoted 19 lines
tools/perf/util/header.c +4 -0
+	free(buf);
+	fclose(file);
+	return NULL;
+}
 /*
  * Check whether a CPU is online
  *
tools/perf/util/header.h +1 -0
index 0eb4bc29a5a4..b0f754364bd4 100644
@@ -166,4 +166,5 @@ int get_cpuid(char *buffer, size_t sz);
 
 char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused);
 int strcmp_cpuid_str(const char *s1, const char *s2);
+char *cpuinfo_field(const char *search);
 #endif /* __PERF_HEADER_H */
Signature · 1 line
2.35.1
Signature · 1 line
- Arnaldo
#3 lore raw

Re: [PATCH V2 1/2] tools/perf: Add utility function to read /proc/cpuinfo for any field

Quoted 46 lines · Arnaldo Carvalho de Melo

Em Thu, May 05, 2022 at 03:09:59PM +0530, Athira Rajeev escreveu:

Quoted 41 lines

/proc/cpuinfo provides information about type of processor, number of CPU's etc. Reading /proc/cpuinfo file outputs useful information by field name like cpu, platform, model (depending on architecture) and its value separated by colon.

Add new utility function "cpuinfo_field" in "util/header.c" which accepts field name as input string to search in /proc/cpuinfo content. This returns the first matching value as resulting string. Example, calling the function "cpuinfo_field(platform)" in powerpc returns the platform value. This can be used to fetch processor information from "cpuinfo" by other utilities/testcases.

---
tools/perf/util/header.c | 53 ++++++++++++++++++++++++++++++++++++++++ tools/perf/util/header.h | 1 +

2 files changed, 54 insertions(+)
tools/perf/util/header.c +15 -0
index a27132e5a5ef..f08857f96606 100644
@@ -983,6 +983,59 @@ static int write_dir_format(struct feat_fd *ff,
 	return do_write(ff, &data->dir.version, sizeof(data->dir.version));
 }
 
+/*
+ * Return entry from /proc/cpuinfo
+ * indicated by "search" parameter.
+ */
+char *cpuinfo_field(const char *search)
+{
+	FILE *file;
+	char *buf = NULL;
+	char *copy_buf = NULL, *p;
+	size_t len = 0;
+
+	if (!search)
+		return NULL;
+
+	file = fopen("/proc/cpuinfo", "r");
Quoted 8 lines

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1005

Quoted 5 lines
tools/perf/util/header.c +5 -0
+	if (!file)
+		return NULL;
+
+	while (getline(&buf, &len, file) > 0) {
+		if (!strncmp(buf, search, strlen(search)))

Can you save the search string lenght in a variable and use it instead of calling strlen() for the same buffer for each line in /proc/cpuinfo?

Hi Arnaldo, Michael

Thanks for review comments. Based on suggestion from Michael, I am reworking on patch 2 to SKIP the test if physical_id is set to -1 irrespective of value from cpuinfo.

In this patch, I had written "cpuinfo_field " function as generic function for retrieving any entry from /proc/cpuinfo. But it won't be used in patch 2 now. Do you think this function is useful to keep ? Otherwise, I will drop patch 1

Thanks
Athira Rajeev

Quoted 64 lines
Quoted 6 lines
tools/perf/util/header.c +5 -0
+			break;
+	}
+
+	if (feof(file))
+		goto done;

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1020

Quoted 10 lines
tools/perf/util/header.c +10 -0
+
+	/*
+	 * Trim the new line and separate
+	 * value for search field from ":"
+	 * in cpuinfo line output.
+	 * Example output line:
+	 * platform : <value>
+	 */
+	copy_buf = buf;
+	p = strchr(copy_buf, ':');

So you assume that this will always be there, right? Shouldn't we not assume that and check if p is NULL and bail out instead?

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1024

Quoted 4 lines
tools/perf/util/header.c +4 -0
+
+	/* Go to string after ":" */
+	copy_buf = p + 1;
+	p = strchr(copy_buf, '\n');

Ditto.

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1034

Quoted 10 lines
tools/perf/util/header.c +10 -0
+	if (p)
+		*p = '\0';
+
+	/* Copy the filtered string after removing space to buf */
+	strcpy(buf, strim(copy_buf));
+
+	fclose(file);
+	return buf;
+
+done:

Please rename this goto label to "not_found", "done" isn't intention revealing.

Quoted 19 lines
tools/perf/util/header.c +4 -0
+	free(buf);
+	fclose(file);
+	return NULL;
+}
 /*
 * Check whether a CPU is online
 *
tools/perf/util/header.h +1 -0
index 0eb4bc29a5a4..b0f754364bd4 100644
@@ -166,4 +166,5 @@ int get_cpuid(char *buffer, size_t sz);
 
 char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused);
 int strcmp_cpuid_str(const char *s1, const char *s2);
+char *cpuinfo_field(const char *search);
 #endif /* __PERF_HEADER_H */
Signature · 1 line
2.35.1
Signature · 1 line
- Arnaldo
#4 lore raw

Re: [PATCH V2 1/2] tools/perf: Add utility function to read /proc/cpuinfo for any field

Quoted 60 lines · Athira Rajeev
Quoted 47 lines · Arnaldo Carvalho de Melo

Em Thu, May 05, 2022 at 03:09:59PM +0530, Athira Rajeev escreveu:

Quoted 41 lines

/proc/cpuinfo provides information about type of processor, number of CPU's etc. Reading /proc/cpuinfo file outputs useful information by field name like cpu, platform, model (depending on architecture) and its value separated by colon.

Add new utility function "cpuinfo_field" in "util/header.c" which accepts field name as input string to search in /proc/cpuinfo content. This returns the first matching value as resulting string. Example, calling the function "cpuinfo_field(platform)" in powerpc returns the platform value. This can be used to fetch processor information from "cpuinfo" by other utilities/testcases.

---
tools/perf/util/header.c | 53 ++++++++++++++++++++++++++++++++++++++++ tools/perf/util/header.h | 1 +

2 files changed, 54 insertions(+)
tools/perf/util/header.c +15 -0
index a27132e5a5ef..f08857f96606 100644
@@ -983,6 +983,59 @@ static int write_dir_format(struct feat_fd *ff,
 	return do_write(ff, &data->dir.version, sizeof(data->dir.version));
 }
 
+/*
+ * Return entry from /proc/cpuinfo
+ * indicated by "search" parameter.
+ */
+char *cpuinfo_field(const char *search)
+{
+	FILE *file;
+	char *buf = NULL;
+	char *copy_buf = NULL, *p;
+	size_t len = 0;
+
+	if (!search)
+		return NULL;
+
+	file = fopen("/proc/cpuinfo", "r");
Quoted 8 lines

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1005

Quoted 5 lines
tools/perf/util/header.c +5 -0
+	if (!file)
+		return NULL;
+
+	while (getline(&buf, &len, file) > 0) {
+		if (!strncmp(buf, search, strlen(search)))

Can you save the search string lenght in a variable and use it instead of calling strlen() for the same buffer for each line in /proc/cpuinfo?

Quoted 7 lines

Hi Arnaldo, Michael

Thanks for review comments. Based on suggestion from Michael, I am reworking on patch 2 to SKIP the test if physical_id is set to -1 irrespective of value from cpuinfo.

In this patch, I had written "cpuinfo_field " function as generic function for retrieving any entry from /proc/cpuinfo. But it won't be used in patch 2 now. Do you think this function is useful to keep ? Otherwise, I will drop patch 1

Hi,

Requesting for suggestions on this change

Thanks
Athira

Quoted 68 lines

Thanks
Athira Rajeev

Quoted 64 lines
Quoted 6 lines
tools/perf/util/header.c +5 -0
+			break;
+	}
+
+	if (feof(file))
+		goto done;

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1020

Quoted 10 lines
tools/perf/util/header.c +10 -0
+
+	/*
+	 * Trim the new line and separate
+	 * value for search field from ":"
+	 * in cpuinfo line output.
+	 * Example output line:
+	 * platform : <value>
+	 */
+	copy_buf = buf;
+	p = strchr(copy_buf, ':');

So you assume that this will always be there, right? Shouldn't we not assume that and check if p is NULL and bail out instead?

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1024

Quoted 4 lines
tools/perf/util/header.c +4 -0
+
+	/* Go to string after ":" */
+	copy_buf = p + 1;
+	p = strchr(copy_buf, '\n');

Ditto.

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1034

Quoted 10 lines
tools/perf/util/header.c +10 -0
+	if (p)
+		*p = '\0';
+
+	/* Copy the filtered string after removing space to buf */
+	strcpy(buf, strim(copy_buf));
+
+	fclose(file);
+	return buf;
+
+done:

Please rename this goto label to "not_found", "done" isn't intention revealing.

Quoted 19 lines
tools/perf/util/header.c +4 -0
+	free(buf);
+	fclose(file);
+	return NULL;
+}
 /*
 * Check whether a CPU is online
 *
tools/perf/util/header.h +1 -0
index 0eb4bc29a5a4..b0f754364bd4 100644
@@ -166,4 +166,5 @@ int get_cpuid(char *buffer, size_t sz);
 
 char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused);
 int strcmp_cpuid_str(const char *s1, const char *s2);
+char *cpuinfo_field(const char *search);
 #endif /* __PERF_HEADER_H */
Signature · 1 line
2.35.1
Signature · 1 line
- Arnaldo
#5 lore raw

Re: [PATCH V2 1/2] tools/perf: Add utility function to read /proc/cpuinfo for any field

Em Tue, May 10, 2022 at 07:08:47PM +0530, Athira Rajeev escreveu:

Quoted 60 lines
Quoted 60 lines · Athira Rajeev
Quoted 55 lines · Arnaldo Carvalho de Melo

Em Thu, May 05, 2022 at 03:09:59PM +0530, Athira Rajeev escreveu:

Quoted 36 lines

/proc/cpuinfo provides information about type of processor, number of CPU's etc. Reading /proc/cpuinfo file outputs useful information by field name like cpu, platform, model (depending on architecture) and its value separated by colon.

Add new utility function "cpuinfo_field" in "util/header.c" which accepts field name as input string to search in /proc/cpuinfo content. This returns the first matching value as resulting string. Example, calling the function "cpuinfo_field(platform)" in powerpc returns the platform value. This can be used to fetch processor information from "cpuinfo" by other utilities/testcases.

---
tools/perf/util/header.c | 53 ++++++++++++++++++++++++++++++++++++++++ tools/perf/util/header.h | 1 +

2 files changed, 54 insertions(+)
tools/perf/util/header.c +10 -0
index a27132e5a5ef..f08857f96606 100644
@@ -983,6 +983,59 @@ static int write_dir_format(struct feat_fd *ff,
 	return do_write(ff, &data->dir.version, sizeof(data->dir.version));
 }
 
+/*
+ * Return entry from /proc/cpuinfo
+ * indicated by "search" parameter.
+ */
+char *cpuinfo_field(const char *search)
+{
+	FILE *file;
+	char *buf = NULL;
+	char *copy_buf = NULL, *p;
+	size_t len = 0;

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1005

Quoted 10 lines
tools/perf/util/header.c +10 -0
+
+	if (!search)
+		return NULL;
+
+	file = fopen("/proc/cpuinfo", "r");
+	if (!file)
+		return NULL;
+
+	while (getline(&buf, &len, file) > 0) {
+		if (!strncmp(buf, search, strlen(search)))

Can you save the search string lenght in a variable and use it instead of calling strlen() for the same buffer for each line in /proc/cpuinfo?

Quoted 7 lines
Quoted 7 lines

Hi Arnaldo, Michael

Thanks for review comments. Based on suggestion from Michael, I am reworking on patch 2 to SKIP the test if physical_id is set to -1 irrespective of value from cpuinfo.

In this patch, I had written "cpuinfo_field " function as generic function for retrieving any entry from /proc/cpuinfo. But it won't be used in patch 2 now. Do you think this function is useful to keep ? Otherwise, I will drop patch 1

Lets add it when the need arises.

- Arnaldo

Quoted 74 lines

Hi,

Requesting for suggestions on this change

Thanks
Athira

Quoted 68 lines

Thanks
Athira Rajeev

Quoted 64 lines
Quoted 6 lines
tools/perf/util/header.c +5 -0
+			break;
+	}
+
+	if (feof(file))
+		goto done;

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1020

Quoted 10 lines
tools/perf/util/header.c +10 -0
+
+	/*
+	 * Trim the new line and separate
+	 * value for search field from ":"
+	 * in cpuinfo line output.
+	 * Example output line:
+	 * platform : <value>
+	 */
+	copy_buf = buf;
+	p = strchr(copy_buf, ':');

So you assume that this will always be there, right? Shouldn't we not assume that and check if p is NULL and bail out instead?

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1024

Quoted 4 lines
tools/perf/util/header.c +4 -0
+
+	/* Go to string after ":" */
+	copy_buf = p + 1;
+	p = strchr(copy_buf, '\n');

Ditto.

tools/perf/util/header.c static int write_dir_format(struct feat_fd *ff, · line 1034

Quoted 10 lines
tools/perf/util/header.c +10 -0
+	if (p)
+		*p = '\0';
+
+	/* Copy the filtered string after removing space to buf */
+	strcpy(buf, strim(copy_buf));
+
+	fclose(file);
+	return buf;
+
+done:

Please rename this goto label to "not_found", "done" isn't intention revealing.

Quoted 19 lines
tools/perf/util/header.c +4 -0
+	free(buf);
+	fclose(file);
+	return NULL;
+}
 /*
 * Check whether a CPU is online
 *
tools/perf/util/header.h +1 -0
index 0eb4bc29a5a4..b0f754364bd4 100644
@@ -166,4 +166,5 @@ int get_cpuid(char *buffer, size_t sz);
 
 char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused);
 int strcmp_cpuid_str(const char *s1, const char *s2);
+char *cpuinfo_field(const char *search);
 #endif /* __PERF_HEADER_H */
Signature · 1 line
2.35.1
Signature · 1 line
- Arnaldo
Signature · 1 line
- Arnaldo
#6 lore raw

PATCH v2 2/2 tools/perf/tests: Fix session topology test to skip the test in guest environment

In reply to Athira Rajeev

The session topology test fails in powerpc pSeries platform. Test logs:
<<>>
Session topology : FAILED!
<<>>

This testcases tests cpu topology by checking the core_id and socket_id stored in perf_env from perf session. The data from perf session is compared with the cpu topology information from "/sys/devices/system/cpu/cpuX/topology" like core_id, physical_package_id. In case of virtual environment, detail like physical_package_id is restricted to be exposed. Hence physical_package_id is set to -1. The testcase fails on such platforms since socket_id can't be fetched from topology info.

Skip the testcase in powerpc for pSeries. Use the utility function "cpuinfo_field" to check platform from /proc/cpuinfo.

Results:

After the patch:
----------------

 # ./perf test 41
 41: Session topology                  : Skip
---
 tools/perf/tests/topology.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
tools/perf/tests/topology.c +17 -0
index ee1e3dcbc0bd..036143928023 100644
@@ -109,6 +109,23 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)
 			&& strncmp(session->header.env.arch, "aarch64", 7))
 		return TEST_SKIP;
 
+	/*
+	 * In powerpc pSeries platform, not all the topology information
+	 * are exposed via sysfs. Due to restriction, detail like
+	 * physical_package_id will be set to -1. Hence skip this
+	 * test for pSeries.
+	 */
+	if (strncmp(session->header.env.arch, "powerpc", 7)) {
+		char *cpuinfo_platform = NULL;
+
+		cpuinfo_platform = cpuinfo_field("platform");
+		if (cpuinfo_platform && !strcmp(cpuinfo_platform, "pSeries")) {
+			free(cpuinfo_platform);
+			return TEST_SKIP;
+		}
+		free(cpuinfo_platform);
+	}
+
 	TEST_ASSERT_VAL("Session header CPU map not set", session->header.env.cpu);
 
 	for (i = 0; i < session->header.env.nr_cpus_avail; i++) {
Signature · 1 line
2.35.1
#7 lore raw

Re: [PATCH V2 2/2] tools/perf/tests: Fix session topology test to skip the test in guest environment

Quoted 15 lines · Athira Rajeev

The session topology test fails in powerpc pSeries platform. Test logs:
<<>>
Session topology : FAILED!
<<>>

This testcases tests cpu topology by checking the core_id and socket_id stored in perf_env from perf session. The data from perf session is compared with the cpu topology information from "/sys/devices/system/cpu/cpuX/topology" like core_id, physical_package_id. In case of virtual environment, detail like physical_package_id is restricted to be exposed. Hence physical_package_id is set to -1. The testcase fails on such platforms since socket_id can't be fetched from topology info.

Quoted 2 lines

Skip the testcase in powerpc for pSeries. Use the utility function "cpuinfo_field" to check platform from /proc/cpuinfo.

I don't think that's the right way to fix it.

If we ever had a "pseries" machine that did expose physical_package_id then this test would continue to skip, even when it could succeed.

So if physical_package_id being -1 is the problem then you should skip the test based on that.

cheers

#8 lore raw
In reply to Athira Rajeev

-----Original Message-----
From: Athira Rajeev <[email protected]>
To: [email protected], [email protected], [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [PATCH V2 0/2] Fix session topology test for powerpc and add utility function to get cpuinfo entries
Date: Thu, 5 May 2022 15:09:58 +0530

The session topology test fails in powerpc pSeries platform.Test logs:<<>>Session topology : FAILED!<<>>
This test uses cpu topology information and in powerpc,some of the topology info is restricted in environmentlike virtualized platform. Hence this test needs to beskipped in pSeries platform for powerpc. The informationabout platform is available in /proc/cpuinfo. Patch 1 adds generic utility function in "util/header.c"to read /proc/cpuinfo for any entry. Though the testcasefix needs value from "platform" entry, making this as ageneric function to return value for any entry from the/proc/cpuinfo file which can be used commonly in futureusecases.
Patch 2 uses the newly added utility function to look forplatform and skip the test in pSeries platform for powerpc.
Athira Rajeev (2): tools/perf: Add utility function to read /proc/cpuinfo for any field tools/perf/tests: Fix session topology
test to skip the test in guest environment
Changelog: V1 -> v2: Addressed review comments from Kajol. Use "strim" to remove space from string. Also use "feof" to check for EOF instead of using new variable "ret".
Tested the patches on powervm and powernv, verified perf test session topology test with the patch set.Tested-by: Disha Goel < [email protected]>

 tools/perf/tests/topology.c | 17 ++++++++++++

tools/perf/util/header.c | 53 +++++++++++++++++++++++++++++++++++++
tools/perf/util/header.h | 1 + 3 files changed, 71 insertions(+)

Reviewed-by on the v2 series
#9 lore raw
In reply to Athira Rajeev
Quoted 19 lines · Athira Rajeev

The session topology test fails in powerpc pSeries platform. Test logs:
<<>>
Session topology : FAILED!
<<>>

This test uses cpu topology information and in powerpc, some of the topology info is restricted in environment like virtualized platform. Hence this test needs to be skipped in pSeries platform for powerpc. The information about platform is available in /proc/cpuinfo.

Patch 1 adds generic utility function in "util/header.c" to read /proc/cpuinfo for any entry. Though the testcase fix needs value from "platform" entry, making this as a generic function to return value for any entry from the /proc/cpuinfo file which can be used commonly in future usecases.

Quoted 7 lines

Patch 2 uses the newly added utility function to look for platform and skip the test in pSeries platform for powerpc.

Athira Rajeev (2):
tools/perf: Add utility function to read /proc/cpuinfo for any field tools/perf/tests: Fix session topology test to skip the test in guest
environment

Hi Athira,
Patchset looks good to me.

Thanks,
Kajol Jain

Quoted 13 lines

Changelog:
V1 -> v2:
Addressed review comments from Kajol.
Use "strim" to remove space from string. Also use "feof" to check for EOF instead of using new variable "ret".

 tools/perf/tests/topology.c | 17 ++++++++++++
 tools/perf/util/header.c    | 53 +++++++++++++++++++++++++++++++++++++
 tools/perf/util/header.h    |  1 +
 3 files changed, 71 insertions(+)