]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
perf tools: Improve robustness of topology parsing code
authorStephane Eranian <eranian@google.com>
Wed, 14 Aug 2013 10:04:26 +0000 (12:04 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 14 Aug 2013 14:42:53 +0000 (11:42 -0300)
This patch improves the robustness of the build_cpu_topo() routine by
allowing either the CPU parsing or the thread parsing to fail and yet
get perf to produce some topology data which could be useful for the
analysis.

Without this patch, if the cpu parsing fails, the thread parsing is not
attempted vice-versa.

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20130814100426.GA3444@quad
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/header.c

index f558f83769af1a7e7b9fe0780ab4c6b4793f260c..a33197a4fd21b4790191ca9f654498e0b660bced 100644 (file)
@@ -716,18 +716,19 @@ static int build_cpu_topo(struct cpu_topo *tp, int cpu)
        char filename[MAXPATHLEN];
        char *buf = NULL, *p;
        size_t len = 0;
+       ssize_t sret;
        u32 i = 0;
        int ret = -1;
 
        sprintf(filename, CORE_SIB_FMT, cpu);
        fp = fopen(filename, "r");
        if (!fp)
-               return -1;
-
-       if (getline(&buf, &len, fp) <= 0)
-               goto done;
+               goto try_threads;
 
+       sret = getline(&buf, &len, fp);
        fclose(fp);
+       if (sret <= 0)
+               goto try_threads;
 
        p = strchr(buf, '\n');
        if (p)
@@ -743,7 +744,9 @@ static int build_cpu_topo(struct cpu_topo *tp, int cpu)
                buf = NULL;
                len = 0;
        }
+       ret = 0;
 
+try_threads:
        sprintf(filename, THRD_SIB_FMT, cpu);
        fp = fopen(filename, "r");
        if (!fp)