/* * Any file that uses trace points, must include the header. * But only one file, must include the header by defining * CREATE_TRACE_POINTS first. This will make the C code that * creates the handles for the trace points.
*/ #define CREATE_TRACE_POINTS #include"sample-trace-array.h"
/* * mytimer: Timer setup to disable tracing for event "sample_event". This * timer is only for the purposes of the sample module to demonstrate access of * Ftrace instances from within kernel.
*/ static DEFINE_TIMER(mytimer, mytimer_handler);
/* * Printing count value using trace_array_printk() - trace_printk() * equivalent for the instance buffers.
*/
trace_array_printk(tr, _THIS_IP_, "trace_array_printk: count=%d\n",
count); /* * Tracepoint for event "sample_event". This will print the * current value of count and current jiffies.
*/
trace_sample_event(count, jiffies);
}
/* * trace_array_put() decrements the reference counter associated with * the trace array - "tr". We are done using the trace array, hence * decrement the reference counter so that it can be destroyed using * trace_array_destroy().
*/
trace_array_put(tr);
return 0;
}
staticint __init sample_trace_array_init(void)
{ /* * Return a pointer to the trace array with name "sample-instance" if it * exists, else create a new trace array. * * NOTE: This function increments the reference counter * associated with the trace array - "tr".
*/
tr = trace_array_get_by_name("sample-instance", "sched,timer,kprobes");
if (!tr) return -1; /* * If context specific per-cpu buffers havent already been allocated.
*/
trace_array_init_printk(tr);
/* * We are unloading our module and no longer require the trace array. * Remove/destroy "tr" using trace_array_destroy()
*/
trace_array_destroy(tr);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.