Skip to content

Commit d731509

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: show details of structures within the ftrace structures
Some of the internal ftrace structures use structures within. The output of a field saying it is just a structure is useless for a format file. A binary reader of the ring buffer needs to know more about how the fields are broken up. This patch adds to the ftrace structure macros new fields to describe the structures inside a structure. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 0a1c49d commit d731509

2 files changed

Lines changed: 66 additions & 7 deletions

File tree

‎kernel/trace/trace.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,18 @@ extern struct tracer boot_tracer;
5353
#undef __field
5454
#define __field(type, item) type item;
5555

56+
#undef __field_struct
57+
#define __field_struct(type, item) __field(type, item)
58+
59+
#undef __field_desc
60+
#define __field_desc(type, container, item)
61+
5662
#undef __array
5763
#define __array(type, item, size) type item[size];
5864

65+
#undef __array_desc
66+
#define __array_desc(type, container, item, size)
67+
5968
#undef __dynamic_array
6069
#define __dynamic_array(type, item) type item[];
6170

‎kernel/trace/trace_entries.h‎

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@
2626
* type item[size];
2727
* in the structure.
2828
*
29+
* * for structures within structures, the format of the internal
30+
* structure is layed out. This allows the internal structure
31+
* to be deciphered for the format file. Although these macros
32+
* may become out of sync with the internal structure, they
33+
* will create a compile error if it happens. Since the
34+
* internel structures are just tracing helpers, this is not
35+
* an issue.
36+
*
37+
* When an internal structure is used, it should use:
38+
*
39+
* __field_struct( type, item )
40+
*
41+
* instead of __field. This will prevent it from being shown in
42+
* the output file. The fields in the structure should use.
43+
*
44+
* __field_desc( type, container, item )
45+
* __array_desc( type, container, item, len )
46+
*
47+
* type, item and len are the same as __field and __array, but
48+
* container is added. This is the name of the item in
49+
* __field_struct that this is describing.
50+
*
51+
*
2952
* @print: the print format shown to users in the format file.
3053
*/
3154

@@ -50,7 +73,9 @@ FTRACE_ENTRY(funcgraph_entry, ftrace_graph_ent_entry,
5073
TRACE_GRAPH_ENT,
5174

5275
F_STRUCT(
53-
__field( struct ftrace_graph_ent, graph_ent )
76+
__field_struct( struct ftrace_graph_ent, graph_ent )
77+
__field_desc( unsigned long, graph_ent, func )
78+
__field_desc( int, graph_ent, depth )
5479
),
5580

5681
F_printk("--> %lx (%d)", __entry->graph_ent.func, __entry->depth)
@@ -62,7 +87,12 @@ FTRACE_ENTRY(funcgraph_exit, ftrace_graph_ret_entry,
6287
TRACE_GRAPH_RET,
6388

6489
F_STRUCT(
65-
__field( struct ftrace_graph_ret, ret )
90+
__field_struct( struct ftrace_graph_ret, ret )
91+
__field_desc( unsigned long, ret, func )
92+
__field_desc( unsigned long long, ret, calltime)
93+
__field_desc( unsigned long long, ret, rettime )
94+
__field_desc( unsigned long, ret, overrun )
95+
__field_desc( int, ret, depth )
6696
),
6797

6898
F_printk("<-- %lx (%d) (start: %llx end: %llx) over: %d",
@@ -218,7 +248,13 @@ FTRACE_ENTRY(mmiotrace_rw, trace_mmiotrace_rw,
218248
TRACE_MMIO_RW,
219249

220250
F_STRUCT(
221-
__field( struct mmiotrace_rw, rw )
251+
__field_struct( struct mmiotrace_rw, rw )
252+
__field_desc( resource_size_t, rw, phys )
253+
__field_desc( unsigned long, rw, value )
254+
__field_desc( unsigned long, rw, pc )
255+
__field_desc( int, rw, map_id )
256+
__field_desc( unsigned char, rw, opcode )
257+
__field_desc( unsigned char, rw, width )
222258
),
223259

224260
F_printk("%lx %lx %lx %d %lx %lx",
@@ -231,7 +267,12 @@ FTRACE_ENTRY(mmiotrace_map, trace_mmiotrace_map,
231267
TRACE_MMIO_MAP,
232268

233269
F_STRUCT(
234-
__field( struct mmiotrace_map, map )
270+
__field_struct( struct mmiotrace_map, map )
271+
__field_desc( resource_size_t, map, phys )
272+
__field_desc( unsigned long, map, virt )
273+
__field_desc( unsigned long, map, len )
274+
__field_desc( int, map, map_id )
275+
__field_desc( unsigned char, map, opcode )
235276
),
236277

237278
F_printk("%lx %lx %lx %d %lx",
@@ -244,7 +285,9 @@ FTRACE_ENTRY(boot_call, trace_boot_call,
244285
TRACE_BOOT_CALL,
245286

246287
F_STRUCT(
247-
__field( struct boot_trace_call, boot_call )
288+
__field_struct( struct boot_trace_call, boot_call )
289+
__field_desc( pid_t, boot_call, caller )
290+
__array_desc( char, boot_call, func, KSYM_SYMBOL_LEN)
248291
),
249292

250293
F_printk("%d %s", __entry->caller, __entry->func)
@@ -255,7 +298,10 @@ FTRACE_ENTRY(boot_ret, trace_boot_ret,
255298
TRACE_BOOT_RET,
256299

257300
F_STRUCT(
258-
__field( struct boot_trace_ret, boot_ret )
301+
__field_struct( struct boot_trace_ret, boot_ret )
302+
__array_desc( char, boot_ret, func, KSYM_SYMBOL_LEN)
303+
__field_desc( int, boot_ret, result )
304+
__field_desc( unsigned long, boot_ret, duration )
259305
),
260306

261307
F_printk("%s %d %lx",
@@ -298,7 +344,11 @@ FTRACE_ENTRY(power, trace_power,
298344
TRACE_POWER,
299345

300346
F_STRUCT(
301-
__field( struct power_trace, state_data )
347+
__field_struct( struct power_trace, state_data )
348+
__field_desc( s64, state_data, stamp )
349+
__field_desc( s64, state_data, end )
350+
__field_desc( int, state_data, type )
351+
__field_desc( int, state_data, state )
302352
),
303353

304354
F_printk("%llx->%llx type:%u state:%u",

0 commit comments

Comments
 (0)