Skip to content

Commit

Permalink
perf top: Remove redundant perf_top->sym_counter
Browse files Browse the repository at this point in the history
We can get that counter index from perf_top->sym_evsel->idx instead.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Mar 11, 2011
1 parent 137ee20 commit ec52d97
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,24 +515,25 @@ static void handle_keypress(struct perf_session *session, int c)
break;
case 'E':
if (top.evlist->nr_entries > 1) {
int counter;
fprintf(stderr, "\nAvailable events:");

list_for_each_entry(top.sym_evsel, &top.evlist->entries, node)
fprintf(stderr, "\n\t%d %s", top.sym_evsel->idx, event_name(top.sym_evsel));

prompt_integer(&top.sym_counter, "Enter details event counter");
prompt_integer(&counter, "Enter details event counter");

if (top.sym_counter >= top.evlist->nr_entries) {
if (counter >= top.evlist->nr_entries) {
top.sym_evsel = list_entry(top.evlist->entries.next, struct perf_evsel, node);
top.sym_counter = 0;
fprintf(stderr, "Sorry, no such event, using %s.\n", event_name(top.sym_evsel));
sleep(1);
break;
}
list_for_each_entry(top.sym_evsel, &top.evlist->entries, node)
if (top.sym_evsel->idx == top.sym_counter)
if (top.sym_evsel->idx == counter)
break;
} else top.sym_counter = 0;
} else
top.sym_evsel = list_entry(top.evlist->entries.next, struct perf_evsel, node);
break;
case 'f':
prompt_integer(&top.count_filter, "Enter display event count filter");
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/top.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ float perf_top__decay_samples(struct perf_top *top, struct rb_root *root)
{
struct sym_entry *syme, *n;
float sum_ksamples = 0.0;
int snap = !top->display_weighted ? top->sym_counter : 0, j;
int snap = !top->display_weighted ? top->sym_evsel->idx : 0, j;

/* Sort the active symbols */
pthread_mutex_lock(&top->active_symbols_lock);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/top.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct perf_top {
u64 exact_samples;
u64 guest_us_samples, guest_kernel_samples;
int print_entries, count_filter, delay_secs;
int display_weighted, freq, rb_entries, sym_counter;
int display_weighted, freq, rb_entries;
pid_t target_pid, target_tid;
bool hide_kernel_symbols, hide_user_symbols, zero;
const char *cpu_list;
Expand Down

0 comments on commit ec52d97

Please sign in to comment.