[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <2cb684452df6a8eb1a55b450e4f5328e28e34495.1386368672.git.yangds.fnst@cn.fujitsu.com>
Date: Fri, 6 Dec 2013 17:25:53 -0500
From: Dongsheng Yang <yangds.fnst@...fujitsu.com>
To: acme@...stprotocols.net
Cc: linux-kernel@...r.kernel.org,
Dongsheng Yang <yangds.fnst@...fujitsu.com>
Subject: [PATCH 3/3] perf tools: Change the default filenames for perf kvm diff to perf.data.xxx and perf.data.xxx.old
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. 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.
Signed-off-by: Dongsheng Yang <yangds.fnst@...fujitsu.com>
---
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..6a32213 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 (!file_name) {
+ 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists