Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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_export.c - export basic ftrace utilities to user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2009 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) #include <linux/stringify.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/kallsyms.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/ftrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "trace_output.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /* Stub function for events with triggers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) static int ftrace_event_register(struct trace_event_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 				 enum trace_reg type, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #undef TRACE_SYSTEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define TRACE_SYSTEM	ftrace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * The FTRACE_ENTRY_REG macro allows ftrace entry to define register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * function and thus become accesible via perf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #undef FTRACE_ENTRY_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, regfn) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /* not needed for this file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #undef __field_struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define __field_struct(type, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #undef __field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define __field(type, item)				type item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #undef __field_fn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define __field_fn(type, item)				type item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #undef __field_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define __field_desc(type, container, item)		type item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #undef __field_packed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define __field_packed(type, container, item)		type item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #undef __array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define __array(type, item, size)			type item[size];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #undef __array_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define __array_desc(type, container, item, size)	type item[size];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #undef __dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define __dynamic_array(type, item)			type item[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #undef F_STRUCT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define F_STRUCT(args...)				args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #undef F_printk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define F_printk(fmt, args...) fmt, args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #undef FTRACE_ENTRY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define FTRACE_ENTRY(name, struct_name, id, tstruct, print)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) struct ____ftrace_##name {						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	tstruct								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) };									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) static void __always_unused ____ftrace_check_##name(void)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct ____ftrace_##name *__entry = NULL;			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	/* force compile-time check on F_printk() */			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	printk(print);							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) #undef FTRACE_ENTRY_DUP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) #include "trace_entries.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #undef __field_ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) #define __field_ext(_type, _item, _filter_type) {			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	.type = #_type, .name = #_item,					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	.size = sizeof(_type), .align = __alignof__(_type),		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	is_signed_type(_type), .filter_type = _filter_type },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #undef __field_ext_packed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #define __field_ext_packed(_type, _item, _filter_type) {	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	.type = #_type, .name = #_item,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	.size = sizeof(_type), .align = 1,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	is_signed_type(_type), .filter_type = _filter_type },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) #undef __field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #define __field(_type, _item) __field_ext(_type, _item, FILTER_OTHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #undef __field_fn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define __field_fn(_type, _item) __field_ext(_type, _item, FILTER_TRACE_FN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #undef __field_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define __field_desc(_type, _container, _item) __field_ext(_type, _item, FILTER_OTHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #undef __field_packed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define __field_packed(_type, _container, _item) __field_ext_packed(_type, _item, FILTER_OTHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #undef __array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define __array(_type, _item, _len) {					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	.type = #_type"["__stringify(_len)"]", .name = #_item,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	.size = sizeof(_type[_len]), .align = __alignof__(_type),	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	is_signed_type(_type), .filter_type = FILTER_OTHER },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #undef __array_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define __array_desc(_type, _container, _item, _len) __array(_type, _item, _len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #undef __dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define __dynamic_array(_type, _item) {					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	.type = #_type "[]", .name = #_item,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	.size = 0, .align = __alignof__(_type),				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	is_signed_type(_type), .filter_type = FILTER_OTHER },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #undef FTRACE_ENTRY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define FTRACE_ENTRY(name, struct_name, id, tstruct, print)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static struct trace_event_fields ftrace_event_fields_##name[] = {	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	tstruct								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	{} };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #include "trace_entries.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #undef __entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #define __entry REC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #undef __field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define __field(type, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #undef __field_fn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define __field_fn(type, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #undef __field_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define __field_desc(type, container, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #undef __field_packed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define __field_packed(type, container, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #undef __array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define __array(type, item, len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #undef __array_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define __array_desc(type, container, item, len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #undef __dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #define __dynamic_array(type, item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #undef F_printk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #define F_printk(fmt, args...) __stringify(fmt) ", "  __stringify(args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #undef FTRACE_ENTRY_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define FTRACE_ENTRY_REG(call, struct_name, etype, tstruct, print, regfn) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static struct trace_event_class __refdata event_class_ftrace_##call = {	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	.system			= __stringify(TRACE_SYSTEM),		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	.fields_array		= ftrace_event_fields_##call,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	.fields			= LIST_HEAD_INIT(event_class_ftrace_##call.fields),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	.reg			= regfn,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) };									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct trace_event_call __used event_##call = {				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	.class			= &event_class_ftrace_##call,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	{								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		.name			= #call,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	},								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	.event.type		= etype,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	.print_fmt		= print,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	.flags			= TRACE_EVENT_FL_IGNORE_ENABLE,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) };									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static struct trace_event_call __used						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) __section("_ftrace_events") *__event_##call = &event_##call;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) #undef FTRACE_ENTRY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #define FTRACE_ENTRY(call, struct_name, etype, tstruct, print)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	FTRACE_ENTRY_REG(call, struct_name, etype,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			 PARAMS(tstruct), PARAMS(print), NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) bool ftrace_event_is_function(struct trace_event_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	return call == &event_function;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #include "trace_entries.h"