aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorYunlong Song <yunlong.song@huawei.com>2015-04-02 09:47:10 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-04-02 12:18:45 -0400
commit9e3b6ec17374299516d83c2e36135b958a895aa3 (patch)
treedc5edf92267d786df87b410e58296c44a365a1e6 /tools
parentc72738355b2ac79506fbfa10ffee8fe3a27e69da (diff)
perf evlist: Support using -f to override perf.data file ownership
Enable perf evlist to use perf.data when it is not owned by current user or root. Example: # perf record ls # chown Yunlong.Song:Yunlong.Song perf.data # ls -al perf.data -rw------- 1 Yunlong.Song Yunlong.Song 28260 Apr 2 10:18 perf.data # id uid=0(root) gid=0(root) groups=0(root),64(pkcs11) Before this patch: # perf evlist File perf.data not owned by current user or root (use -f to override) # perf evlist -f Error: unknown switch `f' usage: perf evlist [<options>] -i, --input <file> Input file name -F, --freq Show the sample frequency -v, --verbose Show all event attr details -g, --group Show event group information As shown above, the -f option does not work at all. After this patch: # perf evlist File perf.data not owned by current user or root (use -f to override) # perf evlist -f cycles As shown above, the -f option really works now. Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1427982439-27388-2-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-evlist.c2
-rw-r--r--tools/perf/util/evsel.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index 0f93f859b782..695ec5a50cf2 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -24,6 +24,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
24 struct perf_data_file file = { 24 struct perf_data_file file = {
25 .path = file_name, 25 .path = file_name,
26 .mode = PERF_DATA_MODE_READ, 26 .mode = PERF_DATA_MODE_READ,
27 .force = details->force,
27 }; 28 };
28 29
29 session = perf_session__new(&file, 0, NULL); 30 session = perf_session__new(&file, 0, NULL);
@@ -47,6 +48,7 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
47 "Show all event attr details"), 48 "Show all event attr details"),
48 OPT_BOOLEAN('g', "group", &details.event_group, 49 OPT_BOOLEAN('g', "group", &details.event_group,
49 "Show event group information"), 50 "Show event group information"),
51 OPT_BOOLEAN('f', "force", &details.force, "don't complain, do it"),
50 OPT_END() 52 OPT_END()
51 }; 53 };
52 const char * const evlist_usage[] = { 54 const char * const evlist_usage[] = {
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index dcf202aebe9f..c5a43d6b13dc 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -335,6 +335,7 @@ struct perf_attr_details {
335 bool freq; 335 bool freq;
336 bool verbose; 336 bool verbose;
337 bool event_group; 337 bool event_group;
338 bool force;
338}; 339};
339 340
340int perf_evsel__fprintf(struct perf_evsel *evsel, 341int perf_evsel__fprintf(struct perf_evsel *evsel,