lkml.org 
[lkml]   [2014]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2014-07-10 01:01    [W:0.218 / U:18.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site