mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: acme@ghostprotocols.net
Cc: linux-kernel@vger.kernel.org,
	Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Subject: [PATCH V3] perf tools: Change the default filenames for perf kvm diff to perf.data.xxx and perf.data.xxx.old
Date: Wed, 11 Dec 2013 11:30:44 -0500	[thread overview]
Message-ID: <1386779444-29624-1-git-send-email-yangds.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1386778882-27906-1-git-send-email-yangds.fnst@cn.fujitsu.com>

Command perf kvm diff is used to diff perf.data.host and
perf.data.guest by default currently. But it is not a good
default behavior.

Example:
	# perf kvm --guestkallsyms /home/kallsyms --guestmodules /home/modules record -a sleep 1
	[ perf record: Woken up 1 times to write data ]
	[ perf record: Captured and wrote 0.669 MB perf.data.guest (~29207 samples) ]
	# perf kvm --guestkallsyms /home/kallsyms --guestmodules /home/modules record -a sleep 1
	[ perf record: Woken up 1 times to write data ]
	[ perf record: Captured and wrote 0.669 MB perf.data.guest (~29207 samples) ]
	# perf kvm --guestkallsyms /home/kallsyms --guestmodules /home/modules diff
	failed to open perf.data.host: No such file or directory
	Failed to open perf.data.host

We are more frequently using it to diff the perf data files with
the same type but captured in different times, such as
perf.data.guest and perf.data.guest.old.

This patch remove the hard coding of default filenames in builtin-diff.c,
and generate the suitable filename from current options in perf kvm diff
command. It makes the default behavior of perf kvm diff be more valuable.

Verification:
	# perf kvm --guestkallsyms /home/kallsyms --guestmodules /home/modules record -a sleep 1
	  [ perf record: Woken up 1 times to write data ]
	  [ perf record: Captured and wrote 0.669 MB perf.data.guest (~29207 samples) ]
	# perf kvm --guestkallsyms /home/kallsyms --guestmodules /home/modules record -a sleep 1
	  [ perf record: Woken up 1 times to write data ]
	  [ perf record: Captured and wrote 0.669 MB perf.data.guest (~29207 samples) ]
	# perf kvm --guestkallsyms /home/kallsyms --guestmodules /home/modules diff
	  # Event 'cycles'
	  #
	  # Baseline    Delta            Shared Object                                   Symbol
	  # ........  .......  .......................  .......................................
	  #
	    92.00%           [guest.kernel.kallsyms]  [g] rb_insert_color
	     7.51%           [guest.kernel.kallsyms]  [g] smp_apic_timer_interrupt
	     0.48%   +0.60%  [guest.kernel.kallsyms]  [g] apic_timer_interrupt
		    +16.35%  [guest.kernel.kallsyms]  [g] kvm_clock_get_cycles
		    +82.56%  [guest.kernel.kallsyms]  [g] irqtime_account_process_tick.isra.2

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
Changelog:
	changes for v3:
		*fix a copy-past bug.
	changes for v2:
		*Add more commit message.

 tools/perf/builtin-diff.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 2a85cc9..8d1b666 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -17,6 +17,7 @@
 #include "util/symbol.h"
 #include "util/util.h"
 #include "util/data.h"
+#include "linux/string.h"
 
 #include <stdlib.h>
 #include <math.h>
@@ -1001,8 +1002,28 @@ static int data_init(int argc, const char **argv)
 			use_default = false;
 		}
 	} else if (perf_guest) {
-		defaults[0] = "perf.data.host";
-		defaults[1] = "perf.data.guest";
+		char *file_name;
+		int len, ret;
+
+		file_name = (char *)get_filename_for_perf_kvm();
+		if (!file_name) {
+			pr_err("Failed to allocate memory for filename\n");
+			return -ENOMEM;
+		}
+
+		defaults[0] = strdup(file_name);
+		if (!defaults[0]) {
+			pr_err("Failed to allocate memory for defaults[0]\n");
+			return -ENOMEM;
+		}
+
+		len = strlen(file_name);
+		ret = str_append(&file_name, &len, ".old");
+		if (ret) {
+			pr_err("Failed to allocate memory for defaults[1]\n");
+			return -ENOMEM;
+		}
+		defaults[1] = file_name;
 	}
 
 	if (sort_compute >= (unsigned int) data__files_cnt) {
-- 
1.8.2.1


  reply	other threads:[~2013-12-11  3:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06 22:25 [PATCH 1/3] perf tools: Move code to generate filename for perf-kvm to function Dongsheng Yang
2013-12-06 22:25 ` [PATCH 2/3] perf tools: Make perf kvm diff support --guestmount Dongsheng Yang
2013-12-11 11:05   ` [tip:perf/core] perf kvm: " tip-bot for Dongsheng Yang
2013-12-06 22:25 ` [PATCH 3/3] perf tools: Change the default filenames for perf kvm diff to perf.data.xxx and perf.data.xxx.old Dongsheng Yang
2013-12-11 16:21   ` [PATCH V2] " Dongsheng Yang
2013-12-11 16:30     ` Dongsheng Yang [this message]
2013-12-11  3:38       ` [PATCH V3] " David Ahern
2013-12-11 16:46         ` Dongsheng Yang
2013-12-11 11:05 ` [tip:perf/core] perf kvm: Move code to generate filename for perf-kvm to function tip-bot for Dongsheng Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386779444-29624-1-git-send-email-yangds.fnst@cn.fujitsu.com \
    --to=yangds.fnst@cn.fujitsu.com \
    --cc=acme@ghostprotocols.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®