Messages in this thread | | | Subject | Re: [PATCH 06/11] perf, tools: Automatically look for event file name for cpu | From | Michael Ellerman <> | Date | Fri, 18 Jul 2014 16:43:15 +1000 |
| |
On Fri, 2014-07-11 at 16:59 -0700, Andi Kleen wrote: > From: Andi Kleen <ak@linux.intel.com> > > When no JSON event file is specified automatically look > for a suitable file in ~/.cache/pmu-events. A "perf download" can > automatically add files there for the current CPUs. ...
> diff --git a/tools/perf/arch/x86/util/header.c b/tools/perf/arch/x86/util/header.c > index 146d12a..76e0ece 100644 > --- a/tools/perf/arch/x86/util/header.c > +++ b/tools/perf/arch/x86/util/header.c > @@ -57,3 +58,15 @@ get_cpuid(char *buffer, size_t sz) > } > return -1; > } > + > +int get_cpuid(char *buffer, size_t sz) > +{ > + return __get_cpuid(buffer, sz, "%s,%u,%u,%u$"); > +} > + > +char *get_cpu_str(void) > +{ > + char *buf = malloc(128);
I realise malloc failure is unlikely, but it's not impossible right?
Seems like it'd be cleaner if the caller allocated the buffer.
> + __get_cpuid(buf, 128, "%s-%d-%X-core"); > + return buf; > +}
cheers
| |