Skip to content

Commit

Permalink
perf kvm: Set name for VM process in guest machine
Browse files Browse the repository at this point in the history
COMM events are not generated in the context of a guest machine, so the
thread name is never set for the VMM process. For example, the qemu-kvm
name applies to the process in the host machine, not the guest machine.
So, samples for guest machines are currently displayed as:

    99.67%     :5671  [unknown]         [g] 0xffffffff81366b41

where 5671 is the pid of the VMM. With this patch the samples in the guest
machine are shown as:

    18.43%  [guest/5671]  [unknown]           [g] 0xffffffff810d68b7

Tested-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1342826756-64663-3-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
David Ahern authored and Arnaldo Carvalho de Melo committed Jul 25, 2012
1 parent f51304d commit 5cd95c2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tools/perf/util/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stdio.h>
#include <unistd.h>
#include "map.h"
#include "thread.h"

const char *map_type__name[MAP__NR_TYPES] = {
[MAP__FUNCTION] = "Functions",
Expand Down Expand Up @@ -585,7 +586,21 @@ int machine__init(struct machine *self, const char *root_dir, pid_t pid)
self->kmaps.machine = self;
self->pid = pid;
self->root_dir = strdup(root_dir);
return self->root_dir == NULL ? -ENOMEM : 0;
if (self->root_dir == NULL)
return -ENOMEM;

if (pid != HOST_KERNEL_ID) {
struct thread *thread = machine__findnew_thread(self, pid);
char comm[64];

if (thread == NULL)
return -ENOMEM;

snprintf(comm, sizeof(comm), "[guest/%d]", pid);
thread__set_comm(thread, comm);
}

return 0;
}

static void dsos__delete(struct list_head *self)
Expand Down

0 comments on commit 5cd95c2

Please sign in to comment.