• Yunlong Song's avatar
    perf lock: Support using -f to override perf.data file ownership · c4ac732a
    Yunlong Song authored
    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: default avatarYunlong Song <yunlong.song@huawei.com>
    Tested-by: default avatarArnaldo 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    c4ac732a
builtin-lock.c 23.1 KB