Something went wrong. Try again.
Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935// SPDX-License-Identifier: GPL-2.0/* * trace_output.c * * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> * */#include "trace.h"#include <linux/module.h>#include <linux/mutex.h>#include <linux/ftrace.h>#include <linux/kprobes.h>#include <linux/sched/clock.h>#include <linux/sched/mm.h>#include <linux/idr.h>#include <linux/btf.h>#include <linux/bpf.h>#include <linux/hashtable.h>
#include "trace_output.h"#include "trace_btf.h"
/* 2^7 = 128 */#define EVENT_HASH_BITS 7
DECLARE_RWSEM(trace_event_sem);
static DEFINE_HASHTABLE(event_hash, EVENT_HASH_BITS);
enum print_line_t trace_print_bputs_msg_only(struct trace_iterator *iter){ struct trace_seq *s = &iter->seq; struct trace_entry *entry = iter->ent; struct bputs_entry *field;
trace_assign_type(field, entry);
trace_seq_puts(s, field->str);
return trace_handle_return(s);}
enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter){ struct trace_seq *s = &iter->seq; struct trace_entry *entry = iter->ent; struct bprint_entry *field;
trace_assign_type(field, entry);
trace_seq_bprintf(s, field->fmt, field->buf);
return trace_handle_return(s);}
enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter){ struct trace_seq *s = &iter->seq; struct trace_entry *entry = iter->ent; struct print_entry *field;
trace_assign_type(field, entry);
trace_seq_puts(s, field->buf);
return trace_handle_return(s);}
const char *trace_print_flags_seq(struct trace_seq *p, const char *delim, unsigned long flags, const struct trace_print_flags *flag_array, size_t flag_array_size){ unsigned long mask; const char *str; const char *ret = trace_seq_buffer_ptr(p); int i, first = 1;
for (i = 0; i < flag_array_size && flags; i++) {
mask = flag_array[i].mask; if ((flags & mask) != mask) continue;
str = flag_array[i].name; flags &= ~mask; if (!first && delim) trace_seq_puts(p, delim); else first = 0; trace_seq_puts(p, str); }
/* check for left over flags */ if (flags) { if (!first && delim) trace_seq_puts(p, delim); trace_seq_printf(p, "0x%lx", flags); }
trace_seq_putc(p, 0);
return ret;}EXPORT_SYMBOL(trace_print_flags_seq);
const char *trace_print_symbols_seq(struct trace_seq *p, unsigned long val, const struct trace_print_flags *symbol_array, size_t symbol_array_size){ int i; const char *ret = trace_seq_buffer_ptr(p);
for (i = 0; i < symbol_array_size; i++) {
if (val != symbol_array[i].mask) continue;
trace_seq_puts(p, symbol_array[i].name); break; }
if (ret == (const char *)(trace_seq_buffer_ptr(p))) trace_seq_printf(p, "0x%lx", val);
trace_seq_putc(p, 0);
return ret;}EXPORT_SYMBOL(trace_print_symbols_seq);
#if BITS_PER_LONG == 32const char *trace_print_flags_seq_u64(struct trace_seq *p, const char *delim, unsigned long long flags, const struct trace_print_flags_u64 *flag_array, size_t flag_array_size){ unsigned long long mask; const char *str; const char *ret = trace_seq_buffer_ptr(p); int i, first = 1;
for (i = 0; i < flag_array_size && flags; i++) {
mask = flag_array[i].mask; if ((flags & mask) != mask) continue;
str = flag_array[i].name; flags &= ~mask; if (!first && delim) trace_seq_puts(p, delim); else first = 0; trace_seq_puts(p, str); }
/* check for left over flags */ if (flags) { if (!first && delim) trace_seq_puts(p, delim); trace_seq_printf(p, "0x%llx", flags); }
trace_seq_putc(p, 0);
return ret;}EXPORT_SYMBOL(trace_print_flags_seq_u64);
const char *trace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val, const struct trace_print_flags_u64 *symbol_array, size_t symbol_array_size){ int i; const char *ret = trace_seq_buffer_ptr(p);
for (i = 0; i < symbol_array_size; i++) {
if (val != symbol_array[i].mask) continue;
trace_seq_puts(p, symbol_array[i].name); break; }
if (ret == (const char *)(trace_seq_buffer_ptr(p))) trace_seq_printf(p, "0x%llx", val);
trace_seq_putc(p, 0);
return ret;}EXPORT_SYMBOL(trace_print_symbols_seq_u64);#endif
/** * trace_print_bitmask_seq - print a bitmask to a sequence buffer * @iter: The trace iterator for the current event instance * @bitmask_ptr: The pointer to the bitmask data * @bitmask_size: The size of the bitmask in bytes * * Prints a bitmask into a sequence buffer as either a hex string or a * human-readable range list, depending on the instance's "bitmask-list" * trace option. The bitmask is formatted into the iterator's temporary * scratchpad rather than the primary sequence buffer. This avoids * duplication and pointer-collision issues when the returned string is * processed by a "%s" specifier in a TP_printk() macro. * * Returns a pointer to the formatted string within the temporary buffer. */const char *trace_print_bitmask_seq(struct trace_iterator *iter, void *bitmask_ptr, unsigned int bitmask_size){ struct trace_seq *p = &iter->tmp_seq; const struct trace_array *tr = iter->tr; const char *ret;
trace_seq_init(p); ret = trace_seq_buffer_ptr(p);
if (tr->trace_flags & TRACE_ITER(BITMASK_LIST)) trace_seq_bitmask_list(p, bitmask_ptr, bitmask_size * 8); else trace_seq_bitmask(p, bitmask_ptr, bitmask_size * 8);
trace_seq_putc(p, 0);
return ret;}EXPORT_SYMBOL_GPL(trace_print_bitmask_seq);
/** * trace_print_hex_seq - print buffer as hex sequence * @p: trace seq struct to write to * @buf: The buffer to print * @buf_len: Length of @buf in bytes * @concatenate: Print @buf as single hex string or with spacing * * Prints the passed buffer as a hex sequence either as a whole, * single hex string if @concatenate is true or with spacing after * each byte in case @concatenate is false. */const char *trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len, bool concatenate){ int i; const char *ret = trace_seq_buffer_ptr(p); const char *fmt = concatenate ? "%*phN" : "%*ph";
for (i = 0; i < buf_len; i += 16) { if (!concatenate && i != 0) trace_seq_putc(p, ' '); trace_seq_printf(p, fmt, min(buf_len - i, 16), &buf[i]); } trace_seq_putc(p, 0);
return ret;}EXPORT_SYMBOL(trace_print_hex_seq);
const char *trace_print_array_seq(struct trace_seq *p, const void *buf, int count, size_t el_size){ const char *ret = trace_seq_buffer_ptr(p); const char *prefix = ""; void *ptr = (void *)buf; size_t buf_len = count * el_size;
trace_seq_putc(p, '{');
while (ptr < buf + buf_len) { switch (el_size) { case 1: trace_seq_printf(p, "%s0x%x", prefix, *(u8 *)ptr); break; case 2: trace_seq_printf(p, "%s0x%x", prefix, *(u16 *)ptr); break; case 4: trace_seq_printf(p, "%s0x%x", prefix, *(u32 *)ptr); break; case 8: trace_seq_printf(p, "%s0x%llx", prefix, *(u64 *)ptr); break; default: trace_seq_printf(p, "BAD SIZE:%zu 0x%x", el_size, *(u8 *)ptr); el_size = 1; } prefix = ","; ptr += el_size; }
trace_seq_putc(p, '}'); trace_seq_putc(p, 0);
return ret;}EXPORT_SYMBOL(trace_print_array_seq);
const char *trace_print_hex_dump_seq(struct trace_seq *p, const char *prefix_str, int prefix_type, int rowsize, int groupsize, const void *buf, size_t len, bool ascii){ const char *ret = trace_seq_buffer_ptr(p);
trace_seq_putc(p, '\n'); trace_seq_hex_dump(p, prefix_str, prefix_type, rowsize, groupsize, buf, len, ascii); trace_seq_putc(p, 0); return ret;}EXPORT_SYMBOL(trace_print_hex_dump_seq);
int trace_raw_output_prep(struct trace_iterator *iter, struct trace_event *trace_event){ struct trace_event_call *event; struct trace_seq *s = &iter->seq; struct trace_seq *p = &iter->tmp_seq; struct trace_entry *entry;
event = container_of(trace_event, struct trace_event_call, event); entry = iter->ent;
if (entry->type != event->event.type) { WARN_ON_ONCE(1); return TRACE_TYPE_UNHANDLED; }
trace_seq_init(p); trace_seq_printf(s, "%s: ", trace_event_name(event));
return trace_handle_return(s);}EXPORT_SYMBOL(trace_raw_output_prep);
void trace_event_printf(struct trace_iterator *iter, const char *fmt, ...){ struct trace_seq *s = &iter->seq; va_list ap;
if (ignore_event(iter)) return;
va_start(ap, fmt); trace_seq_vprintf(s, trace_event_format(iter, fmt), ap); va_end(ap);}EXPORT_SYMBOL(trace_event_printf);
static __printf(3, 0)int trace_output_raw(struct trace_iterator *iter, char *name, char *fmt, va_list ap){ struct trace_seq *s = &iter->seq;
trace_seq_printf(s, "%s: ", name); trace_seq_vprintf(s, trace_event_format(iter, fmt), ap);
return trace_handle_return(s);}
int trace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...){ va_list ap; int ret;
va_start(ap, fmt); ret = trace_output_raw(iter, name, fmt, ap); va_end(ap);
return ret;}EXPORT_SYMBOL_GPL(trace_output_call);
static inline const char *kretprobed(const char *name, unsigned long addr){ if (is_kretprobe_trampoline(addr)) return "[unknown/kretprobe'd]"; return name;}
voidtrace_seq_print_sym(struct trace_seq *s, unsigned long address, bool offset){#ifdef CONFIG_KALLSYMS char str[KSYM_SYMBOL_LEN]; const char *name;
if (offset) sprint_symbol(str, address); else kallsyms_lookup(address, NULL, NULL, NULL, str); name = kretprobed(str, address);
if (name && strlen(name)) { trace_seq_puts(s, name); return; }#endif trace_seq_printf(s, "0x%08lx", address);}
#ifndef CONFIG_64BIT# define IP_FMT "%08lx"#else# define IP_FMT "%016lx"#endif
static int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm, unsigned long ip, unsigned long sym_flags){ struct file *file = NULL; unsigned long vmstart = 0; int ret = 1;
if (s->full) return 0;
if (mm) { const struct vm_area_struct *vma;
mmap_read_lock(mm); vma = find_vma(mm, ip); if (vma) { file = vma->vm_file; vmstart = vma->vm_start; } if (file) { ret = trace_seq_path(s, file_user_path(file)); if (ret) trace_seq_printf(s, "[+0x%lx]", ip - vmstart); } mmap_read_unlock(mm); } if (ret && ((sym_flags & TRACE_ITER(SYM_ADDR)) || !file)) trace_seq_printf(s, " <" IP_FMT ">", ip); return !trace_seq_has_overflowed(s);}
intseq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags){ if (!ip) { trace_seq_putc(s, '0'); goto out; }
trace_seq_print_sym(s, ip, sym_flags & TRACE_ITER(SYM_OFFSET));
if (sym_flags & TRACE_ITER(SYM_ADDR)) trace_seq_printf(s, " <" IP_FMT ">", ip);
out: return !trace_seq_has_overflowed(s);}
/** * trace_print_lat_fmt - print the irq, preempt and lockdep fields * @s: trace seq struct to write to * @entry: The trace entry field from the ring buffer * * Prints the generic fields of irqs off, in hard or softirq, preempt * count. */int trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry){ char hardsoft_irq; char need_resched; char irqs_off; int hardirq; int softirq; int bh_off; int nmi;
nmi = entry->flags & TRACE_FLAG_NMI; hardirq = entry->flags & TRACE_FLAG_HARDIRQ; softirq = entry->flags & TRACE_FLAG_SOFTIRQ; bh_off = entry->flags & TRACE_FLAG_BH_OFF;
irqs_off = (entry->flags & TRACE_FLAG_IRQS_OFF && bh_off) ? 'D' : (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' : bh_off ? 'b' : '.';
switch (entry->flags & (TRACE_FLAG_NEED_RESCHED | TRACE_FLAG_NEED_RESCHED_LAZY | TRACE_FLAG_PREEMPT_RESCHED)) { case TRACE_FLAG_NEED_RESCHED | TRACE_FLAG_NEED_RESCHED_LAZY | TRACE_FLAG_PREEMPT_RESCHED: need_resched = 'B'; break; case TRACE_FLAG_NEED_RESCHED | TRACE_FLAG_PREEMPT_RESCHED: need_resched = 'N'; break; case TRACE_FLAG_NEED_RESCHED_LAZY | TRACE_FLAG_PREEMPT_RESCHED: need_resched = 'L'; break; case TRACE_FLAG_NEED_RESCHED | TRACE_FLAG_NEED_RESCHED_LAZY: need_resched = 'b'; break; case TRACE_FLAG_NEED_RESCHED: need_resched = 'n'; break; case TRACE_FLAG_PREEMPT_RESCHED: need_resched = 'p'; break; case TRACE_FLAG_NEED_RESCHED_LAZY: need_resched = 'l'; break; default: need_resched = '.'; break; }
hardsoft_irq = (nmi && hardirq) ? 'Z' : nmi ? 'z' : (hardirq && softirq) ? 'H' : hardirq ? 'h' : softirq ? 's' : '.' ;
trace_seq_printf(s, "%c%c%c", irqs_off, need_resched, hardsoft_irq);
if (entry->preempt_count & 0xf) trace_seq_printf(s, "%x", entry->preempt_count & 0xf); else trace_seq_putc(s, '.');
if (entry->preempt_count & 0xf0) trace_seq_printf(s, "%x", entry->preempt_count >> 4); else trace_seq_putc(s, '.');
return !trace_seq_has_overflowed(s);}
static intlat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu){ char comm[TASK_COMM_LEN];
trace_find_cmdline(entry->pid, comm);
trace_seq_printf(s, "%8.8s-%-7d %3d", comm, entry->pid, cpu);
return trace_print_lat_fmt(s, entry);}
#undef MARK#define MARK(v, s) {.val = v, .sym = s}/* trace overhead mark */static const struct trace_mark { unsigned long long val; /* unit: nsec */ char sym;} mark[] = { MARK(1000000000ULL , '$'), /* 1 sec */ MARK(100000000ULL , '@'), /* 100 msec */ MARK(10000000ULL , '*'), /* 10 msec */ MARK(1000000ULL , '#'), /* 1000 usecs */ MARK(100000ULL , '!'), /* 100 usecs */ MARK(10000ULL , '+'), /* 10 usecs */};#undef MARK
char trace_find_mark(unsigned long long d){ int i; int size = ARRAY_SIZE(mark);
for (i = 0; i < size; i++) { if (d > mark[i].val) break; }
return (i == size) ? ' ' : mark[i].sym;}
static intlat_print_timestamp(struct trace_iterator *iter, u64 next_ts){ struct trace_array *tr = iter->tr; unsigned long verbose = tr->trace_flags & TRACE_ITER(VERBOSE); unsigned long in_ns = iter->iter_flags & TRACE_FILE_TIME_IN_NS; unsigned long long abs_ts = iter->ts - iter->array_buffer->time_start; unsigned long long rel_ts = next_ts - iter->ts; struct trace_seq *s = &iter->seq;
if (in_ns) { abs_ts = ns2usecs(abs_ts); rel_ts = ns2usecs(rel_ts); }
if (verbose && in_ns) { unsigned long abs_usec = do_div(abs_ts, USEC_PER_MSEC); unsigned long abs_msec = (unsigned long)abs_ts; unsigned long rel_usec = do_div(rel_ts, USEC_PER_MSEC); unsigned long rel_msec = (unsigned long)rel_ts;
trace_seq_printf( s, "[%08llx] %ld.%03ldms (+%ld.%03ldms): ", ns2usecs(iter->ts), abs_msec, abs_usec, rel_msec, rel_usec);
} else if (verbose && !in_ns) { trace_seq_printf( s, "[%016llx] %lld (+%lld): ", iter->ts, abs_ts, rel_ts);
} else if (!verbose && in_ns) { trace_seq_printf( s, " %4lldus%c: ", abs_ts, trace_find_mark(rel_ts * NSEC_PER_USEC));
} else { /* !verbose && !in_ns */ trace_seq_printf(s, " %4lld: ", abs_ts); }
return !trace_seq_has_overflowed(s);}
static void trace_print_time(struct trace_seq *s, struct trace_iterator *iter, unsigned long long ts){ unsigned long secs, usec_rem; unsigned long long t;
if (iter->iter_flags & TRACE_FILE_TIME_IN_NS) { t = ns2usecs(ts); usec_rem = do_div(t, USEC_PER_SEC); secs = (unsigned long)t; trace_seq_printf(s, " %5lu.%06lu", secs, usec_rem); } else trace_seq_printf(s, " %12llu", ts);}
int trace_print_context(struct trace_iterator *iter){ struct trace_array *tr = iter->tr; struct trace_seq *s = &iter->seq; struct trace_entry *entry = iter->ent; char comm[TASK_COMM_LEN];
trace_find_cmdline(entry->pid, comm);
trace_seq_printf(s, "%16s-%-7d ", comm, entry->pid);
if (tr->trace_flags & TRACE_ITER(RECORD_TGID)) { unsigned int tgid = trace_find_tgid(entry->pid);
if (!tgid) trace_seq_printf(s, "(-------) "); else trace_seq_printf(s, "(%7d) ", tgid); }
trace_seq_printf(s, "[%03d] ", iter->cpu);
if (tr->trace_flags & TRACE_ITER(IRQ_INFO)) trace_print_lat_fmt(s, entry);
trace_print_time(s, iter, iter->ts); trace_seq_puts(s, ": ");
return !trace_seq_has_overflowed(s);}
int trace_print_lat_context(struct trace_iterator *iter){ struct trace_entry *entry, *next_entry; struct trace_array *tr = iter->tr; struct trace_seq *s = &iter->seq; unsigned long verbose = (tr->trace_flags & TRACE_ITER(VERBOSE)); u64 next_ts;
next_entry = trace_find_next_entry(iter, NULL, &next_ts); if (!next_entry) next_ts = iter->ts;
/* trace_find_next_entry() may change iter->ent */ entry = iter->ent;
if (verbose) { char comm[TASK_COMM_LEN];
trace_find_cmdline(entry->pid, comm);
trace_seq_printf( s, "%16s %7d %3d %d %08x %08lx ", comm, entry->pid, iter->cpu, entry->flags, entry->preempt_count & 0xf, iter->idx); } else { lat_print_generic(s, entry, iter->cpu); }
lat_print_timestamp(iter, next_ts);
return !trace_seq_has_overflowed(s);}
#ifdef CONFIG_FUNCTION_TRACE_ARGSvoid print_function_args(struct trace_seq *s, unsigned long *args, unsigned long func){ const struct btf_param *param; const struct btf_type *t; const struct btf_enum *enums; const char *param_name; char name[KSYM_NAME_LEN]; unsigned long arg; struct btf *btf; s32 tid, nr = 0; int a, p, x, i; u16 encode;
trace_seq_printf(s, "(");
if (!args) goto out; if (lookup_symbol_name(func, name)) goto out;
/* TODO: Pass module name here too */ t = btf_find_func_proto(name, &btf); if (IS_ERR_OR_NULL(t)) goto out;
param = btf_get_func_param(t, &nr); if (!param) goto out_put;
for (a = 0, p = 0; p < nr; a++, p++) { if (p) trace_seq_puts(s, ", ");
/* This only prints what the arch allows (6 args by default) */ if (a == FTRACE_REGS_MAX_ARGS) { trace_seq_puts(s, "..."); break; }
arg = args[a];
param_name = btf_name_by_offset(btf, param[p].name_off); if (param_name) trace_seq_printf(s, "%s=", param_name); t = btf_type_skip_modifiers(btf, param[p].type, &tid);
switch (t ? BTF_INFO_KIND(t->info) : BTF_KIND_UNKN) { case BTF_KIND_UNKN: trace_seq_putc(s, '?'); /* Still print unknown type values */ fallthrough; case BTF_KIND_PTR: trace_seq_printf(s, "0x%lx", arg); break; case BTF_KIND_INT: encode = btf_int_encoding(t); /* Print unsigned ints as hex */ if (encode & BTF_INT_SIGNED) trace_seq_printf(s, "%ld", arg); else trace_seq_printf(s, "0x%lx", arg); break; case BTF_KIND_ENUM: trace_seq_printf(s, "%ld", arg); enums = btf_enum(t); for (i = 0; i < btf_vlen(t); i++) { if (arg == enums[i].val) { trace_seq_printf(s, " [%s]", btf_name_by_offset(btf, enums[i].name_off)); break; } } break; default: /* This does not handle complex arguments */ trace_seq_printf(s, "(%s)[0x%lx", btf_type_str(t), arg); for (x = sizeof(long); x < t->size; x += sizeof(long)) { trace_seq_putc(s, ':'); if (++a == FTRACE_REGS_MAX_ARGS) { trace_seq_puts(s, "...]"); goto out_put; } trace_seq_printf(s, "0x%lx", args[a]); } trace_seq_putc(s, ']'); break; } }out_put: btf_put(btf);out: trace_seq_printf(s, ")");}#endif
/** * ftrace_find_event - find a registered event * @type: the type of event to look for * * Returns an event of type @type otherwise NULL * Called with trace_event_read_lock() held. */struct trace_event *ftrace_find_event(int type){ struct trace_event *event;
hash_for_each_possible(event_hash, event, node, type) { if (event->type == type) return event; }
return NULL;}
static DEFINE_IDA(trace_event_ida);
static void free_trace_event_type(int type){ if (type >= __TRACE_LAST_TYPE) ida_free(&trace_event_ida, type);}
static int alloc_trace_event_type(void){ int next;
/* Skip static defined type numbers */ next = ida_alloc_range(&trace_event_ida, __TRACE_LAST_TYPE, TRACE_EVENT_TYPE_MAX, GFP_KERNEL); if (next < 0) return 0; return next;}
void trace_event_read_lock(void){ down_read(&trace_event_sem);}
void trace_event_read_unlock(void){ up_read(&trace_event_sem);}
/** * register_trace_event - register output for an event type * @event: the event type to register * * Event types are stored in a hash and this hash is used to * find a way to print an event. If the @event->type is set * then it will use that type, otherwise it will assign a * type to use. * * If you assign your own type, please make sure it is added * to the trace_type enum in trace.h, to avoid collisions * with the dynamic types. * * Returns the event type number or zero on error. */int register_trace_event(struct trace_event *event){ int ret = 0;
down_write(&trace_event_sem);
if (WARN_ON(!event)) goto out;
if (WARN_ON(!event->funcs)) goto out;
if (!event->type) { event->type = alloc_trace_event_type(); if (!event->type) goto out; } else if (WARN(event->type > __TRACE_LAST_TYPE, "Need to add type to trace.h")) { goto out; } else { /* Is this event already used */ if (ftrace_find_event(event->type)) goto out; }
if (event->funcs->trace == NULL) event->funcs->trace = trace_nop_print; if (event->funcs->raw == NULL) event->funcs->raw = trace_nop_print; if (event->funcs->hex == NULL) event->funcs->hex = trace_nop_print; if (event->funcs->binary == NULL) event->funcs->binary = trace_nop_print;
hash_add(event_hash, &event->node, event->type);
ret = event->type; out: up_write(&trace_event_sem);
return ret;}EXPORT_SYMBOL_GPL(register_trace_event);
/* * Used by module code with the trace_event_sem held for write. */int __unregister_trace_event(struct trace_event *event){ hash_del(&event->node); free_trace_event_type(event->type); return 0;}
/** * unregister_trace_event - remove a no longer used event * @event: the event to remove */int unregister_trace_event(struct trace_event *event){ down_write(&trace_event_sem); __unregister_trace_event(event); up_write(&trace_event_sem);
return 0;}EXPORT_SYMBOL_GPL(unregister_trace_event);
/* * Standard events */
static void print_array(struct trace_iterator *iter, void *pos, struct ftrace_event_field *field){ int offset; int len; int i;
offset = *(int *)pos & 0xffff; len = *(int *)pos >> 16;
if (field) offset += field->offset + sizeof(int);
if (offset + len > iter->ent_size) { trace_seq_puts(&iter->seq, "<OVERFLOW>"); return; }
pos = (void *)iter->ent + offset;
for (i = 0; i < len; i++, pos++) { if (i) trace_seq_putc(&iter->seq, ','); trace_seq_printf(&iter->seq, "%02x", *(unsigned char *)pos); }}
static void print_fields(struct trace_iterator *iter, struct trace_event_call *call, struct list_head *head){ struct ftrace_event_field *field; struct trace_array *tr = iter->tr; unsigned long long laddr; unsigned long addr; int offset; int len; int ret; int i; void *pos; char *str;
list_for_each_entry_reverse(field, head, link) { trace_seq_printf(&iter->seq, " %s=", field->name); if (field->offset + field->size > iter->ent_size) { trace_seq_puts(&iter->seq, "<OVERFLOW>"); continue; } pos = (void *)iter->ent + field->offset;
switch (field->filter_type) { case FILTER_COMM: case FILTER_STATIC_STRING: trace_seq_printf(&iter->seq, "%.*s", field->size, (char *)pos); break; case FILTER_RDYN_STRING: case FILTER_DYN_STRING: offset = *(int *)pos & 0xffff; len = *(int *)pos >> 16;
if (field->filter_type == FILTER_RDYN_STRING) offset += field->offset + sizeof(int);
if (offset + len > iter->ent_size) { trace_seq_puts(&iter->seq, "<OVERFLOW>"); break; } str = (char *)iter->ent + offset; /* Check if there's any non printable strings */ for (i = 0; i < len; i++) { if (str[i] && !(isascii(str[i]) && isprint(str[i]))) break; } if (i < len) { for (i = 0; i < len; i++) { if (isascii(str[i]) && isprint(str[i])) trace_seq_putc(&iter->seq, str[i]); else trace_seq_putc(&iter->seq, '.'); } trace_seq_puts(&iter->seq, " ("); for (i = 0; i < len; i++) { if (i) trace_seq_putc(&iter->seq, ':'); trace_seq_printf(&iter->seq, "%02x", str[i]); } trace_seq_putc(&iter->seq, ')'); } else { trace_seq_printf(&iter->seq, "%.*s", len, str); } break; case FILTER_PTR_STRING: if (!iter->fmt_size) trace_iter_expand_format(iter); addr = trace_adjust_address(tr, *(unsigned long *)pos); ret = strncpy_from_kernel_nofault(iter->fmt, (void *)addr, iter->fmt_size); if (ret < 0) trace_seq_printf(&iter->seq, "(0x%px)", pos); else trace_seq_printf(&iter->seq, "(0x%px:%s)", pos, iter->fmt); break; case FILTER_TRACE_FN: addr = trace_adjust_address(tr, *(unsigned long *)pos); trace_seq_printf(&iter->seq, "%pS", (void *)addr); break; case FILTER_CPU: case FILTER_OTHER: switch (field->size) { case 1: if (isprint(*(char *)pos)) { trace_seq_printf(&iter->seq, "'%c'", *(unsigned char *)pos); } trace_seq_printf(&iter->seq, "(%d)", *(unsigned char *)pos); break; case 2: trace_seq_printf(&iter->seq, "0x%x (%d)", *(unsigned short *)pos, *(unsigned short *)pos); break; case 4: /* dynamic array info is 4 bytes */ if (strstr(field->type, "__data_loc")) { print_array(iter, pos, NULL); break; }
if (strstr(field->type, "__rel_loc")) { print_array(iter, pos, field); break; }
addr = *(unsigned int *)pos;
/* Some fields reference offset from _stext. */ if (!strcmp(field->name, "caller_offs") || !strcmp(field->name, "parent_offs")) { unsigned long ip;
ip = addr + (unsigned long)_stext; ip = trace_adjust_address(tr, ip); trace_seq_printf(&iter->seq, "%pS ", (void *)ip); }
if (sizeof(long) == 4) { addr = trace_adjust_address(tr, addr); trace_seq_printf(&iter->seq, "%pS (%d)", (void *)addr, (int)addr); } else { trace_seq_printf(&iter->seq, "0x%x (%d)", (unsigned int)addr, (int)addr); } break; case 8: laddr = *(unsigned long long *)pos; if (sizeof(long) == 8) { laddr = trace_adjust_address(tr, (unsigned long)laddr); trace_seq_printf(&iter->seq, "%pS (%lld)", (void *)(long)laddr, laddr); } else { trace_seq_printf(&iter->seq, "0x%llx (%lld)", laddr, laddr); } break; default: trace_seq_puts(&iter->seq, "<INVALID-SIZE>"); break; } break; default: trace_seq_puts(&iter->seq, "<INVALID-TYPE>"); } } trace_seq_putc(&iter->seq, '\n');}
enum print_line_t print_event_fields(struct trace_iterator *iter, struct trace_event *event){ struct trace_event_call *call; struct list_head *head;
lockdep_assert_held_read(&trace_event_sem);
/* ftrace defined events have separate call structures */ if (event->type <= __TRACE_LAST_TYPE) { bool found = false;
list_for_each_entry(call, &ftrace_events, list) { if (call->event.type == event->type) { found = true; break; } /* No need to search all events */ if (call->event.type > __TRACE_LAST_TYPE) break; } if (!found) { trace_seq_printf(&iter->seq, "UNKNOWN TYPE %d\n", event->type); goto out; } } else { call = container_of(event, struct trace_event_call, event); } head = trace_get_fields(call);
trace_seq_printf(&iter->seq, "%s:", trace_event_name(call));
if (head && !list_empty(head)) print_fields(iter, call, head); else trace_seq_puts(&iter->seq, "No fields found\n");
out: return trace_handle_return(&iter->seq);}
enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags, struct trace_event *event){ trace_seq_printf(&iter->seq, "type: %d\n", iter->ent->type);
return trace_handle_return(&iter->seq);}
static void print_fn_trace(struct trace_seq *s, unsigned long ip, unsigned long parent_ip, unsigned long *args, struct trace_array *tr, int flags){ ip = trace_adjust_address(tr, ip); parent_ip = trace_adjust_address(tr, parent_ip);
seq_print_ip_sym(s, ip, flags); if (args) print_function_args(s, args, ip);
if ((flags & TRACE_ITER(PRINT_PARENT)) && parent_ip) { trace_seq_puts(s, " <-"); seq_print_ip_sym(s, parent_ip, flags); }}
/* TRACE_FN */static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags, struct trace_event *event){ struct ftrace_entry *field; struct trace_seq *s = &iter->seq; unsigned long *args; int args_size;
trace_assign_type(field, iter->ent);
args_size = iter->ent_size - offsetof(struct ftrace_entry, args); if (args_size >= FTRACE_REGS_MAX_ARGS * sizeof(long)) args = field->args; else args = NULL;
print_fn_trace(s, field->ip, field->parent_ip, args, iter->tr, flags); trace_seq_putc(s, '\n');
return trace_handle_return(s);}
static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags, struct trace_event *event){ struct ftrace_entry *field;
trace_assign_type(field, iter->ent);
trace_seq_printf(&iter->seq, "%lx %lx\n", field->ip, field->parent_ip);
return trace_handle_return(&iter->seq);}
static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags, struct trace_event *event){ struct ftrace_entry *field; struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
SEQ_PUT_HEX_FIELD(s, field->ip); SEQ_PUT_HEX_FIELD(s, field->parent_ip);
return trace_handle_return(s);}
static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags, struct trace_event *event){ struct ftrace_entry *field; struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
SEQ_PUT_FIELD(s, field->ip); SEQ_PUT_FIELD(s, field->parent_ip);
return trace_handle_return(s);}
static struct trace_event_functions trace_fn_funcs = { .trace = trace_fn_trace, .raw = trace_fn_raw, .hex = trace_fn_hex, .binary = trace_fn_bin,};
static struct trace_event trace_fn_event = { .type = TRACE_FN, .funcs = &trace_fn_funcs,};
/* TRACE_CTX an TRACE_WAKE */static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter, char *delim){ struct ctx_switch_entry *field; char comm[TASK_COMM_LEN]; int S, T;
trace_assign_type(field, iter->ent);
T = task_index_to_char(field->next_state); S = task_index_to_char(field->prev_state); trace_find_cmdline(field->next_pid, comm); trace_seq_printf(&iter->seq, " %7d:%3d:%c %s [%03d] %7d:%3d:%c %s\n", field->prev_pid, field->prev_prio, S, delim, field->next_cpu, field->next_pid, field->next_prio, T, comm);
return trace_handle_return(&iter->seq);}
static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags, struct trace_event *event){ return trace_ctxwake_print(iter, "==>");}
static enum print_line_t trace_wake_print(struct trace_iterator *iter, int flags, struct trace_event *event){ return trace_ctxwake_print(iter, " +");}
static int trace_ctxwake_raw(struct trace_iterator *iter, char S){ struct ctx_switch_entry *field; int T;
trace_assign_type(field, iter->ent);
if (!S) S = task_index_to_char(field->prev_state); T = task_index_to_char(field->next_state); trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n", field->prev_pid, field->prev_prio, S, field->next_cpu, field->next_pid, field->next_prio, T);
return trace_handle_return(&iter->seq);}
static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags, struct trace_event *event){ return trace_ctxwake_raw(iter, 0);}
static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags, struct trace_event *event){ return trace_ctxwake_raw(iter, '+');}
static int trace_ctxwake_hex(struct trace_iterator *iter, char S){ struct ctx_switch_entry *field; struct trace_seq *s = &iter->seq; int T;
trace_assign_type(field, iter->ent);
if (!S) S = task_index_to_char(field->prev_state); T = task_index_to_char(field->next_state);
SEQ_PUT_HEX_FIELD(s, field->prev_pid); SEQ_PUT_HEX_FIELD(s, field->prev_prio); SEQ_PUT_HEX_FIELD(s, S); SEQ_PUT_HEX_FIELD(s, field->next_cpu); SEQ_PUT_HEX_FIELD(s, field->next_pid); SEQ_PUT_HEX_FIELD(s, field->next_prio); SEQ_PUT_HEX_FIELD(s, T);
return trace_handle_return(s);}
static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags, struct trace_event *event){ return trace_ctxwake_hex(iter, 0);}
static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags, struct trace_event *event){ return trace_ctxwake_hex(iter, '+');}
static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter, int flags, struct trace_event *event){ struct ctx_switch_entry *field; struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
SEQ_PUT_FIELD(s, field->prev_pid); SEQ_PUT_FIELD(s, field->prev_prio); SEQ_PUT_FIELD(s, field->prev_state); SEQ_PUT_FIELD(s, field->next_cpu); SEQ_PUT_FIELD(s, field->next_pid); SEQ_PUT_FIELD(s, field->next_prio); SEQ_PUT_FIELD(s, field->next_state);
return trace_handle_return(s);}
static struct trace_event_functions trace_ctx_funcs = { .trace = trace_ctx_print, .raw = trace_ctx_raw, .hex = trace_ctx_hex, .binary = trace_ctxwake_bin,};
static struct trace_event trace_ctx_event = { .type = TRACE_CTX, .funcs = &trace_ctx_funcs,};
static struct trace_event_functions trace_wake_funcs = { .trace = trace_wake_print, .raw = trace_wake_raw, .hex = trace_wake_hex, .binary = trace_ctxwake_bin,};
static struct trace_event trace_wake_event = { .type = TRACE_WAKE, .funcs = &trace_wake_funcs,};
/* TRACE_STACK */
static enum print_line_t trace_stack_print(struct trace_iterator *iter, int flags, struct trace_event *event){ struct stack_entry *field; struct trace_seq *s = &iter->seq; unsigned long *p; unsigned long *end;
trace_assign_type(field, iter->ent); end = (unsigned long *)((long)iter->ent + iter->ent_size);
trace_seq_puts(s, "<stack trace>\n");
for (p = field->caller; p && p < end && *p != ULONG_MAX; p++) {
if (trace_seq_has_overflowed(s)) break;
trace_seq_puts(s, " => "); if ((*p) == FTRACE_TRAMPOLINE_MARKER) { trace_seq_puts(s, "[FTRACE TRAMPOLINE]\n"); continue; } seq_print_ip_sym(s, trace_adjust_address(iter->tr, *p), flags); trace_seq_putc(s, '\n'); }
return trace_handle_return(s);}
static struct trace_event_functions trace_stack_funcs = { .trace = trace_stack_print,};
static struct trace_event trace_stack_event = { .type = TRACE_STACK, .funcs = &trace_stack_funcs,};
/* TRACE_USER_STACK */static enum print_line_t trace_user_stack_print(struct trace_iterator *iter, int flags, struct trace_event *event){ struct trace_array *tr = iter->tr; struct userstack_entry *field; struct trace_seq *s = &iter->seq; struct mm_struct *mm = NULL; unsigned int i;
trace_assign_type(field, iter->ent);
trace_seq_puts(s, "<user stack trace>\n");
if (tr->trace_flags & TRACE_ITER(SYM_USEROBJ)) { struct task_struct *task; /* * we do the lookup on the thread group leader, * since individual threads might have already quit! */ rcu_read_lock(); task = find_task_by_vpid(field->tgid); if (task) mm = get_task_mm(task); rcu_read_unlock(); }
for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { unsigned long ip = field->caller[i];
if (!ip || trace_seq_has_overflowed(s)) break;
trace_seq_puts(s, " => "); seq_print_user_ip(s, mm, ip, flags); trace_seq_putc(s, '\n'); }
if (mm) mmput(mm);
return trace_handle_return(s);}
static struct trace_event_functions trace_user_stack_funcs = { .trace = trace_user_stack_print,};
static struct trace_event trace_user_stack_event = { .type = TRACE_USER_STACK, .funcs = &trace_user_stack_funcs,};
/* TRACE_HWLAT */static enum print_line_ttrace_hwlat_print(struct trace_iterator *iter, int flags, struct trace_event *event){ struct trace_entry *entry = iter->ent; struct trace_seq *s = &iter->seq; struct hwlat_entry *field;
trace_assign_type(field, entry);
trace_seq_printf(s, "#%-5u inner/outer(us): %4llu/%-5llu ts:%ptSp count:%d", field->seqnum, field->duration, field->outer_duration, &field->timestamp, field->count);
if (field->nmi_count) { /* * The generic sched_clock() is not NMI safe, thus * we only record the count and not the time. */ if (!IS_ENABLED(CONFIG_GENERIC_SCHED_CLOCK)) trace_seq_printf(s, " nmi-total:%llu", field->nmi_total_ts); trace_seq_printf(s, " nmi-count:%u", field->nmi_count); }
trace_seq_putc(s, '\n');
return trace_handle_return(s);}
static enum print_line_ttrace_hwlat_raw(struct trace_iterator *iter, int flags, struct trace_event *event){ struct hwlat_entry *field; struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
trace_seq_printf(s, "%llu %lld %lld %09ld %u\n", field->duration, field->outer_duration, (long long)field->timestamp.tv_sec, field->timestamp.tv_nsec, field->seqnum);
return trace_handle_return(s);}
static struct trace_event_functions trace_hwlat_funcs = { .trace = trace_hwlat_print, .raw = trace_hwlat_raw,};
static struct trace_event trace_hwlat_event = { .type = TRACE_HWLAT, .funcs = &trace_hwlat_funcs,};
/* TRACE_OSNOISE */static enum print_line_ttrace_osnoise_print(struct trace_iterator *iter, int flags, struct trace_event *event){ struct trace_entry *entry = iter->ent; struct trace_seq *s = &iter->seq; struct osnoise_entry *field; u64 ratio, ratio_dec; u64 net_runtime;
trace_assign_type(field, entry);
/* * compute the available % of cpu time. */ net_runtime = field->runtime - field->noise; ratio = net_runtime * 10000000; do_div(ratio, field->runtime); ratio_dec = do_div(ratio, 100000);
trace_seq_printf(s, "%llu %10llu %3llu.%05llu %7llu", field->runtime, field->noise, ratio, ratio_dec, field->max_sample);
trace_seq_printf(s, " %6u", field->hw_count); trace_seq_printf(s, " %6u", field->nmi_count); trace_seq_printf(s, " %6u", field->irq_count); trace_seq_printf(s, " %6u", field->softirq_count); trace_seq_printf(s, " %6u", field->thread_count);
trace_seq_putc(s, '\n');
return trace_handle_return(s);}
static enum print_line_ttrace_osnoise_raw(struct trace_iterator *iter, int flags, struct trace_event *event){ struct osnoise_entry *field; struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
trace_seq_printf(s, "%lld %llu %llu %u %u %u %u %u\n", field->runtime, field->noise, field->max_sample, field->hw_count, field->nmi_count, field->irq_count, field->softirq_count, field->thread_count);
return trace_handle_return(s);}
static struct trace_event_functions trace_osnoise_funcs = { .trace = trace_osnoise_print, .raw = trace_osnoise_raw,};
static struct trace_event trace_osnoise_event = { .type = TRACE_OSNOISE, .funcs = &trace_osnoise_funcs,};
/* TRACE_TIMERLAT */
static char *timerlat_lat_context[] = {"irq", "thread", "user-ret"};static enum print_line_ttrace_timerlat_print(struct trace_iterator *iter, int flags, struct trace_event *event){ struct trace_entry *entry = iter->ent; struct trace_seq *s = &iter->seq; struct timerlat_entry *field;
trace_assign_type(field, entry);
trace_seq_printf(s, "#%-5u context %6s timer_latency %9llu ns\n", field->seqnum, timerlat_lat_context[field->context], field->timer_latency);
return trace_handle_return(s);}
static enum print_line_ttrace_timerlat_raw(struct trace_iterator *iter, int flags, struct trace_event *event){ struct timerlat_entry *field; struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
trace_seq_printf(s, "%u %d %llu\n", field->seqnum, field->context, field->timer_latency);
return trace_handle_return(s);}
static struct trace_event_functions trace_timerlat_funcs = { .trace = trace_timerlat_print, .raw = trace_timerlat_raw,};
static struct trace_event trace_timerlat_event = { .type = TRACE_TIMERLAT, .funcs = &trace_timerlat_funcs,};
/* TRACE_BPUTS */static enum print_line_ttrace_bputs_print(struct trace_iterator *iter, int flags, struct trace_event *event){ struct trace_entry *entry = iter->ent; struct trace_seq *s = &iter->seq; struct bputs_entry *field;
trace_assign_type(field, entry);
seq_print_ip_sym(s, field->ip, flags); trace_seq_puts(s, ": "); trace_seq_puts(s, field->str);
return trace_handle_return(s);}
static enum print_line_ttrace_bputs_raw(struct trace_iterator *iter, int flags, struct trace_event *event){ struct bputs_entry *field; struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
trace_seq_printf(s, ": %lx : ", field->ip); trace_seq_puts(s, field->str);
return trace_handle_return(s);}
static struct trace_event_functions trace_bputs_funcs = { .trace = trace_bputs_print, .raw = trace_bputs_raw,};
static struct trace_event trace_bputs_event = { .type = TRACE_BPUTS, .funcs = &trace_bputs_funcs,};
/* TRACE_BPRINT */static enum print_line_ttrace_bprint_print(struct trace_iterator *iter, int flags, struct trace_event *event){ struct trace_entry *entry = iter->ent; struct trace_seq *s = &iter->seq; struct bprint_entry *field;
trace_assign_type(field, entry);
seq_print_ip_sym(s, field->ip, flags); trace_seq_puts(s, ": "); trace_seq_bprintf(s, field->fmt, field->buf);
return trace_handle_return(s);}
static enum print_line_ttrace_bprint_raw(struct trace_iterator *iter, int flags, struct trace_event *event){ struct bprint_entry *field; struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
trace_seq_printf(s, ": %lx : ", field->ip); trace_seq_bprintf(s, field->fmt, field->buf);
return trace_handle_return(s);}
static struct trace_event_functions trace_bprint_funcs = { .trace = trace_bprint_print, .raw = trace_bprint_raw,};
static struct trace_event trace_bprint_event = { .type = TRACE_BPRINT, .funcs = &trace_bprint_funcs,};
/* TRACE_PRINT */static enum print_line_t trace_print_print(struct trace_iterator *iter, int flags, struct trace_event *event){ struct print_entry *field; struct trace_seq *s = &iter->seq; unsigned long ip;
trace_assign_type(field, iter->ent);
ip = trace_adjust_address(iter->tr, field->ip);
seq_print_ip_sym(s, ip, flags); trace_seq_printf(s, ": %s", field->buf);
return trace_handle_return(s);}
static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags, struct trace_event *event){ struct print_entry *field;
trace_assign_type(field, iter->ent);
trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf);
return trace_handle_return(&iter->seq);}
static struct trace_event_functions trace_print_funcs = { .trace = trace_print_print, .raw = trace_print_raw,};
static struct trace_event trace_print_event = { .type = TRACE_PRINT, .funcs = &trace_print_funcs,};
static enum print_line_t trace_raw_data(struct trace_iterator *iter, int flags, struct trace_event *event){ struct raw_data_entry *field; int i;
trace_assign_type(field, iter->ent);
trace_seq_printf(&iter->seq, "# %x buf:", field->id);
for (i = 0; i < iter->ent_size - offsetof(struct raw_data_entry, buf); i++) trace_seq_printf(&iter->seq, " %02x", (unsigned char)field->buf[i]);
trace_seq_putc(&iter->seq, '\n');
return trace_handle_return(&iter->seq);}
static struct trace_event_functions trace_raw_data_funcs = { .trace = trace_raw_data, .raw = trace_raw_data,};
static struct trace_event trace_raw_data_event = { .type = TRACE_RAW_DATA, .funcs = &trace_raw_data_funcs,};
static enum print_line_ttrace_func_repeats_raw(struct trace_iterator *iter, int flags, struct trace_event *event){ struct func_repeats_entry *field; struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
trace_seq_printf(s, "%lu %lu %u %llu\n", field->ip, field->parent_ip, field->count, FUNC_REPEATS_GET_DELTA_TS(field));
return trace_handle_return(s);}
static enum print_line_ttrace_func_repeats_print(struct trace_iterator *iter, int flags, struct trace_event *event){ struct func_repeats_entry *field; struct trace_seq *s = &iter->seq;
trace_assign_type(field, iter->ent);
print_fn_trace(s, field->ip, field->parent_ip, NULL, iter->tr, flags); trace_seq_printf(s, " (repeats: %u, last_ts:", field->count); trace_print_time(s, iter, iter->ts - FUNC_REPEATS_GET_DELTA_TS(field)); trace_seq_puts(s, ")\n");
return trace_handle_return(s);}
static struct trace_event_functions trace_func_repeats_funcs = { .trace = trace_func_repeats_print, .raw = trace_func_repeats_raw,};
static struct trace_event trace_func_repeats_event = { .type = TRACE_FUNC_REPEATS, .funcs = &trace_func_repeats_funcs,};
static struct trace_event *events[] __initdata = { &trace_fn_event, &trace_ctx_event, &trace_wake_event, &trace_stack_event, &trace_user_stack_event, &trace_bputs_event, &trace_bprint_event, &trace_print_event, &trace_hwlat_event, &trace_osnoise_event, &trace_timerlat_event, &trace_raw_data_event, &trace_func_repeats_event, NULL};
__init int init_events(void){ struct trace_event *event; int i, ret;
for (i = 0; events[i]; i++) { event = events[i]; ret = register_trace_event(event); WARN_ONCE(!ret, "event %d failed to register", event->type); }
return 0;}