Skip to content

Commit

Permalink
perf hists: Introduce function for deleting/removing hist_entry
Browse files Browse the repository at this point in the history
The code being used when decaying and deleting entries from a hists
instance was the same, provide a function to avoid code dup.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-j6ideab7lkakavfvfguw858z@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 21, 2015
1 parent 6733d1b commit 956b65e
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions tools/perf/util/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
return he->stat.period == 0;
}

static void hists__delete_entry(struct hists *hists, struct hist_entry *he)
{
rb_erase(&he->rb_node, &hists->entries);

if (sort__need_collapse)
rb_erase(&he->rb_node_in, &hists->entries_collapsed);

--hists->nr_entries;
if (!he->filtered)
--hists->nr_non_filtered_entries;

hist_entry__delete(he);
}

void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel)
{
struct rb_node *next = rb_first(&hists->entries);
Expand All @@ -258,16 +272,7 @@ void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel)
(zap_kernel && n->level != '.') ||
hists__decay_entry(hists, n)) &&
!n->used) {
rb_erase(&n->rb_node, &hists->entries);

if (sort__need_collapse)
rb_erase(&n->rb_node_in, &hists->entries_collapsed);

--hists->nr_entries;
if (!n->filtered)
--hists->nr_non_filtered_entries;

hist_entry__delete(n);
hists__delete_entry(hists, n);
}
}
}
Expand All @@ -281,16 +286,7 @@ void hists__delete_entries(struct hists *hists)
n = rb_entry(next, struct hist_entry, rb_node);
next = rb_next(&n->rb_node);

rb_erase(&n->rb_node, &hists->entries);

if (sort__need_collapse)
rb_erase(&n->rb_node_in, &hists->entries_collapsed);

--hists->nr_entries;
if (!n->filtered)
--hists->nr_non_filtered_entries;

hist_entry__delete(n);
hists__delete_entry(hists, n);
}
}

Expand Down

0 comments on commit 956b65e

Please sign in to comment.