1. 17 Mar, 2010 8 commits
    • Masami Hiramatsu's avatar
      perf probe: Rename some die_get_* functions · 95a3e4c4
      Masami Hiramatsu authored
      Rename die_get_real_subprogram and die_get_inlinefunc to
      die_find_real_subprogram and die_find_inlinefunc respectively,
      because these functions search its children. After that,
      'die_get_' means getting a property of that die, and
      'die_find_' means searching DIE-tree to get an appropriate
      child die.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
      Cc: systemtap <systemtap@sources.redhat.com>
      Cc: DLE <dle-develop@lists.sourceforge.net>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      LKML-Reference: <20100316220551.32050.36181.stgit@localhost6.localdomain6>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      95a3e4c4
    • Masami Hiramatsu's avatar
      perf probe: Rename session to param · 12a1fadb
      Masami Hiramatsu authored
      Since this name 'session' conflicts with 'perf_session', and
      this structure just holds parameters anymore.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
      Cc: systemtap <systemtap@sources.redhat.com>
      Cc: DLE <dle-develop@lists.sourceforge.net>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      LKML-Reference: <20100316220544.32050.8788.stgit@localhost6.localdomain6>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      12a1fadb
    • Masami Hiramatsu's avatar
      perf probe: Move add-probe routine to util/ · e0faa8d3
      Masami Hiramatsu authored
      Move add-probe routine to util/probe_event.c. This simplifies
      main routine for reducing maintenance cost.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
      Cc: systemtap <systemtap@sources.redhat.com>
      Cc: DLE <dle-develop@lists.sourceforge.net>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      LKML-Reference: <20100316220537.32050.72214.stgit@localhost6.localdomain6>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      e0faa8d3
    • Masami Hiramatsu's avatar
      perf probe: Use wrapper functions · 31facc5f
      Masami Hiramatsu authored
      Use wrapped functions as much as possible, to check out of
      memory conditions in perf probe.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
      Cc: systemtap <systemtap@sources.redhat.com>
      Cc: DLE <dle-develop@lists.sourceforge.net>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      LKML-Reference: <20100316220530.32050.53951.stgit@localhost6.localdomain6>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      31facc5f
    • Masami Hiramatsu's avatar
      perf tools: Introduce xzalloc() for detecting out of memory conditions · a1d37d52
      Masami Hiramatsu authored
      Introducing xzalloc() which wrapping zalloc() for detecting out
      of memory conditions.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
      Cc: systemtap <systemtap@sources.redhat.com>
      Cc: DLE <dle-develop@lists.sourceforge.net>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      LKML-Reference: <20100316220521.32050.85155.stgit@localhost6.localdomain6>
      [ -v2: small cleanups in surrounding code ]
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      a1d37d52
    • Ingo Molnar's avatar
      Merge branch 'perf/urgent' into perf/core · e4713e93
      Ingo Molnar authored
      Merge reason: We'll be queueing dependent changes.
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      e4713e93
    • Frederic Weisbecker's avatar
      perf: Fix unexported generic perf_arch_fetch_caller_regs · a6b84574
      Frederic Weisbecker authored
      perf_arch_fetch_caller_regs() is exported for the overriden x86
      version, but not for the generic weak version.
      
      As a general rule, weak functions should not have their symbol
      exported in the same file they are defined.
      
      So let's export it on trace_event_perf.c as it is used by trace
      events only.
      
      This fixes:
      
      	ERROR: ".perf_arch_fetch_caller_regs" [fs/xfs/xfs.ko] undefined!
      	ERROR: ".perf_arch_fetch_caller_regs" [arch/powerpc/platforms/cell/spufs/spufs.ko] undefined!
      
      -v2: And also only build it if trace events are enabled.
      -v3: Fix changelog mistake
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1268697902-9518-1-git-send-regression-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      a6b84574
    • Robert Richter's avatar
      perf, x86: Report error code that returned from x86_pmu.hw_config() · 984763cb
      Robert Richter authored
      If x86_pmu.hw_config() fails a fixed error code (-EOPNOTSUPP) is
      returned even if a different error was reported. This patch fixes
      this.
      Signed-off-by: default avatarRobert Richter <robert.richter@amd.com>
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      Acked-by: default avatarLin Ming <ming.m.lin@intel.com>
      Cc: acme@redhat.com
      Cc: eranian@google.com
      Cc: gorcunov@openvz.org
      Cc: peterz@infradead.org
      Cc: fweisbec@gmail.com
      LKML-Reference: <20100316160733.GR1585@erda.amd.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      984763cb
  2. 16 Mar, 2010 7 commits
  3. 15 Mar, 2010 4 commits
    • Arnaldo Carvalho de Melo's avatar
      perf annotate: Properly notify the user that vmlinux is missing · d06d92b7
      Arnaldo Carvalho de Melo authored
      Before this patch we would not find a vmlinux, then try to pass
      objdump "[kernel.kallsyms]" as the filename, it would get
      confused and produce no output:
      
       [root@doppio ~]# perf annotate n_tty_write
      
       ------------------------------------------------
        Percent |      Source code & Disassembly of [kernel.kallsyms]
       ------------------------------------------------
      
      Now we check that and emit meaningful warning:
      
       [root@doppio ~]# perf annotate n_tty_write
       Can't annotate n_tty_write: No vmlinux file was found in the
       path: [0] vmlinux
       [1] /boot/vmlinux
       [2] /boot/vmlinux-2.6.34-rc1-tip+
       [3] /lib/modules/2.6.34-rc1-tip+/build/vmlinux
       [4] /usr/lib/debug/lib/modules/2.6.34-rc1-tip+/vmlinux
       [root@doppio ~]#
      
      This bug was introduced when we added automatic search for
      vmlinux, before that time the user had to specify a vmlinux
      file.
      
      v2: Print the warning just for the first symbol found when no
          symbol name is specified, otherwise it will spam the screen
          repeating the warning for each symbol.
      Reported-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: <stable@kernel.org>
      LKML-Reference: <1268669073-6856-1-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      d06d92b7
    • Arnaldo Carvalho de Melo's avatar
      perf top: Properly notify the user that vmlinux is missing · b0a9ab62
      Arnaldo Carvalho de Melo authored
      Before this patch this message would very briefly appear on the
      screen and then the screen would get updates only on the top,
      for number of interrupts received, etc, but no annotation would
      be performed:
      
       [root@doppio linux-2.6-tip]# perf top -s n_tty_write > /tmp/bla
       objdump: '[kernel.kallsyms]': No such file
      
      Now this is what the user gets:
      
       [root@doppio linux-2.6-tip]# perf top -s n_tty_write
       Can't annotate n_tty_write: No vmlinux file was found in the
       path: [0] vmlinux
       [1] /boot/vmlinux
       [2] /boot/vmlinux-2.6.33-rc5
       [3] /lib/modules/2.6.33-rc5/build/vmlinux
       [4] /usr/lib/debug/lib/modules/2.6.33-rc5/vmlinux
       [root@doppio linux-2.6-tip]#
      
      This bug was introduced when we added automatic search for
      vmlinux, before that time the user had to specify a vmlinux
      file.
      Reported-by: default avatarDavid S. Miller <davem@davemloft.net>
      Reported-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: <stable@kernel.org>
      LKML-Reference: <1268664418-28328-2-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      b0a9ab62
    • Eric B Munson's avatar
      perf record: Enable the enable_on_exec flag if record forks the target · bedbfdea
      Eric B Munson authored
      When forking its target, perf record can capture data from
      before the target application is started.  Perf stat uses the
      enable_on_exec flag in the event attributes to keep from
      displaying events from before the target program starts, this
      patch adds the same functionality to perf record when it is will
      fork the target process.
      Signed-off-by: default avatarEric B Munson <ebmunson@us.ibm.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1268664418-28328-1-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      bedbfdea
    • Cyrill Gorcunov's avatar
      perf, x86: Enable not tagged retired instruction counting on P4s · e4495262
      Cyrill Gorcunov authored
      This should turn on instruction counting on P4s, which was missing in
      the first version of the new PMU driver.
      
      It's inaccurate for now, we still need dependant event to tag mops
      before we can count them precisely. The result is that the number of
      instruction may be lifted up.
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
      Signed-off-by: default avatarLin Ming <ming.m.lin@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      LKML-Reference: <1268629102.3355.11.camel@minggr.sh.intel.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      e4495262
  4. 13 Mar, 2010 4 commits
  5. 12 Mar, 2010 11 commits
    • Ingo Molnar's avatar
      Merge branch 'perf/x86' into perf/core · 03086359
      Ingo Molnar authored
      Merge reason: The new P4 driver is stable and ready now for more
                    testing.
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      03086359
    • Arnaldo Carvalho de Melo's avatar
      perf hist: Don't fprintf the callgraph unconditionally · 3997d377
      Arnaldo Carvalho de Melo authored
      [root@doppio ~]# perf report -i newt.data | head -10
        # Samples: 11999679868
        #
        # Overhead  Command                  Shared Object  Symbol
        # ........  .......  .............................  ......
        #
            63.61%     perf  libslang.so.2.1.4              [.] SLsmg_write_chars
             6.30%     perf  perf                           [.] symbols__find
             2.19%     perf  libnewt.so.0.52.10             [.] newtListboxAppendEntry
             2.08%     perf  libslang.so.2.1.4              [.] SLsmg_write_chars@plt
             1.99%     perf  libc-2.10.2.so                 [.] _IO_vfprintf_internal
        [root@doppio ~]#
      
      Not good, the newt form for report works, but slang has to eat
      the cost of the additional callgraph lines everytime it prints a
      line, and the callgraph doesn't appear on the screen, so move
      the callgraph printing to a separate function and don't use it
      in newt.c.
      
      Newt tree widgets are being investigated to properly support
      callgraphs, but till that gets merged, lets remove this huge
      overhead and show at least the symbol overheads for a callgraph
      rich perf.data with good performance.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1268408808-13595-2-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      3997d377
    • Arnaldo Carvalho de Melo's avatar
      perf newt: Use newtGetScreenSize · cb7afb70
      Arnaldo Carvalho de Melo authored
      For consistency, use the newt API more fully.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1268408808-13595-1-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      cb7afb70
    • Arnaldo Carvalho de Melo's avatar
      perf newt: Add 'Q', 'q' and Ctrl+C as ways to exit from forms · 7081e087
      Arnaldo Carvalho de Melo authored
      These are keys people expect when pressed to exit the current
      widget, so have associate all of them to this semantic.
      Suggested-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1268401692-9361-1-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      7081e087
    • Arnaldo Carvalho de Melo's avatar
      perf report: Implement initial UI using newt · f9224c5c
      Arnaldo Carvalho de Melo authored
      Newt has widespread availability and provides a rather simple
      API as can be seen by the size of this patch.
      
      The work needed to support it will benefit other frontends too.
      
      In this initial patch it just checks if the output is a tty, if
      not it falls back to the previous behaviour, also if
      newt-devel/libnewt-dev is not installed the previous behaviour
      is maintaned.
      
      Pressing enter on a symbol will annotate it, ESC in the
      annotation window will return to the report symbol list.
      
      More work will be done to remove the special casing in
      color_fprintf, stop using fmemopen/FILE in the printing of
      hist_entries, etc.
      
      Also the annotation doesn't need to be done via spawning "perf
      annotate" and then browsing its output, we can do better by
      calling directly the builtin-annotate.c functions, that would
      then be moved to tools/perf/util/annotate.c and shared with perf
      top, etc
      
      But lets go by baby steps, this patch already improves perf
      usability by allowing to quickly do annotations on symbols from
      the report screen and provides a first experimentation with
      libnewt/TUI integration of tools.
      
      Tested on RHEL5 and Fedora12 X86_64 and on Debian PARISC64 to
      browse a perf.data file collected on a Fedora12 x86_64 box.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Avi Kivity <avi@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1268349164-5822-5-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      f9224c5c
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Add missing bytes printed in hist_entry__fprintf · dd2ee78d
      Arnaldo Carvalho de Melo authored
      We need those to properly size the browser widht in the newt
      TUI.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1268349164-5822-4-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      dd2ee78d
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Use eprintf for pr_{err,warning,info} too · b4f5296f
      Arnaldo Carvalho de Melo authored
      Just like we do for pr_debug, so that we can have a single point
      where to redirect to the currently used output system, be it
      stdio or newt.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1268349164-5822-3-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      b4f5296f
    • Arnaldo Carvalho de Melo's avatar
      perf top: Export get_window_dimensions · 895f0edc
      Arnaldo Carvalho de Melo authored
      Will be used by the newt code too.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1268349164-5822-2-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      895f0edc
    • Arnaldo Carvalho de Melo's avatar
      perf symbols: Bump plt synthesizing warning debug level · fe2197b8
      Arnaldo Carvalho de Melo authored
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1268349164-5822-1-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      fe2197b8
    • Ingo Molnar's avatar
      Merge branch 'perf/urgent' into perf/core · 937779db
      Ingo Molnar authored
      Merge reason: We want to queue up a dependent patch.
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      937779db
    • Cyrill Gorcunov's avatar
      x86, perf: Fix NULL deref on not assigned x86_pmu · 0b861225
      Cyrill Gorcunov authored
      In case of not assigned x86_pmu and software events NULL dereference may
      being hit via x86_pmu::schedule_events method.
      
      Fix it by checking if x86_pmu is initialized at all.
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
      Cc: Lin Ming <ming.m.lin@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Robert Richter <robert.richter@amd.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      LKML-Reference: <20100311215016.GG25162@lenovo>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      0b861225
  6. 11 Mar, 2010 6 commits
    • Arnaldo Carvalho de Melo's avatar
      perf record: Mention paranoid sysctl when failing to create counter · 6230f2c7
      Arnaldo Carvalho de Melo authored
      [acme@mica linux-2.6-tip]$ perf record -a -f
         Fatal: Permission error - are you root?
       	 Consider tweaking /proc/sys/kernel/perf_event_paranoid.
      
       [acme@mica linux-2.6-tip]$
      Suggested-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1268333592-30872-2-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      6230f2c7
    • Arnaldo Carvalho de Melo's avatar
      perf record: Don't try to find buildids in a zero sized file · 9f591fd7
      Arnaldo Carvalho de Melo authored
      Fixing this symptom:
      
       [acme@mica linux-2.6-tip]$ perf record -a -f
         Fatal: Permission error - are you root?
      
       Bus error
       [acme@mica linux-2.6-tip]$
      
      I.e. if for some reason no data is collected, in this case a non
      root user trying to do systemwide profiling, no data will be
      collected, and then we end up trying to mmap a zero sized file
      and access the file header, b00m.
      Reported-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: <stable@kernel.org>
      LKML-Reference: <1268333592-30872-1-git-send-email-acme@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      9f591fd7
    • Cyrill Gorcunov's avatar
      perf, x86: Implement initial P4 PMU driver · a072738e
      Cyrill Gorcunov authored
      The netburst PMU is way different from the "architectural
      perfomance monitoring" specification that current CPUs use.
      P4 uses a tuple of ESCR+CCCR+COUNTER MSR registers to handle
      perfomance monitoring events.
      
      A few implementational details:
      
      1) We need a separate x86_pmu::hw_config helper in struct
         x86_pmu since register bit-fields are quite different from P6,
         Core and later cpu series.
      
      2) For the same reason is a x86_pmu::schedule_events helper
         introduced.
      
      3) hw_perf_event::config consists of packed ESCR+CCCR values.
         It's allowed since in reality both registers only use a half
         of their size. Of course before making a real write into a
         particular MSR we need to unpack the value and extend it to
         a proper size.
      
      4) The tuple of packed ESCR+CCCR in hw_perf_event::config
         doesn't describe the memory address of ESCR MSR register
         so that we need to keep a mapping between these tuples
         used and available ESCR (various P4 events may use same
         ESCRs but not simultaneously), for this sake every active
         event has a per-cpu map of hw_perf_event::idx <--> ESCR
         addresses.
      
      5) Since hw_perf_event::idx is an offset to counter/control register
         we need to lift X86_PMC_MAX_GENERIC up, otherwise kernel
         strips it down to 8 registers and event armed may never be turned
         off (ie the bit in active_mask is set but the loop never reaches
         this index to check), thanks to Peter Zijlstra
      
      Restrictions:
      
       - No cascaded counters support (do we ever need them?)
       - No dependent events support (so PERF_COUNT_HW_INSTRUCTIONS
         doesn't work for now)
       - There are events with same counters which can't work simultaneously
         (need to use intersected ones due to broken counter 1)
       - No PERF_COUNT_HW_CACHE_ events yet
      
      Todo:
      
       - Implement dependent events
       - Need proper hashing for event opcodes (no linear search, good for
         debugging stage but not in real loads)
       - Some events counted during a clock cycle -- need to set threshold
         for them and count every clock cycle just to get summary statistics
         (ie to behave the same way as other PMUs do)
       - Need to swicth to use event_constraints
       - To support RAW events we need to encode a global list of P4 events
         into p4_templates
       - Cache events need to be added
      
      Event support status matrix:
      
       Event			status
       -----------------------------
       cycles			works
       cache-references	works
       cache-misses		works
       branch-misses		works
       bus-cycles		partially (does not work on 64bit cpu with HT enabled)
       instruction		doesnt work (needs dependent event [mop tagging])
       branches		doesnt work
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
      Signed-off-by: default avatarLin Ming <ming.m.lin@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Robert Richter <robert.richter@amd.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <20100311165439.GB5129@lenovo>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      a072738e
    • eranian@google.com's avatar
      perf_events: Improve task_sched_in() · 9b33fa6b
      eranian@google.com authored
      This patch is an optimization in perf_event_task_sched_in() to avoid
      scheduling the events twice in a row.
      
      Without it, the perf_disable()/perf_enable() pair is invoked twice,
      thereby pinned events counts while scheduling flexible events and we go
      throuh hw_perf_enable() twice.
      
      By encapsulating, the whole sequence into perf_disable()/perf_enable() we
      ensure, hw_perf_enable() is going to be invoked only once because of the
      refcount protection.
      Signed-off-by: default avatarStephane Eranian <eranian@google.com>
      Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      LKML-Reference: <1268288765-5326-1-git-send-email-eranian@google.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      9b33fa6b
    • Xiao Guangrong's avatar
      perf: export perf_trace_regs and perf_arch_fetch_caller_regs · 639fe4b1
      Xiao Guangrong authored
      Export perf_trace_regs and perf_arch_fetch_caller_regs since module will
      use these.
      Signed-off-by: default avatarXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
      [ use EXPORT_PER_CPU_SYMBOL_GPL() ]
      Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      LKML-Reference: <4B989C1B.2090407@cn.fujitsu.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      639fe4b1
    • Peter Zijlstra's avatar
      perf, x86: Fix hw_perf_enable() event assignment · 45e16a68
      Peter Zijlstra authored
      What happens is that we schedule badly like:
      
      <...>-1987  [019]   280.252808: x86_pmu_start: event-46/1300c0: idx: 0
      <...>-1987  [019]   280.252811: x86_pmu_start: event-47/1300c0: idx: 1
      <...>-1987  [019]   280.252812: x86_pmu_start: event-48/1300c0: idx: 2
      <...>-1987  [019]   280.252813: x86_pmu_start: event-49/1300c0: idx: 3
      <...>-1987  [019]   280.252814: x86_pmu_start: event-50/1300c0: idx: 32
      <...>-1987  [019]   280.252825: x86_pmu_stop: event-46/1300c0: idx: 0
      <...>-1987  [019]   280.252826: x86_pmu_stop: event-47/1300c0: idx: 1
      <...>-1987  [019]   280.252827: x86_pmu_stop: event-48/1300c0: idx: 2
      <...>-1987  [019]   280.252828: x86_pmu_stop: event-49/1300c0: idx: 3
      <...>-1987  [019]   280.252829: x86_pmu_stop: event-50/1300c0: idx: 32
      <...>-1987  [019]   280.252834: x86_pmu_start: event-47/1300c0: idx: 1
      <...>-1987  [019]   280.252834: x86_pmu_start: event-48/1300c0: idx: 2
      <...>-1987  [019]   280.252835: x86_pmu_start: event-49/1300c0: idx: 3
      <...>-1987  [019]   280.252836: x86_pmu_start: event-50/1300c0: idx: 32
      <...>-1987  [019]   280.252837: x86_pmu_start: event-51/1300c0: idx: 32 *FAIL*
      
      This happens because we only iterate the n_running events in the first
      pass, and reset their index to -1 if they don't match to force a
      re-assignment.
      
      Now, in our RR example, n_running == 0 because we fully unscheduled, so
      event-50 will retain its idx==32, even though in scheduling it will have
      gotten idx=0, and we don't trigger the re-assign path.
      
      The easiest way to fix this is the below patch, which simply validates
      the full assignment in the second pass.
      Reported-by: default avatarStephane Eranian <eranian@google.com>
      Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      LKML-Reference: <1268311069.5037.31.camel@laptop>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      45e16a68