linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 0/7 V2] Add support of user space symboles for guest.
  2013-12-20 20:52 [PATCH 0/7 V2] Add support of user space symboles for guest Dongsheng Yang
@ 2013-12-20 15:02 ` David Ahern
  2013-12-30 15:32   ` Dongsheng Yang
  2013-12-20 20:52 ` [PATCH 1/7] perf tools: Add support for PERF_RECORD_MISC_GUEST_USER in thread__find_addr_map() Dongsheng Yang
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: David Ahern @ 2013-12-20 15:02 UTC (permalink / raw)
  To: Dongsheng Yang, acme, linux-kernel; +Cc: mingo, namhyung.kim, jolsa

On 12/20/13, 1:52 PM, Dongsheng Yang wrote:
> Hi Arnaldo:
> 	Please help to review this patchset.
>
> Changelog:
> 	- v2:
> 		* splite the first commit.
>

At best you are creating knowledge of running tasks in the VMs when the 
perf session is started. That's it. That information cannot be used 
since the host has no idea what task is running in a VM at any given 
moment. No insight into process creation, mmaps, exits, etc.

David


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 0/7 V2] Add support of user space symboles for guest.
@ 2013-12-20 20:52 Dongsheng Yang
  2013-12-20 15:02 ` David Ahern
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Dongsheng Yang @ 2013-12-20 20:52 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, namhyung.kim, jolsa, dsahern, Dongsheng Yang

Hi Arnaldo:
	Please help to review this patchset.

Changelog:
	- v2:
		* splite the first commit.

Dongsheng Yang (7):
  perf tools: Add support for PERF_RECORD_MISC_GUEST_USER in
    thread__find_addr_map().
  perf tools: Find the proc info under machine->root_dir.
  perf tools: Set event->header.misc to PERF_RECORD_MISC_GUEST_USER if
    machine is guest.
  perf tools: Use machine->pid for tgid if mahicne is guest.
  perf tools: Do not synthesize the treads of default guest.
  perf tools: Add support of user space symbols for guest in perf kvm
    top.
  perf tools: Add support of user space symbols for guest in perf kvm
    record.

 tools/perf/builtin-record.c | 10 ++++++++++
 tools/perf/builtin-top.c    | 15 ++++++++++-----
 tools/perf/util/event.c     | 44 ++++++++++++++++++++++++++++++--------------
 3 files changed, 50 insertions(+), 19 deletions(-)

-- 
1.8.2.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/7] perf tools: Add support for PERF_RECORD_MISC_GUEST_USER in thread__find_addr_map().
  2013-12-20 20:52 [PATCH 0/7 V2] Add support of user space symboles for guest Dongsheng Yang
  2013-12-20 15:02 ` David Ahern
@ 2013-12-20 20:52 ` Dongsheng Yang
  2014-01-12 18:36   ` [tip:perf/core] " tip-bot for Dongsheng Yang
  2013-12-20 20:52 ` [PATCH 2/7] perf tools: Find the proc info under machine->root_dir Dongsheng Yang
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Dongsheng Yang @ 2013-12-20 20:52 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, namhyung.kim, jolsa, dsahern, Dongsheng Yang

