aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorYunlong Song <yunlong.song@huawei.com>2015-04-02 09:47:14 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-04-02 12:18:48 -0400
commitc4ac732a0377d1544a8385393a9877b693ff0652 (patch)
tree1c1ec4f87f91925139749c0173e5dc54e61766cd /tools
parent8cc5ec1f754355ed788838390e86389c9ffb7590 (diff)
perf lock: Support using -f to override perf.data file ownership
Enable perf lock to use perf.data when it is not owned by current user or root. Example: # perf lock record ls # chown Yunlong.Song:Yunlong.Song perf.data # ls -al perf.data -rw------- 1 Yunlong.Song Yunlong.Song 4880686 Apr 2 14:14 perf.data # id uid=0(root) gid=0(root) groups=0(root),64(pkcs11) Before this patch: # perf lock report File perf.data not owned by current user or root (use -f to override) Initializing perf session failed # perf lock report -f Error: unknown switch `f' usage: perf lock report [<options>] -k, --key <acquired> key for sorting (acquired / contended / avg_wait / wait_total / wait_max / wait_min) As shown above, the -f option does not work at all. After this patch: # perf lock report File perf.data not owned by current user or root (use -f to override) Initializing perf session failed # perf lock report -f Name acquired contended avg wait (ns) total wait (ns) ... &ldata->output_l... 128 0 0 0 ... &ctx->lock 114 0 0 0 ... &p->pi_lock 112 0 0 0 ... &(&pool->lock)->... 112 0 0 0 ... &(&dentry->d_loc... 70 0 0 0 ... &(&newf->file_lo... 62 0 0 0 ... &(&fs->lock)->rl... 43 0 0 0 ... ... 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-6-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-lock.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 7893a9bba2a7..d49c2ab85fc2 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -846,6 +846,8 @@ static const struct perf_evsel_str_handler lock_tracepoints[] = {
846 { "lock:lock_release", perf_evsel__process_lock_release, }, /* CONFIG_LOCKDEP */ 846 { "lock:lock_release", perf_evsel__process_lock_release, }, /* CONFIG_LOCKDEP */
847}; 847};
848 848
849static bool force;
850
849static int __cmd_report(bool display_info) 851static int __cmd_report(bool display_info)
850{ 852{
851 int err = -EINVAL; 853 int err = -EINVAL;
@@ -857,6 +859,7 @@ static int __cmd_report(bool display_info)
857 struct perf_data_file file = { 859 struct perf_data_file file = {
858 .path = input_name, 860 .path = input_name,
859 .mode = PERF_DATA_MODE_READ, 861 .mode = PERF_DATA_MODE_READ,
862 .force = force,
860 }; 863 };
861 864
862 session = perf_session__new(&file, false, &eops); 865 session = perf_session__new(&file, false, &eops);
@@ -945,6 +948,7 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
945 "dump thread list in perf.data"), 948 "dump thread list in perf.data"),
946 OPT_BOOLEAN('m', "map", &info_map, 949 OPT_BOOLEAN('m', "map", &info_map,
947 "map of lock instances (address:name table)"), 950 "map of lock instances (address:name table)"),
951 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
948 OPT_END() 952 OPT_END()
949 }; 953 };
950 const struct option lock_options[] = { 954 const struct option lock_options[] = {
@@ -956,6 +960,7 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
956 const struct option report_options[] = { 960 const struct option report_options[] = {
957 OPT_STRING('k', "key", &sort_key, "acquired", 961 OPT_STRING('k', "key", &sort_key, "acquired",
958 "key for sorting (acquired / contended / avg_wait / wait_total / wait_max / wait_min)"), 962 "key for sorting (acquired / contended / avg_wait / wait_total / wait_max / wait_min)"),
963 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
959 /* TODO: type */ 964 /* TODO: type */
960 OPT_END() 965 OPT_END()
961 }; 966 };