1. 18 10月, 2013 2 次提交
    • A
      perf trace: Improve messages related to /proc/sys/kernel/perf_event_paranoid · a8f23d8f
      Arnaldo Carvalho de Melo 提交于
      kernel/events/core.c has:
      
        /*
         * perf event paranoia level:
         *  -1 - not paranoid at all
         *   0 - disallow raw tracepoint access for unpriv
         *   1 - disallow cpu events for unpriv
         *   2 - disallow kernel profiling for unpriv
         */
        int sysctl_perf_event_paranoid __read_mostly = 1;
      
      So, with the default being 1, a non-root user can trace his stuff:
      
        [acme@zoo ~]$ cat /proc/sys/kernel/perf_event_paranoid
        1
        [acme@zoo ~]$ yes > /dev/null &
        [1] 15338
        [acme@zoo ~]$ trace -p 15338 | head -5
             0.005 ( 0.005 ms): write(fd: 1</dev/null>, buf: 0x7fe6db765000, count: 4096 ) = 4096
             0.045 ( 0.001 ms): write(fd: 1</dev/null>, buf: 0x7fe6db765000, count: 4096 ) = 4096
             0.085 ( 0.001 ms): write(fd: 1</dev/null>, buf: 0x7fe6db765000, count: 4096 ) = 4096
             0.125 ( 0.001 ms): write(fd: 1</dev/null>, buf: 0x7fe6db765000, count: 4096 ) = 4096
             0.165 ( 0.001 ms): write(fd: 1</dev/null>, buf: 0x7fe6db765000, count: 4096 ) = 4096
        [acme@zoo ~]$
        [acme@zoo ~]$ trace --duration 1 sleep 1
          1002.148 (1001.218 ms): nanosleep(rqtp: 0x7fff46c79250                           ) = 0
        [acme@zoo ~]$
        [acme@zoo ~]$ trace -- usleep 1 | tail -5
             0.905 ( 0.002 ms): brk(                                                     ) = 0x1c82000
             0.910 ( 0.003 ms): brk(brk: 0x1ca3000                                       ) = 0x1ca3000
             0.913 ( 0.001 ms): brk(                                                     ) = 0x1ca3000
             0.990 ( 0.059 ms): nanosleep(rqtp: 0x7fffe31a3280                           ) = 0
             0.995 ( 0.000 ms): exit_group(
        [acme@zoo ~]$
      
      But can't do system wide tracing:
      
        [acme@zoo ~]$ trace
        Error:	Operation not permitted.
        Hint:	Check /proc/sys/kernel/perf_event_paranoid setting.
        Hint:	For system wide tracing it needs to be set to -1.
        Hint:	The current value is 1.
        [acme@zoo ~]$
      
        [acme@zoo ~]$ trace --cpu 0
        Error:	Operation not permitted.
        Hint:	Check /proc/sys/kernel/perf_event_paranoid setting.
        Hint:	For system wide tracing it needs to be set to -1.
        Hint:	The current value is 1.
        [acme@zoo ~]$
      
      If the paranoid level is >= 2, i.e. turn this perf stuff off for !root users:
      
        [acme@zoo ~]$ sudo sh -c 'echo 2 > /proc/sys/kernel/perf_event_paranoid'
        [acme@zoo ~]$ cat /proc/sys/kernel/perf_event_paranoid
        2
        [acme@zoo ~]$
        [acme@zoo ~]$ trace usleep 1
        Error:	Permission denied.
        Hint:	Check /proc/sys/kernel/perf_event_paranoid setting.
        Hint:	For your workloads it needs to be <= 1
        Hint:	For system wide tracing it needs to be set to -1.
        Hint:	The current value is 2.
        [acme@zoo ~]$
        [acme@zoo ~]$ trace
        Error:	Permission denied.
        Hint:	Check /proc/sys/kernel/perf_event_paranoid setting.
        Hint:	For your workloads it needs to be <= 1
        Hint:	For system wide tracing it needs to be set to -1.
        Hint:	The current value is 2.
        [acme@zoo ~]$
        [acme@zoo ~]$ trace --cpu 1
        Error:	Permission denied.
        Hint:	Check /proc/sys/kernel/perf_event_paranoid setting.
        Hint:	For your workloads it needs to be <= 1
        Hint:	For system wide tracing it needs to be set to -1.
        Hint:	The current value is 2.
        [acme@zoo ~]$
      
      If the user manages to get what he/she wants, convincing root not
      to be paranoid at all...
      
        [root@zoo ~]# echo -1 > /proc/sys/kernel/perf_event_paranoid
        [root@zoo ~]# cat /proc/sys/kernel/perf_event_paranoid
        -1
        [root@zoo ~]#
      
        [acme@zoo ~]$ ps -eo user,pid,comm | grep Xorg
        root       729 Xorg
        [acme@zoo ~]$
        [acme@zoo ~]$ trace -a --duration 0.001 -e \!select,ioctl,writev | grep Xorg  | head -5
            23.143 ( 0.003 ms): Xorg/729 setitimer(which: REAL, value: 0x7fffaadf16e0 ) = 0
            23.152 ( 0.004 ms): Xorg/729 read(fd: 31, buf: 0x2544af0, count: 4096     ) = 8
            23.161 ( 0.002 ms): Xorg/729 read(fd: 31, buf: 0x2544af0, count: 4096     ) = -1 EAGAIN Resource temporarily unavailable
            23.175 ( 0.002 ms): Xorg/729 setitimer(which: REAL, value: 0x7fffaadf16e0 ) = 0
            23.235 ( 0.002 ms): Xorg/729 setitimer(which: REAL, value: 0x7fffaadf16e0 ) = 0
        [acme@zoo ~]$
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-di28olfwd28rvkox7v3hqhu1@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a8f23d8f
    • A
      perf evlist: Introduce perf_evlist__strerror_tp method · 6ef068cb
      Arnaldo Carvalho de Melo 提交于
      Out of 'perf trace', should be used by other tools that uses
      tracepoints.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ramkumar Ramachandra <artagnon@gmail.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-lyvtxhchz4ga8fwht15x8wou@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6ef068cb
  2. 17 10月, 2013 1 次提交
  3. 16 10月, 2013 2 次提交
    • A
      perf trace: Use vfs_getname hook if available · c522739d
      Arnaldo Carvalho de Melo 提交于
      Initially it tries to find a probe:vfs_getname that should be setup
      with:
      
       perf probe 'vfs_getname=getname_flags:65 pathname=result->name:string'
      
      or with slight changes to cope with code flux in the getname_flags code.
      
      In the future, if a "vfs:getname" tracepoint becomes available, then it
      will be preferred.
      
      This is not strictly required and more expensive method of reading the
      /proc/pid/fd/ symlink will be used when the fd->path array entry is not
      populated by a previous vfs_getname + open syscall ret sequence.
      
      As with any other 'perf probe' probe the setup must be done just once
      and the probe will be left inactive, waiting for users, be it 'perf
      trace' of any other tool.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-ujg8se8glq5izmu8cdkq15po@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c522739d
    • A
      perf trace: Split fd -> pathname array handling · 97119f37
      Arnaldo Carvalho de Melo 提交于
      So that the part that grows the array as needed is untied from the code
      that reads the /proc/pid/fd symlink and can be used for the vfs_getname
      hook that will set the fd -> path translation too, when available.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-ydo5rumyv9hdc1vsfmqamugs@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      97119f37
  4. 14 10月, 2013 2 次提交
    • D
      perf trace: Add summary option to dump syscall statistics · bf2575c1
      David Ahern 提交于
      When enabled dumps a summary of all syscalls by task with the usual
      statistics -- min, max, average and relative stddev. For example,
      
      make - 26341 :       3344   [ 17.4% ]      0.000 ms
      
                      read :   52    0.000     4.802     0.644   30.08
                     write :   20    0.004     0.036     0.010   21.72
                      open :   24    0.003     0.046     0.014   23.68
                     close :   64    0.002     0.055     0.008   22.53
                      stat : 2714    0.002     0.222     0.004    4.47
                     fstat :   18    0.001     0.041     0.006   46.26
                      mmap :   30    0.003     0.009     0.006    5.71
                  mprotect :    8    0.006     0.039     0.016   32.16
                    munmap :   12    0.007     0.077     0.020   38.25
                       brk :   48    0.002     0.014     0.004   10.18
              rt_sigaction :   18    0.002     0.002     0.002    2.11
            rt_sigprocmask :   60    0.002     0.128     0.010   32.88
                    access :    2    0.006     0.006     0.006    0.00
                      pipe :   12    0.004     0.048     0.013   35.98
                     vfork :   34    0.448     0.980     0.692    3.04
                    execve :   20    0.000     0.387     0.046   56.66
                     wait4 :   34    0.017  9923.287   593.221   68.45
                     fcntl :    8    0.001     0.041     0.013   48.79
                  getdents :   48    0.002     0.079     0.013   19.62
                    getcwd :    2    0.005     0.005     0.005    0.00
                     chdir :    2    0.070     0.070     0.070    0.00
                 getrlimit :    2    0.045     0.045     0.045    0.00
                arch_prctl :    2    0.002     0.002     0.002    0.00
                 setrlimit :    2    0.002     0.002     0.002    0.00
                    openat :   94    0.003     0.005     0.003    2.11
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1381289214-24885-3-git-send-email-dsahern@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bf2575c1
    • R
      perf trace: Improve the error messages · 87f91868
      Ramkumar Ramachandra 提交于
      Currently, execution of 'perf trace' reports the following cryptic
      message to the user:
      
      $ perf trace
      Couldn't read the raw_syscalls tracepoints information!
      
      Typically this happens because the user does not have permissions to
      read the debugfs filesystem. Also handle the case when the kernel was
      not compiled with debugfs support or when it isn't mounted.
      
      Now, the tool prints detailed error messages:
      
      $ perf trace
      Error:	Unable to find debugfs
      Hint:	Was your kernel was compiled with debugfs support?
      Hint:	Is the debugfs filesystem mounted?
      Hint:	Try 'sudo mount -t debugfs nodev /sys/kernel/debug'
      
      $ perf trace
      Error:	No permissions to read /sys/kernel/debug//tracing/events/raw_syscalls
      Hint:	Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/'
      Signed-off-by: NRamkumar Ramachandra <artagnon@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/1380863851-14460-1-git-send-email-artagnon@gmail.com
      [ Added ready to use commands to fix the issues as extra hints, use the
        current debugfs mount point when reporting permission error, use
        strerror_r instead of the deprecated sys_errlist, as reported by David Ahern ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      87f91868
  5. 11 10月, 2013 6 次提交
    • A
      perf trace: Initial beautifier for ioctl's 'cmd' arg · 78645cf3
      Arnaldo Carvalho de Melo 提交于
       [root@zoo linux]# trace -e ioctl | grep -v "cmd: 0x" | head -10
            0.386 ( 0.001 ms): trace/1602 ioctl(fd: 1<pipe:[127057]>, cmd: TCGETS, arg: 0x7fff59fcb4d0          ) = -1 ENOTTY Inappropriate ioctl for device
         1459.368 ( 0.002 ms): inotify_reader/10352 ioctl(fd: 18<anon_inode:inotify>, cmd: FIONREAD, arg: 0x7fb835228bcc  ) = 0
         1463.586 ( 0.002 ms): inotify_reader/10352 ioctl(fd: 18<anon_inode:inotify>, cmd: FIONREAD, arg: 0x7fb835228bcc  ) = 0
         1463.611 ( 0.002 ms): inotify_reader/10352 ioctl(fd: 18<anon_inode:inotify>, cmd: FIONREAD, arg: 0x7fb835228bcc  ) = 0
         3740.526 ( 0.002 ms): awk/1612 ioctl(fd: 1<pipe:[128265]>, cmd: TCGETS, arg: 0x7fff4d166b90          ) = -1 ENOTTY Inappropriate ioctl for device
         3740.704 ( 0.001 ms): awk/1612 ioctl(fd: 3</proc/meminfo>, cmd: TCGETS, arg: 0x7fff4d1669a0          ) = -1 ENOTTY Inappropriate ioctl for device
         3742.550 ( 0.002 ms): ps/1614 ioctl(fd: 1<pipe:[128266]>, cmd: TIOCGWINSZ, arg: 0x7fff591762b0      ) = -1 ENOTTY Inappropriate ioctl for device
         3742.555 ( 0.003 ms): ps/1614 ioctl(fd: 2<socket:[19550]>, cmd: TIOCGWINSZ, arg: 0x7fff591762b0     ) = -1 ENOTTY Inappropriate ioctl for device
         3742.558 ( 0.002 ms): ps/1614 ioctl(cmd: TIOCGWINSZ, arg: 0x7fff591762b0                            ) = -1 ENOTTY Inappropriate ioctl for device
         3742.572 ( 0.002 ms): ps/1614 ioctl(fd: 1<pipe:[128266]>, cmd: TCGETS, arg: 0x7fff59176220          ) = -1 ENOTTY Inappropriate ioctl for device
       [root@zoo linux]#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-afajwap3mr60dfl4qpdl1pxn@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      78645cf3
    • A
      perf trace: Prepare the strarray scnprintf method for reuse · 975b7c2f
      Arnaldo Carvalho de Melo 提交于
      Right now when an index passed to that method has no string associated
      it'll print the index as a decimal number, prepare it so that we can use
      it to print it in hex as well, for ioctls, for instance.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-nsvy06sqj64qvnkmzvwxsx2v@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      975b7c2f
    • A
      perf trace: Allow specifying index offset in strarrays · 03e3adc9
      Arnaldo Carvalho de Melo 提交于
      So that the index passed doesn't have to start at zero, being
      decremented from an offset specified when declaring the strarray before
      being used as the real array index.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-k1ce6uqyt4qar9edrj3mevod@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      03e3adc9
    • D
      perf trace: Use new machine method to loop over threads · 896cbb56
      David Ahern 提交于
      Use the new machine method that loops over threads to dump summary data.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1380395584-9025-3-git-send-email-dsahern@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      896cbb56
    • D
      perf trace: Add record option · 5e2485b1
      David Ahern 提交于
      The record option is a convience alias to include the -e raw_syscalls:*
      argument to perf-record. All other options are passed to perf-record's
      handler. Resulting data file can be analyzed by perf-trace -i.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1380395584-9025-5-git-send-email-dsahern@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5e2485b1
    • D
      perf trace: Fix comm resolution when reading events from file · 8fb598e5
      David Ahern 提交于
      Task comm's are getting lost when processing events from a file. The
      problem is that the trace struct used by the live processing has its
      host machine and the perf-session used for file based processing has its
      host machine.  Fix by having both references point to the same machine.
      
      Before:
      
           0.030 ( 0.001 ms): :27743/27743 brk( ...
           0.057 ( 0.004 ms): :27743/27743 mmap(len: 4096, prot: READ|WRITE, flags: ...
           0.075 ( 0.006 ms): :27743/27743 access(filename: 0x7f3809fbce00, mode: R ...
           0.091 ( 0.005 ms): :27743/27743 open(filename: 0x7f3809fba14c, flags: CLOEXEC ...
      ...
      
      After:
           0.030 ( 0.001 ms): make/27743 brk( ...
           0.057 ( 0.004 ms): make/27743 mmap(len: 4096, prot: READ|WRITE, flags: ...
           0.075 ( 0.006 ms): make/27743 access(filename: 0x7f3809fbce00, mode: R ...
           0.091 ( 0.005 ms): make/27743 open(filename: 0x7f3809fba14c, flags: CLOEXEC ...
      ...
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1380395584-9025-4-git-send-email-dsahern@gmail.com
      [ Moved creation of new host machine to a separate constructor: machine__new_host() ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8fb598e5
  6. 10 10月, 2013 10 次提交
  7. 09 10月, 2013 17 次提交