ftrace: printk formatted recording
Subsystems (3)
Steven Rostedt
maintainerv2 cover ftrace: printk formatted recording
I previously sent out a patch to add printk formatted recording to the ftrace buffers. Andrew Morton suggested to get rid of my hacked trace_cont structure and do it properly with one structure at the top and two other structures to handle the difference between the fields and the continuation entry.
That is to have a top entry:
struct trace_entry {
char type;
union {
struct trace_field field;
struct trace_cont cont;
};
};instead of having a separate trace_cont that was outside the trace_entry and would be typecasted when used. This would be a source of bugs with later modifications of the ftrace code if a developer did not relize the connection between trace_entry and trace_cont. Using this proper method keeps the two tighly coupled for new developers to see.
Unfortunatly, doing it the proper way caused a large code change since now all the users of trace_entry (and there are many) must now dereference the field item.
The first patch just does the struct update and changes all the users to do the dereferencing properly.
The second patch in this series adds the user of the trace_cont, which is the ftrace_printk.
Note: I can no longer use the unspecified array size buf[] because gcc complains about:
struct trace_cont {
buf[];
};I now use buf[sizeof(struct trace_field)] which I think is a better solution anyways.
-- Steve
Steven Rostedt
maintainerPATCH v2 1/2 ftrace: new continue entry - separate out from trace_entry
Some tracers will need to work with more than one entry. In order to do this the trace_entry structure was split into two fields. One for the start of all entries, and one to continue an existing entry.
The trace_entry structure now has a "field" entry that consists of the previous content of the trace_entry, and a "cont" entry that is just a string buffer the size of the "field" entry.
Thanks to Andrew Morton for suggesting this idea.
--- kernel/trace/trace.c | 267 +++++++++++++++++++++-------------------- kernel/trace/trace.h | 17 ++ kernel/trace/trace_mmiotrace.c | 12 - 3 files changed, 160 insertions(+), 136 deletions(-)
kernel/trace/trace.c +140 -127
@@ -826,10 +826,11 @@ tracing_generic_entry_update(struct trac pc =preempt_count (); - entry->preempt_count = pc &0xff ; - entry->pid = (tsk) ? tsk->pid :0 ; - entry->t =ftrace_now (raw_smp_processor_id ()); - entry->flags = (irqs_disabled_flags (flags) ?TRACE_FLAG_IRQS_OFF :0 ) | + entry->field.preempt_count = pc &0xff ; + entry->field.pid = (tsk) ? tsk->pid :0 ; + entry->field.t =ftrace_now (raw_smp_processor_id ()); + entry->field.flags = + (irqs_disabled_flags (flags) ?TRACE_FLAG_IRQS_OFF :0 ) | ((pc &HARDIRQ_MASK ) ?TRACE_FLAG_HARDIRQ :0 ) | ((pc &SOFTIRQ_MASK ) ?TRACE_FLAG_SOFTIRQ :0 ) | (need_resched () ?TRACE_FLAG_NEED_RESCHED :0 );
@@ -844,11 +845,11 @@ trace_function(struct trace_array *tr, sraw_local_irq_save (irq_flags);__raw_spin_lock (&data->lock); - entry =tracing_get_trace_entry (tr, data); + entry =tracing_get_trace_entry (tr, data);tracing_generic_entry_update (entry, flags); - entry->type =TRACE_FN ; - entry->fn.ip = ip; - entry->fn.parent_ip = parent_ip; + entry->type =TRACE_FN ; + entry->field.fn.ip = ip; + entry->field.fn.parent_ip = parent_ip;__raw_spin_unlock (&data->lock);raw_local_irq_restore (irq_flags); }
@@ -871,10 +872,10 @@ void __trace_mmiotrace_rw(struct trace_araw_local_irq_save (irq_flags);__raw_spin_lock (&data->lock); - entry =tracing_get_trace_entry (tr, data); + entry =tracing_get_trace_entry (tr, data);tracing_generic_entry_update (entry,0 ); - entry->type =TRACE_MMIO_RW ; - entry->mmiorw = *rw; + entry->type =TRACE_MMIO_RW ; + entry->field.mmiorw = *rw;__raw_spin_unlock (&data->lock);raw_local_irq_restore (irq_flags);
@@ -891,10 +892,10 @@ void __trace_mmiotrace_map(struct trace_raw_local_irq_save (irq_flags);__raw_spin_lock (&data->lock); - entry =tracing_get_trace_entry (tr, data); + entry =tracing_get_trace_entry (tr, data);tracing_generic_entry_update (entry,0 ); - entry->type =TRACE_MMIO_MAP ; - entry->mmiomap = *map; + entry->type =TRACE_MMIO_MAP ; + entry->field.mmiomap = *map;__raw_spin_unlock (&data->lock);raw_local_irq_restore (irq_flags);
@@ -918,12 +919,12 @@ void __trace_stack(struct trace_array *ttracing_generic_entry_update (entry, flags); entry->type =TRACE_STACK ; -memset (&entry->stack,0 ,sizeof (entry->stack)); +memset (&entry->field.stack,0 ,sizeof (entry->field.stack)); trace.nr_entries =0 ; trace.max_entries =FTRACE_STACK_ENTRIES ; trace.skip = skip; - trace.entries = entry->stack.caller; + trace.entries = entry->field.stack.caller;save_stack_trace (&trace); }
@@ -939,12 +940,12 @@ __trace_special(void *__tr, void *__dataraw_local_irq_save (irq_flags);__raw_spin_lock (&data->lock); - entry =tracing_get_trace_entry (tr, data); + entry =tracing_get_trace_entry (tr, data);tracing_generic_entry_update (entry,0 ); - entry->type =TRACE_SPECIAL ; - entry->special.arg1 = arg1; - entry->special.arg2 = arg2; - entry->special.arg3 = arg3; + entry->type =TRACE_SPECIAL ; + entry->field.special.arg1 = arg1; + entry->field.special.arg2 = arg2; + entry->field.special.arg3 = arg3;__trace_stack (tr, data, irq_flags,4 );__raw_spin_unlock (&data->lock);raw_local_irq_restore (irq_flags);
@@ -964,15 +965,15 @@ tracing_sched_switch_trace(struct trace_raw_local_irq_save (irq_flags);__raw_spin_lock (&data->lock); - entry =tracing_get_trace_entry (tr, data); + entry =tracing_get_trace_entry (tr, data);tracing_generic_entry_update (entry, flags); - entry->type =TRACE_CTX ; - entry->ctx.prev_pid = prev->pid; - entry->ctx.prev_prio = prev->prio; - entry->ctx.prev_state = prev->state; - entry->ctx.next_pid = next->pid; - entry->ctx.next_prio = next->prio; - entry->ctx.next_state = next->state; + entry->type =TRACE_CTX ; + entry->field.ctx.prev_pid = prev->pid; + entry->field.ctx.prev_prio = prev->prio; + entry->field.ctx.prev_state = prev->state; + entry->field.ctx.next_pid = next->pid; + entry->field.ctx.next_prio = next->prio; + entry->field.ctx.next_state = next->state;__trace_stack (tr, data, flags,5 );__raw_spin_unlock (&data->lock);raw_local_irq_restore (irq_flags);
@@ -993,12 +994,12 @@ tracing_sched_wakeup_trace(struct trace_ entry =tracing_get_trace_entry (tr, data);tracing_generic_entry_update (entry, flags); entry->type =TRACE_WAKE ; - entry->ctx.prev_pid = curr->pid; - entry->ctx.prev_prio = curr->prio; - entry->ctx.prev_state = curr->state; - entry->ctx.next_pid = wakee->pid; - entry->ctx.next_prio = wakee->prio; - entry->ctx.next_state = wakee->state; + entry->field.ctx.prev_pid = curr->pid; + entry->field.ctx.prev_prio = curr->prio; + entry->field.ctx.prev_state = curr->state; + entry->field.ctx.next_pid = wakee->pid; + entry->field.ctx.next_prio = wakee->prio; + entry->field.ctx.next_state = wakee->state;__trace_stack (tr, data, flags,6 );__raw_spin_unlock (&data->lock);raw_local_irq_restore (irq_flags);
@@ -1127,7 +1128,7 @@ find_next_entry(struct trace_iterator *i/* * Pick the entry with the smallest timestamp: */ -if (ent && (!next || ent->t < next->t)) { +if (ent && (!next || ent->field.t < next->field.t)) { next = ent; next_cpu = cpu; }
@@ -1431,19 +1432,20 @@ print_trace_header(struct seq_file *m, sstatic void lat_print_generic (struct trace_seq *s,struct trace_entry *entry,int cpu) { +struct trace_field *field = &entry->field;int hardirq, softirq;char *comm; - comm =trace_find_cmdline (entry->pid); + comm =trace_find_cmdline (field->pid); -trace_seq_printf (s,"%8.8s-%-5d " , comm, entry->pid); +trace_seq_printf (s,"%8.8s-%-5d " , comm, field->pid);trace_seq_printf (s,"%d" , cpu);trace_seq_printf (s,"%c%c" , - (entry->flags &TRACE_FLAG_IRQS_OFF ) ?'d' :'.' , - ((entry->flags &TRACE_FLAG_NEED_RESCHED ) ?'N' :'.' )); + (field->flags &TRACE_FLAG_IRQS_OFF ) ?'d' :'.' , + ((field->flags &TRACE_FLAG_NEED_RESCHED ) ?'N' :'.' )); - hardirq = entry->flags &TRACE_FLAG_HARDIRQ ; - softirq = entry->flags &TRACE_FLAG_SOFTIRQ ; + hardirq = field->flags &TRACE_FLAG_HARDIRQ ; + softirq = field->flags &TRACE_FLAG_SOFTIRQ ;if (hardirq && softirq) {trace_seq_putc (s,'H' ); }else {
@@ -1457,8 +1459,8 @@ lat_print_generic(struct trace_seq *s, s } } -if (entry->preempt_count) -trace_seq_printf (s,"%x" , entry->preempt_count); +if (field->preempt_count) +trace_seq_printf (s,"%x" , field->preempt_count);else trace_seq_puts (s,"." ); }
@@ -1488,6 +1490,7 @@ print_lat_fmt(struct trace_iterator *itestruct trace_entry *next_entry =find_next_entry (iter,NULL );unsigned long verbose = (trace_flags &TRACE_ITER_VERBOSE );struct trace_entry *entry = iter->ent; +struct trace_field *field = &entry->field;unsigned long abs_usecs;unsigned long rel_usecs;char *comm;
@@ -1497,17 +1500,17 @@ print_lat_fmt(struct trace_iterator *iteif (!next_entry) next_entry = entry; - rel_usecs =ns2usecs (next_entry->t - entry->t); - abs_usecs =ns2usecs (entry->t - iter->tr->time_start); + rel_usecs =ns2usecs (next_entry->field.t - entry->field.t); + abs_usecs =ns2usecs (entry->field.t - iter->tr->time_start);if (verbose) { - comm =trace_find_cmdline (entry->pid); + comm =trace_find_cmdline (field->pid);trace_seq_printf (s,"%16s %5d %d %d %08x %08x [%08lx]" " %ld.%03ldms (+%ld.%03ldms): " , comm, - entry->pid, cpu, entry->flags, - entry->preempt_count, trace_idx, -ns2usecs (entry->t), + field->pid, cpu, field->flags, + field->preempt_count, trace_idx, +ns2usecs (field->t), abs_usecs/1000 , abs_usecs %1000 , rel_usecs/1000 , rel_usecs %1000 );
@@ -1517,41 +1520,42 @@ print_lat_fmt(struct trace_iterator *ite }switch (entry->type) {case TRACE_FN : -seq_print_ip_sym (s, entry->fn.ip, sym_flags); +seq_print_ip_sym (s, field->fn.ip, sym_flags);trace_seq_puts (s," (" ); -if (kretprobed (entry->fn.parent_ip)) +if (kretprobed (field->fn.parent_ip))trace_seq_puts (s,KRETPROBE_MSG );else -seq_print_ip_sym (s, entry->fn.parent_ip, sym_flags); +seq_print_ip_sym (s, field->fn.parent_ip, sym_flags);trace_seq_puts (s,")\n" );break ;case TRACE_CTX :case TRACE_WAKE : -T = entry->ctx.next_state <sizeof (state_to_char) ? - state_to_char[entry->ctx.next_state] :'X' ; +T = field->ctx.next_state <sizeof (state_to_char) ? + state_to_char[field->ctx.next_state] :'X' ; - state = entry->ctx.prev_state ?__ffs (entry->ctx.prev_state) +1 :0 ; + state = field->ctx.prev_state ? +__ffs (field->ctx.prev_state) +1 :0 ;S = state <sizeof (state_to_char) -1 ? state_to_char[state] :'X' ; - comm =trace_find_cmdline (entry->ctx.next_pid); + comm =trace_find_cmdline (field->ctx.next_pid);trace_seq_printf (s," %5d:%3d:%c %s %5d:%3d:%c %s\n" , - entry->ctx.prev_pid, - entry->ctx.prev_prio, + field->ctx.prev_pid, + field->ctx.prev_prio,S , entry->type ==TRACE_CTX ?"==>" :" +" , - entry->ctx.next_pid, - entry->ctx.next_prio, + field->ctx.next_pid, + field->ctx.next_prio,T , comm);break ;case TRACE_SPECIAL :trace_seq_printf (s,"# %ld %ld %ld\n" , - entry->special.arg1, - entry->special.arg2, - entry->special.arg3); + field->special.arg1, + field->special.arg2, + field->special.arg3);break ;case TRACE_STACK :for (i =0 ; i <FTRACE_STACK_ENTRIES ; i++) {if (i)trace_seq_puts (s," <= " ); -seq_print_ip_sym (s, entry->stack.caller[i], sym_flags); +seq_print_ip_sym (s, field->stack.caller[i], sym_flags); }trace_seq_puts (s,"\n" );break ;
@@ -1566,6 +1570,7 @@ static int print_trace_fmt(struct trace_struct trace_seq *s = &iter->seq;unsigned long sym_flags = (trace_flags &TRACE_ITER_SYM_MASK );struct trace_entry *entry; +struct trace_field *field;unsigned long usec_rem;unsigned long long t;unsigned long secs;
@@ -1575,14 +1580,15 @@ static int print_trace_fmt(struct trace_int i; entry = iter->ent; + field = &entry->field; - comm =trace_find_cmdline (iter->ent->pid); + comm =trace_find_cmdline (iter->ent->field.pid); - t =ns2usecs (entry->t); + t =ns2usecs (field->t); usec_rem =do_div (t,1000000ULL ); secs = (unsigned long )t; - ret =trace_seq_printf (s,"%16s-%-5d " , comm, entry->pid); + ret =trace_seq_printf (s,"%16s-%-5d " , comm, field->pid);if (!ret)return 0 ; ret =trace_seq_printf (s,"[%02d] " , iter->cpu);
@@ -1594,18 +1600,19 @@ static int print_trace_fmt(struct trace_switch (entry->type) {case TRACE_FN : - ret =seq_print_ip_sym (s, entry->fn.ip, sym_flags); + ret =seq_print_ip_sym (s, field->fn.ip, sym_flags);if (!ret)return 0 ;if ((sym_flags &TRACE_ITER_PRINT_PARENT ) && - entry->fn.parent_ip) { + field->fn.parent_ip) { ret =trace_seq_printf (s," <-" );if (!ret)return 0 ; -if (kretprobed (entry->fn.parent_ip)) +if (kretprobed (field->fn.parent_ip)) ret =trace_seq_puts (s,KRETPROBE_MSG );else - ret =seq_print_ip_sym (s, entry->fn.parent_ip, + ret =seq_print_ip_sym (s, + field->fn.parent_ip, sym_flags);if (!ret)return 0 ;
@@ -1616,26 +1623,26 @@ static int print_trace_fmt(struct trace_break ;case TRACE_CTX :case TRACE_WAKE : -S = entry->ctx.prev_state <sizeof (state_to_char) ? - state_to_char[entry->ctx.prev_state] :'X' ; -T = entry->ctx.next_state <sizeof (state_to_char) ? - state_to_char[entry->ctx.next_state] :'X' ; +S = field->ctx.prev_state <sizeof (state_to_char) ? + state_to_char[field->ctx.prev_state] :'X' ; +T = field->ctx.next_state <sizeof (state_to_char) ? + state_to_char[field->ctx.next_state] :'X' ; ret =trace_seq_printf (s," %5d:%3d:%c %s %5d:%3d:%c\n" , - entry->ctx.prev_pid, - entry->ctx.prev_prio, + field->ctx.prev_pid, + field->ctx.prev_prio,S , entry->type ==TRACE_CTX ?"==>" :" +" , - entry->ctx.next_pid, - entry->ctx.next_prio, + field->ctx.next_pid, + field->ctx.next_prio,T );if (!ret)return 0 ;break ;case TRACE_SPECIAL : ret =trace_seq_printf (s,"# %ld %ld %ld\n" , - entry->special.arg1, - entry->special.arg2, - entry->special.arg3); + field->special.arg1, + field->special.arg2, + field->special.arg3);if (!ret)return 0 ;break ;
@@ -1646,7 +1653,7 @@ static int print_trace_fmt(struct trace_if (!ret)return 0 ; } - ret =seq_print_ip_sym (s, entry->stack.caller[i], + ret =seq_print_ip_sym (s, field->stack.caller[i], sym_flags);if (!ret)return 0 ;
@@ -1663,37 +1670,40 @@ static int print_raw_fmt(struct trace_it {struct trace_seq *s = &iter->seq;struct trace_entry *entry; +struct trace_field *field;int ret;int S ,T ; entry = iter->ent; + field = &entry->field; ret =trace_seq_printf (s,"%d %d %llu " , - entry->pid, iter->cpu, entry->t); + field->pid, iter->cpu, field->t);if (!ret)return 0 ;switch (entry->type) {case TRACE_FN : ret =trace_seq_printf (s,"%x %x\n" , - entry->fn.ip, entry->fn.parent_ip); + field->fn.ip, + field->fn.parent_ip);if (!ret)return 0 ;break ;case TRACE_CTX :case TRACE_WAKE : -S = entry->ctx.prev_state <sizeof (state_to_char) ? - state_to_char[entry->ctx.prev_state] :'X' ; -T = entry->ctx.next_state <sizeof (state_to_char) ? - state_to_char[entry->ctx.next_state] :'X' ; +S = field->ctx.prev_state <sizeof (state_to_char) ? + state_to_char[field->ctx.prev_state] :'X' ; +T = field->ctx.next_state <sizeof (state_to_char) ? + state_to_char[field->ctx.next_state] :'X' ;if (entry->type ==TRACE_WAKE )S ='+' ; ret =trace_seq_printf (s,"%d %d %c %d %d %c\n" , - entry->ctx.prev_pid, - entry->ctx.prev_prio, + field->ctx.prev_pid, + field->ctx.prev_prio,S , - entry->ctx.next_pid, - entry->ctx.next_prio, + field->ctx.next_pid, + field->ctx.next_prio,T );if (!ret)return 0 ;
@@ -1701,9 +1711,9 @@ static int print_raw_fmt(struct trace_itcase TRACE_SPECIAL :case TRACE_STACK : ret =trace_seq_printf (s,"# %ld %ld %ld\n" , - entry->special.arg1, - entry->special.arg2, - entry->special.arg3); + field->special.arg1, + field->special.arg2, + field->special.arg3);if (!ret)return 0 ;break ;
@@ -1728,40 +1738,41 @@ static int print_hex_fmt(struct trace_itstruct trace_seq *s = &iter->seq;unsigned char newline ='\n' ;struct trace_entry *entry; +struct trace_field *field;int S ,T ; entry = iter->ent; + field = &entry->field; -SEQ_PUT_HEX_FIELD_RET (s, entry->pid); +SEQ_PUT_HEX_FIELD_RET (s, field->pid);SEQ_PUT_HEX_FIELD_RET (s, iter->cpu); -SEQ_PUT_HEX_FIELD_RET (s, entry->t); +SEQ_PUT_HEX_FIELD_RET (s, field->t);switch (entry->type) {case TRACE_FN : -SEQ_PUT_HEX_FIELD_RET (s, entry->fn.ip); -SEQ_PUT_HEX_FIELD_RET (s, entry->fn.parent_ip); +SEQ_PUT_HEX_FIELD_RET (s, field->fn.ip); +SEQ_PUT_HEX_FIELD_RET (s, field->fn.parent_ip);break ;case TRACE_CTX :case TRACE_WAKE : -S = entry->ctx.prev_state <sizeof (state_to_char) ? - state_to_char[entry->ctx.prev_state] :'X' ; -T = entry->ctx.next_state <sizeof (state_to_char) ? - state_to_char[entry->ctx.next_state] :'X' ; +S = field->ctx.prev_state <sizeof (state_to_char) ? + state_to_char[field->ctx.prev_state] :'X' ; +T = field->ctx.next_state <sizeof (state_to_char) ? + state_to_char[field->ctx.next_state] :'X' ;if (entry->type ==TRACE_WAKE )S ='+' ; -SEQ_PUT_HEX_FIELD_RET (s, entry->ctx.prev_pid); -SEQ_PUT_HEX_FIELD_RET (s, entry->ctx.prev_prio); +SEQ_PUT_HEX_FIELD_RET (s, field->ctx.prev_pid); +SEQ_PUT_HEX_FIELD_RET (s, field->ctx.prev_prio);SEQ_PUT_HEX_FIELD_RET (s,S ); -SEQ_PUT_HEX_FIELD_RET (s, entry->ctx.next_pid); -SEQ_PUT_HEX_FIELD_RET (s, entry->ctx.next_prio); -SEQ_PUT_HEX_FIELD_RET (s, entry->fn.parent_ip); +SEQ_PUT_HEX_FIELD_RET (s, field->ctx.next_pid); +SEQ_PUT_HEX_FIELD_RET (s, field->ctx.next_prio);SEQ_PUT_HEX_FIELD_RET (s,T );break ;case TRACE_SPECIAL :case TRACE_STACK : -SEQ_PUT_HEX_FIELD_RET (s, entry->special.arg1); -SEQ_PUT_HEX_FIELD_RET (s, entry->special.arg2); -SEQ_PUT_HEX_FIELD_RET (s, entry->special.arg3); +SEQ_PUT_HEX_FIELD_RET (s, field->special.arg1); +SEQ_PUT_HEX_FIELD_RET (s, field->special.arg2); +SEQ_PUT_HEX_FIELD_RET (s, field->special.arg3);break ; }SEQ_PUT_FIELD_RET (s, newline);
@@ -1773,31 +1784,33 @@ static int print_bin_fmt(struct trace_it {struct trace_seq *s = &iter->seq;struct trace_entry *entry; +struct trace_field *field; entry = iter->ent; + field = &entry->field; -SEQ_PUT_FIELD_RET (s, entry->pid); -SEQ_PUT_FIELD_RET (s, entry->cpu); -SEQ_PUT_FIELD_RET (s, entry->t); +SEQ_PUT_FIELD_RET (s, field->pid); +SEQ_PUT_FIELD_RET (s, field->cpu); +SEQ_PUT_FIELD_RET (s, field->t);switch (entry->type) {case TRACE_FN : -SEQ_PUT_FIELD_RET (s, entry->fn.ip); -SEQ_PUT_FIELD_RET (s, entry->fn.parent_ip); +SEQ_PUT_FIELD_RET (s, field->fn.ip); +SEQ_PUT_FIELD_RET (s, field->fn.parent_ip);break ;case TRACE_CTX : -SEQ_PUT_FIELD_RET (s, entry->ctx.prev_pid); -SEQ_PUT_FIELD_RET (s, entry->ctx.prev_prio); -SEQ_PUT_FIELD_RET (s, entry->ctx.prev_state); -SEQ_PUT_FIELD_RET (s, entry->ctx.next_pid); -SEQ_PUT_FIELD_RET (s, entry->ctx.next_prio); -SEQ_PUT_FIELD_RET (s, entry->ctx.next_state); +SEQ_PUT_FIELD_RET (s, field->ctx.prev_pid); +SEQ_PUT_FIELD_RET (s, field->ctx.prev_prio); +SEQ_PUT_FIELD_RET (s, field->ctx.prev_state); +SEQ_PUT_FIELD_RET (s, field->ctx.next_pid); +SEQ_PUT_FIELD_RET (s, field->ctx.next_prio); +SEQ_PUT_FIELD_RET (s, field->ctx.next_state);break ;case TRACE_SPECIAL :case TRACE_STACK : -SEQ_PUT_FIELD_RET (s, entry->special.arg1); -SEQ_PUT_FIELD_RET (s, entry->special.arg2); -SEQ_PUT_FIELD_RET (s, entry->special.arg3); +SEQ_PUT_FIELD_RET (s, field->special.arg1); +SEQ_PUT_FIELD_RET (s, field->special.arg2); +SEQ_PUT_FIELD_RET (s, field->special.arg3);break ; }return 1 ;
kernel/trace/trace.h +14 -3
@@ -61,13 +61,12 @@ struct stack_entry { };/* -* The trace entry - the most basic unit of tracing. This is what +* The trace field - the most basic unit of tracing. This is what * is printed in the end as a single line in the trace output, such as: * * bash-15816 [01] 235.197585: idle_cpu <- irq_enter */ -struct trace_entry { -char type; +struct trace_field {char cpu;char flags;char preempt_count;
@@ -83,6 +82,18 @@ struct trace_entry { }; }; +struct trace_field_cont { +char buf[sizeof (struct trace_field )]; +}; + +struct trace_entry { +char type; +union { +struct trace_field field; +struct trace_field_cont cont; + }; +}; +#define TRACE_ENTRY_SIZE sizeof(struct trace_entry)/*
kernel/trace/trace_mmiotrace.c +6 -6
@@ -174,14 +174,14 @@ print_out:static int mmio_print_rw (struct trace_iterator *iter) {struct trace_entry *entry = iter->ent; -struct mmiotrace_rw *rw = &entry->mmiorw; +struct mmiotrace_rw *rw = &entry->field.mmiorw;struct trace_seq *s = &iter->seq; -unsigned long long t =ns2usecs (entry->t); +unsigned long long t =ns2usecs (entry->field.t);unsigned long usec_rem =do_div (t,1000000ULL );unsigned secs = (unsigned long )t;int ret =1 ; -switch (entry->mmiorw.opcode) { +switch (entry->field.mmiorw.opcode) {case MMIO_READ : ret = trace_seq_printf(s, "R %d %lu.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
@@ -216,14 +216,14 @@ static int mmio_print_rw(struct trace_itstatic int mmio_print_map (struct trace_iterator *iter) {struct trace_entry *entry = iter->ent; -struct mmiotrace_map *m = &entry->mmiomap; +struct mmiotrace_map *m = &entry->field.mmiomap;struct trace_seq *s = &iter->seq; -unsigned long long t =ns2usecs (entry->t); +unsigned long long t =ns2usecs (entry->field.t);unsigned long usec_rem =do_div (t,1000000ULL );unsigned secs = (unsigned long )t;int ret =1 ; -switch (entry->mmiorw.opcode) { +switch (entry->field.mmiorw.opcode) {case MMIO_PROBE : ret = trace_seq_printf(s, "MAP %lu.%06lu %d 0x%llx 0x%lx 0x%lx 0x%lx %d\n",
Steven Rostedt
maintainerPATCH v2 2/2 ftrace: printk formatting infrastructure
In reply to Steven RostedtThis patch adds a feature that can help kernel developers debug their code using ftrace.
int ftrace_printk(const char *fmt, ...);
This records into the ftrace buffer using printf formatting. The entry size in the buffers are still a fixed length. A new type has been added that allows for more entries to be used for a single recording.
The start of the print is still the same as the other entries.
It returns the number of characters written to the ftrace buffer.
For example:
Having a module with the following code:
static int __init ftrace_print_test(void)
{
ftrace_printk("jiffies are %ld\n", jiffies);
return 0;
}Gives me:
insmod-5441 3...1 7569us : ftrace_print_test: jiffies are 4296626666
for the latency_trace file and:
insmod-5441 [03] 1959.370498: ftrace_print_test jiffies are 4296626666
for the trace file.
Note: Only the infrastructure should go into the kernel. It is to help facilitate debugging for other kernel developers. Calls to ftrace_printk is not intended to be left in the kernel, and should be frowned upon just like scattering printks around in the code.
But having this easily at your fingertips helps the debugging go faster and bugs be solved quicker.
Maybe later on, we can hook this with markers and have their printf format be sucked into ftrace output.
--- include/linux/ftrace.h | 10 + kernel/trace/trace.c | 273 +++++++++++++++++++++++++++++++++++++----- kernel/trace/trace.h | 11 + kernel/trace/trace_selftest.c | 11 + 4 files changed, 272 insertions(+), 33 deletions(-)
include/linux/ftrace.h +10 -0
@@ -137,10 +137,20 @@ static inline void tracer_disable(void)extern void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3);extern void ftrace_dump (void ); +# define ftrace_printk(x...) __ftrace_printk(_THIS_IP_, x) +extern int +__ftrace_printk (unsigned long ip,const char *fmt, ...) + __attribute__ ((format (printf,2 ,3 )));#else static inline void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3) { }static inline void ftrace_dump (void ) { } +static inline int +ftrace_printk (const char *fmt, ...) __attribute__ ((format (printf,1 ,0 ))) +{ +return 0 ; +}#endif +#endif /* _LINUX_FTRACE_H */
kernel/trace/trace.c +244 -29
387 lines not on this page · raw message
kernel/trace/trace.h +11 -0
@@ -13,7 +13,9 @@ enum trace_type {TRACE_FN ,TRACE_CTX ,TRACE_WAKE , +TRACE_CONT ,TRACE_STACK , +TRACE_PRINT ,TRACE_SPECIAL ,TRACE_MMIO_RW , TRACE_MMIO_MAP,
@@ -61,6 +63,14 @@ struct stack_entry { };/* +* ftrace_printk entry: +*/ +struct print_entry { +unsigned long ip; +char buf[]; +}; + +/* * The trace field - the most basic unit of tracing. This is what * is printed in the end as a single line in the trace output, such as: *
@@ -77,6 +87,7 @@ struct trace_field {struct ctx_switch_entry ctx;struct special_entry special;struct stack_entry stack; +struct print_entry print;struct mmiotrace_rw mmiorw;struct mmiotrace_map mmiomap; };
kernel/trace/trace_selftest.c +7 -4
@@ -9,7 +9,9 @@ static inline int trace_valid_entry(strucase TRACE_FN :case TRACE_CTX :case TRACE_WAKE : +case TRACE_CONT :case TRACE_STACK : +case TRACE_PRINT :case TRACE_SPECIAL :return 1 ; }
@@ -120,11 +122,11 @@ int trace_selftest_startup_dynamic_tracistruct trace_array *tr, int (*func)(void)) { -unsigned long count; -int ret; int save_ftrace_enabled = ftrace_enabled;int save_tracer_enabled = tracer_enabled; +unsigned long count;char *func_name; +int ret;/* The ftrace test PASSED */ printk (KERN_CONT "PASSED\n" );
@@ -157,6 +159,7 @@ int trace_selftest_startup_dynamic_traci/* enable tracing */ tr->ctrl =1 ; trace->init (tr); +/* Sleep for a 1/10 of a second */ msleep (100 );
@@ -212,10 +215,10 @@ int trace_selftest_startup_dynamic_traciint trace_selftest_startup_function (struct tracer *trace,struct trace_array *tr) { -unsigned long count; -int ret;int save_ftrace_enabled = ftrace_enabled;int save_tracer_enabled = tracer_enabled; +unsigned long count; +int ret;/* make sure msleep has been recorded */ msleep (1 );
Re: [PATCH v2 2/2] ftrace: printk formatting infrastructure
Quoted 3 lines · On Fri, 01 Aug 2008 12:26:41 -0400 Steven Rostedt wrote:
+/**
+ *ftrace_printk- printf formatting in the ftrace buffer
+ * @fmt - the printf format for printing.
* @fmt: the printf format for printing
* @ip: <description>
Quoted 13 lines
+ *
+ * Note:__ftrace_printkis an internal function forftrace_printkand
+ * the @ip is passed in via theftrace_printkmacro.
+ *
+ * This function allows a kernel developer to debug fast path sections
+ * that printk is not appropriate for. By scattering in various
+ * printk like tracing in the code, a developer can quickly see
+ * where problems are occurring.
+ *
+ * This is intended as a debugging tool for the developer only.
+ * Please reframe from leavingftrace_printksscattered around in
+ * your code.
+ */
kernel/trace/trace.c void ftrace_dump(void) · line 3263
Quoted 2 lines
kernel/trace/trace.c +2
-0+int __ftrace_printk (unsigned long ip,const char *fmt, ...) +{
---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/
Steven Rostedt
maintainerRe: [PATCH v2 2/2] ftrace: printk formatting infrastructure
Quoted 12 lines · Randy Dunlap
Quoted 3 lines · On Fri, 01 Aug 2008 12:26:41 -0400 Steven Rostedt wrote:
+/**
+ *ftrace_printk- printf formatting in the ftrace buffer
+ * @fmt - the printf format for printing.* @fmt: the printf format for printing
* @ip: <description>Quoted 3 lines
+ *
+ * Note:__ftrace_printkis an internal function forftrace_printkand
+ * the @ip is passed in via theftrace_printkmacro.
The above note actually explains this ;-)
Should I move the description to the ftrace_printk macro?
In include/linux/ftrace.h you see:
#ifdef CONFIG_TRACING
[...]
# define ftrace_printk(x...) __ftrace_printk(_THIS_IP_, x)
extern int
__ftrace_printk(unsigned long ip, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
#else
[...]
static inline int
ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1,
0)))
{
return 0;
}
#endifThe true API is ftrace_printk(const char *fmt) and the __ftrace_printk version should not be used.
Do you still think I should document the @ip?
I could also just remove the passing of _THIS_IP_ and use _RET_IP_ inside of ftrace_printk but the _THIS_IP_ seems to be more accurate especially when we have stack unwinding returns.
-- Steve
Quoted 19 lines
kernel/trace/trace.c void ftrace_dump(void) · line 3263
Quoted 12 lines
+ *
+ * This function allows a kernel developer to debug fast path sections
+ * that printk is not appropriate for. By scattering in various
+ * printk like tracing in the code, a developer can quickly see
+ * where problems are occurring.
+ *
+ * This is intended as a debugging tool for the developer only.
+ * Please reframe from leavingftrace_printksscattered around in
+ * your code.
+ */kernel/trace/trace.c +2
-0+int __ftrace_printk (unsigned long ip,const char *fmt, ...) +{---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/
Re: [PATCH v2 2/2] ftrace: printk formatting infrastructure
Quoted 9 lines · On Fri, 1 Aug 2008 12:53:17 -0400 (EDT) Steven Rostedt wrote:
Quoted 6 lines · Randy Dunlap
Quoted 3 lines · On Fri, 01 Aug 2008 12:26:41 -0400 Steven Rostedt wrote:
+/**
+ *ftrace_printk- printf formatting in the ftrace buffer
+ * @fmt - the printf format for printing.
Quoted 8 lines
Quoted 6 lines
* @fmt: the printf format for printing
* @ip: <description>Quoted 3 lines
+ *
+ * Note:__ftrace_printkis an internal function forftrace_printkand
+ * the @ip is passed in via theftrace_printkmacro.The above note actually explains this ;-)
I read that.
Quoted 1 line
Should I move the description to the
ftrace_printkmacro?
Probably.
Quoted 18 lines
In
include/linux/ftrace.hyou see:#ifdef
CONFIG_TRACING
[...]# define ftrace_printk(x...) __ftrace_printk(_THIS_IP_, x) extern int __ftrace_printk(unsigned long ip, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); #else [...] static inline int ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0))) { return 0; } #endif
Quoted 4 lines
The true API is
ftrace_printk(const char *fmt)and the__ftrace_printkversion should not be used.Do you still think I should document the @ip?
Just move the kernel-doc to the macro then.
Quoted 8 lines
I could also just remove the passing of _THIS_IP_ and use _RET_IP_ inside of
ftrace_printkbut the _THIS_IP_ seems to be more accurate especially when we have stack unwinding returns.-- Steve
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
+ *
+ * This function allows a kernel developer to debug fast path sections
+ * that printk is not appropriate for. By scattering in various
+ * printk like tracing in the code, a developer can quickly seeQuoted 8 lines
kernel/trace/trace.c void ftrace_dump(void) · line 3263
Quoted 8 lines
+ * where problems are occurring.
+ *
+ * This is intended as a debugging tool for the developer only.
+ * Please reframe from leavingftrace_printksscattered around in
+ * your code.
+ */kernel/trace/trace.c +2
-0+int __ftrace_printk (unsigned long ip,const char *fmt, ...) +{
---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/
Steven Rostedt
maintainer[PATCH v2 3/2] ftrace: ftrace_printk doc moved
Based on Randy Dunlap's suggestion, the ftrace_printk kernel-doc belongs with the ftrace_printk macro that should be used. Not with the __ftrace_printk internal function.
--- include/linux/ftrace.h | 19 ++++++++++++++++++- kernel/trace/trace.c | 16 ---------------- 2 files changed, 18 insertions(+), 17 deletions(-)
include/linux/ftrace.h +18 -1
@@ -137,7 +137,24 @@ static inline void tracer_disable(void)extern void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3);extern void ftrace_dump (void ); -# define ftrace_printk(x...) __ftrace_printk(_THIS_IP_, x) + +/** +* ftrace_printk - printf formatting in the ftrace buffer +* @fmt - the printf format for printing. +* +* Note: __ftrace_printk is an internal function for ftrace_printk and +* the @ip is passed in via the ftrace_printk macro. +* +* This function allows a kernel developer to debug fast path sections +* that printk is not appropriate for. By scattering in various +* printk like tracing in the code, a developer can quickly see +* where problems are occurring. +* +* This is intended as a debugging tool for the developer only. +* Please reframe from leaving ftrace_printks scattered around in +* your code. +*/ +# define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt)extern int __ftrace_printk (unsigned long ip,const char *fmt, ...) __attribute__ ((format (printf,2 ,3 )));
kernel/trace/trace.c +0 -16
@@ -3243,22 +3243,6 @@ void ftrace_dump(void) (sizeof(struct trace_field) - offsetof(struct trace_field, print.buf))#define TRACE_CONT_BUF_SIZE sizeof(struct trace_field) -/** -* ftrace_printk - printf formatting in the ftrace buffer -* @fmt - the printf format for printing. -* -* Note: __ftrace_printk is an internal function for ftrace_printk and -* the @ip is passed in via the ftrace_printk macro. -* -* This function allows a kernel developer to debug fast path sections -* that printk is not appropriate for. By scattering in various -* printk like tracing in the code, a developer can quickly see -* where problems are occurring. -* -* This is intended as a debugging tool for the developer only. -* Please reframe from leaving ftrace_printks scattered around in -* your code. -*/ int __ftrace_printk (unsigned long ip,const char *fmt, ...) {struct trace_array *tr = &global_trace;
Re: [PATCH v2 3/2] ftrace: ftrace_printk doc moved
Quoted 16 lines · On Fri, 1 Aug 2008 14:17:42 -0400 (EDT) Steven Rostedt wrote:
Based on Randy Dunlap's suggestion, the
ftrace_printkkernel-doc belongs with theftrace_printkmacro that should be used. Not with the__ftrace_printkinternal function.Signed-off-by Steven Rostedt <[email protected]>--- include/linux/ftrace.h | 19 ++++++++++++++++++- kernel/trace/trace.c | 16 ---------------- 2 files changed, 18 insertions(+), 17 deletions(-)Index:
linux-tip.git/include/linux/ftrace.h
===================================================================
include/linux/ftrace.h static inline void tracer_disable(void) · line 143
Quoted 8 lines
include/linux/ftrace.h +4
-1@@ -137,7 +137,24 @@ static inline void tracer_disable(void)extern void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3);extern void ftrace_dump (void ); -# define ftrace_printk(x...) __ftrace_printk(_THIS_IP_, x) + +/** +* ftrace_printk - printf formatting in the ftrace buffer +* @fmt - the printf format for printing.
* @fmt: the printf format for printing
include/linux/ftrace.h static inline void tracer_disable(void) · line 154
Quoted 11 lines
include/linux/ftrace.h +11
-0+* +* Note: __ftrace_printk is an internal function for ftrace_printk and +* the @ip is passed in via the ftrace_printk macro. +* +* This function allows a kernel developer to debug fast path sections +* that printk is not appropriate for. By scattering in various +* printk like tracing in the code, a developer can quickly see +* where problems are occurring. +* +* This is intended as a debugging tool for the developer only. +* Please reframe from leaving ftrace_printks scattered around in
refrain
Quoted 23 lines
include/linux/ftrace.h +3
-0+* your code. +*/ +# define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt)extern int __ftrace_printk (unsigned long ip,const char *fmt, ...) __attribute__ ((format (printf,2 ,3 )));Index:
linux-tip.git/kernel/trace/trace.c
===================================================================kernel/trace/trace.c +0
-9@@ -3243,22 +3243,6 @@ void ftrace_dump(void) (sizeof(struct trace_field) - offsetof(struct trace_field, print.buf))#define TRACE_CONT_BUF_SIZE sizeof(struct trace_field) -/** -* ftrace_printk - printf formatting in the ftrace buffer -* @fmt - the printf format for printing. -* -* Note: __ftrace_printk is an internal function for ftrace_printk and -* the @ip is passed in via the ftrace_printk macro. -* -* This function allows a kernel developer to debug fast path sections -* that printk is not appropriate for. By scattering in various
kernel/trace/trace.c void ftrace_dump(void) · line 3248
Quoted 10 lines
kernel/trace/trace.c +0
-7-* printk like tracing in the code, a developer can quickly see -* where problems are occurring. -* -* This is intended as a debugging tool for the developer only. -* Please reframe from leaving ftrace_printks scattered around in -* your code. -*/ int __ftrace_printk (unsigned long ip,const char *fmt, ...) {struct trace_array *tr = &global_trace;
---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/
Steven Rostedt
maintainerRe: [PATCH v2 3/2] ftrace: ftrace_printk doc moved
Quoted 13 lines · Randy Dunlap
Quoted 11 lines · On Fri, 1 Aug 2008 14:17:42 -0400 (EDT) Steven Rostedt wrote:
Based on Randy Dunlap's suggestion, the
ftrace_printkkernel-doc belongs with theftrace_printkmacro that should be used. Not with the__ftrace_printkinternal function.Signed-off-by Steven Rostedt <[email protected]>--- include/linux/ftrace.h | 19 ++++++++++++++++++- kernel/trace/trace.c | 16 ---------------- 2 files changed, 18 insertions(+), 17 deletions(-)
Quoted 15 lines
include/linux/ftrace.h static inline void tracer_disable(void) · line 143
Quoted 13 lines
Index:
linux-tip.git/include/linux/ftrace.h
===================================================================include/linux/ftrace.h +4
-1@@ -137,7 +137,24 @@ static inline void tracer_disable(void)extern void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3);extern void ftrace_dump (void ); -# define ftrace_printk(x...) __ftrace_printk(_THIS_IP_, x) + +/** +* ftrace_printk - printf formatting in the ftrace buffer +* @fmt - the printf format for printing. * @fmt: the printf format for printing
OK, thanks.
Quoted 13 lines
include/linux/ftrace.h static inline void tracer_disable(void) · line 154
Quoted 12 lines
include/linux/ftrace.h +11
-0+* +* Note: __ftrace_printk is an internal function for ftrace_printk and +* the @ip is passed in via the ftrace_printk macro. +* +* This function allows a kernel developer to debug fast path sections +* that printk is not appropriate for. By scattering in various +* printk like tracing in the code, a developer can quickly see +* where problems are occurring. +* +* This is intended as a debugging tool for the developer only. +* Please reframe from leaving ftrace_printks scattered around in
Quoted 1 line
refrain
Heh, I manually fixed that before sending out the original. I never fixed it in the quilt queue. Darn!
-- Steve
Quoted 5 lines
Quoted 5 lines
include/linux/ftrace.h +3
-0+* your code. +*/ +# define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt) extern int
Steven Rostedt
maintainer[PATCH v3 3/2] ftrace: ftrace_printk doc moved
In reply to Randy DunlapBased on Randy Dunlap's suggestion, the ftrace_printk kernel-doc belongs with the ftrace_printk macro that should be used. Not with the __ftrace_printk internal function.
--- include/linux/ftrace.h | 19 ++++++++++++++++++- kernel/trace/trace.c | 16 ---------------- 2 files changed, 18 insertions(+), 17 deletions(-)
include/linux/ftrace.h +18 -1
@@ -137,7 +137,24 @@ static inline void tracer_disable(void)extern void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3);extern void ftrace_dump (void ); -# define ftrace_printk(x...) __ftrace_printk(_THIS_IP_, x) + +/** +* ftrace_printk - printf formatting in the ftrace buffer +* @fmt: the printf format for printing +* +* Note: __ftrace_printk is an internal function for ftrace_printk and +* the @ip is passed in via the ftrace_printk macro. +* +* This function allows a kernel developer to debug fast path sections +* that printk is not appropriate for. By scattering in various +* printk like tracing in the code, a developer can quickly see +* where problems are occurring. +* +* This is intended as a debugging tool for the developer only. +* Please refrain from leaving ftrace_printks scattered around in +* your code. +*/ +# define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt)extern int __ftrace_printk (unsigned long ip,const char *fmt, ...) __attribute__ ((format (printf,2 ,3 )));
kernel/trace/trace.c +0 -16
@@ -3243,22 +3243,6 @@ void ftrace_dump(void) (sizeof(struct trace_field) - offsetof(struct trace_field, print.buf))#define TRACE_CONT_BUF_SIZE sizeof(struct trace_field) -/** -* ftrace_printk - printf formatting in the ftrace buffer -* @fmt - the printf format for printing. -* -* Note: __ftrace_printk is an internal function for ftrace_printk and -* the @ip is passed in via the ftrace_printk macro. -* -* This function allows a kernel developer to debug fast path sections -* that printk is not appropriate for. By scattering in various -* printk like tracing in the code, a developer can quickly see -* where problems are occurring. -* -* This is intended as a debugging tool for the developer only. -* Please reframe from leaving ftrace_printks scattered around in -* your code. -*/ int __ftrace_printk (unsigned long ip,const char *fmt, ...) {struct trace_array *tr = &global_trace;
Randy Dunlap
Acked-byRe: [PATCH v3 3/2] ftrace: ftrace_printk doc moved
Quoted 6 lines · On Fri, 1 Aug 2008 16:45:49 -0400 (EDT) Steven Rostedt wrote:
Based on Randy Dunlap's suggestion, the
ftrace_printkkernel-doc belongs with theftrace_printkmacro that should be used. Not with the__ftrace_printkinternal function.Signed-off-by Steven Rostedt <[email protected]>
Quoted 52 lines
--- include/linux/ftrace.h | 19 ++++++++++++++++++- kernel/trace/trace.c | 16 ---------------- 2 files changed, 18 insertions(+), 17 deletions(-)Index:
linux-tip.git/include/linux/ftrace.h
===================================================================include/linux/ftrace.h +18
-1@@ -137,7 +137,24 @@ static inline void tracer_disable(void)extern void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3);extern void ftrace_dump (void ); -# define ftrace_printk(x...) __ftrace_printk(_THIS_IP_, x) + +/** +* ftrace_printk - printf formatting in the ftrace buffer +* @fmt: the printf format for printing +* +* Note: __ftrace_printk is an internal function for ftrace_printk and +* the @ip is passed in via the ftrace_printk macro. +* +* This function allows a kernel developer to debug fast path sections +* that printk is not appropriate for. By scattering in various +* printk like tracing in the code, a developer can quickly see +* where problems are occurring. +* +* This is intended as a debugging tool for the developer only. +* Please refrain from leaving ftrace_printks scattered around in +* your code. +*/ +# define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt)extern int __ftrace_printk (unsigned long ip,const char *fmt, ...) __attribute__ ((format (printf,2 ,3 )));Index:
linux-tip.git/kernel/trace/trace.c
===================================================================kernel/trace/trace.c +0
-9@@ -3243,22 +3243,6 @@ void ftrace_dump(void) (sizeof(struct trace_field) - offsetof(struct trace_field, print.buf))#define TRACE_CONT_BUF_SIZE sizeof(struct trace_field) -/** -* ftrace_printk - printf formatting in the ftrace buffer -* @fmt - the printf format for printing. -* -* Note: __ftrace_printk is an internal function for ftrace_printk and -* the @ip is passed in via the ftrace_printk macro. -* -* This function allows a kernel developer to debug fast path sections -* that printk is not appropriate for. By scattering in various
kernel/trace/trace.c void ftrace_dump(void) · line 3248
Quoted 10 lines
kernel/trace/trace.c +0
-7-* printk like tracing in the code, a developer can quickly see -* where problems are occurring. -* -* This is intended as a debugging tool for the developer only. -* Please reframe from leaving ftrace_printks scattered around in -* your code. -*/ int __ftrace_printk (unsigned long ip,const char *fmt, ...) {struct trace_array *tr = &global_trace;
---
~Randy
Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/
Ingo Molnar
AppliedQuoted 5 lines · Steven Rostedt
I previously sent out a patch to add printk formatted recording to the ftrace buffers. Andrew Morton suggested to get rid of my hacked
trace_contstructure and do it properly with one structure at the top and two other structures to handle the difference between the fields and the continuation entry.
applied all 3 patches to tip/tracing/ftrace - thanks Steve.
Ingo
PATCH 1/1 ftrace: build fix
Quoted 2 lines
From
00968bd78e3346f35dc809f7a7c811a3d88cf07cMon Sep 17 00:00:00 2001
From: Ingo Molnar <[email protected]>
Date: Fri, 15 Aug 2008 17:48:02 +0200
Subject: [PATCH] ftrace: build fix
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
fix:
In file included from init/main.c:65:
include/linux/ftrace.h:166: error: expected ‘,' or ‘;' before ‘{' token make[1]: *** [init/main.o] Error 1
make: *** [init/main.o] Error 2
--- include/linux/ftrace.h | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
include/linux/ftrace.h +4 -1
@@ -162,7 +162,10 @@ extern void ftrace_dump(void);static inline void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3) { }static inline int -ftrace_printk (const char *fmt, ...) __attribute__ ((format (printf,1 ,0 ))) +ftrace_printk (const char *fmt, ...) __attribute__ ((format (printf,1 ,0 ))); + +static inline int +ftrace_printk (const char *fmt, ...) {return 0 ; }