mm/migrate: correct failure handling if !hugepage_migration_support()
[firefly-linux-kernel-4.4.55.git] / tools / perf / builtin-timechart.c
index db9c4c1725877f5828cb5809bc890e8662351a68..652af0b66a625305deac34b0f18ec2e5ccf1d8f0 100644 (file)
@@ -58,7 +58,8 @@ struct timechart {
                                first_time, last_time;
        bool                    power_only,
                                tasks_only,
-                               with_backtrace;
+                               with_backtrace,
+                               topology;
 };
 
 struct per_pidcomm;
@@ -487,8 +488,7 @@ static const char *cat_backtrace(union perf_event *event,
                                 * It seems the callchain is corrupted.
                                 * Discard all.
                                 */
-                               free(p);
-                               p = NULL;
+                               zfree(&p);
                                goto exit;
                        }
                        continue;
@@ -840,7 +840,6 @@ static void draw_cpu_usage(struct timechart *tchart)
                                                    sample->start_time,
                                                    sample->end_time,
                                                    p->pid,
-                                                   "sample",
                                                    c->comm,
                                                    sample->backtrace);
                                }
@@ -1077,6 +1076,18 @@ static int process_header(struct perf_file_section *section __maybe_unused,
        case HEADER_NRCPUS:
                tchart->numcpus = ph->env.nr_cpus_avail;
                break;
+
+       case HEADER_CPU_TOPOLOGY:
+               if (!tchart->topology)
+                       break;
+
+               if (svg_build_topology_map(ph->env.sibling_cores,
+                                          ph->env.nr_sibling_cores,
+                                          ph->env.sibling_threads,
+                                          ph->env.nr_sibling_threads))
+                       fprintf(stderr, "problem building topology\n");
+               break;
+
        default:
                break;
        }
@@ -1239,6 +1250,23 @@ parse_process(const struct option *opt __maybe_unused, const char *arg,
        return 0;
 }
 
+static int
+parse_highlight(const struct option *opt __maybe_unused, const char *arg,
+               int __maybe_unused unset)
+{
+       unsigned long duration = strtoul(arg, NULL, 0);
+
+       if (svg_highlight || svg_highlight_name)
+               return -1;
+
+       if (duration)
+               svg_highlight = duration;
+       else
+               svg_highlight_name = strdup(arg);
+
+       return 0;
+}
+
 int cmd_timechart(int argc, const char **argv,
                  const char *prefix __maybe_unused)
 {
@@ -1257,6 +1285,9 @@ int cmd_timechart(int argc, const char **argv,
        OPT_STRING('i', "input", &input_name, "file", "input file name"),
        OPT_STRING('o', "output", &output_name, "file", "output file name"),
        OPT_INTEGER('w', "width", &svg_page_width, "page width"),
+       OPT_CALLBACK(0, "highlight", NULL, "duration or task name",
+                     "highlight tasks. Pass duration in ns or process name.",
+                      parse_highlight),
        OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"),
        OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only,
                    "output processes data only"),
@@ -1267,6 +1298,8 @@ int cmd_timechart(int argc, const char **argv,
                    "Look for files with symbols relative to this directory"),
        OPT_INTEGER('n', "proc-num", &tchart.proc_num,
                    "min. number of tasks to print"),
+       OPT_BOOLEAN('t', "topology", &tchart.topology,
+                   "sort CPUs according to topology"),
        OPT_END()
        };
        const char * const timechart_usage[] = {