1. 13 Aug, 2010 1 commit
    • Marcin Slusarz's avatar
      tracing: Sanitize value returned from write(trace_marker, "...", len) · 1aa54bca
      Marcin Slusarz authored
      When userspace code writes non-new-line-terminated string to trace_marker
      file, write handler appends new-line and returns number of bytes written
      to trace buffer, so
      write(fd, "abc", 3) will return 4
      
      That's unexpected and unfortunately it confuses glibc's fprintf function.
      
      Example:
      int main() {
        fprintf(stderr, "abc");
        return 0;
      }
      
      $ gcc test.c -o test
      $ echo mmiotrace > /sys/kernel/debug/tracing/current_tracer
      $ ./test 2>/sys/kernel/debug/tracing/trace_marker
      
      results in infinite loop:
      write(fd, "abc", 3) = 4
      write(fd, "", 1) = 0
      write(fd, "", 1) = 0
      write(fd, "", 1) = 0
      write(fd, "", 1) = 0
      write(fd, "", 1) = 0
      write(fd, "", 1) = 0
      write(fd, "", 1) = 0
      (...)
      
      ...and kernel trace buffer full of empty markers.
      
      Fix it by sanitizing write return value.
      Signed-off-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
      LKML-Reference: <20100727231801.GB2826@joi.lan>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      1aa54bca
  2. 12 Aug, 2010 2 commits
    • Steven Rostedt's avatar
      tracing/events: Convert format output to seq_file · 2a37a3df
      Steven Rostedt authored
      Two new events were added that broke the current format output.
      
      Both from the SCSI system: scsi_dispatch_cmd_done and scsi_dispatch_cmd_timeout
      
      The reason is that their print_fmt exceeded a page size. Since the output
      of the format used simple_read_from_buffer and trace_seq, it was limited
      to a page size in output.
      
      This patch converts the printing of the format of an event into seq_file,
      which allows greater than a page size to be shown.
      
      I diffed all event formats comparing the output with and without this
      patch. All matched except for the above two, which showed just:
      
        FORMAT TOO BIG
      
      without this patch, but now properly displays the output with this patch.
      
      v2: Remove updating *pos in seq start function.
         [ Thanks to Li Zefan for pointing that out ]
      Reviewed-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Kei Tokunaga <tokunaga.keiich@jp.fujitsu.com>
      Cc: James Bottomley <James.Bottomley@suse.de>
      Cc: Tomohiro Kusumi <kusumi.tomohiro@jp.fujitsu.com>
      Cc: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      2a37a3df
    • Mike Frysinger's avatar
      tracing: Extend recordmcount to better support Blackfin mcount · 465c6cca
      Mike Frysinger authored
      The mcount call on Blackfin systems includes some stack manipulation
      around the actual call site, so extend the build time perl script to
      support this.  This way we can avoid doing the calculation at runtime.
      Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
      LKML-Reference: <1281079584-21205-1-git-send-email-vapier@gentoo.org>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      465c6cca
  3. 06 Aug, 2010 2 commits
    • Huang Ying's avatar
      tracing: Fix ring_buffer_read_page reading out of page boundary · 18fab912
      Huang Ying authored
      With the configuration: CONFIG_DEBUG_PAGEALLOC=y and Shaohua's patch:
      
      [PATCH]x86: make spurious_fault check correct pte bit
      
      Function call graph trace with the following will trigger a page fault.
      
      # cd /sys/kernel/debug/tracing/
      # echo function_graph > current_tracer
      # cat per_cpu/cpu1/trace_pipe_raw > /dev/null
      
      BUG: unable to handle kernel paging request at ffff880006e99000
      IP: [<ffffffff81085572>] rb_event_length+0x1/0x3f
      PGD 1b19063 PUD 1b1d063 PMD 3f067 PTE 6e99160
      Oops: 0000 [#1] SMP DEBUG_PAGEALLOC
      last sysfs file: /sys/devices/virtual/net/lo/operstate
      CPU 1
      Modules linked in:
      
      Pid: 1982, comm: cat Not tainted 2.6.35-rc6-aes+ #300 /Bochs
      RIP: 0010:[<ffffffff81085572>]  [<ffffffff81085572>] rb_event_length+0x1/0x3f
      RSP: 0018:ffff880006475e38  EFLAGS: 00010006
      RAX: 0000000000000ff0 RBX: ffff88000786c630 RCX: 000000000000001d
      RDX: ffff880006e98000 RSI: 0000000000000ff0 RDI: ffff880006e99000
      RBP: ffff880006475eb8 R08: 000000145d7008bd R09: 0000000000000000
      R10: 0000000000008000 R11: ffffffff815d9336 R12: ffff880006d08000
      R13: ffff880006e605d8 R14: 0000000000000000 R15: 0000000000000018
      FS:  00007f2b83e456f0(0000) GS:ffff880002100000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: ffff880006e99000 CR3: 00000000064a8000 CR4: 00000000000006e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Process cat (pid: 1982, threadinfo ffff880006474000, task ffff880006e40770)
      Stack:
       ffff880006475eb8 ffffffff8108730f 0000000000000ff0 000000145d7008bd
      <0> ffff880006e98010 ffff880006d08010 0000000000000296 ffff88000786c640
      <0> ffffffff81002956 0000000000000000 ffff8800071f4680 ffff8800071f4680
      Call Trace:
       [<ffffffff8108730f>] ? ring_buffer_read_page+0x15a/0x24a
       [<ffffffff81002956>] ? return_to_handler+0x15/0x2f
       [<ffffffff8108a575>] tracing_buffers_read+0xb9/0x164
       [<ffffffff810debfe>] vfs_read+0xaf/0x150
       [<ffffffff81002941>] return_to_handler+0x0/0x2f
       [<ffffffff810248b0>] __bad_area_nosemaphore+0x17e/0x1a1
       [<ffffffff81002941>] return_to_handler+0x0/0x2f
       [<ffffffff810248e6>] bad_area_nosemaphore+0x13/0x15
      Code: 80 25 b2 16 b3 00 fe c9 c3 55 48 89 e5 f0 80 0d a4 16 b3 00 02 c9 c3 55 31 c0 48 89 e5 48 83 3d 94 16 b3 00 01 c9 0f 94 c0 c3 55 <8a> 0f 48 89 e5 83 e1 1f b8 08 00 00 00 0f b6 d1 83 fa 1e 74 27
      RIP  [<ffffffff81085572>] rb_event_length+0x1/0x3f
       RSP <ffff880006475e38>
      CR2: ffff880006e99000
      ---[ end trace a6877bb92ccb36bb ]---
      
      The root cause is that ring_buffer_read_page() may read out of page
      boundary, because the boundary checking is done after reading. This is
      fixed via doing boundary checking before reading.
      Reported-by: default avatarShaohua Li <shaohua.li@intel.com>
      Cc: <stable@kernel.org>
      Signed-off-by: default avatarHuang Ying <ying.huang@intel.com>
      LKML-Reference: <1280297641.2771.307.camel@yhuang-dev>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      18fab912
    • Shaohua Li's avatar
      tracing: Fix an unallocated memory access in function_graph · 575570f0
      Shaohua Li authored
      With CONFIG_DEBUG_PAGEALLOC, I observed an unallocated memory access in
      function_graph trace. It appears we find a small size entry in ring buffer,
      but we access it as a big size entry. The access overflows the page size
      and touches an unallocated page.
      
      Cc: <stable@kernel.org>
      Signed-off-by: default avatarShaohua Li <shaohua.li@intel.com>
      LKML-Reference: <1280217994.32400.76.camel@sli10-desk.sh.intel.com>
      [ Added a comment to explain the problem - SDR ]
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      575570f0
  4. 22 Jul, 2010 2 commits
    • Conny Seidel's avatar
      perf tools: Fix fallback to cplus_demangle() when bfd_demangle() is not available · 8a4fd31e
      Conny Seidel authored
      make version 3.80 doesn't support "else ifdef" on the same line, also it
      doesn't support unindented nested constructs.
      
      Build fails with:
      Makefile:608: Extraneous text after `else' directive
      Makefile:611: *** only one `else' per conditional.  Stop.
      
      This patch fixes the build for make 3.80.
      
      Cc: Ingo Molnar <mingo@elte.hu>,
      Cc: Borislav Petkov <borislav.petkov@amd.com>
      LKML-Reference: <1278430783-17259-1-git-send-email-conny.seidel@amd.com>
      Signed-off-by: default avatarConny Seidel <conny.seidel@amd.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8a4fd31e
    • Arnaldo Carvalho de Melo's avatar
      perf annotate: Fix handling of goto labels that are valid hex numbers · 70a7cb3b
      Arnaldo Carvalho de Melo authored
      When parsing the objdump disassembly output we can have goto labels that
      are valid hex numbers and thus get confused with lines with machine
      code.
      
      Handle the common case of a label that has nothing after it and other
      cases where there is just source code by validating the resulting "ip".
      
      It is still possible that we find goto labels that are in the function
      address range, but only if they are located before the real address we
      should be OK.
      
      A change in the objdump output to have a clear marker separating
      addresses from the disassembly would come handy, but we would still have
      to deal with older versions.
      Reported-by: default avatarGleb Natapov <gleb@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Gleb Natapov <gleb@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      LKML-Reference: <20100722170541.GF17631@ghostprotocols.net>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      70a7cb3b
  5. 20 Jul, 2010 1 commit
    • Sam Ravnborg's avatar
      tracing: Properly align linker defined symbols · 07fca0e5
      Sam Ravnborg authored
      We define a number of symbols in the linker scipt like this:
      
          __start_syscalls_metadata = .;
          *(__syscalls_metadata)
      
      But we do not know the alignment of "." when we assign
      the __start_syscalls_metadata symbol.
      gcc started to uses bigger alignment for structs (32 bytes),
      so we saw situations where the linker due to alignment
      constraints increased the value of "." after the symbol assignment.
      
      This resulted in boot fails.
      
      Fix this by forcing a 32 byte alignment of "." before the
      assignment.
      
      This patch introduces the forced alignment for
      ftrace_events and syscalls_metadata.
      It may be required in more places.
      Reported-by: default avatarZeev Tarantov <zeev.tarantov@gmail.com>
      Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
      LKML-Reference: <20100710063459.GA14596@merkur.ravnborg.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      07fca0e5
  6. 16 Jul, 2010 2 commits
    • Gui Jianfeng's avatar
      perf symbols: Fix directory descriptor leaking · 74534341
      Gui Jianfeng authored
      When I ran "perf kvm ... top", I encountered the following error output.
      
        Error: perfcounter syscall returned with -1 (Too many open files)
      
        Fatal: No CONFIG_PERF_EVENTS=y kernel support configured?
      
      Looking into perf, I found perf opens too many directories at
      initialization time, but forgets to close them. Here is the fix.
      
      LKML-Reference: <4C230362.5080704@cn.fujitsu.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: default avatarGui Jianfeng <guijianfeng@cn.fujitsu.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      74534341
    • Frederic Weisbecker's avatar
      perf: Fix various display bugs with parent filtering · 58c34390
      Frederic Weisbecker authored
      Hists that have been filtered, because they don't have callchains
      matching the parent filter, won't be printed. As such,
      hist_entry__snprintf() returns 0 for them, but we don't control
      this value and we always print the buffer, which might be
      untouched and then only made of random stack garbage.
      
      Not only does it paint the screen with barf, it also prints
      the callchains for these hists, even though they have been filtered,
      since the hist has been filtered as well.
      
      We need to check the return value of hist_entry__snprintf() and
      ignore the hist if it is 0, which means it didn't get any callchain
      matching the parent filter. This fixes the barf and the undesired
      callchains.
      Reported-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      58c34390
  7. 09 Jul, 2010 1 commit
  8. 08 Jul, 2010 2 commits
    • Frederic Weisbecker's avatar
      perf: Sync callchains with period based hits · 108553e1
      Frederic Weisbecker authored
      Hists have their hits increased by the event period. And this
      period based counting is the foundation of all the stats in
      perf report.
      
      But callchains still use the raw number of hits, without taking
      the period into account. So when we compute the percentage,
      absolute based percentages are totally broken, and relative ones
      too in the first parent level. Because we pass the number of events
      muliplied by their period as the total number of hits to the
      callchain filtering, while callchains expect this number to be
      the number of raw hits.
      
      perf report -g graph was simply not working, showing no graph unless
      the min percent was zero. And even there the percentage of the
      branches was always 0. And may be fractal filtering was broken on
      the first branch level too.
      
      flat also was broken, but it was hidden because of other breakages.
      
      Anyway fix this by counting using periods on callchains.
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      108553e1
    • Frederic Weisbecker's avatar
      perf: Resurrect flat callchains · 97aa1052
      Frederic Weisbecker authored
      Initialize the callchain radix tree root correctly.
      
      When we walk through the parents, we must stop after the root, but
      since it wasn't well initialized, its parent pointer was random.
      
      Also the number of hits was random because uninitialized, hence it
      was part of the callchain while the root doesn't contain anything.
      
      This fixes segfaults and percentages followed by empty callchains
      while running:
      
      	perf report -g flat
      Reported-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: 2.6.31.x-2.6.34.x <stable@kernel.org>
      97aa1052
  9. 05 Jul, 2010 10 commits
  10. 04 Jul, 2010 1 commit
    • Will Deacon's avatar
      ARM: 6205/1: perf: ensure counter delta is treated as unsigned · 446a5a8b
      Will Deacon authored
      Hardware performance counters on ARM are 32-bits wide but atomic64_t
      variables are used to represent counter data in the hw_perf_event structure.
      
      The armpmu_event_update function right-shifts a signed 64-bit delta variable
      and adds the result to the event count. This can lead to shifting in sign-bits
      if the MSB of the 32-bit counter value is set. This results in perf output
      such as:
      
       Performance counter stats for 'sleep 20':
      
       18446744073460670464  cycles             <-- 0xFFFFFFFFF12A6000
              7783773  instructions             #      0.000 IPC
                  465  context-switches
                  161  page-faults
              1172393  branches
      
         20.154242147  seconds time elapsed
      
      This patch ensures that the delta value is treated as unsigned so that the
      right shift sets the upper bits to zero.
      
      Cc: <stable@kernel.org>
      Acked-by: default avatarJamie Iles <jamie.iles@picochip.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      446a5a8b
  11. 03 Jul, 2010 1 commit
  12. 02 Jul, 2010 15 commits