This patch remove a TODO in thread__find_addr_map() and add support of PERF_RECORD_MISC_GUEST_USER.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 tools/perf/util/event.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 6948768..44992ed 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -658,15 +658,10 @@ void thread__find_addr_map(struct thread *thread,
 		al->level = 'g';
 		mg = &machine->kmaps;
 		load_map = true;
+	} else if (cpumode == PERF_RECORD_MISC_GUEST_USER && perf_guest) {
+		al->level = 'u';
 	} else {
-		/*
-		 * 'u' means guest os user space.
-		 * TODO: We don't support guest user space. Might support late.
-		 */
-		if (cpumode == PERF_RECORD_MISC_GUEST_USER && perf_guest)
-			al->level = 'u';
-		else
-			al->level = 'H';
+		al->level = 'H';
 		al->map = NULL;
 
 		if ((cpumode == PERF_RECORD_MISC_GUEST_USER ||
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/7] perf tools: Find the proc info under machine->root_dir.
  2013-12-20 20:52 [PATCH 0/7 V2] Add support of user space symboles for guest Dongsheng Yang
  2013-12-20 15:02 ` David Ahern
  2013-12-20 20:52 ` [PATCH 1/7] perf tools: Add support for PERF_RECORD_MISC_GUEST_USER in thread__find_addr_map() Dongsheng Yang
@ 2013-12-20 20:52 ` Dongsheng Yang
  2014-01-12 18:37   ` [tip:perf/core] perf tools: Find the proc info under machine-> root_dir tip-bot for Dongsheng Yang
  2013-12-20 20:52 ` [PATCH 3/7] perf tools: Set event->header.misc to PERF_RECORD_MISC_GUEST_USER if machine is guest Dongsheng Yang
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Dongsheng Yang @ 2013-12-20 20:52 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, namhyung.kim, jolsa, dsahern, Dongsheng Yang

When we synthesize the threads, we are looking for the infomation
under /proc. But it is only for host.

This patch look for the path of proc under machine->root_dir, then
XXX__synthesize_threads() functions can support guest machines.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 tools/perf/util/event.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 44992ed..c75046f 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -129,7 +129,8 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
 		goto out;
 	}
 
-	snprintf(filename, sizeof(filename), "/proc/%d/task", pid);
+	snprintf(filename, sizeof(filename), "%s/proc/%d/task",
+		 machine->root_dir, pid);
 
 	tasks = opendir(filename);
 	if (tasks == NULL) {
@@ -178,7 +179,8 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
 	FILE *fp;
 	int rc = 0;
 
-	snprintf(filename, sizeof(filename), "/proc/%d/maps", pid);
+	snprintf(filename, sizeof(filename), "%s/proc/%d/maps",
+		 machine->root_dir, pid);
 
 	fp = fopen(filename, "r");
 	if (fp == NULL) {
@@ -387,6 +389,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
 				   struct machine *machine, bool mmap_data)
 {
 	DIR *proc;
+	char proc_path[PATH_MAX];
 	struct dirent dirent, *next;
 	union perf_event *comm_event, *mmap_event;
 	int err = -1;
@@ -399,7 +402,9 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
 	if (mmap_event == NULL)
 		goto out_free_comm;
 
-	proc = opendir("/proc");
+	snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir);
+	proc = opendir(proc_path);
+
 	if (proc == NULL)
 		goto out_free_mmap;
 
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/7] perf tools: Set event->header.misc to PERF_RECORD_MISC_GUEST_USER if machine is guest.
  2013-12-20 20:52 [PATCH 0/7 V2] Add support of user space symboles for guest Dongsheng Yang
                   ` (2 preceding siblings ...)
  2013-12-20 20:52 ` [PATCH 2/7] perf tools: Find the proc info under machine->root_dir Dongsheng Yang
@ 2013-12-20 20:52 ` Dongsheng Yang
  2014-01-12 18:37   ` [tip:perf/core] perf tools: Set event-> header.misc " tip-bot for Dongsheng Yang
  2013-12-20 20:52 ` [PATCH 4/7] perf tools: Use machine->pid for tgid if mahicne " Dongsheng Yang
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Dongsheng Yang @ 2013-12-20 20:52 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, namhyung.kim, jolsa, dsahern, Dongsheng Yang

When we synthesize the mmap events of user space, if machine is guest, we should
set the event->header.misc to PERF_RECORD_MISC_GUEST_USER, rather than
PERF_RECORD_MISC_USER.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 tools/perf/util/event.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index c75046f..2d90ed8 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -220,7 +220,10 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
 		/*
 		 * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c
 		 */
-		event->header.misc = PERF_RECORD_MISC_USER;
+		if (machine__is_host(machine))
+			event->header.misc = PERF_RECORD_MISC_USER;
+		else
+			event->header.misc = PERF_RECORD_MISC_GUEST_USER;
 
 		if (prot[2] != 'x') {
 			if (!mmap_data || prot[0] != 'r')
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/7] perf tools: Use machine->pid for tgid if mahicne is guest.
  2013-12-20 20:52 [PATCH 0/7 V2] Add support of user space symboles for guest Dongsheng Yang
                   ` (3 preceding siblings ...)
  2013-12-20 20:52 ` [PATCH 3/7] perf tools: Set event->header.misc to PERF_RECORD_MISC_GUEST_USER if machine is guest Dongsheng Yang
@ 2013-12-20 20:52 ` Dongsheng Yang
  2014-01-12 18:37   ` [tip:perf/core] perf tools: Use machine-> pid for tgid if machine " tip-bot for Dongsheng Yang
  2013-12-20 20:53 ` [PATCH 5/7] perf tools: Do not synthesize the treads of default guest Dongsheng Yang
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Dongsheng Yang @ 2013-12-20 20:52 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, namhyung.kim, jolsa, dsahern, Dongsheng Yang

When we synthesize an comm event, if machine is guest, we should
use the pid of machine as the event->comm.pid, rather than tgid
of thread.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 tools/perf/util/event.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2d90ed8..93c6701 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -106,8 +106,12 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
 
 	memset(&event->comm, 0, sizeof(event->comm));
 
-	tgid = perf_event__get_comm_tgid(pid, event->comm.comm,
-					 sizeof(event->comm.comm));
+	if (machine__is_host(machine))
+		tgid = perf_event__get_comm_tgid(pid, event->comm.comm,
+						 sizeof(event->comm.comm));
+	else
+		tgid = machine->pid;
+
 	if (tgid < 0)
 		goto out;
 
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/7] perf tools: Do not synthesize the treads of default guest.
  2013-12-20 20:52 [PATCH 0/7 V2] Add support of user space symboles for guest Dongsheng Yang
                   ` (4 preceding siblings ...)
  2013-12-20 20:52 ` [PATCH 4/7] perf tools: Use machine->pid for tgid if mahicne " Dongsheng Yang
@ 2013-12-20 20:53 ` Dongsheng Yang
  2014-01-12 18:37   ` [tip:perf/core] " tip-bot for Dongsheng Yang
  2013-12-20 20:53 ` [PATCH 6/7] perf tools: Add support of user space symbols for guest in perf kvm top Dongsheng Yang
  2013-12-20 20:53 ` [PATCH 7/7] perf tools: Add support of user space symbols for guest in perf kvm record Dongsheng Yang
  7 siblings, 1 reply; 15+ messages in thread
From: Dongsheng Yang @ 2013-12-20 20:53 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, namhyung.kim, jolsa, dsahern, Dongsheng Yang

As the default guest is designed to handle orphan kernel symboles
with --guestkallsysms and --guestmoudles, it has no user space. So we
should skip synthesizing threads if machine is default guest.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 tools/perf/util/event.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 93c6701..598b73e 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -133,6 +133,9 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
 		goto out;
 	}
 
+	if (machine__is_default_guest(machine))
+		return 0;
+
 	snprintf(filename, sizeof(filename), "%s/proc/%d/task",
 		 machine->root_dir, pid);
 
@@ -183,6 +186,9 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
 	FILE *fp;
 	int rc = 0;
 
+	if (machine__is_default_guest(machine))
+		return 0;
+
 	snprintf(filename, sizeof(filename), "%s/proc/%d/maps",
 		 machine->root_dir, pid);
 
@@ -409,6 +415,9 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
 	if (mmap_event == NULL)
 		goto out_free_comm;
 
+	if (machine__is_default_guest(machine))
+		return 0;
+
 	snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir);
 	proc = opendir(proc_path);
 
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 6/7] perf tools: Add support of user space symbols for guest in perf kvm top.
  2013-12-20 20:52 [PATCH 0/7 V2] Add support of user space symboles for guest Dongsheng Yang
                   ` (5 preceding siblings ...)
  2013-12-20 20:53 ` [PATCH 5/7] perf tools: Do not synthesize the treads of default guest Dongsheng Yang
@ 2013-12-20 20:53 ` Dongsheng Yang
  2013-12-20 20:53 ` [PATCH 7/7] perf tools: Add support of user space symbols for guest in perf kvm record Dongsheng Yang
  7 siblings, 0 replies; 15+ messages in thread
From: Dongsheng Yang @ 2013-12-20 20:53 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, namhyung.kim, jolsa, dsahern, Dongsheng Yang

	# perf kvm --guestmount /tmp/guestmount/ top
	Samples: 1K of event 'cycles', Event count (approx.): 259112905
	 17.34%  libcrypto.so.1.0.1e  [u] 0x000000000007d971
	  5.60%  [guest.kernel]       [g] kallsyms_expand_symbol
	  5.44%  libcrypto.so.1.0.1e  [u] md5_block_asm_data_order
	  4.09%  [guest.kernel]       [g] number.isra.1
	  3.59%  [guest.kernel]       [g] vsnprintf
	  3.52%  sshd                 [u] 0x00000000000441c0
	  2.37%  [guest.kernel]       [g] format_decode
	  2.36%  [guest.kernel]       [g] memcpy
	  2.11%  [guest.kernel]       [g] strnlen

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 tools/perf/builtin-top.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 03d37a7..670bd0b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -821,11 +821,9 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
 			break;
 		case PERF_RECORD_MISC_GUEST_USER:
 			++top->guest_us_samples;
-			/*
-			 * TODO: we don't process guest user from host side
-			 * except simple counting.
-			 */
-			/* Fall thru */
+			machine = perf_session__find_machine(session,
+							     sample.pid);
+			break;
 		default:
 			goto next_event;
 		}
@@ -912,6 +910,7 @@ static int __cmd_top(struct perf_top *top)
 	struct perf_record_opts *opts = &top->record_opts;
 	pthread_t thread;
 	int ret;
+	struct rb_node *nd;
 
 	top->session = perf_session__new(NULL, false, NULL);
 	if (top->session == NULL)
@@ -931,6 +930,12 @@ static int __cmd_top(struct perf_top *top)
 
 	machine__synthesize_threads(&top->session->machines.host, &opts->target,
 				    top->evlist->threads, false);
+
+	for (nd = rb_first(&top->session->machines.guests); nd; nd = rb_next(nd)) {
+		struct machine *pos = rb_entry(nd, struct machine, rb_node);
+		machine__synthesize_threads(pos, &opts->target, top->evlist->threads, false);
+	}
+
 	ret = perf_top__start_counters(top);
 	if (ret)
 		goto out_delete;
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 7/7] perf tools: Add support of user space symbols for guest in perf kvm record.
  2013-12-20 20:52 [PATCH 0/7 V2] Add support of user space symboles for guest Dongsheng Yang
                   ` (6 preceding siblings ...)
  2013-12-20 20:53 ` [PATCH 6/7] perf tools: Add support of user space symbols for guest in perf kvm top Dongsheng Yang
@ 2013-12-20 20:53 ` Dongsheng Yang
  7 siblings, 0 replies; 15+ messages in thread
From: Dongsheng Yang @ 2013-12-20 20:53 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, namhyung.kim, jolsa, dsahern, Dongsheng Yang

	# perf kvm --guestmount /tmp/guestmount/ record -a sleep 1
	[ perf record: Woken up 1 times to write data ]
	[ perf record: Captured and wrote 0.828 MB perf.data.guest (~36163 samples) ]

	# perf kvm --guestmount /tmp/guestmount/ report
	Samples: 4K of event 'cycles', Event count (approx.): 2662750816
	  8.67%  [guest/9217]  dd                            [u] 0x0000000000004e90
	  6.62%  [guest/9217]  [guest.kernel.kallsyms.9217]  [g] fget_light
	  6.17%  [guest/9217]  [guest.kernel.kallsyms.9217]  [g] system_call
	  5.97%  [guest/9217]  [guest.kernel.kallsyms.9217]  [g] __srcu_read_lock
	  5.53%  [guest/9217]  [guest.kernel.kallsyms.9217]  [g] __srcu_read_unlock
	  5.47%  [guest/9217]  [guest.kernel.kallsyms.9217]  [g] __audit_syscall_exit
	  5.38%  [guest/9217]  [guest.kernel.kallsyms.9217]  [g] fsnotify
	  5.32%  [guest/9217]  [guest.kernel.kallsyms.9217]  [g] system_call_after_swapgs
	  4.45%  [guest/9217]  libc-2.17.so                  [u] __GI___libc_write
	  4.15%  [guest/9217]  [guest.kernel.kallsyms.9217]  [g] sys_write
	  3.97%  [guest/9217]  [guest.kernel.kallsyms.9217]  [g] vfs_read
	  3.78%  [guest/9217]  libc-2.17.so                  [u] __GI___libc_read

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 tools/perf/builtin-record.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index c1c1200..ac1e540 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -279,6 +279,9 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
 {
 	int err;
 	struct perf_tool *tool = data;
+	struct perf_record *rec = container_of(tool, struct perf_record, tool);
+	struct perf_record_opts *opts = &rec->opts;
+	struct perf_evlist *evsel_list = rec->evlist;
 	/*
 	 *As for guest kernel when processing subcommand record&report,
 	 *we arrange module mmap prior to guest kernel mmap and trigger
@@ -305,6 +308,13 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
 	if (err < 0)
 		pr_err("Couldn't record guest kernel [%d]'s reference"
 		       " relocation symbol.\n", machine->pid);
+
+	err = __machine__synthesize_threads(machine, tool, &opts->target, evsel_list->threads,
+					    process_synthesized_event, opts->sample_address);
+
+	if (err < 0)
+		pr_err("Couldn't record guest userspace [%d]'s reference"
+		       " relocation symbol.\n", machine->pid);
 }
 
 static struct perf_event_header finished_round_event = {
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/7 V2] Add support of user space symboles for guest.
  2013-12-20 15:02 ` David Ahern
@ 2013-12-30 15:32   ` Dongsheng Yang
  0 siblings, 0 replies; 15+ messages in thread
From: Dongsheng Yang @ 2013-12-30 15:32 UTC (permalink / raw)
  To: David Ahern; +Cc: acme, linux-kernel, mingo, namhyung.kim, jolsa

On 12/20/2013 10:02 AM, David Ahern wrote:
> On 12/20/13, 1:52 PM, Dongsheng Yang wrote:
>> Hi Arnaldo:
>>     Please help to review this patchset.
>>
>> Changelog:
>>     - v2:
>>         * splite the first commit.
>>
>
> At best you are creating knowledge of running tasks in the VMs when 
> the perf session is started. That's it. That information cannot be 
> used since the host has no idea what task is running in a VM at any 
> given moment. No insight into process creation, mmaps, exits, etc.
>

Yes, you are right. host has no idea what task is running in a VM.

Thanx for your reply.

Yang
> David
>
> -- 
> To unsubscribe from this list: send the line "unsubscribe 
> linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tip:perf/core] perf tools: Add support for PERF_RECORD_MISC_GUEST_USER in thread__find_addr_map().
  2013-12-20 20:52 ` [PATCH 1/7] perf tools: Add support for PERF_RECORD_MISC_GUEST_USER in thread__find_addr_map() Dongsheng Yang
@ 2014-01-12 18:36   ` tip-bot for Dongsheng Yang
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-01-12 18:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, namhyung.kim, jolsa, dsahern,
	tglx, yangds.fnst

Commit-ID:  fb50bb43d051d12aad9e2337d0d5d14d0d3dd281
Gitweb:     http://git.kernel.org/tip/fb50bb43d051d12aad9e2337d0d5d14d0d3dd281
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Fri, 20 Dec 2013 15:52:56 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 23 Dec 2013 16:49:49 -0300

perf tools: Add support for PERF_RECORD_MISC_GUEST_USER in thread__find_addr_map().

This patch remove a TODO in thread__find_addr_map() and add support of
PERF_RECORD_MISC_GUEST_USER.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Link: http://lkml.kernel.org/r/3dd652201171a19c910b500984c7c3590e77603b.1387572416.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/event.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index fe20227..484e994 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -659,15 +659,10 @@ void thread__find_addr_map(struct thread *thread,
 		al->level = 'g';
 		mg = &machine->kmaps;
 		load_map = true;
+	} else if (cpumode == PERF_RECORD_MISC_GUEST_USER && perf_guest) {
+		al->level = 'u';
 	} else {
-		/*
-		 * 'u' means guest os user space.
-		 * TODO: We don't support guest user space. Might support late.
-		 */
-		if (cpumode == PERF_RECORD_MISC_GUEST_USER && perf_guest)
-			al->level = 'u';
-		else
-			al->level = 'H';
+		al->level = 'H';
 		al->map = NULL;
 
 		if ((cpumode == PERF_RECORD_MISC_GUEST_USER ||

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [tip:perf/core] perf tools: Find the proc info under machine-> root_dir.
  2013-12-20 20:52 ` [PATCH 2/7] perf tools: Find the proc info under machine->root_dir Dongsheng Yang
@ 2014-01-12 18:37   ` tip-bot for Dongsheng Yang
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-01-12 18:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, namhyung.kim, jolsa, dsahern,
	tglx, yangds.fnst

Commit-ID:  995634650ef1f907196bd7e9ae45354124a80e47
Gitweb:     http://git.kernel.org/tip/995634650ef1f907196bd7e9ae45354124a80e47
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Fri, 20 Dec 2013 15:52:57 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 23 Dec 2013 16:49:49 -0300

perf tools: Find the proc info under machine->root_dir.

When we synthesize the threads, we are looking for the infomation under
/proc. But it is only for host.

This patch look for the path of proc under machine->root_dir, then
XXX__synthesize_threads() functions can support guest machines.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Link: http://lkml.kernel.org/r/927b937da9177a079abafe4532fa9c9b60b5c4b7.1387572416.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/event.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 484e994..a61726e 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -129,7 +129,8 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
 		goto out;
 	}
 
-	snprintf(filename, sizeof(filename), "/proc/%d/task", pid);
+	snprintf(filename, sizeof(filename), "%s/proc/%d/task",
+		 machine->root_dir, pid);
 
 	tasks = opendir(filename);
 	if (tasks == NULL) {
@@ -178,7 +179,8 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
 	FILE *fp;
 	int rc = 0;
 
-	snprintf(filename, sizeof(filename), "/proc/%d/maps", pid);
+	snprintf(filename, sizeof(filename), "%s/proc/%d/maps",
+		 machine->root_dir, pid);
 
 	fp = fopen(filename, "r");
 	if (fp == NULL) {
@@ -387,6 +389,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
 				   struct machine *machine, bool mmap_data)
 {
 	DIR *proc;
+	char proc_path[PATH_MAX];
 	struct dirent dirent, *next;
 	union perf_event *comm_event, *mmap_event;
 	int err = -1;
@@ -399,7 +402,9 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
 	if (mmap_event == NULL)
 		goto out_free_comm;
 
-	proc = opendir("/proc");
+	snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir);
+	proc = opendir(proc_path);
+
 	if (proc == NULL)
 		goto out_free_mmap;
 

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [tip:perf/core] perf tools: Set event-> header.misc to PERF_RECORD_MISC_GUEST_USER if machine is guest.
  2013-12-20 20:52 ` [PATCH 3/7] perf tools: Set event->header.misc to PERF_RECORD_MISC_GUEST_USER if machine is guest Dongsheng Yang
@ 2014-01-12 18:37   ` tip-bot for Dongsheng Yang
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-01-12 18:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, namhyung.kim, jolsa, dsahern,
	tglx, yangds.fnst

Commit-ID:  73547aacdcd45cdf8b53245ded9593d7c587501a
Gitweb:     http://git.kernel.org/tip/73547aacdcd45cdf8b53245ded9593d7c587501a
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Fri, 20 Dec 2013 15:52:58 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 23 Dec 2013 16:49:50 -0300

perf tools: Set event->header.misc to PERF_RECORD_MISC_GUEST_USER if machine is guest.

When we synthesize the mmap events of user space, if machine is guest,
we should set the event->header.misc to PERF_RECORD_MISC_GUEST_USER,
rather than PERF_RECORD_MISC_USER.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Link: http://lkml.kernel.org/r/e6f8ff6505d2db8a4b21bff8e448bb9be0bcff35.1387572416.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/event.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index a61726e..07c0783 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -220,7 +220,10 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
 		/*
 		 * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c
 		 */
-		event->header.misc = PERF_RECORD_MISC_USER;
+		if (machine__is_host(machine))
+			event->header.misc = PERF_RECORD_MISC_USER;
+		else
+			event->header.misc = PERF_RECORD_MISC_GUEST_USER;
 
 		if (prot[2] != 'x') {
 			if (!mmap_data || prot[0] != 'r')

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [tip:perf/core] perf tools: Use machine-> pid for tgid if machine is guest.
  2013-12-20 20:52 ` [PATCH 4/7] perf tools: Use machine->pid for tgid if mahicne " Dongsheng Yang
@ 2014-01-12 18:37   ` tip-bot for Dongsheng Yang
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-01-12 18:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, namhyung.kim, jolsa, dsahern,
	tglx, yangds.fnst

Commit-ID:  f5db57c4c47f3985dfc677152e25636a3401fa13
Gitweb:     http://git.kernel.org/tip/f5db57c4c47f3985dfc677152e25636a3401fa13
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Fri, 20 Dec 2013 15:52:59 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 23 Dec 2013 16:49:50 -0300

perf tools: Use machine->pid for tgid if machine is guest.

When we synthesize an comm event, if machine is guest, we should
use the pid of machine as the event->comm.pid, rather than tgid
of thread.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Link: http://lkml.kernel.org/r/22455abe107c618a361e7b667ad0f098f7c9b4a3.1387572416.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/event.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 07c0783..2905771 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -106,8 +106,12 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
 
 	memset(&event->comm, 0, sizeof(event->comm));
 
-	tgid = perf_event__get_comm_tgid(pid, event->comm.comm,
-					 sizeof(event->comm.comm));
+	if (machine__is_host(machine))
+		tgid = perf_event__get_comm_tgid(pid, event->comm.comm,
+						 sizeof(event->comm.comm));
+	else
+		tgid = machine->pid;
+
 	if (tgid < 0)
 		goto out;
 

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [tip:perf/core] perf tools: Do not synthesize the treads of default guest.
  2013-12-20 20:53 ` [PATCH 5/7] perf tools: Do not synthesize the treads of default guest Dongsheng Yang
@ 2014-01-12 18:37   ` tip-bot for Dongsheng Yang
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-01-12 18:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, namhyung.kim, jolsa, dsahern,
	tglx, yangds.fnst

Commit-ID:  c239c25a82808ad2cbc795b69e621c4c24f154d6
Gitweb:     http://git.kernel.org/tip/c239c25a82808ad2cbc795b69e621c4c24f154d6
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Fri, 20 Dec 2013 15:53:00 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 23 Dec 2013 16:49:51 -0300

perf tools: Do not synthesize the treads of default guest.

As the default guest is designed to handle orphan kernel symboles with
--guestkallsysms and --guestmodules, it has no user space.

So we should skip synthesizing threads if machine is default guest.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Link: http://lkml.kernel.org/r/e9ddb5dac6f963169657218b12ceb3c2030f54e8.1387572416.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/event.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2905771..45a76c6 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -133,6 +133,9 @@ static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
 		goto out;
 	}
 
+	if (machine__is_default_guest(machine))
+		return 0;
+
 	snprintf(filename, sizeof(filename), "%s/proc/%d/task",
 		 machine->root_dir, pid);
 
@@ -183,6 +186,9 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
 	FILE *fp;
 	int rc = 0;
 
+	if (machine__is_default_guest(machine))
+		return 0;
+
 	snprintf(filename, sizeof(filename), "%s/proc/%d/maps",
 		 machine->root_dir, pid);
 
@@ -409,6 +415,9 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
 	if (mmap_event == NULL)
 		goto out_free_comm;
 
+	if (machine__is_default_guest(machine))
+		return 0;
+
 	snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir);
 	proc = opendir(proc_path);
 

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-01-12 18:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-20 20:52 [PATCH 0/7 V2] Add support of user space symboles for guest Dongsheng Yang
2013-12-20 15:02 ` David Ahern
2013-12-30 15:32   ` Dongsheng Yang
2013-12-20 20:52 ` [PATCH 1/7] perf tools: Add support for PERF_RECORD_MISC_GUEST_USER in thread__find_addr_map() Dongsheng Yang
2014-01-12 18:36   ` [tip:perf/core] " tip-bot for Dongsheng Yang
2013-12-20 20:52 ` [PATCH 2/7] perf tools: Find the proc info under machine->root_dir Dongsheng Yang
2014-01-12 18:37   ` [tip:perf/core] perf tools: Find the proc info under machine-> root_dir tip-bot for Dongsheng Yang
2013-12-20 20:52 ` [PATCH 3/7] perf tools: Set event->header.misc to PERF_RECORD_MISC_GUEST_USER if machine is guest Dongsheng Yang
2014-01-12 18:37   ` [tip:perf/core] perf tools: Set event-> header.misc " tip-bot for Dongsheng Yang
2013-12-20 20:52 ` [PATCH 4/7] perf tools: Use machine->pid for tgid if mahicne " Dongsheng Yang
2014-01-12 18:37   ` [tip:perf/core] perf tools: Use machine-> pid for tgid if machine " tip-bot for Dongsheng Yang
2013-12-20 20:53 ` [PATCH 5/7] perf tools: Do not synthesize the treads of default guest Dongsheng Yang
2014-01-12 18:37   ` [tip:perf/core] " tip-bot for Dongsheng Yang
2013-12-20 20:53 ` [PATCH 6/7] perf tools: Add support of user space symbols for guest in perf kvm top Dongsheng Yang
2013-12-20 20:53 ` [PATCH 7/7] perf tools: Add support of user space symbols for guest in perf kvm record Dongsheng Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).