[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140709221933.GF20938@krava.redhat.com>
Date: Thu, 10 Jul 2014 00:19:33 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Andi Kleen <andi@...stfloor.org>
Cc: linux-kernel@...r.kernel.org, namhyung@...nel.org,
acme@...radead.org, Andi Kleen <ak@...ux.intel.com>
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@...ux.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists