Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'trace-v6.2-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull tracing fix from Steven Rostedt:
"Fix showing of TASK_COMM_LEN instead of its value

The TASK_COMM_LEN was converted from a macro into an enum so that BTF
would have access to it. But this unfortunately caused TASK_COMM_LEN
to display in the format fields of trace events, as they are created
by the TRACE_EVENT() macro and such, macros convert to their values,
where as enums do not.

To handle this, instead of using the field itself to be display, save
the value of the array size as another field in the trace_event_fields
structure, and use that instead.

Not only does this fix the issue, but also converts the other trace
events that have this same problem (but were not breaking tooling).

With this change, the original work around b3bc8547d3be6 ("tracing:
Have TRACE_DEFINE_ENUM affect trace event types as well") could be
reverted (but that should be done in the merge window)"

* tag 'trace-v6.2-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
tracing: Fix TASK_COMM_LEN in trace event format file

+36 -11
+1
include/linux/trace_events.h
··· 270 270 const int align; 271 271 const int is_signed; 272 272 const int filter_type; 273 + const int len; 273 274 }; 274 275 int (*define_fields)(struct trace_event_call *); 275 276 };
+2 -1
include/trace/stages/stage4_event_fields.h
··· 26 26 #define __array(_type, _item, _len) { \ 27 27 .type = #_type"["__stringify(_len)"]", .name = #_item, \ 28 28 .size = sizeof(_type[_len]), .align = ALIGN_STRUCTFIELD(_type), \ 29 - .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER }, 29 + .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER,\ 30 + .len = _len }, 30 31 31 32 #undef __dynamic_array 32 33 #define __dynamic_array(_type, _item, _len) { \
+1
kernel/trace/trace.h
··· 1282 1282 int offset; 1283 1283 int size; 1284 1284 int is_signed; 1285 + int len; 1285 1286 }; 1286 1287 1287 1288 struct prog_entry;
+30 -9
kernel/trace/trace_events.c
··· 114 114 115 115 static int __trace_define_field(struct list_head *head, const char *type, 116 116 const char *name, int offset, int size, 117 - int is_signed, int filter_type) 117 + int is_signed, int filter_type, int len) 118 118 { 119 119 struct ftrace_event_field *field; 120 120 ··· 133 133 field->offset = offset; 134 134 field->size = size; 135 135 field->is_signed = is_signed; 136 + field->len = len; 136 137 137 138 list_add(&field->link, head); 138 139 ··· 151 150 152 151 head = trace_get_fields(call); 153 152 return __trace_define_field(head, type, name, offset, size, 154 - is_signed, filter_type); 153 + is_signed, filter_type, 0); 155 154 } 156 155 EXPORT_SYMBOL_GPL(trace_define_field); 156 + 157 + int trace_define_field_ext(struct trace_event_call *call, const char *type, 158 + const char *name, int offset, int size, int is_signed, 159 + int filter_type, int len) 160 + { 161 + struct list_head *head; 162 + 163 + if (WARN_ON(!call->class)) 164 + return 0; 165 + 166 + head = trace_get_fields(call); 167 + return __trace_define_field(head, type, name, offset, size, 168 + is_signed, filter_type, len); 169 + } 157 170 158 171 #define __generic_field(type, item, filter_type) \ 159 172 ret = __trace_define_field(&ftrace_generic_fields, #type, \ 160 173 #item, 0, 0, is_signed_type(type), \ 161 - filter_type); \ 174 + filter_type, 0); \ 162 175 if (ret) \ 163 176 return ret; 164 177 ··· 181 166 "common_" #item, \ 182 167 offsetof(typeof(ent), item), \ 183 168 sizeof(ent.item), \ 184 - is_signed_type(type), FILTER_OTHER); \ 169 + is_signed_type(type), FILTER_OTHER, 0); \ 185 170 if (ret) \ 186 171 return ret; 187 172 ··· 1603 1588 seq_printf(m, "\tfield:%s %s;\toffset:%u;\tsize:%u;\tsigned:%d;\n", 1604 1589 field->type, field->name, field->offset, 1605 1590 field->size, !!field->is_signed); 1606 - else 1607 - seq_printf(m, "\tfield:%.*s %s%s;\toffset:%u;\tsize:%u;\tsigned:%d;\n", 1591 + else if (field->len) 1592 + seq_printf(m, "\tfield:%.*s %s[%d];\toffset:%u;\tsize:%u;\tsigned:%d;\n", 1608 1593 (int)(array_descriptor - field->type), 1609 1594 field->type, field->name, 1610 - array_descriptor, field->offset, 1595 + field->len, field->offset, 1611 1596 field->size, !!field->is_signed); 1597 + else 1598 + seq_printf(m, "\tfield:%.*s %s[];\toffset:%u;\tsize:%u;\tsigned:%d;\n", 1599 + (int)(array_descriptor - field->type), 1600 + field->type, field->name, 1601 + field->offset, field->size, !!field->is_signed); 1612 1602 1613 1603 return 0; 1614 1604 } ··· 2399 2379 } 2400 2380 2401 2381 offset = ALIGN(offset, field->align); 2402 - ret = trace_define_field(call, field->type, field->name, 2382 + ret = trace_define_field_ext(call, field->type, field->name, 2403 2383 offset, field->size, 2404 - field->is_signed, field->filter_type); 2384 + field->is_signed, field->filter_type, 2385 + field->len); 2405 2386 if (WARN_ON_ONCE(ret)) { 2406 2387 pr_err("error code is %d\n", ret); 2407 2388 break;
+2 -1
kernel/trace/trace_export.c
··· 111 111 #define __array(_type, _item, _len) { \ 112 112 .type = #_type"["__stringify(_len)"]", .name = #_item, \ 113 113 .size = sizeof(_type[_len]), .align = __alignof__(_type), \ 114 - is_signed_type(_type), .filter_type = FILTER_OTHER }, 114 + is_signed_type(_type), .filter_type = FILTER_OTHER, \ 115 + .len = _len }, 115 116 116 117 #undef __array_desc 117 118 #define __array_desc(_type, _container, _item, _len) __array(_type, _item, _len)