Merge reason: this mini-topic had outstanding problems that delayed its merge, so it does not fast-forward.
Showing the changes to include/trace (2 of 9 files). Show all
Unified · Split
| @@ -7,18 +7,18 @@ · 6 unmodified lines | ||
| 7 | 7 | #undef TRACE_SYSTEM |
| 8 | 8 | #define TRACE_SYSTEM irq |
| 9 | 9 | |
| 10 | −#define softirq_name(sirq) { sirq, #sirq } | |
| 11 | −#define show_softirq_name(val) \ | |
| 12 | − __print_symbolic(val, \ | |
| 13 | − softirq_name(HI_SOFTIRQ), \ | |
| 14 | − softirq_name(TIMER_SOFTIRQ), \ | |
| 15 | − softirq_name(NET_TX_SOFTIRQ), \ | |
| 16 | − softirq_name(NET_RX_SOFTIRQ), \ | |
| 17 | − softirq_name(BLOCK_SOFTIRQ), \ | |
| 18 | − softirq_name(TASKLET_SOFTIRQ), \ | |
| 19 | − softirq_name(SCHED_SOFTIRQ), \ | |
| 20 | − softirq_name(HRTIMER_SOFTIRQ), \ | |
| 21 | − softirq_name(RCU_SOFTIRQ)) | |
| 10 | +#define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq } | |
| 11 | +#define show_softirq_name(val) \ | |
| 12 | + __print_symbolic(val, \ | |
| 13 | + softirq_name(HI), \ | |
| 14 | + softirq_name(TIMER), \ | |
| 15 | + softirq_name(NET_TX), \ | |
| 16 | + softirq_name(NET_RX), \ | |
| 17 | + softirq_name(BLOCK), \ | |
| 18 | + softirq_name(TASKLET), \ | |
| 19 | + softirq_name(SCHED), \ | |
| 20 | + softirq_name(HRTIMER), \ | |
| 21 | + softirq_name(RCU)) | |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * irq_handler_entry - called immediately before the irq action handler |
| @@ -18,14 +18,17 @@ · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | #include <linux/ftrace_event.h> |
| 20 | 20 | |
| 21 | +#undef __field | |
| 22 | +#define __field(type, item) type item; | |
| 23 | + | |
| 21 | 24 | #undef __array |
| 22 | 25 | #define __array(type, item, len) type item[len]; |
| 23 | 26 | |
| 24 | −#undef __field | |
| 25 | −#define __field(type, item) type item; | |
| 27 | +#undef __dynamic_array | |
| 28 | +#define __dynamic_array(type, item, len) unsigned short __data_loc_##item; | |
| 26 | 29 | |
| 27 | 30 | #undef __string |
| 28 | −#define __string(item, src) unsigned short __str_loc_##item; | |
| 31 | +#define __string(item, src) __dynamic_array(char, item, -1) | |
| 29 | 32 | |
| 30 | 33 | #undef TP_STRUCT__entry |
| 31 | 34 | #define TP_STRUCT__entry(args...) args |
| @@ -35,7 +38,7 @@ · 3 unmodified lines | ||
| 35 | 38 | struct ftrace_raw_##name { \ |
| 36 | 39 | struct trace_entry ent; \ |
| 37 | 40 | tstruct \ |
| 38 | − char __str_data[0]; \ | |
| 41 | + char __data[0]; \ | |
| 39 | 42 | }; \ |
| 40 | 43 | static struct ftrace_event_call event_##name |
| 41 | 44 | |
| @@ -47,30 +50,31 @@ · 5 unmodified lines | ||
| 47 | 50 | * |
| 48 | 51 | * Include the following: |
| 49 | 52 | * |
| 50 | − * struct ftrace_str_offsets_<call> { | |
| 51 | − * int <str1>; | |
| 52 | − * int <str2>; | |
| 53 | + * struct ftrace_data_offsets_<call> { | |
| 54 | + * int <item1>; | |
| 55 | + * int <item2>; | |
| 53 | 56 | * [...] |
| 54 | 57 | * }; |
| 55 | 58 | * |
| 56 | − * The __string() macro will create each int <str>, this is to | |
| 57 | − * keep the offset of each string from the beggining of the event | |
| 58 | − * once we perform the strlen() of the src strings. | |
| 59 | − * | |
| 59 | + * The __dynamic_array() macro will create each int <item>, this is | |
| 60 | + * to keep the offset of each array from the beginning of the event. | |
| 60 | 61 | */ |
| 61 | 62 | |
| 63 | +#undef __field | |
| 64 | +#define __field(type, item); | |
| 65 | + | |
| 62 | 66 | #undef __array |
| 63 | 67 | #define __array(type, item, len) |
| 64 | 68 | |
| 65 | −#undef __field | |
| 66 | −#define __field(type, item); | |
| 69 | +#undef __dynamic_array | |
| 70 | +#define __dynamic_array(type, item, len) int item; | |
| 67 | 71 | |
| 68 | 72 | #undef __string |
| 69 | −#define __string(item, src) int item; | |
| 73 | +#define __string(item, src) __dynamic_array(char, item, -1) | |
| 70 | 74 | |
| 71 | 75 | #undef TRACE_EVENT |
| 72 | 76 | #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \ |
| 73 | − struct ftrace_str_offsets_##call { \ | |
| 77 | + struct ftrace_data_offsets_##call { \ | |
| 74 | 78 | tstruct; \ |
| 75 | 79 | }; |
| 76 | 80 | |
| @@ -119,8 +123,12 @@ · 42 unmodified lines | ||
| 119 | 123 | #undef TP_printk |
| 120 | 124 | #define TP_printk(fmt, args...) fmt "\n", args |
| 121 | 125 | |
| 126 | +#undef __get_dynamic_array | |
| 127 | +#define __get_dynamic_array(field) \ | |
| 128 | + ((void *)__entry + __entry->__data_loc_##field) | |
| 129 | + | |
| 122 | 130 | #undef __get_str |
| 123 | −#define __get_str(field) ((char *)__entry + __entry->__str_loc_##field) | |
| 131 | +#define __get_str(field) (char *)__get_dynamic_array(field) | |
| 124 | 132 | |
| 125 | 133 | #undef __print_flags |
| 126 | 134 | #define __print_flags(flag, delim, flag_array...) \ |
| @@ -207,16 +215,19 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \ · 80 unmodified lines | ||
| 207 | 215 | if (!ret) \ |
| 208 | 216 | return 0; |
| 209 | 217 | |
| 210 | −#undef __string | |
| 211 | −#define __string(item, src) \ | |
| 212 | − ret = trace_seq_printf(s, "\tfield: __str_loc " #item ";\t" \ | |
| 213 | − "offset:%u;tsize:%u;\n", \ | |
| 218 | +#undef __dynamic_array | |
| 219 | +#define __dynamic_array(type, item, len) \ | |
| 220 | + ret = trace_seq_printf(s, "\tfield:__data_loc " #item ";\t" \ | |
| 221 | + "offset:%u;\tsize:%u;\n", \ | |
| 214 | 222 | (unsigned int)offsetof(typeof(field), \ |
| 215 | − __str_loc_##item), \ | |
| 216 | − (unsigned int)sizeof(field.__str_loc_##item)); \ | |
| 223 | + __data_loc_##item), \ | |
| 224 | + (unsigned int)sizeof(field.__data_loc_##item)); \ | |
| 217 | 225 | if (!ret) \ |
| 218 | 226 | return 0; |
| 219 | 227 | |
| 228 | +#undef __string | |
| 229 | +#define __string(item, src) __dynamic_array(char, item, -1) | |
| 230 | + | |
| 220 | 231 | #undef __entry |
| 221 | 232 | #define __entry REC |
| 222 | 233 | |
| @@ -260,11 +271,14 @@ ftrace_format_##call(struct trace_seq *s) \ · 37 unmodified lines | ||
| 260 | 271 | if (ret) \ |
| 261 | 272 | return ret; |
| 262 | 273 | |
| 274 | +#undef __dynamic_array | |
| 275 | +#define __dynamic_array(type, item, len) \ | |
| 276 | + ret = trace_define_field(event_call, "__data_loc" "[" #type "]", #item,\ | |
| 277 | + offsetof(typeof(field), __data_loc_##item), \ | |
| 278 | + sizeof(field.__data_loc_##item), 0); | |
| 279 | + | |
| 263 | 280 | #undef __string |
| 264 | −#define __string(item, src) \ | |
| 265 | − ret = trace_define_field(event_call, "__str_loc", #item, \ | |
| 266 | − offsetof(typeof(field), __str_loc_##item), \ | |
| 267 | − sizeof(field.__str_loc_##item), 0); | |
| 281 | +#define __string(item, src) __dynamic_array(char, item, -1) | |
| 268 | 282 | |
| 269 | 283 | #undef TRACE_EVENT |
| 270 | 284 | #define TRACE_EVENT(call, proto, args, tstruct, func, print) \ |
| @@ -288,6 +302,43 @@ ftrace_define_fields_##call(void) \ · 17 unmodified lines | ||
| 288 | 302 | |
| 289 | 303 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 290 | 304 | |
| 305 | +/* | |
| 306 | + * remember the offset of each array from the beginning of the event. | |
| 307 | + */ | |
| 308 | + | |
| 309 | +#undef __entry | |
| 310 | +#define __entry entry | |
| 311 | + | |
| 312 | +#undef __field | |
| 313 | +#define __field(type, item) | |
| 314 | + | |
| 315 | +#undef __array | |
| 316 | +#define __array(type, item, len) | |
| 317 | + | |
| 318 | +#undef __dynamic_array | |
| 319 | +#define __dynamic_array(type, item, len) \ | |
| 320 | + __data_offsets->item = __data_size + \ | |
| 321 | + offsetof(typeof(*entry), __data); \ | |
| 322 | + __data_size += (len) * sizeof(type); | |
| 323 | + | |
| 324 | +#undef __string | |
| 325 | +#define __string(item, src) __dynamic_array(char, item, strlen(src) + 1) \ | |
| 326 | + | |
| 327 | +#undef TRACE_EVENT | |
| 328 | +#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \ | |
| 329 | +static inline int ftrace_get_offsets_##call( \ | |
| 330 | + struct ftrace_data_offsets_##call *__data_offsets, proto) \ | |
| 331 | +{ \ | |
| 332 | + int __data_size = 0; \ | |
| 333 | + struct ftrace_raw_##call __maybe_unused *entry; \ | |
| 334 | + \ | |
| 335 | + tstruct; \ | |
| 336 | + \ | |
| 337 | + return __data_size; \ | |
| 338 | +} | |
| 339 | + | |
| 340 | +#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | |
| 341 | + | |
| 291 | 342 | /* |
| 292 | 343 | * Stage 4 of the trace events. |
| 293 | 344 | * |
| @@ -432,15 +483,15 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\ · 138 unmodified lines | ||
| 432 | 483 | #undef __array |
| 433 | 484 | #define __array(type, item, len) |
| 434 | 485 | |
| 486 | +#undef __dynamic_array | |
| 487 | +#define __dynamic_array(type, item, len) \ | |
| 488 | + __entry->__data_loc_##item = __data_offsets.item; | |
| 489 | + | |
| 435 | 490 | #undef __string |
| 436 | −#define __string(item, src) \ | |
| 437 | − __str_offsets.item = __str_size + \ | |
| 438 | − offsetof(typeof(*entry), __str_data); \ | |
| 439 | − __str_size += strlen(src) + 1; | |
| 491 | +#define __string(item, src) __dynamic_array(char, item, -1) \ | |
| 440 | 492 | |
| 441 | 493 | #undef __assign_str |
| 442 | 494 | #define __assign_str(dst, src) \ |
| 443 | − __entry->__str_loc_##dst = __str_offsets.dst; \ | |
| 444 | 495 | strcpy(__get_str(dst), src); |
| 445 | 496 | |
| 446 | 497 | #undef TRACE_EVENT |
| @@ -451,27 +502,30 @@ static struct ftrace_event_call event_##call; \ · 4 unmodified lines | ||
| 451 | 502 | \ |
| 452 | 503 | static void ftrace_raw_event_##call(proto) \ |
| 453 | 504 | { \ |
| 454 | − struct ftrace_str_offsets_##call __maybe_unused __str_offsets; \ | |
| 505 | + struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\ | |
| 455 | 506 | struct ftrace_event_call *event_call = &event_##call; \ |
| 456 | 507 | struct ring_buffer_event *event; \ |
| 457 | 508 | struct ftrace_raw_##call *entry; \ |
| 458 | 509 | unsigned long irq_flags; \ |
| 459 | − int __str_size = 0; \ | |
| 510 | + int __data_size; \ | |
| 460 | 511 | int pc; \ |
| 461 | 512 | \ |
| 462 | 513 | local_save_flags(irq_flags); \ |
| 463 | 514 | pc = preempt_count(); \ |
| 464 | 515 | \ |
| 465 | − tstruct; \ | |
| 516 | + __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \ | |
| 466 | 517 | \ |
| 467 | 518 | event = trace_current_buffer_lock_reserve(event_##call.id, \ |
| 468 | − sizeof(struct ftrace_raw_##call) + __str_size,\ | |
| 519 | + sizeof(*entry) + __data_size, \ | |
| 469 | 520 | irq_flags, pc); \ |
| 470 | 521 | if (!event) \ |
| 471 | 522 | return; \ |
| 472 | 523 | entry = ring_buffer_event_data(event); \ |
| 473 | 524 | \ |
| 474 | − assign; \ | |
| 525 | + \ | |
| 526 | + tstruct \ | |
| 527 | + \ | |
| 528 | + { assign; } \ | |
| 475 | 529 | \ |
| 476 | 530 | if (!filter_current_check_discard(event_call, entry, event)) \ |
| 477 | 531 | trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \ |