1. 21 7月, 2015 4 次提交
    • W
      perf record: Apply filter to all events in a glob matching · 15bfd2cc
      Wang Nan 提交于
      There is an old problem in perf's filter applying which first posted at
      Sep. 2014 at https://lkml.org/lkml/2014/9/9/944 that, if passing
      multiple events in a glob matching expression in cmdline then add
      '--filter' after them, the filter will be applied on only the last one.
      
      For example:
      
       # dd if=/dev/zero of=/dev/null &
       [1] 464
       # perf record -a -e 'syscalls:sys_*_read' --filter 'common_pid != 464' sleep 0.1
       [ perf record: Woken up 1 times to write data ]
       [ perf record: Captured and wrote 0.239 MB perf.data (2094 samples) ]
       # perf report --stdio | tee
       ...
       # Samples: 2K of event 'syscalls:sys_enter_read'
       # Event count (approx.): 2092
       ...
       # Samples: 2  of event 'syscalls:sys_exit_read'
       # Event count (approx.): 2
       ...
      
      In this example, filter only applied on 'syscalls:sys_exit_read', and
      there's no way to set filter for ''syscalls:sys_enter_read'.
      
      This patch adds a 'cmdline_group_boundary' for 'struct evsel', and
      apply filter on all events between two boundary marks.
      
      After applying this patch:
      
       # perf record -a -e 'syscalls:sys_*_read' --filter 'common_pid != 464' sleep 0.1
       [ perf record: Woken up 1 times to write data ]
       [ perf record: Captured and wrote 0.031 MB perf.data (3 samples) ]
       # perf report --stdio | tee
       ...
       # Samples: 1  of event 'syscalls:sys_enter_read'
       # Event count (approx.): 1
       ...
       # Samples: 2  of event 'syscalls:sys_exit_read'
       # Event count (approx.): 2
       ...
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Reported-by: NBrendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1436513770-8896-1-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      15bfd2cc
    • A
      perf trace: Support 'strace' syscall event groups · 005438a8
      Arnaldo Carvalho de Melo 提交于
      I.e.:
      
        $ cat ~/share/perf-core/strace/groups/file
        access
        chmod
        creat
        execve
        faccessat
        getcwd
        lstat
        mkdir
        open
        openat
        quotactl
        readlink
        rename
        rmdir
        stat
        statfs
        symlink
        unlink
        $
      
      Then, on a quiet desktop, try running this and then moving your mouse to
      see the deluge of mouse related activity:
      
        # perf probe 'vfs_getname=getname_flags:72 pathname=filename:string'
        Added new event:
          probe:vfs_getname    (on getname_flags:72 with pathname=filename:string)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e probe:vfs_getname -aR sleep 1
        #
        # trace --ev probe:vfs_getname --filter-pids 2232 -e file
         0.042 (0.042 ms): mousetweaks/2235 open(filename: 0x14e3910, mode: 438                                   ) ...
         0.042 (        ): probe:vfs_getname:(ffffffff812230bc) pathname="/home/acme/.icons/Adwaita/cursors/xterm")
         0.100 (0.100 ms): mousetweaks/2235  ... [continued]: open()) = -1 ENOENT No such file or directory
         0.142 (0.018 ms): mousetweaks/2235 open(filename: 0x14c3c10, mode: 438                                   ) ...
         0.142 (        ): probe:vfs_getname:(ffffffff812230bc) pathname="/home/acme/.icons/Adwaita/index.theme")
         0.192 (0.069 ms): mousetweaks/2235  ... [continued]: open()) = -1 ENOENT No such file or directory
         0.230 (0.017 ms): mousetweaks/2235 open(filename: 0x14c3c10, mode: 438                                   ) ...
         0.230 (        ): probe:vfs_getname:(ffffffff812230bc) pathname="/usr/share/icons/Adwaita/cursors/xterm")
         0.253 (0.041 ms): mousetweaks/2235  ... [continued]: open()) = 14
         0.459 (0.008 ms): mousetweaks/2235 open(filename: 0x14e3910, mode: 438                                   ) ...
         0.459 (        ): probe:vfs_getname:(ffffffff812230bc) pathname="/home/acme/.icons/Adwaita/cursors/left_side")
         0.468 (0.017 ms): mousetweaks/2235  ... [continued]: open()) = -1 ENOENT No such file or directory
      
      Need to combine that raw_syscalls:sys_enter(open) + probe:vfs_getname +
      raw_syscalls:sys_exit(open) sequence...
      
      Now, if you're bored, please write some more syscall groups, like the ones
      in 'strace' and send it our way :-)
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Milian Wolff <mail@milianw.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-a42xklu59lcbxp7bbnic74a8@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      005438a8
    • A
      perf strlist: Make parse_list() private · 8816d38d
      Arnaldo Carvalho de Melo 提交于
      It is not used anywhere, expose it when/if needed.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-f6in51stj17avhk4rv11gjgg@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8816d38d
    • A
      perf strlist: Allow substitutions from file contents in a given directory · 8ff9daf3
      Arnaldo Carvalho de Melo 提交于
      So, if we have an strlist equal to:
      
         "file,close"
      
      And we call it as:
      
         struct strlist_config *config = { .dirname = "~/strace/groups", };
         struct strlist *slist = strlist__new("file, close", &config);
      
      And we have:
        $ cat ~/strace/groups/file
        access
        open
        openat
        statfs
      
      Then the resulting strlist will have these contents:
      
        [ "access", "open", "openat", "statfs", "close" ]
      
      This will be used to implement strace syscall groups in 'perf trace',
      but can be used in some other tool, thus being implemented in 'strlist'.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-wi6l6qtomqlywwr6005jvs05@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8ff9daf3
  2. 20 7月, 2015 1 次提交
  3. 16 7月, 2015 1 次提交
  4. 14 7月, 2015 1 次提交
  5. 06 7月, 2015 16 次提交
  6. 02 7月, 2015 13 次提交
  7. 26 6月, 2015 4 次提交
    • D
      libnvdimm, nfit: handle unarmed dimms, mark namespaces read-only · 58138820
      Dan Williams 提交于
      Upon detection of an unarmed dimm in a region, arrange for descendant
      BTT, PMEM, or BLK instances to be read-only.  A dimm is primarily marked
      "unarmed" via flags passed by platform firmware (NFIT).
      
      The flags in the NFIT memory device sub-structure indicate the state of
      the data on the nvdimm relative to its energy source or last "flush to
      persistence".  For the most part there is nothing the driver can do but
      advertise the state of these flags in sysfs and emit a message if
      firmware indicates that the contents of the device may be corrupted.
      However, for the case of ACPI_NFIT_MEM_ARMED, the driver can arrange for
      the block devices incorporating that nvdimm to be marked read-only.
      This is a safe default as the data is still available and new writes are
      held off until the administrator either forces read-write mode, or the
      energy source becomes armed.
      
      A 'read_only' attribute is added to REGION devices to allow for
      overriding the default read-only policy of all descendant block devices.
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      58138820
    • D
      tools/testing/nvdimm: libnvdimm unit test infrastructure · 6bc75619
      Dan Williams 提交于
      'libnvdimm' is the first driver sub-system in the kernel to implement
      mocking for unit test coverage.  The nfit_test module gets built as an
      external module and arranges for external module replacements of nfit,
      libnvdimm, nd_pmem, and nd_blk.  These replacements use the linker
      --wrap option to redirect calls to ioremap() + request_mem_region() to
      custom defined unit test resources.  The end result is a fully
      functional nvdimm_bus, as far as userspace is concerned, but with the
      capability to perform otherwise destructive tests on emulated resources.
      
      Q: Why not use QEMU for this emulation?
      QEMU is not suitable for unit testing.  QEMU's role is to faithfully
      emulate the platform.  A unit test's role is to unfaithfully implement
      the platform with the goal of triggering bugs in the corners of the
      sub-system implementation.  As bugs are discovered in platforms, or the
      sub-system itself, the unit tests are extended to backstop a fix with a
      reproducer unit test.
      
      Another problem with QEMU is that it would require coordination of 3
      software projects instead of 2 (kernel + libndctl [1]) to maintain and
      execute the tests.  The chances for bit rot and the difficulty of
      getting the tests running goes up non-linearly the more components
      involved.
      
      
      Q: Why submit this to the kernel tree instead of external modules in
         libndctl?
      Simple, to alleviate the same risk that out-of-tree external modules
      face.  Updates to drivers/nvdimm/ can be immediately evaluated to see if
      they have any impact on tools/testing/nvdimm/.
      
      
      Q: What are the negative implications of merging this?
      It is a unique maintenance burden because the purpose of mocking an
      interface to enable a unit test is to purposefully short circuit the
      semantics of a routine to enable testing.  For example
      __wrap_ioremap_cache() fakes the pmem driver into "ioremap()'ing" a test
      resource buffer allocated by dma_alloc_coherent().  The future
      maintenance burden hits when someone changes the semantics of
      ioremap_cache() and wonders what the implications are for the unit test.
      
      [1]: https://github.com/pmem/ndctl
      
      Cc: <linux-acpi@vger.kernel.org>
      Cc: Lv Zheng <lv.zheng@intel.com>
      Cc: Robert Moore <robert.moore@intel.com>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      6bc75619
    • L
      perf symbols: Check access permission when reading symbol files · 36c8bb56
      Li Zhang 提交于
      There 2 problems when reading symbols files:
      
      *  It doesn't report any errors even if when users specify symbol
         files which don't exist with --kallsyms or --vmlinux. The result
         just shows the address without symbols, which is not what is expected.
         So it's better to report errors and exit the program.
      
      *  When using command perf report --kallsyms=/proc/kallsyms with a
         non-root user, symbols are resolved. Then select one symbol and
         annotate it, it reports the error as the following:
         Can't annotate __clear_user: No vmlinux file with build id xxx was
         found.
      
         The problem is caused by reading /proc/kcore without access permission.
         /proc/kcore requires CAP_SYS_RAWIO capability to access, so it needs to
         change access permission to allow a specific user to read /proc/kcore or
         use root to execute the perf command.
      
      This patch is to report errors when symbol files specified by users
      don't exist. And check access permission of /proc/kcore when reading it.
      Signed-off-by: NLi Zhang <zhlcindy@linux.vnet.ibm.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1434704253-2632-1-git-send-email-zhlcindy@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      36c8bb56
    • J
      perf stat: Introduce --per-thread option · 32b8af82
      Jiri Olsa 提交于
      Currently all the -p option PID arguments tasks values get aggregated
      and printed as single values.
      
      Adding --per-tasks option to print values per task.
      
        $ perf stat  -e cycles,instructions --per-thread -p 30190,30242
        ^C
         Performance counter stats for process id '30190,30242':
      
                     cat-30190                     0      cycles
                     yes-30242         3,842,525,421      cycles
                     cat-30190                     0      instructions
                     yes-30242        10,370,817,010      instructions
      
               1.143155657 seconds time elapsed
      
      Also works under interval mode:
      
        $ perf stat  -e cycles,instructions --per-thread -p 30190,30242 -I 1000
        #           time             comm-pid                  counts unit events
             1.000073435              cat-30190                89,058      cycles
             1.000073435              yes-30242         3,360,786,902      cycles                     (100.00%)
             1.000073435              cat-30190                14,066      instructions
             1.000073435              yes-30242         9,069,937,462      instructions
             2.000204830              cat-30190                     0      cycles
             2.000204830              yes-30242         3,351,667,626      cycles
             2.000204830              cat-30190                     0      instructions
             2.000204830              yes-30242         9,045,796,885      instructions
        ^C     2.771286639              cat-30190                     0      cycles
             2.771286639              yes-30242         2,593,884,166      cycles
             2.771286639              cat-30190                     0      instructions
             2.771286639              yes-30242         7,001,171,191      instructions
      
      It works only with -t and -p options, otherwise following error is
      printed:
      
        $ perf stat  -e cycles --per-thread  -I 1000 ls
        The --per-thread option is only available when monitoring via -p -t options.
            -p, --pid <pid>       stat events on existing process id
            -t, --tid <tid>       stat events on existing thread id
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1435310967-14570-23-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      32b8af82