Re: [PATCH] PowerPC: Remove trailing comma in cpu_name.
William Cohen <[email protected]>
| Newsgroups | gmane.linux.oprofile |
|---|---|
| Message-ID | <[email protected]> |
On 03/16/2018 03:54 PM, Carl Love wrote: > OProfile maintainers: > > A recent kernel for a Power 9 platform has the following entry in > /proc/cpuinfo for the cpu, "POWER9, altivec supported". The comma > after the name POWER9 is being returned as part of the CPU type string > by the function _get_cpuinfo_cpu_type_line in op_cpu_type.c. This > results in the call to op_get_cpu_number() in the Power specific > function _get_ppc64_cpu_type() to not find the processor type. The net > effect is operf and ophelp exit on an invalid CPU type. The following > patch removes any trailing commas in the Power processor cpu name. > > The patch has been tested on a Power 8LE and a Power9 system. > > Please let me know if the patch is acceptable. Thanks. > > Carl Love > > > ---------------------------------------- > PowerPC: Remove trailing comma in cpu_name. > > The processor type for some Power 9 systems had a comma after POWER9. > Remove the comma before returning the string for the CPU. > --- > libop/op_cpu_type.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c > index feea948..e96360f 100644 > --- a/libop/op_cpu_type.c > +++ b/libop/op_cpu_type.c > @@ -171,6 +171,11 @@ static char * _get_cpuinfo_cpu_type_line(char * buf, int len, const char * prefi > } > } > > + /* Remove comma the end of the name if it exists. */ > + end = buf; > + if (*(--end) == ',') > + *(--buf) = '\0'; > + > fclose(fp); > return ret; > } Hi Carl, Would it be clearer fold this comma removal into the existing loops for trimming trailing white space? Or are there cases where the might be a ',' somewhere other than the end of the buffer? Something like the the attached. It compiles, but has not been tested. -Will ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ oprofile-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/oprofile-list
oprofile-cpuinfo-comma.patch
(text/x-patch, 853 B)
diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c
index feea9487..fb66754e 100644
--- a/libop/op_cpu_type.c
+++ b/libop/op_cpu_type.c
@@ -154,17 +154,17 @@ static char * _get_cpuinfo_cpu_type_line(char * buf, int len, const char * prefi
/* if token param 0 then read the whole line else
* first token only. */
if (token == 0) {
- /* Trim trailing whitespace */
+ /* Trim trailing whitespace and comma */
end = buf + strlen(buf) - 1;
- while (isspace(*end))
+ while (isspace(*end) || *end==',')
--end;
*(++end) = '\0';
break;
} else {
/* Scan ahead to the end of the token */
- while (*buf && !isspace(*buf))
+ while (*buf && !(isspace(*buf) || *buf==','))
++buf;
- /* Trim trailing whitespace */
+ /* Trim trailing whitespace and comma */
*buf = '\0';
break;
}