Re: [patch 9/9] x86, bts, ftrace: a BTS ftrace plug-in prototype

From: Frédéric Weisbecker
Date: Tue Nov 25 2008 - 05:39:46 EST


Hi Markus,

2008/11/25 Markus Metzger <markus.t.metzger@xxxxxxxxx>:
> +static enum print_line_t bts_trace_print_line(struct trace_iterator *iter)
> +{
> + struct trace_entry *entry = iter->ent;
> + struct trace_seq *seq = &iter->seq;
> + struct bts_entry *it;
> +
> + trace_assign_type(it, entry);
> +
> + if (entry->type == TRACE_BTS) {
> + int ret;
> +#ifdef CONFIG_KALLSYMS
> + char function[KSYM_SYMBOL_LEN];
> + sprint_symbol(function, it->from);
> +#else
> + char *function = "<unknown>";
> +#endif
> +
> + ret = trace_seq_printf(seq, "%4d 0x%lx -> 0x%lx [%s]\n",
> + entry->cpu, it->from, it->to, function);


You can use seq_print_ip_sym() which handles the ifdef and the sprint_symbol...


> +void trace_bts(struct trace_array *tr, unsigned long from, unsigned long to)
> +{
> + struct ring_buffer_event *event;
> + struct bts_entry *entry;
> + unsigned long irq;
> +
> + event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), &irq);
> + if (!event)
> + return;
> + entry = ring_buffer_event_data(event);
> + tracing_generic_entry_update(&entry->ent, 0, from);
> + entry->ent.type = TRACE_BTS;
> + entry->ent.cpu = smp_processor_id();


If you look at the struct trace_entry, you will see find the cpu
field. It is already inserted automatically :-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/