1. 21 3月, 2009 7 次提交
  2. 19 3月, 2009 1 次提交
    • F
      tracing/ring-buffer: fix non cpu hotplug case · 3bf832ce
      Frederic Weisbecker 提交于
      Impact: fix warning with irqsoff tracer
      
      The ring buffer allocates its buffers on pre-smp time (early_initcall).
      It means that, at first, only the boot cpu buffer is allocated and
      the ring-buffer cpumask only has the boot cpu set (cpu_online_mask).
      
      Later, the secondary cpu will show up and the ring-buffer will be notified
      about this event: the appropriate buffer will be allocated and the cpumask
      will be updated.
      
      Unfortunately, if !CONFIG_CPU_HOTPLUG, the ring-buffer will not be
      notified about the secondary cpus, meaning that the cpumask will have
      only the cpu boot set, and only one cpu buffer allocated.
      
      We fix that by using cpu_possible_mask if !CONFIG_CPU_HOTPLUG.
      
      This patch fixes the following warning with irqsoff tracer running:
      
      [  169.317794] WARNING: at kernel/trace/trace.c:466 update_max_tr_single+0xcc/0xf3()
      [  169.318002] Hardware name: AMILO Li 2727
      [  169.318002] Modules linked in:
      [  169.318002] Pid: 5624, comm: bash Not tainted 2.6.29-rc8-tip-02636-g6aafa6c #11
      [  169.318002] Call Trace:
      [  169.318002]  [<ffffffff81036182>] warn_slowpath+0xea/0x13d
      [  169.318002]  [<ffffffff8100b9d6>] ? ftrace_call+0x5/0x2b
      [  169.318002]  [<ffffffff8100b9d6>] ? ftrace_call+0x5/0x2b
      [  169.318002]  [<ffffffff8100b9d1>] ? ftrace_call+0x0/0x2b
      [  169.318002]  [<ffffffff8101ef10>] ? ftrace_modify_code+0xa9/0x108
      [  169.318002]  [<ffffffff8106e27f>] ? trace_hardirqs_off+0x25/0x27
      [  169.318002]  [<ffffffff8149afe7>] ? _spin_unlock_irqrestore+0x1f/0x2d
      [  169.318002]  [<ffffffff81064f52>] ? ring_buffer_reset_cpu+0xf6/0xfb
      [  169.318002]  [<ffffffff8106637c>] ? ring_buffer_reset+0x36/0x48
      [  169.318002]  [<ffffffff8106aeda>] update_max_tr_single+0xcc/0xf3
      [  169.318002]  [<ffffffff8100bc17>] ? sysret_check+0x22/0x5d
      [  169.318002]  [<ffffffff8106e3ea>] stop_critical_timing+0x142/0x204
      [  169.318002]  [<ffffffff8106e4cf>] trace_hardirqs_on_caller+0x23/0x25
      [  169.318002]  [<ffffffff8149ac28>] trace_hardirqs_on_thunk+0x3a/0x3c
      [  169.318002]  [<ffffffff8100bc17>] ? sysret_check+0x22/0x5d
      [  169.318002] ---[ end trace db76cbf775a750cf ]---
      
      Because this tracer may try to swap two cpu ring buffers for an
      unregistered cpu on the ring buffer.
      
      This patch might also fix a fair loss of traces due to unallocated buffers
      for secondary cpus.
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Acked-b: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1237470453-5427-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      3bf832ce
  3. 18 3月, 2009 9 次提交
    • F
      tracing/ftrace: stop {irqs, preempt}soff tracers when tracing is stopped · 49036200
      Frederic Weisbecker 提交于
      Impact: fix a selftest warning
      
      In some cases, it's possible to see the following warning on irqsoff
      tracer selftest:
      
      [    4.640003] Testing tracer irqsoff: <4>------------[ cut here ]------------
      [    4.653562] WARNING: at kernel/trace/trace.c:458 update_max_tr_single+0x9a/0xc4()
      [    4.660000] Hardware name: System Product Name
      [    4.660000] Modules linked in:
      [    4.660000] Pid: 301, comm: kstop/1 Not tainted 2.6.29-rc8-tip #35837
      [    4.660000] Call Trace:
      [    4.660000]  [<4014b588>] warn_slowpath+0x79/0x8f
      [    4.660000]  [<402d6949>] ? put_dec+0x64/0x6b
      [    4.660000]  [<40162b56>] ? getnstimeofday+0x58/0xdd
      [    4.660000]  [<40162210>] ? clocksource_read+0x3/0xf
      [    4.660000]  [<4015eb44>] ? ktime_set+0x8/0x34
      [    4.660000]  [<4014101a>] ? balance_runtime+0x8/0x56
      [    4.660000]  [<405f6f11>] ? _spin_lock+0x3/0x10
      [    4.660000]  [<4011f643>] ? ftrace_call+0x5/0x8
      [    4.660000]  [<4015d0f1>] ? task_cputime_zero+0x3/0x27
      [    4.660000]  [<40190ee7>] ? cpupri_set+0x90/0xcb
      [    4.660000]  [<405f7208>] ? _spin_lock_irqsave+0x22/0x34
      [    4.660000]  [<40190f12>] ? cpupri_set+0xbb/0xcb
      [    4.660000]  [<405f7151>] ? _spin_unlock_irqrestore+0x23/0x35
      [    4.660000]  [<4018493f>] ? ring_buffer_reset_cpu+0x27/0x51
      [    4.660000]  [<405f7208>] ? _spin_lock_irqsave+0x22/0x34
      [    4.660000]  [<40184962>] ? ring_buffer_reset_cpu+0x4a/0x51
      [    4.660000]  [<405f7151>] ? _spin_unlock_irqrestore+0x23/0x35
      [    4.660000]  [<4018cc29>] ? trace_hardirqs_off+0x1a/0x1c
      [    4.660000]  [<405f7151>] ? _spin_unlock_irqrestore+0x23/0x35
      [    4.660000]  [<40184962>] ? ring_buffer_reset_cpu+0x4a/0x51
      [    4.660000]  [<401850f3>] ? cpumask_next+0x15/0x18
      [    4.660000]  [<4018a41f>] update_max_tr_single+0x9a/0xc4
      [    4.660000]  [<4014e5fe>] ? exit_notify+0x16/0xf2
      [    4.660000]  [<4018cd13>] check_critical_timing+0xcc/0x11e
      [    4.660000]  [<4014e5fe>] ? exit_notify+0x16/0xf2
      [    4.660000]  [<4014e5fe>] ? exit_notify+0x16/0xf2
      [    4.660000]  [<4018cdf1>] stop_critical_timing+0x8c/0x9f
      [    4.660000]  [<4014e5c4>] ? forget_original_parent+0xac/0xd0
      [    4.660000]  [<4018ce3a>] trace_hardirqs_on+0x1a/0x1c
      [    4.660000]  [<4014e5c4>] forget_original_parent+0xac/0xd0
      [    4.660000]  [<4014e5fe>] exit_notify+0x16/0xf2
      [    4.660000]  [<4014e8a5>] do_exit+0x1cb/0x225
      [    4.660000]  [<4015c72b>] ? kthread+0x0/0x69
      [    4.660000]  [<4011f61d>] kernel_thread_helper+0xd/0x10
      [    4.660000] ---[ end trace a7919e7f17c0a725 ]---
      [    4.660164] .. no entries found ..FAILED!
      
      During the selftest of irqsoff tracer, we do that:
      
      	/* disable interrupts for a bit */
      	local_irq_disable();
      	udelay(100);
      	local_irq_enable();
      	/* stop the tracing. */
      	tracing_stop();
      	/* check both trace buffers */
      	ret = trace_test_buffer(tr, NULL);
      
      If a callsite performs a new max delay with irqs off just after
      tracing_stop, update_max_tr_single() -> ring_buffer_swap_cpu()
      will be called with the buffers disabled by tracing_stop(), hence
      the warning, then ring_buffer_swap_cpu() return -EAGAIN and
      update_max_tr_single() complains.
      
      Fix it by also stopping the tracer before stopping the tracing globally.
      A similar situation can happen with preemptoff and preemptirqsoff tracers
      where we apply the same fix.
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1237325938-5240-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      49036200
    • C
      tracing: fix command line to pid reverse map · a635cf04
      Carsten Emde 提交于
      Impact: fix command line to pid mapping
      
      map_cmdline_to_pid[] is checked in trace_save_cmdline(), but never
      updated. This results in stale pid to command line mappings and the
      tracer output will associate the wrong comm string.
      Signed-off-by: NCarsten Emde <Carsten.Emde@osadl.org>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <new-submission>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      a635cf04
    • T
      tracing: fix trace_find_cmdline() · 50d88758
      Thomas Gleixner 提交于
      Impact: prevent stale command line output
      
      In case there is no valid command line mapping for a pid
      trace_find_cmdline() returns without updating the comm buffer. The
      trace dump keeps the previous entry which results in confusing trace
      output:
      
           <idle>-0     [000]   280.702056 ....
           <idle>-23456 [000]   280.702080 ....
      
      Update the comm buffer with "<...>" when no mapping is found.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <new-submission>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      50d88758
    • T
      tracing: replace the crude (unsigned) -1 hackery · 2c7eea4c
      Thomas Gleixner 提交于
      Impact: cleanup
      
      The command line recorder uses (unsigned) -1 to mark non mapped
      entries in the pid to command line maps. The validity check is
      completely unintuitive: idx >= SAVED_CMDLINES
      
      There is no need for such casting games. Use a constant to mark
      unmapped entries and check for that constant to make the code readable
      and understandable.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <new-submission>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      2c7eea4c
    • T
      tracing: stop command line recording when tracing is disabled · 18aecd36
      Thomas Gleixner 提交于
      Impact: prevent overwrite of command line entries
      
      When the tracer is stopped the command line recording continues to
      record. The check for tracing_is_on() is not sufficient here as the
      ringbuffer status is not affected by setting
      debug/tracing/tracing_enabled to 0. On a non idle system this can
      result in the loss of the command line information for the stopped
      trace, which makes the trace harder to read and analyse.
      
      Check tracer_enabled to allow further recording.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <new-submission>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      18aecd36
    • S
      tracing: make power tracer start/stop methods lighter weight · 62524d55
      Steven Rostedt 提交于
      The start/stop methods of a tracer should be able to be executed
      in all contexts. This patch converts the power tracer to do so.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      62524d55
    • S
      tracing: make sched_switch stop/start light weight · 5fec6ddc
      Steven Rostedt 提交于
      The stopping and starting of a tracer should be light weight and
      be able to be called in all contexts. The sched_switch grabbed
      mutexes in the start/stop functions. This patch changes it to a
      simple variable, on/off.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      5fec6ddc
    • S
      tracing: add global-clock option to provide cross CPU clock to traces · af4617bd
      Steven Rostedt 提交于
      Impact: feature to allow better serialized clock
      
      This patch adds an option called "global-clock" that will allow
      the tracer to switch to a slower but more accurate (across CPUs)
      clock.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      af4617bd
    • S
      ring-buffer: add api to allow a tracer to change clock source · 37886f6a
      Steven Rostedt 提交于
      This patch adds a new function called ring_buffer_set_clock that
      allows a tracer to assign its own clock source to the buffer.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      37886f6a
  4. 17 3月, 2009 4 次提交
    • T
      tracing: fix leak in event_format_read() · c269fc8c
      Tom Zanussi 提交于
      Impact: fix memory leak
      
      If event_format_read() exits early due to nonzero ppos, the
      previous kmalloc doesn't get freed - might as well do the
      check before the kmalloc and avoid the problem.
      Signed-off-by: NTom Zanussi <tzanussi@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: =?ISO-8859-1?Q?Fr=E9d=E9ric?= Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1237270859.8033.141.camel@charm-linux>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      c269fc8c
    • S
      tracing: stop comm recording on tracing off · 6adaad14
      Steven Rostedt 提交于
      Impact: fix for losing comms in trace
      
      The command lines of tasks are cached at sched switch to not need
      to record them at every trace point.  Disabling the tracing on stops
      the recording of traces, but does not stop the caching of command lines.
      When the tracing is off the cache may overflow and cause the tracing
      to show incorrect tasks matching the PIDs.
      
      This patch disables prevents updates to the comm cache when the ring buffer
      is off.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      6adaad14
    • S
      tracing: protect reader of cmdline output · 4ca53085
      Steven Rostedt 提交于
      Impact: fix to one cause of incorrect comm outputs in trace
      
      The spinlock only protected the creation of a comm <=> pid pair.
      But it was possible that a reader could look up a pid, and get the
      wrong comm because it had no locking.
      
      This also required changing trace_find_cmdline to copy the comm cache
      and not just send back a pointer to it.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      4ca53085
    • F
      tracing/ftrace: fix the check on nopped sites · 03303549
      Frederic Weisbecker 提交于
      Impact: fix a dynamic tracing failure
      
      Recently, the function and function graph tracers failed to use dynamic
      tracing after the following commit:
      
      fa9d13cf
      (ftrace: don't try to __ftrace_replace_code on !FTRACE_FL_CONVERTED rec)
      
      The patch is right except a mistake on the check for the FTRACE_FL_CONVERTED
      flag. The code patching is aborted in case of successfully nopped sites.
      What we want is the opposite: ignore the callsites that haven't been nopped.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      03303549
  5. 16 3月, 2009 7 次提交
    • F
      tracing/core: fix early free of cpumasks · 2fc1dfbe
      Frederic Weisbecker 提交于
      Impact: fix crashes when tracing cpumasks
      
      While ring-buffer allocation, the cpumasks are allocated too,
      including the tracing cpumask and the per-cpu file mask handler.
      But these cpumasks are freed accidentally just after.
      Fix it.
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1237164303-11476-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      2fc1dfbe
    • F
      tracing/ftrace: fix double calls to tracing_start() · ac1d52d0
      Frederic Weisbecker 提交于
      Impact: fix a warning during preemptirqsoff selftests
      
      When the preemptirqsoff selftest fails, we see the following
      warning:
      
      [    6.050000] Testing tracer preemptirqsoff: .. no entries found ..
      ------------[ cut here ]------------
      [    6.060000] WARNING: at kernel/trace/trace.c:688 tracing_start+0x67/0xd3()
      [    6.060000] Modules linked in:
      [    6.060000] Pid: 1, comm: swapper Tainted: G
      [    6.060000] Call Trace:
      [    6.060000]  [<ffffffff802460ff>] warn_slowpath+0xb1/0x100
      [    6.060000]  [<ffffffff802a8f5b>] ? trace_preempt_on+0x35/0x4b
      [    6.060000]  [<ffffffff802a37fb>] ? tracing_start+0x31/0xd3
      [    6.060000]  [<ffffffff802a37fb>] ? tracing_start+0x31/0xd3
      [    6.060000]  [<ffffffff80271e0b>] ? __lock_acquired+0xe6/0x1f2
      [    6.060000]  [<ffffffff802a37fb>] ? tracing_start+0x31/0xd3
      [    6.060000]  [<ffffffff802a3831>] tracing_start+0x67/0xd3
      [    6.060000]  [<ffffffff802a8ace>] ? irqsoff_tracer_reset+0x2d/0x57
      [    6.060000]  [<ffffffff802a4d1c>] trace_selftest_startup_preemptirqsoff+0x1c8/0x1f1
      [    6.060000]  [<ffffffff802a4798>] register_tracer+0x12f/0x241
      [    6.060000]  [<ffffffff810250d0>] ? init_irqsoff_tracer+0x0/0x53
      [    6.060000]  [<ffffffff8102510b>] init_irqsoff_tracer+0x3b/0x53
      
      This is because in fail case, the preemptirqsoff tracer selftest calls twice
      the tracing_start() function:
      
      int
      trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *tr)
      {
              if (!ret && !count) {
                      printk(KERN_CONT ".. no entries found ..");
                      ret = -1;
                      tracing_start(); <-----
                      goto out;
              }
              [...]
      out:
              trace->reset(tr);
              tracing_start(); <------
              tracing_max_latency = save_max;
      
              return ret;
      }
      
      Since it is well handled in the out path, we don't need the conditional one.
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1237159961-7447-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      ac1d52d0
    • F
      tracing/core: fix missing mutex unlock on tracing_set_tracer() · 59f586db
      Frederic Weisbecker 提交于
      Impact: fix possible locking imbalance
      
      In case of ring buffer resize failure, tracing_set_tracer forgot to
      release trace_types_lock. Fix it.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1237151439-6755-5-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      59f586db
    • F
      tracing/syscalls: select kallsysms · 0ea1c415
      Frederic Weisbecker 提交于
      Syscall tracing must select kallsysms.
      
      The arch code builds a table to find the syscall metadata by syscall
      number. It needs the syscalls names resolution from the symbol table
      to know which name found on the syscalls metadatas match a function
      pointer from the arch sys_call_table.
      Reported-by: NAndrew Morton <akpm@linux-foundation.org>
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1237151439-6755-4-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      0ea1c415
    • F
      tracing/syscalls: protect thread flag toggling from races · 5be71b61
      Frederic Weisbecker 提交于
      Impact: fix syscall tracer enable/disable race
      
      The current thread flag toggling is racy as shown in the following
      scenario:
      
      - task A is the last user of syscall tracing, it releases the
        TIF_SYSCALL_FTRACE on each tasks
      
      - at the same time task B start syscall tracing. refcount == 0 so
        it sets up TIF_SYSCALL_FTRACE on each tasks.
      
      The effect of the mixup is unpredictable.
      So this fix adds a mutex on {start,stop}_syscall_tracing().
      Reported-by: NAndrew Morton <akpm@linux-foundation.org>
      Reported-by: NIngo Molnar <mingo@elte.hu>
      LKML-Reference: <1237151439-6755-3-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      5be71b61
    • F
      tracing/syscalls: various cleanups · 64044345
      Frederic Weisbecker 提交于
      Impact: cleanup
      
      - Drop unused cpu variable
      - Fix some errors on comments
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1237151439-6755-2-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      64044345
    • F
      tracing/syscalls: fix missing release of tracing · ac99c58c
      Frederic Weisbecker 提交于
      Impact: fix 'stuck' syscall tracer
      
      The syscall tracer uses a refcounter to enable several users
      simultaneously.
      
      But the refcounter did not behave correctly and always restored
      its value to 0 after calling start_syscall_tracing(). Therefore,
      stop_syscall_tracing() couldn't release correctly the tasks from
      tracing.
      
      Also the tracer forgot to reset the buffer when it is released.
      
      Drop the pointless refcount decrement on start_syscall_tracing()
      and reset the buffer when we release the tracer.
      
      This fixes two reported issue:
      
      - when we switch from syscall tracer to another tracer, syscall
        tracing continued.
      
      - incorrect use of the refcount.
      Reported-by: NAndrew Morton <akpm@linux-foundation.org>
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1237151439-6755-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      ac99c58c
  6. 13 3月, 2009 12 次提交