LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: tip-bot for Yunlong Song <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, a.p.zijlstra@chello.nl,
	paulus@samba.org, tglx@linutronix.de, wangnan0@huawei.com,
	acme@redhat.com, yunlong.song@huawei.com, hpa@zytor.com,
	mingo@kernel.org
Subject: [tip:perf/core] perf mem: Support using -f to override perf.data file ownership
Date: Thu, 2 Apr 2015 22:09:30 -0700	[thread overview]
Message-ID: <tip-62a1a63a77451dee8fd318a5106ca108d6a8ebcb@git.kernel.org> (raw)
In-Reply-To: <1427982439-27388-7-git-send-email-yunlong.song@huawei.com>

Commit-ID:  62a1a63a77451dee8fd318a5106ca108d6a8ebcb
Gitweb:     http://git.kernel.org/tip/62a1a63a77451dee8fd318a5106ca108d6a8ebcb
Author:     Yunlong Song <yunlong.song@huawei.com>
AuthorDate: Thu, 2 Apr 2015 21:47:15 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 2 Apr 2015 13:18:49 -0300

perf mem: Support using -f to override perf.data file ownership

Enable perf mem to use perf.data when it is not owned by current user or
root.

Example:

 # perf mem -t load record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 16392 Apr  2 14:34 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

 # perf mem -D report
 File perf.data not owned by current user or root (use -f to override)
 # perf mem -D -f report
   Error: unknown switch `f'

  usage: perf mem [<options>] {record|report}

     -t, --type <type>     memory operations(load,store) Default load,store
     -D, --dump-raw-samples
                           dump raw samples in ASCII
     -U, --hide-unresolved
                           Only display entries resolved to a symbol
     -i, --input <file>    input file name
     -C, --cpu <cpu>       list of cpus to profile
     -x, --field-separator <separator>
                           separator for columns, no spaces will be added
                           between columns '.' is reserved.

As shown above, the -f option does not work at all.

After this patch:

 # perf mem -D report
 File perf.data not owned by current user or root (use -f to override)
 # perf mem -D -f report
 # PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL
 39095 39095 0xffffffff81127e40 0x016ffff887f45148338 8 0x68100142
 /proc/kcore:perf_event_aux
 39095 39095 0xffffffff8100a3fe 0xffff89007f8cb7d0 6 0x68100142
 /proc/kcore:native_sched_clock
 39095 39095 0xffffffff81309139 0xffff88bf44c9ded8 6 0x68100142
 /proc/kcore:acpi_map_lookup
 39095 39095 0xffffffff810f8c4c 0xffff89007f8ccd88 6 0x68100142
 /proc/kcore:rcu_nmi_exit
 39095 39095 0xffffffff81136346 0xffff88fea995dd50 6 0x68100142
 /proc/kcore:unlock_page
 39095 39095 0xffffffff812a64a2 0xffff88fea995dcc8 6 0x68100142
 /proc/kcore:half_md4_transform
 39095 39095 0x7f0cf877c7e9 0x25dfb94 6 0x68100142
 /lib64/libc-2.19.so:__readdir64
 39095 39095 0x7f0cf87575a3 0x7f0cf9163731 6 0x68100142
 /lib64/libc-2.19.so:__strcoll_l
 39095 39095 0xffffffff8116910e 0xffffea01c1bfbd50 23 0x68100242
 /proc/kcore:page_remove_rmap

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-7-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-mem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index b4dcf0b..675216e 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -15,6 +15,7 @@ struct perf_mem {
 	char const		*input_name;
 	bool			hide_unresolved;
 	bool			dump_raw;
+	bool			force;
 	int			operation;
 	const char		*cpu_list;
 	DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
@@ -120,6 +121,7 @@ static int report_raw_events(struct perf_mem *mem)
 	struct perf_data_file file = {
 		.path = input_name,
 		.mode = PERF_DATA_MODE_READ,
+		.force = mem->force,
 	};
 	int err = -EINVAL;
 	int ret;
@@ -290,6 +292,7 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
 		   "separator",
 		   "separator for columns, no spaces will be added"
 		   " between columns '.' is reserved."),
+	OPT_BOOLEAN('f', "force", &mem.force, "don't complain, do it"),
 	OPT_END()
 	};
 	const char *const mem_subcommands[] = { "record", "report", NULL };

  reply	other threads:[~2015-04-03  5:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 13:47 [PATCH 00/10] perf tools: Support using -f to override file ownership for perf commands Yunlong Song
2015-04-02 13:47 ` [PATCH 01/10] perf tools: Support using -f to override perf.data file ownership for evlist Yunlong Song
2015-04-03  5:08   ` [tip:perf/core] perf evlist: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 02/10] perf tools: Support using -f to override perf.data file ownership for inject Yunlong Song
2015-04-03  5:08   ` [tip:perf/core] perf inject: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 03/10] perf tools: Support using -f to override perf.data file ownership for kmem Yunlong Song
2015-04-03  5:08   ` [tip:perf/core] perf kmem: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 04/10] perf tools: Support using -f to override perf.data.guest file ownership for kvm Yunlong Song
2015-04-03  5:08   ` [tip:perf/core] perf kvm: Support using -f to override perf.data.guest file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 05/10] perf tools: Support using -f to override perf.data file ownership for lock Yunlong Song
2015-04-03  5:09   ` [tip:perf/core] perf lock: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 06/10] perf tools: Support using -f to override perf.data file ownership for mem Yunlong Song
2015-04-03  5:09   ` tip-bot for Yunlong Song [this message]
2015-04-02 13:47 ` [PATCH 07/10] perf tools: Support using -f to override perf.data file ownership for script Yunlong Song
2015-04-03  5:09   ` [tip:perf/core] perf script: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 08/10] perf tools: Support using -f to override perf.data file ownership for timechart Yunlong Song
2015-04-03  5:10   ` [tip:perf/core] perf timechart: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 09/10] perf tools: Support using -f to override perf.data file ownership for trace Yunlong Song
2015-04-03  5:10   ` [tip:perf/core] perf trace: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 10/10] perf tools: Support using -f to override perf.data file ownership for data convert Yunlong Song
2015-04-03  5:10   ` [tip:perf/core] perf data: Support using -f to override perf.data file ownership for 'convert' tip-bot for Yunlong Song
2015-04-02 15:13 ` [PATCH 00/10] perf tools: Support using -f to override file ownership for perf commands Arnaldo Carvalho de Melo

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=tip-62a1a63a77451dee8fd318a5106ca108d6a8ebcb@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    --cc=yunlong.song@huawei.com \
    --subject='Re: [tip:perf/core] perf mem: Support using -f to override perf.data file ownership' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).