perf kmem: Support using -f to override perf.data file ownership
authorYunlong Song <yunlong.song@huawei.com>
Thu, 2 Apr 2015 13:47:12 +0000 (21:47 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 2 Apr 2015 16:18:46 +0000 (13:18 -0300)
commitd1eeb77c1811fd178442ccb8f58004a19ec40dd3
treea30d6ff25aa2b6d6cd681f40927e5bdf4a9c7b7a
parentccaa474c8a0983d26ecb3eac755672b546b997c3
perf kmem: Support using -f to override perf.data file ownership

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

Example:

 # perf kmem record ls
 # chown Yunlong.Song:Yunlong.Song perf.data
 # ls -al perf.data
 -rw------- 1 Yunlong.Song Yunlong.Song 5315665 Apr  2 10:54 perf.data
 # id
 uid=0(root) gid=0(root) groups=0(root),64(pkcs11)

Before this patch:

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

  usage: perf kmem [<options>] {record|stat}

     -i, --input <file>    input file name
     -v, --verbose         be more verbose (show symbol address, etc)
         --caller          show per-callsite statistics
         --alloc           show per-allocation statistics
     -s, --sort <key[,key2...]>
                           sort by keys: ptr, call_site, bytes, hit,
                           pingpong, frag
     -l, --line <num>      show n lines
         --raw-ip          show raw ip instead of symbol

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

After this patch:

 # perf kmem stat
 File perf.data not owned by current user or root (use -f to override)
 # perf kmem stat -f
 SUMMARY
 =======
 Total bytes requested: 437599
 Total bytes allocated: 615472
 Total bytes wasted on internal fragmentation: 177873
 Internal fragmentation: 28.900259%
 Cross CPU allocations: 6/1192

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-4-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-kmem.c