Messages in this thread | | | Date | Thu, 10 Jul 2014 00:19:33 +0200 | From | Jiri Olsa <> | Subject | Re: [PATCH 4/9] perf, tools: Automatically look for event file name for cpu v3 |
| |
On Fri, Jun 27, 2014 at 04:15:59PM -0700, Andi Kleen wrote: > From: Andi Kleen <ak@linux.intel.com>
SNIP
> new file mode 100644 > index 0000000..e1cd76c > --- /dev/null > +++ b/tools/perf/arch/x86/util/cpustr.c > @@ -0,0 +1,34 @@ > +#include <stdio.h> > +#include <stdlib.h> > +#include "../../util/jevents.h" > + > +char *get_cpu_str(void) > +{ > + char *line = NULL; > + size_t llen = 0; > + int found = 0, n; > + char vendor[30]; > + int model, fam; > + char *res = NULL; > + FILE *f = fopen("/proc/cpuinfo", "r"); > + > + if (!f) > + return NULL; > + while (getline(&line, &llen, f) > 0) { > + if (sscanf(line, "vendor_id : %30s", vendor) == 1) > + found++; > + else if (sscanf(line, "model : %d", &model) == 1) > + found++; > + else if (sscanf(line, "cpu family : %d", &fam) == 1) > + found++; > + if (found == 3) { > + n = asprintf(&res, "%s-%d-%X-core", vendor, fam, model); > + if (n < 0) > + res = NULL; > + break; > + } > + } > + free(line); > + fclose(f); > + return res;
we already have arch get_cpuid, which seems to do same thing via cpuid it would be nice to share those if possible
jirka
| |