On Fri, Jun 27, 2014 at 04:15:59PM -0700, Andi Kleen wrote:
> From: Andi Kleen <a...@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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to