1. 13 3月, 2009 23 次提交
  2. 12 3月, 2009 4 次提交
    • S
      ring-buffer: only allocate buffers for online cpus · 554f786e
      Steven Rostedt 提交于
      Impact: save on memory
      
      Currently, a ring buffer was allocated for each "possible_cpus". On
      some systems, this is the same as NR_CPUS. Thus, if a system defined
      NR_CPUS = 64 but it only had 1 CPU, we could have possibly 63 useless
      ring buffers taking up space. With a default buffer of 3 megs, this
      could be quite drastic.
      
      This patch changes the ring buffer code to only allocate ring buffers
      for online CPUs.  If a CPU goes off line, we do not free the buffer.
      This is because the user may still have trace data in that buffer
      that they would like to look at.
      
      Perhaps in the future we could add code to delete a ring buffer if
      the CPU is offline and the ring buffer becomes empty.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      554f786e
    • S
      tracing: fix trace_wait to know to wait on all cpus or just one · 9aba60fe
      Steven Rostedt 提交于
      Impact: fix to task live locking on reading trace_pipe on one CPU
      
      The same code is used for both trace_pipe (all CPUS) and the per_cpu
      trace_pipe file. When there is no data to read, it will check for
      signals and wait on the trace wait queue.
      
      The problem happens with the per_cpu wait. The trace_wait code checks
      all CPUs. Thus, if there's data in another CPU buffer, then it will
      exit the wait, without checking for signals or waiting on the wait queue.
      
      It would then try to read the empty buffer, and since that will just
      return nothing, then it will try to wait again. Unfortunately, that will
      again fail due to there still being data in the other buffers. This
      ends up with a live lock for the task.
      
      This patch fixes the trace_wait to be aware that the iterator may only
      be waiting on a single buffer.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      9aba60fe
    • S
      tracing: expand the ring buffers when an event is activated · 1852fcce
      Steven Rostedt 提交于
      To save memory, the tracer ring buffers are set to a minimum.
      The activating of a trace expands the ring buffer size. This patch
      adds this expanding, when an event is activated.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      1852fcce
    • S
      tracing: keep ring buffer to minimum size till used · 73c5162a
      Steven Rostedt 提交于
      Impact: less memory impact on systems not using tracer
      
      When the kernel boots up that has tracing configured, it allocates
      the default size of the ring buffer. This currently happens to be
      1.4Megs per possible CPU. This is quite a bit of wasted memory if
      the system is never using the tracer.
      
      The current solution is to keep the ring buffers to a minimum size
      until the user uses them. Once a tracer is piped into the current_tracer
      the ring buffer will be expanded to the default size. If the user
      changes the size of the ring buffer, it will take the size given
      by the user immediately.
      
      If the user adds a "ftrace=" to the kernel command line, then the ring
      buffers will be set to the default size on initialization.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      73c5162a
  3. 11 3月, 2009 7 次提交
  4. 10 3月, 2009 6 次提交
    • S
      tracing: do not allow modifying the ftrace events via the event files · 40e26815
      Steven Rostedt 提交于
      Impact: fix to prevent crash on calling NULL function pointer
      
      The ftrace internal records have their format exported via the event
      system under the ftrace subsystem. These are only for exporting the
      format to allow binary readers to be able to parse them in a binary
      output.
      
      The ftrace subsystem events can only be enabled via the ftrace tracers
      and do not have a registering function. The event files expect the
      event record to have registering function and will call it directly.
      Passing in a ftrace subsystem event will cause the kernel to crash
      because it will execute a NULL pointer.
      
      This patch prevents the ftrace subsystem from being viewable to the
      event enabling files.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      40e26815
    • S
      tracing: fix printk format specifier · ce8eb2bf
      Steven Rostedt 提交于
      Impact: clean up
      
      The offsetof and sizeof are of type size_t, and instead of typecasting
      them to unsigned int for printk formatting, one could just use %zu.
      Reported-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      ce8eb2bf
    • K
      tracing: Don't assume possible cpu list have continuous numbers · bbcd3063
      KOSAKI Motohiro 提交于
      "for (++cpu ; cpu < num_possible_cpus(); cpu++)" statement assumes
      possible cpus have continuous number - but that's a wrong assumption.
      
      Insted, cpumask_next() should be used.
      Signed-off-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <20090310104437.A480.A69D9226@jp.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      bbcd3063
    • S
      tracing: remove obsolete TRACE_EVENT_FORMAT macro · 157587d7
      Steven Rostedt 提交于
      Impact: clean up
      
      The TRACE_EVENT_FORMAT macro is no longer used by trace points
      and only the DECLARE_TRACE, TRACE_FORMAT or TRACE_EVENT macros should
      be used by them. Although the TRACE_EVENT_FORMAT macro is still used
      by the internal tracing utility, it should not be used in core
      kernel code.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      157587d7
    • S
      tracing: new format for specialized trace points · da4d0302
      Steven Rostedt 提交于
      Impact: clean up and enhancement
      
      The TRACE_EVENT_FORMAT macro looks quite ugly and is limited in its
      ability to save data as well as to print the record out. Working with
      Ingo Molnar, we came up with a new format that is much more pleasing to
      the eye of C developers. This new macro is more C style than the old
      macro, and is more obvious to what it does.
      
      Here's the example. The only updated macro in this patch is the
      sched_switch trace point.
      
      The old method looked like this:
      
       TRACE_EVENT_FORMAT(sched_switch,
              TP_PROTO(struct rq *rq, struct task_struct *prev,
                      struct task_struct *next),
              TP_ARGS(rq, prev, next),
              TP_FMT("task %s:%d ==> %s:%d",
                    prev->comm, prev->pid, next->comm, next->pid),
              TRACE_STRUCT(
                      TRACE_FIELD(pid_t, prev_pid, prev->pid)
                      TRACE_FIELD(int, prev_prio, prev->prio)
                      TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN],
                                          next_comm,
                                          TP_CMD(memcpy(TRACE_ENTRY->next_comm,
                                                       next->comm,
                                                       TASK_COMM_LEN)))
                      TRACE_FIELD(pid_t, next_pid, next->pid)
                      TRACE_FIELD(int, next_prio, next->prio)
              ),
              TP_RAW_FMT("prev %d:%d ==> next %s:%d:%d")
              );
      
      The above method is hard to read and requires two format fields.
      
      The new method:
      
       /*
        * Tracepoint for task switches, performed by the scheduler:
        *
        * (NOTE: the 'rq' argument is not used by generic trace events,
        *        but used by the latency tracer plugin. )
        */
       TRACE_EVENT(sched_switch,
      
      	TP_PROTO(struct rq *rq, struct task_struct *prev,
      		 struct task_struct *next),
      
      	TP_ARGS(rq, prev, next),
      
      	TP_STRUCT__entry(
      		__array(	char,	prev_comm,	TASK_COMM_LEN	)
      		__field(	pid_t,	prev_pid			)
      		__field(	int,	prev_prio			)
      		__array(	char,	next_comm,	TASK_COMM_LEN	)
      		__field(	pid_t,	next_pid			)
      		__field(	int,	next_prio			)
      	),
      
      	TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
      		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
      		__entry->next_comm, __entry->next_pid, __entry->next_prio),
      
      	TP_fast_assign(
      		memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
      		__entry->prev_pid	= prev->pid;
      		__entry->prev_prio	= prev->prio;
      		memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
      		__entry->next_pid	= next->pid;
      		__entry->next_prio	= next->prio;
      	)
       );
      
      This macro is called TRACE_EVENT, it is broken up into 5 parts:
      
       TP_PROTO:        the proto type of the trace point
       TP_ARGS:         the arguments of the trace point
       TP_STRUCT_entry: the structure layout of the entry in the ring buffer
       TP_printk:       the printk format
       TP_fast_assign:  the method used to write the entry into the ring buffer
      
      The structure is the definition of how the event will be saved in the
      ring buffer. The printk is used by the internal tracing in case of
      an oops, and the kernel needs to print out the format of the record
      to the console. This the TP_printk gives a means to show the records
      in a human readable format. It is also used to print out the data
      from the trace file.
      
      The TP_fast_assign is executed directly. It is basically like a C function,
      where the __entry is the handle to the record.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      da4d0302
    • S
      tracing: use generic __stringify · 9cc26a26
      Steven Rostedt 提交于
      Impact: clean up
      
      This removes the custom made STR(x) macros in the tracer and uses
      the generic __stringify macro instead.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      9cc26a26