Skip to content

Commit

Permalink
perf tools: Rename "kernel_info" to "machine"
Browse files Browse the repository at this point in the history
struct kernel_info and kerninfo__ are too vague, what they really
describe are machines, virtual ones or hosts.

There are more changes to introduce helpers to shorten function calls
and to make more clear what is really being done, but I left that for
subsequent patches.

Cc: Avi Kivity <avi@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Zhang, Yanmin <yanmin_zhang@linux.intel.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Apr 28, 2010
1 parent 462b04e commit 23346f2
Show file tree
Hide file tree
Showing 16 changed files with 280 additions and 287 deletions.
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ static int __cmd_annotate(void)
perf_session__fprintf(session, stdout);

if (verbose > 2)
dsos__fprintf(&session->kerninfo_root, stdout);
dsos__fprintf(&session->machines, stdout);

perf_session__collapse_resort(&session->hists);
perf_session__output_resort(&session->hists, session->event_total[0]);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-buildid-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static int __cmd_buildid_list(void)
if (with_hits)
perf_session__process_events(session, &build_id__mark_dso_hit_ops);

dsos__fprintf_buildid(&session->kerninfo_root, stdout, with_hits);
dsos__fprintf_buildid(&session->machines, stdout, with_hits);

perf_session__delete(session);
return err;
Expand Down
8 changes: 4 additions & 4 deletions tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
int n_lines, int is_caller)
{
struct rb_node *next;
struct kernel_info *kerninfo;
struct machine *machine;

printf("%.102s\n", graph_dotted_line);
printf(" %-34s |", is_caller ? "Callsite": "Alloc Ptr");
Expand All @@ -361,16 +361,16 @@ static void __print_result(struct rb_root *root, struct perf_session *session,

next = rb_first(root);

kerninfo = kerninfo__findhost(&session->kerninfo_root);
if (!kerninfo) {
machine = perf_session__find_host_machine(session);
if (!machine) {
pr_err("__print_result: couldn't find kernel information\n");
return;
}
while (next && n_lines--) {
struct alloc_stat *data = rb_entry(next, struct alloc_stat,
node);
struct symbol *sym = NULL;
struct map_groups *kmaps = &kerninfo->kmaps;
struct map_groups *kmaps = &machine->kmaps;
struct map *map;
char buf[BUFSIZ];
u64 addr;
Expand Down
36 changes: 17 additions & 19 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,14 @@ static void atexit_header(void)
}
}

static void event__synthesize_guest_os(struct kernel_info *kerninfo,
void *data __attribute__((unused)))
static void event__synthesize_guest_os(struct machine *machine, void *data)
{
int err;
char *guest_kallsyms;
char path[PATH_MAX];
struct perf_session *psession = data;

if (is_host_kernel(kerninfo))
if (machine__is_host(machine))
return;

/*
Expand All @@ -475,16 +475,15 @@ static void event__synthesize_guest_os(struct kernel_info *kerninfo,
*in module instead of in guest kernel.
*/
err = event__synthesize_modules(process_synthesized_event,
session,
kerninfo);
psession, machine);
if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", kerninfo->pid);
" relocation symbol.\n", machine->pid);

if (is_default_guest(kerninfo))
if (machine__is_default_guest(machine))
guest_kallsyms = (char *) symbol_conf.default_guest_kallsyms;
else {
sprintf(path, "%s/proc/kallsyms", kerninfo->root_dir);
sprintf(path, "%s/proc/kallsyms", machine->root_dir);
guest_kallsyms = path;
}

Expand All @@ -493,13 +492,13 @@ static void event__synthesize_guest_os(struct kernel_info *kerninfo,
* have no _text sometimes.
*/
err = event__synthesize_kernel_mmap(process_synthesized_event,
session, kerninfo, "_text");
psession, machine, "_text");
if (err < 0)
err = event__synthesize_kernel_mmap(process_synthesized_event,
session, kerninfo, "_stext");
psession, machine, "_stext");
if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", kerninfo->pid);
" relocation symbol.\n", machine->pid);
}

