From: Maynard J. <may...@us...> - 2014-08-01 13:22:13
|
On 08/01/2014 06:16 AM, Andreas Arnez wrote: > On Thu, Jul 31 2014, Andreas Arnez wrote: > >> [...] I think I can provide you with a patch that implements >> _get_s390_cpu_type() by tomorrow. > > OK, here you go. Note that I only unit-tested the new function > _get_s390_cpu_type(), but I didn't build (and test) oprofile with this > change. Patch committed. Pretty simple. Now operf and ocount support s390. Thanks! -Maynard > > > -- >8 -- > From: Andreas Arnez <ar...@li...> > Date: Fri, 1 Aug 2014 13:12:01 +0200 > Subject: [PATCH] Determine s390 cpu type from /proc/cpuinfo. > > Signed-off-by: Andreas Arnez <ar...@li...> > --- > libop/op_cpu_type.c | 36 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > > diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c > index 055c64b..94d832f 100644 > --- a/libop/op_cpu_type.c > +++ b/libop/op_cpu_type.c > @@ -629,6 +629,39 @@ static op_cpu _get_mips_cpu_type(void) > return CPU_NO_GOOD; > } > > +static op_cpu _get_s390_cpu_type(void) > +{ > + char line[100]; > + char *ptr; > + const char prefix[] = "machine = "; > + unsigned model; > + > + ptr = _get_cpuinfo_cpu_type_line(line, sizeof(line), "processor", 0); > + if (!ptr) > + return CPU_NO_GOOD; > + > + ptr = strstr(ptr, prefix); > + if (!ptr) > + return CPU_NO_GOOD; > + > + ptr += sizeof(prefix) - 1; > + if (sscanf(ptr, "%u", &model) != 1) > + return CPU_NO_GOOD; > + > + switch (model) { > + case 2097: > + case 2098: > + return CPU_S390_Z10; > + case 2817: > + case 2818: > + return CPU_S390_Z196; > + case 2827: > + case 2828: > + return CPU_S390_ZEC12; > + } > + return CPU_NO_GOOD; > +} > + > static op_cpu __get_cpu_type_alt_method(void) > { > struct utsname uname_info; > @@ -654,6 +687,9 @@ static op_cpu __get_cpu_type_alt_method(void) > if (strncmp(uname_info.machine, "mips", 4) == 0) { > return _get_mips_cpu_type(); > } > + if (strncmp(uname_info.machine, "s390", 4) == 0) { > + return _get_s390_cpu_type(); > + } > return CPU_NO_GOOD; > } > |