Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140995
b: refs/heads/master
c: 2fbcdb3
h: refs/heads/master
i:
  140993: 61101fc
  140991: 7c6a40f
v: v3
  • Loading branch information
Steven Rostedt committed Mar 19, 2009
1 parent a800f28 commit 97eb037
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5ef841f6f32dce0b752a4fa0622781ee67a0e874
refs/heads/master: 2fbcdb35aca614f9529a0e7d340146cf0b71684f
91 changes: 69 additions & 22 deletions trunk/kernel/trace/trace_functions_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#include "trace.h"
#include "trace_output.h"

struct fgraph_data {
pid_t last_pid;
int depth;
};

#define TRACE_GRAPH_INDENT 2

/* Flag options */
Expand Down Expand Up @@ -231,16 +236,16 @@ print_graph_proc(struct trace_seq *s, pid_t pid)

/* If the pid changed since the last trace, output this event */
static enum print_line_t
verif_pid(struct trace_seq *s, pid_t pid, int cpu, pid_t *last_pids_cpu)
verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
{
pid_t prev_pid;
pid_t *last_pid;
int ret;

if (!last_pids_cpu)
if (!data)
return TRACE_TYPE_HANDLED;

last_pid = per_cpu_ptr(last_pids_cpu, cpu);
last_pid = &(per_cpu_ptr(data, cpu)->last_pid);

if (*last_pid == pid)
return TRACE_TYPE_HANDLED;
Expand Down Expand Up @@ -471,6 +476,7 @@ print_graph_entry_leaf(struct trace_iterator *iter,
struct ftrace_graph_ent_entry *entry,
struct ftrace_graph_ret_entry *ret_entry, struct trace_seq *s)
{
struct fgraph_data *data = iter->private;
struct ftrace_graph_ret *graph_ret;
struct ftrace_graph_ent *call;
unsigned long long duration;
Expand All @@ -481,6 +487,18 @@ print_graph_entry_leaf(struct trace_iterator *iter,
call = &entry->graph_ent;
duration = graph_ret->rettime - graph_ret->calltime;

if (data) {
int cpu = iter->cpu;
int *depth = &(per_cpu_ptr(data, cpu)->depth);

/*
* Comments display at + 1 to depth. Since
* this is a leaf function, keep the comments
* equal to this depth.
*/
*depth = call->depth - 1;
}

/* Overhead */
ret = print_graph_overhead(duration, s);
if (!ret)
Expand Down Expand Up @@ -512,12 +530,21 @@ print_graph_entry_leaf(struct trace_iterator *iter,
}

static enum print_line_t
print_graph_entry_nested(struct ftrace_graph_ent_entry *entry,
struct trace_seq *s, pid_t pid, int cpu)
print_graph_entry_nested(struct trace_iterator *iter,
struct ftrace_graph_ent_entry *entry,
struct trace_seq *s, int cpu)
{
int i;
int ret;
struct ftrace_graph_ent *call = &entry->graph_ent;
struct fgraph_data *data = iter->private;
int ret;
int i;

if (data) {
int cpu = iter->cpu;
int *depth = &(per_cpu_ptr(data, cpu)->depth);

*depth = call->depth;
}

/* No overhead */
ret = print_graph_overhead(-1, s);
Expand Down Expand Up @@ -557,13 +584,13 @@ static enum print_line_t
print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
int type, unsigned long addr)
{
struct fgraph_data *data = iter->private;
struct trace_entry *ent = iter->ent;
pid_t *last_pid = iter->private;
int cpu = iter->cpu;
int ret;

/* Pid */
if (verif_pid(s, ent->pid, cpu, last_pid) == TRACE_TYPE_PARTIAL_LINE)
if (verif_pid(s, ent->pid, cpu, data) == TRACE_TYPE_PARTIAL_LINE)
return TRACE_TYPE_PARTIAL_LINE;

if (type) {
Expand Down Expand Up @@ -616,19 +643,32 @@ print_graph_entry(struct ftrace_graph_ent_entry *field, struct trace_seq *s,
if (leaf_ret)
return print_graph_entry_leaf(iter, field, leaf_ret, s);
else
return print_graph_entry_nested(field, s, iter->ent->pid, cpu);
return print_graph_entry_nested(iter, field, s, cpu);

}

static enum print_line_t
print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
struct trace_entry *ent, struct trace_iterator *iter)
{
int i;
int ret;
int cpu = iter->cpu;
pid_t pid = ent->pid;
unsigned long long duration = trace->rettime - trace->calltime;
struct fgraph_data *data = iter->private;
pid_t pid = ent->pid;
int cpu = iter->cpu;
int ret;
int i;

if (data) {
int cpu = iter->cpu;
int *depth = &(per_cpu_ptr(data, cpu)->depth);

/*
* Comments display at + 1 to depth. This is the
* return from a function, we now want the comments
* to display at the same level of the bracket.
*/
*depth = trace->depth - 1;
}

if (print_graph_prologue(iter, s, 0, 0))
return TRACE_TYPE_PARTIAL_LINE;
Expand Down Expand Up @@ -675,8 +715,13 @@ static enum print_line_t
print_graph_comment(struct bprint_entry *trace, struct trace_seq *s,
struct trace_entry *ent, struct trace_iterator *iter)
{
int i;
struct fgraph_data *data = iter->private;
int depth = 0;
int ret;
int i;

if (data)
depth = per_cpu_ptr(data, iter->cpu)->depth;

if (print_graph_prologue(iter, s, 0, 0))
return TRACE_TYPE_PARTIAL_LINE;
Expand All @@ -694,8 +739,8 @@ print_graph_comment(struct bprint_entry *trace, struct trace_seq *s,
}

/* Indentation */
if (trace->depth > 0)
for (i = 0; i < (trace->depth + 1) * TRACE_GRAPH_INDENT; i++) {
if (depth > 0)
for (i = 0; i < (depth + 1) * TRACE_GRAPH_INDENT; i++) {
ret = trace_seq_printf(s, " ");
if (!ret)
return TRACE_TYPE_PARTIAL_LINE;
Expand Down Expand Up @@ -780,19 +825,21 @@ static void print_graph_headers(struct seq_file *s)

static void graph_trace_open(struct trace_iterator *iter)
{
/* pid on the last trace processed */
pid_t *last_pid = alloc_percpu(pid_t);
/* pid and depth on the last trace processed */
struct fgraph_data *data = alloc_percpu(struct fgraph_data);
int cpu;

if (!last_pid)
if (!data)
pr_warning("function graph tracer: not enough memory\n");
else
for_each_possible_cpu(cpu) {
pid_t *pid = per_cpu_ptr(last_pid, cpu);
pid_t *pid = &(per_cpu_ptr(data, cpu)->last_pid);
int *depth = &(per_cpu_ptr(data, cpu)->depth);
*pid = -1;
*depth = 0;
}

iter->private = last_pid;
iter->private = data;
}

static void graph_trace_close(struct trace_iterator *iter)
Expand Down

0 comments on commit 97eb037

Please sign in to comment.