lkml.org 
[lkml]   [2014]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 06/11] perf, tools: Automatically look for event file name for cpu
From
Date
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




\
 
 \ /
  Last update: 2014-07-18 09:21    [W:0.268 / U:1.684 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site