aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2013-08-14 06:04:26 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-08-14 10:42:53 -0400
commitc5885749e4ebe568cca969d43488a233e69e6454 (patch)
tree143ce6ecec02d49bc1d1cb1bf644c13bc996ea31
parent309b5185047c5309bbc576025f6c5e257edd9f69 (diff)
perf tools: Improve robustness of topology parsing code
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>
-rw-r--r--tools/perf/util/header.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index f558f83769af..a33197a4fd21 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -716,18 +716,19 @@ static int build_cpu_topo(struct cpu_topo *tp, int cpu)
716 char filename[MAXPATHLEN]; 716 char filename[MAXPATHLEN];
717 char *buf = NULL, *p; 717 char *buf = NULL, *p;
718 size_t len = 0; 718 size_t len = 0;
719 ssize_t sret;
719 u32 i = 0; 720 u32 i = 0;
720 int ret = -1; 721 int ret = -1;
721 722
722 sprintf(filename, CORE_SIB_FMT, cpu); 723 sprintf(filename, CORE_SIB_FMT, cpu);
723 fp = fopen(filename, "r"); 724 fp = fopen(filename, "r");
724 if (!fp) 725 if (!fp)
725 return -1; 726 goto try_threads;
726
727 if (getline(&buf, &len, fp) <= 0)
728 goto done;
729 727
728 sret = getline(&buf, &len, fp);
730 fclose(fp); 729 fclose(fp);
730 if (sret <= 0)
731 goto try_threads;
731 732
732 p = strchr(buf, '\n'); 733 p = strchr(buf, '\n');
733 if (p) 734 if (p)
@@ -743,7 +744,9 @@ static int build_cpu_topo(struct cpu_topo *tp, int cpu)
743 buf = NULL; 744 buf = NULL;
744 len = 0; 745 len = 0;
745 } 746 }
747 ret = 0;
746 748
749try_threads:
747 sprintf(filename, THRD_SIB_FMT, cpu); 750 sprintf(filename, THRD_SIB_FMT, cpu);
748 fp = fopen(filename, "r"); 751 fp = fopen(filename, "r");
749 if (!fp) 752 if (!fp)