[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-e1a2b174dbbe08dce12bde9f05f64dbbae652bed@git.kernel.org>
Date: Wed, 11 Dec 2013 03:05:37 -0800
From: tip-bot for Dongsheng Yang <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: acme@...hat.com, linux-kernel@...r.kernel.org, hpa@...or.com,
mingo@...nel.org, tglx@...utronix.de, yangds.fnst@...fujitsu.com
Subject: [tip:perf/core] perf kvm:
Move code to generate filename for perf-kvm to function.
Commit-ID: e1a2b174dbbe08dce12bde9f05f64dbbae652bed
Gitweb: http://git.kernel.org/tip/e1a2b174dbbe08dce12bde9f05f64dbbae652bed
Author: Dongsheng Yang <yangds.fnst@...fujitsu.com>
AuthorDate: Fri, 6 Dec 2013 17:25:51 -0500
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Mon, 9 Dec 2013 15:23:56 -0300
perf kvm: Move code to generate filename for perf-kvm to function.
The code in builtin-kvm.c to generate filename for perf-kvm is useful to
other command such as builtin-diff.
This patch move the related code form builtin-kvm.c to util/util.c and
wrap them in a function named get_filename_for_perf_kvm.
Signed-off-by: Dongsheng Yang <yangds.fnst@...fujitsu.com>
Link: http://lkml.kernel.org/r/5e09a5c47e8a495e888cbdc65a6fafb2c950f529.1386368672.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/builtin-kvm.c | 7 +------
tools/perf/util/util.c | 14 ++++++++++++++
tools/perf/util/util.h | 2 ++
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index c2e5d56..c6fa3cb 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1713,12 +1713,7 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
perf_guest = 1;
if (!file_name) {
- if (perf_host && !perf_guest)
- file_name = strdup("perf.data.host");
- else if (!perf_host && perf_guest)
- file_name = strdup("perf.data.guest");
- else
- file_name = strdup("perf.data.kvm");
+ file_name = get_filename_for_perf_kvm();
if (!file_name) {
pr_err("Failed to allocate memory for filename\n");
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index bae8756..4a57609 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -482,3 +482,17 @@ int filename__read_str(const char *filename, char **buf, size_t *sizep)
close(fd);
return err;
}
+
+const char *get_filename_for_perf_kvm(void)
+{
+ const char *filename;
+
+ if (perf_host && !perf_guest)
+ filename = strdup("perf.data.host");
+ else if (!perf_host && perf_guest)
+ filename = strdup("perf.data.guest");
+ else
+ filename = strdup("perf.data.kvm");
+
+ return filename;
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 659abf3..0171213 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -321,4 +321,6 @@ void free_srcline(char *srcline);
int filename__read_int(const char *filename, int *value);
int filename__read_str(const char *filename, char **buf, size_t *sizep);
+
+const char *get_filename_for_perf_kvm(void);
#endif /* GIT_COMPAT_UTIL_H */
--
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