Skip to content

Commit

Permalink
perf callchains: Use thread->mg->machine
Browse files Browse the repository at this point in the history
The unwind__get_entries() already receives the thread parameter, from where it can
obtain the matching machine structure, shorten the signature.

Cc: Adrian Hunter <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Don Zickus <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jean Pihet <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Oct 29, 2014
1 parent cc8b7c2 commit dd8c17a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
18 changes: 9 additions & 9 deletions tools/perf/tests/dwarf-unwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
}

__attribute__ ((noinline))
static int unwind_thread(struct thread *thread, struct machine *machine)
static int unwind_thread(struct thread *thread)
{
struct perf_sample sample;
unsigned long cnt = 0;
Expand All @@ -72,7 +72,7 @@ static int unwind_thread(struct thread *thread, struct machine *machine)
goto out;
}

err = unwind__get_entries(unwind_entry, &cnt, machine, thread,
err = unwind__get_entries(unwind_entry, &cnt, thread,
&sample, MAX_STACK);
if (err)
pr_debug("unwind failed\n");
Expand All @@ -89,21 +89,21 @@ static int unwind_thread(struct thread *thread, struct machine *machine)
}

__attribute__ ((noinline))
static int krava_3(struct thread *thread, struct machine *machine)
static int krava_3(struct thread *thread)
{
return unwind_thread(thread, machine);
return unwind_thread(thread);
}

__attribute__ ((noinline))
static int krava_2(struct thread *thread, struct machine *machine)
static int krava_2(struct thread *thread)
{
return krava_3(thread, machine);
return krava_3(thread);
}

__attribute__ ((noinline))
static int krava_1(struct thread *thread, struct machine *machine)
static int krava_1(struct thread *thread)
{
return krava_2(thread, machine);
return krava_2(thread);
}

int test__dwarf_unwind(void)
Expand Down Expand Up @@ -137,7 +137,7 @@ int test__dwarf_unwind(void)
goto out;
}

err = krava_1(thread, machine);
err = krava_1(thread);

out:
machine__delete_threads(machine);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ int thread__resolve_callchain(struct thread *thread,
(!sample->user_stack.size))
return 0;

return unwind__get_entries(unwind_entry, &callchain_cursor, thread->mg->machine,
return unwind__get_entries(unwind_entry, &callchain_cursor,
thread, sample, max_stack);

}
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/util/unwind-libdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ frame_callback(Dwfl_Frame *state, void *arg)
}

int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct machine *machine, struct thread *thread,
struct thread *thread,
struct perf_sample *data,
int max_stack)
{
struct unwind_info ui = {
.sample = data,
.thread = thread,
.machine = machine,
.machine = thread->mg->machine,
.cb = cb,
.arg = arg,
.max_stack = max_stack,
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/util/unwind-libunwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,14 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
}

int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct machine *machine, struct thread *thread,
struct thread *thread,
struct perf_sample *data, int max_stack)
{
u64 ip;
struct unwind_info ui = {
.sample = data,
.thread = thread,
.machine = machine,
.machine = thread->mg->machine,
};
int ret;

Expand Down
2 changes: 0 additions & 2 deletions tools/perf/util/unwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);

#ifdef HAVE_DWARF_UNWIND_SUPPORT
int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct machine *machine,
struct thread *thread,
struct perf_sample *data, int max_stack);
/* libunwind specific */
Expand All @@ -38,7 +37,6 @@ static inline void unwind__finish_access(struct thread *thread __maybe_unused) {
static inline int
unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
void *arg __maybe_unused,
struct machine *machine __maybe_unused,
struct thread *thread __maybe_unused,
struct perf_sample *data __maybe_unused,
int max_stack __maybe_unused)
Expand Down

0 comments on commit dd8c17a

Please sign in to comment.