1. 26 Sep, 2014 9 commits
  2. 25 Sep, 2014 14 commits
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Filter out POLLHUP'ed file descriptors · 46fb3c21
      Arnaldo Carvalho de Melo authored
      So that we don't continue polling on vanished file descriptors, i.e.
      file descriptors for events monitoring threads that exited.
      
      I.e. the following 'trace' command now exits as expected, instead
      of staying in an eternal loop:
      
            $ sleep 5s &
            $ trace -p `pidof sleep`
      Reported-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      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-6qegv786zbf6i8us6t4rxug9@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      46fb3c21
    • Arnaldo Carvalho de Melo's avatar
      perf record: Filter out POLLHUP'ed file descriptors · 6dcf45ef
      Arnaldo Carvalho de Melo authored
      So that we don't continue polling on vanished file descriptors, i.e.
      file descriptors for events monitoring threads that exited.
      
      I.e. the following 'perf record' command now exits as expected, instead
      of staying in an eternal loop:
      
        $ sleep 5s &
        $ perf record -p `pidof sleep`
      Reported-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      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-8dg8o21t2ntzly2bfh53p3sg@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6dcf45ef
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Unmap when all refcounts to fd are gone and events drained · e4b356b5
      Arnaldo Carvalho de Melo authored
      As noticed by receiving a POLLHUP for all its pollfd entries.
      
      That will remove the refcount taken in perf_evlist__mmap_per_evsel(),
      and when all events are consumed via perf_evlist__mmap_read() +
      perf_evlist__mmap_consume(), the ring buffer will be unmap'ed.
      
      Thanks to Jiri Olsa for pointing out that we must wait till all events
      are consumed, not being ok to unmmap just when receiving all the
      POLLHUPs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/n/tip-t10w1xk4myp7ca7m9fvip6a0@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e4b356b5
    • Arnaldo Carvalho de Melo's avatar
      tools lib fd array: Allow associating an integer cookie with each entry · 2171a925
      Arnaldo Carvalho de Melo authored
      We will use this in perf's evlist class so that it can, at
      fdarray__filter() time, to unmap the associated ring buffer.
      
      We may need to have further info associated with each fdarray entry, in
      that case we'll make that int array a 'union fdarray_priv' one and put a
      pointer there so that users can stash whatever they want there. For now,
      an int is enough tho.
      
      v2: Add clarification to the per array entry priv area, as well as make
          it a union, which makes usage a bit longer, but if/when we make it
          use more space by allowing per entry pointers existing users source
          code will not have to be changed, just rebuilt.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      
      Link: http://lkml.kernel.org/n/tip-0p00bn83quck3fio3kcs9vca@git.kernel.org
      2171a925
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Refcount mmaps · 82396986
      Arnaldo Carvalho de Melo authored
      We need to know how many fds are using a perf mmap via
      PERF_EVENT_IOC_SET_OUTPUT, so that we can know when to ditch an mmap,
      refcount it.
      
      v2: Automatically unmap it when the refcount hits one, which will happen
      when all fds are filtered by perf_evlist__filter_pollfd(), in later
      patches.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20140908153824.GG2773@kernel.org
      Link: http://lkml.kernel.org/n/tip-cpv7v2lw0g74ucmxa39xdpms@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      82396986
    • Arnaldo Carvalho de Melo's avatar
      tools lib api: Adopt fdarray class from perf's evlist · 1b85337d
      Arnaldo Carvalho de Melo authored
      The extensible file description array that grew in the perf_evlist class
      can be useful for other tools, as it is not something that only evlists
      need, so move it to tools/lib/api/fd to ease sharing it.
      
      v2: Don't use {} like in:
      
       libapi_dirs:
      	$(QUIET_MKDIR)mkdir -p $(OUTPUT){fs,fd}/
      
      in Makefiles, as it will not work in some systems, as in ubuntu13.10.
      
      v3: Add fd/*.[ch] to LIBAPIKFS_SOURCES (Fix from Jiri Olsa)
      
      v4: Leave the fcntl(fd, O_NONBLOCK) in the evlist layer, remains to
          be checked if it is really needed there, but has no place in the
          fdarray class (Fix from Jiri Olsa)
      
      v5: Remove evlist details from fdarray grow/filter tests. Improve it a
          bit doing more tests about expected internal state.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/n/tip-kleuni3hckbc3s0lu6yb9x40@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1b85337d
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Introduce poll method for common code idiom · f66a889d
      Arnaldo Carvalho de Melo authored
      Since we have access two evlist members in all these poll calls, provide
      a helper.
      
      This will also help to make the patch introducing the pollfd class more
      clear, as the evlist specific uses will be hiden away
      perf_evlist__poll().
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/n/tip-jr9d4aop4lvy9453qahbcgp0@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f66a889d
    • Arnaldo Carvalho de Melo's avatar
      perf kvm stat live: Use perf_evlist__add_pollfd() instead of local equivalent · 0a04c9e0
      Arnaldo Carvalho de Melo authored
      Since we can add file descriptors to the evlist pollfd and it will
      autogrow, no need to copy all events to a local pollfd array, just add
      the timer and stdin file descriptors.
      Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/n/tip-2hvp9iromiheh6rl4oaa08x5@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0a04c9e0
    • Arnaldo Carvalho de Melo's avatar
      perf tests: Add pollfd growing test · 9ae28035
      Arnaldo Carvalho de Melo authored
        [acme@ssdandy linux]$ perf test "Add fd"
        34: Add fd to pollfd array, making it autogrow             : Ok
        [acme@ssdandy linux]$ perf test -v "Add fd"
        34: Add fd to pollfd array, making it autogrow             :
        --- start ---
        test child forked, pid 19817
      
        before growing array:   2 [ 1, 2 ]
        after 3rd add_pollfd:   3 [ 1, 2, 35 ]
        after 4th add_pollfd:   4 [ 1, 2, 35, 88 ]
        test child finished with 0
        ---- end ----
        Add fd to pollfd array, making it autogrow: Ok
        [acme@ssdandy linux]$
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/n/tip-smflpyta146bzog7z0effjss@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9ae28035
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Allow growing pollfd on add method · ad6765dd
      Arnaldo Carvalho de Melo authored
      This way we will be able to add more file descriptors to be polled,
      like stdin or some timer fd.
      
      At this point we might as well yank the pollfd class from evlist so that
      it can be used in other places.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/n/tip-o2mzsjl7taumsoc35ryol00i@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ad6765dd
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: We need to poll all event file descriptors · 033fa713
      Arnaldo Carvalho de Melo authored
      Because we want to notice when they get POLLHUP'ed, so that we can
      figure out when all threads exited in a workload being monitored.
      
      We can't just monitor the fds that were mmaped, we need to notice when
      all the fds that were PERF_EVENT_IOC_SET_OUTPUT'ed too, because the mmap
      stays even after the fd that originally was used to do the mmap call
      went away, its only when all the set-output fds for a mmap are gone that
      the mmap is.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20140908151016.GH17728@krava.brq.redhat.com
      Link: http://lkml.kernel.org/n/tip-24omlq5asrfg4uo3muuzn2bl@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      033fa713
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Monitor POLLERR and POLLHUP events too · 8179672c
      Arnaldo Carvalho de Melo authored
      We want to know when the fd went away, like when a monitored thread
      exits.
      
      If we do not monitor such events, then the tools will wait forever on
      events from a vanished thread, like when running:
      
       $ sleep 5s &
       $ perf record -p `pidof sleep`
      
      This builds upon the kernel patch by Jiri Olsa that actually makes a
      poll on those file descriptors to return POLLHUP.
      
      It is also needed to change the tools to use
      perf_evlist__filter_pollfd() to check if there are remainings fds to
      monitor or if all are gone, in which case they will exit the
      poll/mmap/read loop.
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      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-a4fslwspov0bs69nj825hqpq@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8179672c
    • Arnaldo Carvalho de Melo's avatar
      perf tests: Add test for perf_evlist__filter_pollfd() · 54dbfae3
      Arnaldo Carvalho de Melo authored
      That will use a synthetic evlist with just what is touched by this new
      method to check that it works as expected.
      
      Output in verbose mode:
      
        $ perf test -v pollfd
        33: Filter fds with revents mask in a pollfd array         :
        --- start ---
        filtering all but pollfd[2]:
        before:   5 [ 5, 4, 3, 2, 1 ]
         after:   1 [ 3 ]
        filtering all but (pollfd[0], pollfd[3]):
        before:   5 [ 5, 4, 3, 2, 1 ]
         after:   2 [ 5, 2 ]
        test child finished with 0
        ---- end ----
        Filter fds with revents mask in a pollfd array: Ok
        $
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      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-x7c8liszdvc3ocmanf2cet8p@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      54dbfae3
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Introduce perf_evlist__filter_pollfd method · 1ddec7f0
      Arnaldo Carvalho de Melo authored
      To remove all entries in evlist->pollfd[] that have revents matching at
      least one of the bits in the specified mask.
      
      It'll adjust evlist->nr_fds to the number of unfiltered fds and will
      return this value, as a convenience and to avoid requiring direct access
      to internal state of perf_evlist objects.
      
      This will be used after polling the evlist fds so that we remove fds
      that were closed by the kernel.
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      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-y2sca7z3wicvvy40a50lozwm@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1ddec7f0
  3. 24 Sep, 2014 13 commits
  4. 19 Sep, 2014 1 commit
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 4f7cf3a9
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      User visible changes:
      
        o Add +field argument support for --sort option (Jiri Olsa)
      
        o Do not access kallsyms when analyzing user binaries with 'probe' (Masami Hiramatsu)
      
        o Ignore stripped vmlinux and fallback to kallsyms (Anton Blanchard)
      
        o Add path to Ubuntu kernel debuginfo file (Anton Blanchard)
      
        o Disable kernel symbol demangling by default (Avi Kivity)
      
      Infrastructure changes:
      
        o More intel PT prep work, from Adrian Hunter, including:
      
          - Let a user specify a PMU event without any config terms
          - Add perf-with-kcore script
          - Let default config be defined for a PMU
          - Add perf_pmu__scan_file()
      
        o "perf kvm stat report" improvements by Alexander Yarygin:
          o  Save pid string in opts.target.pid
          o  Enable the target.system_wide flag
          o  Unify the title bar output
      
        o Fix build issue on powerpc when DWARF support is disabled (Anton Blanchard)
      
        o Allow to specify lib compile variable for spec usage (Jiri Olsa)
      
        o Fix build on ARM (Stephane Eranian)
      
        o Fix build on powerpc when DWARF support is disabled (Anton Blanchard)
      
        o Don't include sys/poll.h directly (Arnaldo Carvalho de Melo)
      
        o Use ring buffer consume method to look like other tools (Arnaldo Carvalho de Melo)
      
        o Allow to specify lib compile variable for spec usage (Jiri Olsa)
      
        o Fix GNU-only grep usage in Makefile (John Spencer)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      4f7cf3a9
  5. 17 Sep, 2014 3 commits