[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1453109064-1026-10-git-send-email-jolsa@kernel.org>
Date: Mon, 18 Jan 2016 10:24:07 +0100
From: Jiri Olsa <jolsa@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
David Ahern <dsahern@...il.com>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [PATCH 09/26] perf tools: Allocate output sort field
Currently we use static output fields, because we
have single global list of all sort/output fields.
We will add hists specific sort and output lists in
following patches, so we need all format entries to
be dynamically allocated. Adding support to allocate
output sort field.
Link: http://lkml.kernel.org/n/tip-35p3t3tqxcjbua9bhnkehady@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/ui/hist.c | 16 ++++++++++++++--
tools/perf/util/sort.c | 41 +++++++++++++++++++++++++++++++++--------
2 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index b0fcaecb7d1d..c877c52ff4bc 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -533,11 +533,23 @@ void perf_hpp__column_disable(unsigned col)
void perf_hpp__cancel_cumulate(void)
{
+ struct perf_hpp_fmt *fmt, *acc, *ovh, *tmp;
+
if (is_strict_order(field_order))
return;
- perf_hpp__column_disable(PERF_HPP__OVERHEAD_ACC);
- perf_hpp__format[PERF_HPP__OVERHEAD].name = "Overhead";
+ ovh = &perf_hpp__format[PERF_HPP__OVERHEAD];
+ acc = &perf_hpp__format[PERF_HPP__OVERHEAD_ACC];
+
+ perf_hpp__for_each_format_safe(fmt, tmp) {
+ if (acc->equal(acc, fmt)) {
+ perf_hpp__column_unregister(fmt);
+ continue;
+ }
+
+ if (ovh->equal(ovh, fmt))
+ fmt->name = "Overhead";
+ }
}
static bool fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 1b57ec9d7c2f..a4ce4807fbb7 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1576,6 +1576,19 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd)
return hse;
}
+static struct perf_hpp_fmt *__hpp_dimension__alloc_hpp(struct hpp_dimension *hd)
+{
+ struct perf_hpp_fmt *fmt;
+
+ fmt = memdup(hd->fmt, sizeof(*fmt));
+ if (fmt) {
+ INIT_LIST_HEAD(&fmt->list);
+ INIT_LIST_HEAD(&fmt->sort_list);
+ }
+
+ return fmt;
+}
+
static int __sort_dimension__add_hpp_sort(struct sort_dimension *sd)
{
struct hpp_sort_entry *hse = __sort_dimension__alloc_hpp(sd);
@@ -2065,11 +2078,17 @@ static int __sort_dimension__add(struct sort_dimension *sd)
static int __hpp_dimension__add(struct hpp_dimension *hd)
{
- if (!hd->taken) {
- hd->taken = 1;
+ struct perf_hpp_fmt *fmt;
- perf_hpp__register_sort_field(hd->fmt);
- }
+ if (hd->taken)
+ return 0;
+
+ fmt = __hpp_dimension__alloc_hpp(hd);
+ if (!fmt)
+ return -1;
+
+ hd->taken = 1;
+ perf_hpp__register_sort_field(fmt);
return 0;
}
@@ -2087,11 +2106,17 @@ static int __sort_dimension__add_output(struct sort_dimension *sd)
static int __hpp_dimension__add_output(struct hpp_dimension *hd)
{
- if (!hd->taken) {
- hd->taken = 1;
+ struct perf_hpp_fmt *fmt;
- perf_hpp__column_register(hd->fmt);
- }
+ if (hd->taken)
+ return 0;
+
+ fmt = __hpp_dimension__alloc_hpp(hd);
+ if (!fmt)
+ return -1;
+
+ hd->taken = 1;
+ perf_hpp__column_register(fmt);
return 0;
}
--
2.4.3
Powered by blists - more mailing lists