From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
David Ahern <dsahern@gmail.com>
Subject: [PATCH 3/7] perf tools: Move TUI-specific fields to struct hist_entry_tui
Date: Mon, 20 Apr 2015 22:00:46 +0900 [thread overview]
Message-ID: <1429534850-13526-4-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1429534850-13526-1-git-send-email-namhyung@kernel.org>
Since perf diff only supports stdio output, TUI fields are only accessed
from perf report (or perf top). So add new struct hist_entry_tui and
move those fields into them. And include it as an union member.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/ui/browsers/hists.c | 52 +++++++++++++++++++++---------------------
tools/perf/util/hist.c | 4 ++--
tools/perf/util/sort.h | 20 +++++++++++-----
3 files changed, 42 insertions(+), 34 deletions(-)
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 995b7a8596b1..8b8a647be999 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -61,7 +61,7 @@ static int hist_browser__get_folding(struct hist_browser *browser)
rb_entry(nd, struct hist_entry, rb_node);
if (he->ms.unfolded)
- unfolded_rows += he->nr_rows;
+ unfolded_rows += he->tui.nr_rows;
}
return unfolded_rows;
}
@@ -288,16 +288,16 @@ static bool hist_browser__toggle_fold(struct hist_browser *browser)
struct hist_entry *he = browser->he_selection;
hist_entry__init_have_children(he);
- browser->b.nr_entries -= he->nr_rows;
- browser->nr_callchain_rows -= he->nr_rows;
+ browser->b.nr_entries -= he->tui.nr_rows;
+ browser->nr_callchain_rows -= he->tui.nr_rows;
if (he->ms.unfolded)
- he->nr_rows = callchain__count_rows(&he->sorted_chain);
+ he->tui.nr_rows = callchain__count_rows(&he->sorted_chain);
else
- he->nr_rows = 0;
+ he->tui.nr_rows = 0;
- browser->b.nr_entries += he->nr_rows;
- browser->nr_callchain_rows += he->nr_rows;
+ browser->b.nr_entries += he->tui.nr_rows;
+ browser->nr_callchain_rows += he->tui.nr_rows;
return true;
}
@@ -367,9 +367,9 @@ static void hist_entry__set_folding(struct hist_entry *he, bool unfold)
if (he->ms.has_children) {
int n = callchain__set_folding(&he->sorted_chain, unfold);
- he->nr_rows = unfold ? n : 0;
+ he->tui.nr_rows = unfold ? n : 0;
} else
- he->nr_rows = 0;
+ he->tui.nr_rows = 0;
}
static void
@@ -383,7 +383,7 @@ __hist_browser__set_folding(struct hist_browser *browser, bool unfold)
nd = rb_next(nd)) {
struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
hist_entry__set_folding(he, unfold);
- browser->nr_callchain_rows += he->nr_rows;
+ browser->nr_callchain_rows += he->tui.nr_rows;
}
}
@@ -459,7 +459,7 @@ static int hist_browser__run(struct hist_browser *browser,
browser->b.rows,
browser->b.index,
browser->b.top_idx,
- h->row_offset, h->nr_rows);
+ h->tui.row_offset, h->tui.nr_rows);
}
break;
case 'C':
@@ -742,7 +742,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
int width = browser->b.width;
char folded_sign = ' ';
bool current_entry = ui_browser__is_current_entry(&browser->b, row);
- off_t row_offset = entry->row_offset;
+ off_t row_offset = entry->tui.row_offset;
bool first = true;
struct perf_hpp_fmt *fmt;
@@ -997,7 +997,7 @@ static void ui_browser__hists_seek(struct ui_browser *browser,
* row_offset:
*/
h = rb_entry(browser->top, struct hist_entry, rb_node);
- h->row_offset = 0;
+ h->tui.row_offset = 0;
/*
* Here we have to check if nd is expanded (+), if it is we can't go
@@ -1017,12 +1017,12 @@ do_offset:
do {
h = rb_entry(nd, struct hist_entry, rb_node);
if (h->ms.unfolded) {
- u16 remaining = h->nr_rows - h->row_offset;
+ u16 remaining = h->tui.nr_rows - h->tui.row_offset;
if (offset > remaining) {
offset -= remaining;
- h->row_offset = 0;
+ h->tui.row_offset = 0;
} else {
- h->row_offset += offset;
+ h->tui.row_offset += offset;
offset = 0;
browser->top = nd;
break;
@@ -1039,21 +1039,21 @@ do_offset:
h = rb_entry(nd, struct hist_entry, rb_node);
if (h->ms.unfolded) {
if (first) {
- if (-offset > h->row_offset) {
- offset += h->row_offset;
- h->row_offset = 0;
+ if (-offset > h->tui.row_offset) {
+ offset += h->tui.row_offset;
+ h->tui.row_offset = 0;
} else {
- h->row_offset += offset;
+ h->tui.row_offset += offset;
offset = 0;
browser->top = nd;
break;
}
} else {
- if (-offset > h->nr_rows) {
- offset += h->nr_rows;
- h->row_offset = 0;
+ if (-offset > h->tui.nr_rows) {
+ offset += h->tui.nr_rows;
+ h->tui.row_offset = 0;
} else {
- h->row_offset = h->nr_rows + offset;
+ h->tui.row_offset = h->tui.nr_rows + offset;
offset = 0;
browser->top = nd;
break;
@@ -1075,7 +1075,7 @@ do_offset:
*/
h = rb_entry(nd, struct hist_entry, rb_node);
if (h->ms.unfolded)
- h->row_offset = h->nr_rows;
+ h->tui.row_offset = h->tui.nr_rows;
break;
}
first = false;
@@ -1083,7 +1083,7 @@ do_offset:
} else {
browser->top = nd;
h = rb_entry(nd, struct hist_entry, rb_node);
- h->row_offset = 0;
+ h->tui.row_offset = 0;
}
}
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index cc22b9158b93..d2fc802db26a 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1164,8 +1164,8 @@ static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h
/* force fold unfiltered entry for simplicity */
h->ms.unfolded = false;
- h->row_offset = 0;
- h->nr_rows = 0;
+ h->tui.row_offset = 0;
+ h->tui.nr_rows = 0;
hists->stats.nr_non_filtered_samples += h->stat.nr_events;
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index de3303fe726d..c4598984e366 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -70,6 +70,11 @@ struct hist_entry_diff {
};
};
+struct hist_entry_tui {
+ u16 row_offset;
+ u16 nr_rows;
+};
+
/**
* struct hist_entry - histogram entry
*
@@ -93,18 +98,21 @@ struct hist_entry {
s32 cpu;
u8 cpumode;
- struct hist_entry_diff diff;
-
/* We are added by hists__add_dummy_entry. */
bool dummy;
- /* XXX These two should move to some tree widget lib */
- u16 row_offset;
- u16 nr_rows;
-
bool init_have_children;
char level;
u8 filtered;
+ union {
+ /*
+ * Since perf diff only supports the stdio output, TUI
+ * fields are only accessed from perf report (or perf
+ * top). So make it an union to reduce memory usage.
+ */
+ struct hist_entry_diff diff;
+ struct hist_entry_tui tui;
+ };
char *srcline;
struct symbol *parent;
struct rb_root sorted_chain;
--
2.3.5
next prev parent reply other threads:[~2015-04-20 13:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-20 13:00 [PATCHSET 0/7] perf tools: Assorted cleanup for TUI (v2) Namhyung Kim
2015-04-20 13:00 ` [PATCH 1/7] perf tools: Get rid of position field from struct hist_entry Namhyung Kim
2015-04-20 13:00 ` [PATCH 2/7] perf diff: Make hist_entry_diff fields union Namhyung Kim
2015-04-20 13:00 ` Namhyung Kim [this message]
2015-04-20 19:44 ` [PATCH 3/7] perf tools: Move TUI-specific fields to struct hist_entry_tui Arnaldo Carvalho de Melo
2015-04-21 6:34 ` Namhyung Kim
2015-04-20 13:00 ` [PATCH 4/7] perf tools: Move init_have_children field " Namhyung Kim
2015-04-20 13:00 ` [PATCH 5/7] perf hists browser: Fix possible memory leak Namhyung Kim
2015-04-20 13:00 ` [PATCH 6/7] perf hists browser: Split popup menu actions Namhyung Kim
2015-04-20 13:00 ` [PATCH 7/7] perf hists browser: Simplify zooming code a bit Namhyung Kim
-- strict thread matches above, loose matches on Subject: below --
2015-04-19 4:04 [PATCHSET 0/7] perf tools: Assorted cleanup for TUI (v1) Namhyung Kim
2015-04-19 4:04 ` [PATCH 3/7] perf tools: Move TUI-specific fields to struct hist_entry_tui Namhyung Kim
2015-04-20 8:20 ` Jiri Olsa
2015-04-20 12:10 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1429534850-13526-4-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome