^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * trace_output.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/ftrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/sched/clock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/sched/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "trace_output.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /* must be a power of 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define EVENT_HASHSIZE 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) DECLARE_RWSEM(trace_event_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static int next_event_type = __TRACE_LAST_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) enum print_line_t trace_print_bputs_msg_only(struct trace_iterator *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct trace_entry *entry = iter->ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct bputs_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) trace_assign_type(field, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) trace_seq_puts(s, field->str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct trace_entry *entry = iter->ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct bprint_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) trace_assign_type(field, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) trace_seq_bprintf(s, field->fmt, field->buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct trace_entry *entry = iter->ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct print_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) trace_assign_type(field, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) trace_seq_puts(s, field->buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) trace_print_flags_seq(struct trace_seq *p, const char *delim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) unsigned long flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) const struct trace_print_flags *flag_array)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) unsigned long mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) const char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int i, first = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) for (i = 0; flag_array[i].name && flags; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) mask = flag_array[i].mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if ((flags & mask) != mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) str = flag_array[i].name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) flags &= ~mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if (!first && delim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) trace_seq_puts(p, delim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) first = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) trace_seq_puts(p, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* check for left over flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (flags) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (!first && delim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) trace_seq_puts(p, delim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) trace_seq_printf(p, "0x%lx", flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) EXPORT_SYMBOL(trace_print_flags_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) trace_print_symbols_seq(struct trace_seq *p, unsigned long val,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) const struct trace_print_flags *symbol_array)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) for (i = 0; symbol_array[i].name; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (val != symbol_array[i].mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) trace_seq_puts(p, symbol_array[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) if (ret == (const char *)(trace_seq_buffer_ptr(p)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) trace_seq_printf(p, "0x%lx", val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) EXPORT_SYMBOL(trace_print_symbols_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #if BITS_PER_LONG == 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) trace_print_flags_seq_u64(struct trace_seq *p, const char *delim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) unsigned long long flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) const struct trace_print_flags_u64 *flag_array)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) unsigned long long mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) const char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) int i, first = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) for (i = 0; flag_array[i].name && flags; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) mask = flag_array[i].mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if ((flags & mask) != mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) str = flag_array[i].name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) flags &= ~mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (!first && delim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) trace_seq_puts(p, delim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) first = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) trace_seq_puts(p, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* check for left over flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (flags) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (!first && delim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) trace_seq_puts(p, delim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) trace_seq_printf(p, "0x%llx", flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) EXPORT_SYMBOL(trace_print_flags_seq_u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) trace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) const struct trace_print_flags_u64 *symbol_array)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) for (i = 0; symbol_array[i].name; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (val != symbol_array[i].mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) trace_seq_puts(p, symbol_array[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (ret == (const char *)(trace_seq_buffer_ptr(p)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) trace_seq_printf(p, "0x%llx", val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) EXPORT_SYMBOL(trace_print_symbols_seq_u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) trace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) unsigned int bitmask_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) trace_seq_bitmask(p, bitmask_ptr, bitmask_size * 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) EXPORT_SYMBOL_GPL(trace_print_bitmask_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * trace_print_hex_seq - print buffer as hex sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * @p: trace seq struct to write to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * @buf: The buffer to print
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * @buf_len: Length of @buf in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * @concatenate: Print @buf as single hex string or with spacing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * Prints the passed buffer as a hex sequence either as a whole,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * single hex string if @concatenate is true or with spacing after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * each byte in case @concatenate is false.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) bool concatenate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) const char *fmt = concatenate ? "%*phN" : "%*ph";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) for (i = 0; i < buf_len; i += 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) trace_seq_printf(p, fmt, min(buf_len - i, 16), &buf[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) EXPORT_SYMBOL(trace_print_hex_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) trace_print_array_seq(struct trace_seq *p, const void *buf, int count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) size_t el_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) const char *prefix = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) void *ptr = (void *)buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) size_t buf_len = count * el_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) trace_seq_putc(p, '{');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) while (ptr < buf + buf_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) switch (el_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) trace_seq_printf(p, "%s0x%x", prefix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) *(u8 *)ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) trace_seq_printf(p, "%s0x%x", prefix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) *(u16 *)ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) case 4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) trace_seq_printf(p, "%s0x%x", prefix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) *(u32 *)ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) case 8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) trace_seq_printf(p, "%s0x%llx", prefix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) *(u64 *)ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) trace_seq_printf(p, "BAD SIZE:%zu 0x%x", el_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) *(u8 *)ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) el_size = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) prefix = ",";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) ptr += el_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) trace_seq_putc(p, '}');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) EXPORT_SYMBOL(trace_print_array_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) const char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) trace_print_hex_dump_seq(struct trace_seq *p, const char *prefix_str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) int prefix_type, int rowsize, int groupsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) const void *buf, size_t len, bool ascii)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) trace_seq_putc(p, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) trace_seq_hex_dump(p, prefix_str, prefix_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) rowsize, groupsize, buf, len, ascii);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) EXPORT_SYMBOL(trace_print_hex_dump_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) int trace_raw_output_prep(struct trace_iterator *iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) struct trace_event *trace_event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) struct trace_event_call *event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) struct trace_seq *p = &iter->tmp_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) struct trace_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) event = container_of(trace_event, struct trace_event_call, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) entry = iter->ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) if (entry->type != event->event.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) return TRACE_TYPE_UNHANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) trace_seq_init(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) trace_seq_printf(s, "%s: ", trace_event_name(event));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) EXPORT_SYMBOL(trace_raw_output_prep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static int trace_output_raw(struct trace_iterator *iter, char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) char *fmt, va_list ap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) trace_seq_printf(s, "%s: ", name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) trace_seq_vprintf(s, fmt, ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) int trace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) va_list ap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) va_start(ap, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) ret = trace_output_raw(iter, name, fmt, ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) va_end(ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) EXPORT_SYMBOL_GPL(trace_output_call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) #ifdef CONFIG_KRETPROBES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) static inline const char *kretprobed(const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) static const char tramp_name[] = "kretprobe_trampoline";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) int size = sizeof(tramp_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) if (strncmp(tramp_name, name, size) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) return "[unknown/kretprobe'd]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) return name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) static inline const char *kretprobed(const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) return name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) #endif /* CONFIG_KRETPROBES */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) seq_print_sym(struct trace_seq *s, unsigned long address, bool offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) #ifdef CONFIG_KALLSYMS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) char str[KSYM_SYMBOL_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) if (offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) sprint_symbol(str, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) kallsyms_lookup(address, NULL, NULL, NULL, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) name = kretprobed(str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) if (name && strlen(name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) trace_seq_puts(s, name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) trace_seq_printf(s, "0x%08lx", address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) #ifndef CONFIG_64BIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) # define IP_FMT "%08lx"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) # define IP_FMT "%016lx"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) static int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) unsigned long ip, unsigned long sym_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) struct file *file = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) unsigned long vmstart = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) int ret = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) if (s->full)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) if (mm) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) const struct vm_area_struct *vma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) mmap_read_lock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) vma = find_vma(mm, ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) if (vma) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) file = vma->vm_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) vmstart = vma->vm_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) if (file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) ret = trace_seq_path(s, &file->f_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) trace_seq_printf(s, "[+0x%lx]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) ip - vmstart);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) mmap_read_unlock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) trace_seq_printf(s, " <" IP_FMT ">", ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) return !trace_seq_has_overflowed(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) if (!ip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) trace_seq_putc(s, '0');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) seq_print_sym(s, ip, sym_flags & TRACE_ITER_SYM_OFFSET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) if (sym_flags & TRACE_ITER_SYM_ADDR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) trace_seq_printf(s, " <" IP_FMT ">", ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) return !trace_seq_has_overflowed(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) * trace_print_lat_fmt - print the irq, preempt and lockdep fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) * @s: trace seq struct to write to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) * @entry: The trace entry field from the ring buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) * Prints the generic fields of irqs off, in hard or softirq, preempt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) * count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) int trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) char hardsoft_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) char need_resched;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) char irqs_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) int hardirq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) int softirq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) int nmi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) nmi = entry->flags & TRACE_FLAG_NMI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) hardirq = entry->flags & TRACE_FLAG_HARDIRQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) softirq = entry->flags & TRACE_FLAG_SOFTIRQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) irqs_off =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) (entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ? 'X' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) '.';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) switch (entry->flags & (TRACE_FLAG_NEED_RESCHED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) TRACE_FLAG_PREEMPT_RESCHED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) case TRACE_FLAG_NEED_RESCHED | TRACE_FLAG_PREEMPT_RESCHED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) need_resched = 'N';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) case TRACE_FLAG_NEED_RESCHED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) need_resched = 'n';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) case TRACE_FLAG_PREEMPT_RESCHED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) need_resched = 'p';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) need_resched = '.';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) hardsoft_irq =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) (nmi && hardirq) ? 'Z' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) nmi ? 'z' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) (hardirq && softirq) ? 'H' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) hardirq ? 'h' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) softirq ? 's' :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) '.' ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) trace_seq_printf(s, "%c%c%c",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) irqs_off, need_resched, hardsoft_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) if (entry->preempt_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) trace_seq_printf(s, "%x", entry->preempt_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) trace_seq_putc(s, '.');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) return !trace_seq_has_overflowed(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) char comm[TASK_COMM_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) trace_find_cmdline(entry->pid, comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) trace_seq_printf(s, "%8.8s-%-7d %3d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) comm, entry->pid, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) return trace_print_lat_fmt(s, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) #undef MARK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) #define MARK(v, s) {.val = v, .sym = s}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) /* trace overhead mark */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) static const struct trace_mark {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) unsigned long long val; /* unit: nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) char sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) } mark[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) MARK(1000000000ULL , '$'), /* 1 sec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) MARK(100000000ULL , '@'), /* 100 msec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) MARK(10000000ULL , '*'), /* 10 msec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) MARK(1000000ULL , '#'), /* 1000 usecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) MARK(100000ULL , '!'), /* 100 usecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) MARK(10000ULL , '+'), /* 10 usecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) #undef MARK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) char trace_find_mark(unsigned long long d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) int size = ARRAY_SIZE(mark);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) for (i = 0; i < size; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) if (d > mark[i].val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) return (i == size) ? ' ' : mark[i].sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) lat_print_timestamp(struct trace_iterator *iter, u64 next_ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) struct trace_array *tr = iter->tr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) unsigned long verbose = tr->trace_flags & TRACE_ITER_VERBOSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) unsigned long in_ns = iter->iter_flags & TRACE_FILE_TIME_IN_NS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) unsigned long long abs_ts = iter->ts - iter->array_buffer->time_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) unsigned long long rel_ts = next_ts - iter->ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) if (in_ns) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) abs_ts = ns2usecs(abs_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) rel_ts = ns2usecs(rel_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) if (verbose && in_ns) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) unsigned long abs_usec = do_div(abs_ts, USEC_PER_MSEC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) unsigned long abs_msec = (unsigned long)abs_ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) unsigned long rel_usec = do_div(rel_ts, USEC_PER_MSEC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) unsigned long rel_msec = (unsigned long)rel_ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) trace_seq_printf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) s, "[%08llx] %ld.%03ldms (+%ld.%03ldms): ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) ns2usecs(iter->ts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) abs_msec, abs_usec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) rel_msec, rel_usec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) } else if (verbose && !in_ns) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) trace_seq_printf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) s, "[%016llx] %lld (+%lld): ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) iter->ts, abs_ts, rel_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) } else if (!verbose && in_ns) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) trace_seq_printf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) s, " %4lldus%c: ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) abs_ts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) trace_find_mark(rel_ts * NSEC_PER_USEC));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) } else { /* !verbose && !in_ns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) trace_seq_printf(s, " %4lld: ", abs_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) return !trace_seq_has_overflowed(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) int trace_print_context(struct trace_iterator *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) struct trace_array *tr = iter->tr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) struct trace_entry *entry = iter->ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) unsigned long long t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) unsigned long secs, usec_rem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) char comm[TASK_COMM_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) trace_find_cmdline(entry->pid, comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) trace_seq_printf(s, "%16s-%-7d ", comm, entry->pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) if (tr->trace_flags & TRACE_ITER_RECORD_TGID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) unsigned int tgid = trace_find_tgid(entry->pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) if (!tgid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) trace_seq_printf(s, "(-------) ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) trace_seq_printf(s, "(%7d) ", tgid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) trace_seq_printf(s, "[%03d] ", iter->cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) if (tr->trace_flags & TRACE_ITER_IRQ_INFO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) trace_print_lat_fmt(s, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) if (iter->iter_flags & TRACE_FILE_TIME_IN_NS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) t = ns2usecs(iter->ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) usec_rem = do_div(t, USEC_PER_SEC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) secs = (unsigned long)t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) trace_seq_printf(s, " %5lu.%06lu: ", secs, usec_rem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) trace_seq_printf(s, " %12llu: ", iter->ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) return !trace_seq_has_overflowed(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) int trace_print_lat_context(struct trace_iterator *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) struct trace_entry *entry, *next_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) struct trace_array *tr = iter->tr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) unsigned long verbose = (tr->trace_flags & TRACE_ITER_VERBOSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) u64 next_ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) next_entry = trace_find_next_entry(iter, NULL, &next_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) if (!next_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) next_ts = iter->ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) /* trace_find_next_entry() may change iter->ent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) entry = iter->ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) if (verbose) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) char comm[TASK_COMM_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) trace_find_cmdline(entry->pid, comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) trace_seq_printf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) s, "%16s %7d %3d %d %08x %08lx ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) comm, entry->pid, iter->cpu, entry->flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) entry->preempt_count, iter->idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) lat_print_generic(s, entry, iter->cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) lat_print_timestamp(iter, next_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) return !trace_seq_has_overflowed(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) * ftrace_find_event - find a registered event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) * @type: the type of event to look for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) * Returns an event of type @type otherwise NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) * Called with trace_event_read_lock() held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) struct trace_event *ftrace_find_event(int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) struct trace_event *event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) unsigned key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) key = type & (EVENT_HASHSIZE - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) hlist_for_each_entry(event, &event_hash[key], node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) if (event->type == type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) return event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) static LIST_HEAD(ftrace_event_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) static int trace_search_list(struct list_head **list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) struct trace_event *e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) int next = __TRACE_LAST_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) if (list_empty(&ftrace_event_list)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) *list = &ftrace_event_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) return next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) * We used up all possible max events,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) * lets see if somebody freed one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) list_for_each_entry(e, &ftrace_event_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) if (e->type != next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) next++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) /* Did we used up all 65 thousand events??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) if (next > TRACE_EVENT_TYPE_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) *list = &e->list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) return next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) void trace_event_read_lock(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) down_read(&trace_event_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) void trace_event_read_unlock(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) up_read(&trace_event_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) * register_trace_event - register output for an event type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) * @event: the event type to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) * Event types are stored in a hash and this hash is used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) * find a way to print an event. If the @event->type is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) * then it will use that type, otherwise it will assign a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) * type to use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) * If you assign your own type, please make sure it is added
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) * to the trace_type enum in trace.h, to avoid collisions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) * with the dynamic types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) * Returns the event type number or zero on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) int register_trace_event(struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) unsigned key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) down_write(&trace_event_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) if (WARN_ON(!event))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) if (WARN_ON(!event->funcs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) INIT_LIST_HEAD(&event->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) if (!event->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) struct list_head *list = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) if (next_event_type > TRACE_EVENT_TYPE_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) event->type = trace_search_list(&list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) if (!event->type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) event->type = next_event_type++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) list = &ftrace_event_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) if (WARN_ON(ftrace_find_event(event->type)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) list_add_tail(&event->list, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) } else if (event->type > __TRACE_LAST_TYPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) printk(KERN_WARNING "Need to add type to trace.h\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) /* Is this event already used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) if (ftrace_find_event(event->type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) if (event->funcs->trace == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) event->funcs->trace = trace_nop_print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) if (event->funcs->raw == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) event->funcs->raw = trace_nop_print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) if (event->funcs->hex == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) event->funcs->hex = trace_nop_print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) if (event->funcs->binary == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) event->funcs->binary = trace_nop_print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) key = event->type & (EVENT_HASHSIZE - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) hlist_add_head(&event->node, &event_hash[key]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) ret = event->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) up_write(&trace_event_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) EXPORT_SYMBOL_GPL(register_trace_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) * Used by module code with the trace_event_sem held for write.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) int __unregister_trace_event(struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) hlist_del(&event->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) list_del(&event->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) * unregister_trace_event - remove a no longer used event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) * @event: the event to remove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) int unregister_trace_event(struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) down_write(&trace_event_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) __unregister_trace_event(event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) up_write(&trace_event_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) EXPORT_SYMBOL_GPL(unregister_trace_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) * Standard events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) trace_seq_printf(&iter->seq, "type: %d\n", iter->ent->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) return trace_handle_return(&iter->seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) /* TRACE_FN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) struct ftrace_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) seq_print_ip_sym(s, field->ip, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) trace_seq_puts(s, " <-");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) seq_print_ip_sym(s, field->parent_ip, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) trace_seq_putc(s, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) struct ftrace_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) trace_seq_printf(&iter->seq, "%lx %lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) field->ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) field->parent_ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) return trace_handle_return(&iter->seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) struct ftrace_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) SEQ_PUT_HEX_FIELD(s, field->ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) SEQ_PUT_HEX_FIELD(s, field->parent_ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) struct ftrace_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) SEQ_PUT_FIELD(s, field->ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) SEQ_PUT_FIELD(s, field->parent_ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) static struct trace_event_functions trace_fn_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) .trace = trace_fn_trace,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) .raw = trace_fn_raw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) .hex = trace_fn_hex,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) .binary = trace_fn_bin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) static struct trace_event trace_fn_event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) .type = TRACE_FN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) .funcs = &trace_fn_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) /* TRACE_CTX an TRACE_WAKE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) char *delim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) struct ctx_switch_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) char comm[TASK_COMM_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) int S, T;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) T = task_index_to_char(field->next_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) S = task_index_to_char(field->prev_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) trace_find_cmdline(field->next_pid, comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) trace_seq_printf(&iter->seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) " %7d:%3d:%c %s [%03d] %7d:%3d:%c %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) field->prev_pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) field->prev_prio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) S, delim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) field->next_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) field->next_pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) field->next_prio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) T, comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) return trace_handle_return(&iter->seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) return trace_ctxwake_print(iter, "==>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) static enum print_line_t trace_wake_print(struct trace_iterator *iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) int flags, struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) return trace_ctxwake_print(iter, " +");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) static int trace_ctxwake_raw(struct trace_iterator *iter, char S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) struct ctx_switch_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) int T;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) if (!S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) S = task_index_to_char(field->prev_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) T = task_index_to_char(field->next_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) field->prev_pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) field->prev_prio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) S,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) field->next_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) field->next_pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) field->next_prio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) return trace_handle_return(&iter->seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) return trace_ctxwake_raw(iter, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) return trace_ctxwake_raw(iter, '+');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) static int trace_ctxwake_hex(struct trace_iterator *iter, char S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) struct ctx_switch_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) int T;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) if (!S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) S = task_index_to_char(field->prev_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) T = task_index_to_char(field->next_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) SEQ_PUT_HEX_FIELD(s, field->prev_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) SEQ_PUT_HEX_FIELD(s, field->prev_prio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) SEQ_PUT_HEX_FIELD(s, S);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) SEQ_PUT_HEX_FIELD(s, field->next_cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) SEQ_PUT_HEX_FIELD(s, field->next_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) SEQ_PUT_HEX_FIELD(s, field->next_prio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) SEQ_PUT_HEX_FIELD(s, T);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) return trace_ctxwake_hex(iter, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) return trace_ctxwake_hex(iter, '+');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) int flags, struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) struct ctx_switch_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) SEQ_PUT_FIELD(s, field->prev_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) SEQ_PUT_FIELD(s, field->prev_prio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) SEQ_PUT_FIELD(s, field->prev_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) SEQ_PUT_FIELD(s, field->next_cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) SEQ_PUT_FIELD(s, field->next_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) SEQ_PUT_FIELD(s, field->next_prio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) SEQ_PUT_FIELD(s, field->next_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) static struct trace_event_functions trace_ctx_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) .trace = trace_ctx_print,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) .raw = trace_ctx_raw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) .hex = trace_ctx_hex,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) .binary = trace_ctxwake_bin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) static struct trace_event trace_ctx_event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) .type = TRACE_CTX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) .funcs = &trace_ctx_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) static struct trace_event_functions trace_wake_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) .trace = trace_wake_print,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) .raw = trace_wake_raw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) .hex = trace_wake_hex,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) .binary = trace_ctxwake_bin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) static struct trace_event trace_wake_event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) .type = TRACE_WAKE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) .funcs = &trace_wake_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) /* TRACE_STACK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) static enum print_line_t trace_stack_print(struct trace_iterator *iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) int flags, struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) struct stack_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) unsigned long *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) unsigned long *end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) end = (unsigned long *)((long)iter->ent + iter->ent_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) trace_seq_puts(s, "<stack trace>\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) for (p = field->caller; p && p < end && *p != ULONG_MAX; p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) if (trace_seq_has_overflowed(s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) trace_seq_puts(s, " => ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) seq_print_ip_sym(s, *p, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) trace_seq_putc(s, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) static struct trace_event_functions trace_stack_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) .trace = trace_stack_print,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) static struct trace_event trace_stack_event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) .type = TRACE_STACK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) .funcs = &trace_stack_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) /* TRACE_USER_STACK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) int flags, struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) struct trace_array *tr = iter->tr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) struct userstack_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) struct mm_struct *mm = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) trace_seq_puts(s, "<user stack trace>\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) if (tr->trace_flags & TRACE_ITER_SYM_USEROBJ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) struct task_struct *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) * we do the lookup on the thread group leader,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) * since individual threads might have already quit!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) task = find_task_by_vpid(field->tgid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) if (task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) mm = get_task_mm(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) unsigned long ip = field->caller[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) if (!ip || trace_seq_has_overflowed(s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) trace_seq_puts(s, " => ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) seq_print_user_ip(s, mm, ip, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) trace_seq_putc(s, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) if (mm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) mmput(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) static struct trace_event_functions trace_user_stack_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) .trace = trace_user_stack_print,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) static struct trace_event trace_user_stack_event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) .type = TRACE_USER_STACK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) .funcs = &trace_user_stack_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) /* TRACE_HWLAT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) static enum print_line_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) trace_hwlat_print(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) struct trace_entry *entry = iter->ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) struct hwlat_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) trace_assign_type(field, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) trace_seq_printf(s, "#%-5u inner/outer(us): %4llu/%-5llu ts:%lld.%09ld count:%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) field->seqnum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) field->duration,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) field->outer_duration,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) (long long)field->timestamp.tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) field->timestamp.tv_nsec, field->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) if (field->nmi_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) * The generic sched_clock() is not NMI safe, thus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) * we only record the count and not the time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) if (!IS_ENABLED(CONFIG_GENERIC_SCHED_CLOCK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) trace_seq_printf(s, " nmi-total:%llu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) field->nmi_total_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) trace_seq_printf(s, " nmi-count:%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) field->nmi_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) trace_seq_putc(s, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) static enum print_line_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) trace_hwlat_raw(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) struct hwlat_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) trace_seq_printf(s, "%llu %lld %lld %09ld %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) field->duration,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) field->outer_duration,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) (long long)field->timestamp.tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) field->timestamp.tv_nsec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) field->seqnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) static struct trace_event_functions trace_hwlat_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) .trace = trace_hwlat_print,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) .raw = trace_hwlat_raw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) static struct trace_event trace_hwlat_event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) .type = TRACE_HWLAT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) .funcs = &trace_hwlat_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) /* TRACE_BPUTS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) static enum print_line_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) trace_bputs_print(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) struct trace_entry *entry = iter->ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) struct bputs_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) trace_assign_type(field, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) seq_print_ip_sym(s, field->ip, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) trace_seq_puts(s, ": ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) trace_seq_puts(s, field->str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) static enum print_line_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) trace_bputs_raw(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) struct bputs_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) trace_seq_printf(s, ": %lx : ", field->ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) trace_seq_puts(s, field->str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) static struct trace_event_functions trace_bputs_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) .trace = trace_bputs_print,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) .raw = trace_bputs_raw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) static struct trace_event trace_bputs_event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) .type = TRACE_BPUTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) .funcs = &trace_bputs_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) /* TRACE_BPRINT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) static enum print_line_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) trace_bprint_print(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) struct trace_entry *entry = iter->ent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) struct bprint_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) trace_assign_type(field, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) seq_print_ip_sym(s, field->ip, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) trace_seq_puts(s, ": ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) trace_seq_bprintf(s, field->fmt, field->buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) static enum print_line_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) trace_bprint_raw(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) struct bprint_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) trace_seq_printf(s, ": %lx : ", field->ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) trace_seq_bprintf(s, field->fmt, field->buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) static struct trace_event_functions trace_bprint_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) .trace = trace_bprint_print,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) .raw = trace_bprint_raw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) static struct trace_event trace_bprint_event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) .type = TRACE_BPRINT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) .funcs = &trace_bprint_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) /* TRACE_PRINT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) static enum print_line_t trace_print_print(struct trace_iterator *iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) int flags, struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) struct print_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) struct trace_seq *s = &iter->seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) seq_print_ip_sym(s, field->ip, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) trace_seq_printf(s, ": %s", field->buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) return trace_handle_return(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) struct print_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) return trace_handle_return(&iter->seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) static struct trace_event_functions trace_print_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) .trace = trace_print_print,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) .raw = trace_print_raw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) static struct trace_event trace_print_event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) .type = TRACE_PRINT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) .funcs = &trace_print_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) static enum print_line_t trace_raw_data(struct trace_iterator *iter, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) struct trace_event *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) struct raw_data_entry *field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) trace_assign_type(field, iter->ent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) trace_seq_printf(&iter->seq, "# %x buf:", field->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) for (i = 0; i < iter->ent_size - offsetof(struct raw_data_entry, buf); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) trace_seq_printf(&iter->seq, " %02x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) (unsigned char)field->buf[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) trace_seq_putc(&iter->seq, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) return trace_handle_return(&iter->seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) static struct trace_event_functions trace_raw_data_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) .trace = trace_raw_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) .raw = trace_raw_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) static struct trace_event trace_raw_data_event = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) .type = TRACE_RAW_DATA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) .funcs = &trace_raw_data_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) static struct trace_event *events[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) &trace_fn_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) &trace_ctx_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) &trace_wake_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) &trace_stack_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) &trace_user_stack_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) &trace_bputs_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) &trace_bprint_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) &trace_print_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) &trace_hwlat_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) &trace_raw_data_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) __init static int init_events(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) struct trace_event *event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) int i, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) for (i = 0; events[i]; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) event = events[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) ret = register_trace_event(event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) printk(KERN_WARNING "event %d failed to register\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) event->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) early_initcall(init_events);