static int __cmd_record(int argc, const char **argv)
Expand All @@ -513,7 +512,7 @@ static int __cmd_record(int argc, const char **argv)
int child_ready_pipe[2], go_pipe[2];
const bool forks = argc > 0;
char buf;
struct kernel_info *kerninfo;
struct machine *machine;

page_size = sysconf(_SC_PAGE_SIZE);

Expand Down Expand Up @@ -682,31 +681,30 @@ static int __cmd_record(int argc, const char **argv)
advance_output(err);
}

kerninfo = kerninfo__findhost(&session->kerninfo_root);
if (!kerninfo) {
machine = perf_session__find_host_machine(session);
if (!machine) {
pr_err("Couldn't find native kernel information.\n");
return -1;
}

err = event__synthesize_kernel_mmap(process_synthesized_event,
session, kerninfo, "_text");
session, machine, "_text");
if (err < 0)
err = event__synthesize_kernel_mmap(process_synthesized_event,
session, kerninfo, "_stext");
session, machine, "_stext");
if (err < 0) {
pr_err("Couldn't record kernel reference relocation symbol.\n");
return err;
}

err = event__synthesize_modules(process_synthesized_event,
session, kerninfo);
session, machine);
if (err < 0) {
pr_err("Couldn't record kernel reference relocation symbol.\n");
return err;
}
if (perf_guest)
kerninfo__process_allkernels(&session->kerninfo_root,
event__synthesize_guest_os, session);
perf_session__process_machines(session, event__synthesize_guest_os);

if (!system_wide && profile_cpu == -1)
event__synthesize_thread(target_tid, process_synthesized_event,
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static int __cmd_report(void)
perf_session__fprintf(session, stdout);

if (verbose > 2)
dsos__fprintf(&session->kerninfo_root, stdout);
dsos__fprintf(&session->machines, stdout);

next = rb_first(&session->stats_by_id);
while (next) {
Expand Down
15 changes: 7 additions & 8 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ static void handle_keypress(struct perf_session *session, int c)
case 'Q':
printf("exiting.\n");
if (dump_symtab)
dsos__fprintf(&session->kerninfo_root, stderr);
dsos__fprintf(&session->machines, stderr);
exit(0);
case 's':
prompt_symbol(&sym_filter_entry, "Enter details symbol");
Expand Down Expand Up @@ -982,7 +982,7 @@ static void event__process_sample(const event_t *self,
u64 ip = self->ip.ip;
struct sym_entry *syme;
struct addr_location al;
struct kernel_info *kerninfo;
struct machine *machine;
u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;

++samples;
Expand All @@ -992,18 +992,17 @@ static void event__process_sample(const event_t *self,
++us_samples;
if (hide_user_symbols)
return;
kerninfo = kerninfo__findhost(&session->kerninfo_root);
machine = perf_session__find_host_machine(session);
break;
case PERF_RECORD_MISC_KERNEL:
++kernel_samples;
if (hide_kernel_symbols)
return;
kerninfo = kerninfo__findhost(&session->kerninfo_root);
machine = perf_session__find_host_machine(session);
break;
case PERF_RECORD_MISC_GUEST_KERNEL:
++guest_kernel_samples;
kerninfo = kerninfo__find(&session->kerninfo_root,
self->ip.pid);
machine = perf_session__find_machine(session, self->ip.pid);
break;
case PERF_RECORD_MISC_GUEST_USER:
++guest_us_samples;
Expand All @@ -1016,7 +1015,7 @@ static void event__process_sample(const event_t *self,
return;
}

if (!kerninfo && perf_guest) {
if (!machine && perf_guest) {
pr_err("Can't find guest [%d]'s kernel information\n",
self->ip.pid);
return;
Expand All @@ -1041,7 +1040,7 @@ static void event__process_sample(const event_t *self,
* --hide-kernel-symbols, even if the user specifies an
* invalid --vmlinux ;-)
*/
if (al.map == kerninfo->vmlinux_maps[MAP__FUNCTION] &&
if (al.map == machine->vmlinux_maps[MAP__FUNCTION] &&
RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION])) {
pr_err("The %s file can't be used\n",
symbol_conf.vmlinux_name);
Expand Down
Loading

0 comments on commit 23346f2

Please sign in to comment.