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

Merge tag 'trace-v5.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt:

- rtla (Real-Time Linux Analysis tool):
- fix typo in man page
- Update API -e to -E before it is released
- Error message fix and memory leak fix

- Partially uninline trace event soft disable to shrink text

- Fix function graph start up test

- Have triggers affect the trace instance they are in and not top level

- Have osnoise sleep in the units it says it uses

- Remove unused ftrace stub function

- Remove event probe redundant info from event in the buffer

- Fix group ownership setting in tracefs

- Ensure trace buffer is minimum size to prevent crashes

* tag 'trace-v5.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
rtla/osnoise: Fix error message when failing to enable trace instance
rtla/osnoise: Free params at the exit
rtla/hist: Make -E the short version of --entries
tracing: Fix selftest config check for function graph start up test
tracefs: Set the group ownership in apply_options() not parse_options()
tracing/osnoise: Make osnoise_main to sleep for microseconds
ftrace: Remove unused ftrace_startup_enable() stub
tracing: Ensure trace buffer is at least 4096 bytes large
tracing: Uninline trace_trigger_soft_disabled() partly
eprobes: Remove redundant event type information
tracing: Have traceon and traceoff trigger honor the instance
tracing: Dump stacktrace trigger to the corresponding instance
rtla: Fix systme -> system typo on man page

+148 -79
+1 -1
Documentation/tools/rtla/common_hist_options.rst
··· 2 2 3 3 Set the histogram bucket size (default *1*). 4 4 5 - **-e**, **--entries** *N* 5 + **-E**, **--entries** *N* 6 6 7 7 Set the number of entries of the histogram (default 256). 8 8
+1 -1
Documentation/tools/rtla/common_osnoise_description.rst
··· 1 1 The **rtla osnoise** tool is an interface for the *osnoise* tracer. The 2 2 *osnoise* tracer dispatches a kernel thread per-cpu. These threads read the 3 3 time in a loop while with preemption, softirq and IRQs enabled, thus 4 - allowing all the sources of operating systme noise during its execution. 4 + allowing all the sources of operating system noise during its execution. 5 5 The *osnoise*'s tracer threads take note of the delta between each time 6 6 read, along with an interference counter of all sources of interference. 7 7 At the end of each period, the *osnoise* tracer displays a summary of
+1 -1
Documentation/tools/rtla/rtla-osnoise-hist.rst
··· 36 36 **rtla** tool. The tool is also set to run for *one minute*. The output 37 37 histogram is set to group outputs in buckets of *10us* and *25* entries:: 38 38 39 - [root@f34 ~/]# rtla osnoise hist -P F:1 -c 0-11 -r 900000 -d 1M -b 10 -e 25 39 + [root@f34 ~/]# rtla osnoise hist -P F:1 -c 0-11 -r 900000 -d 1M -b 10 -E 25 40 40 # RTLA osnoise histogram 41 41 # Time unit is microseconds (us) 42 42 # Duration: 0 00:01:00
+3 -2
fs/tracefs/inode.c
··· 264 264 if (!gid_valid(gid)) 265 265 return -EINVAL; 266 266 opts->gid = gid; 267 - set_gid(tracefs_mount->mnt_root, gid); 268 267 break; 269 268 case Opt_mode: 270 269 if (match_octal(&args[0], &option)) ··· 290 291 inode->i_mode |= opts->mode; 291 292 292 293 inode->i_uid = opts->uid; 293 - inode->i_gid = opts->gid; 294 + 295 + /* Set all the group ids to the mount option */ 296 + set_gid(sb->s_root, opts->gid); 294 297 295 298 return 0; 296 299 }
+12 -10
include/linux/trace_events.h
··· 699 699 700 700 bool trace_event_ignore_this_pid(struct trace_event_file *trace_file); 701 701 702 + bool __trace_trigger_soft_disabled(struct trace_event_file *file); 703 + 702 704 /** 703 705 * trace_trigger_soft_disabled - do triggers and test if soft disabled 704 706 * @file: The file pointer of the event to test ··· 710 708 * triggers that require testing the fields, it will return true, 711 709 * otherwise false. 712 710 */ 713 - static inline bool 711 + static __always_inline bool 714 712 trace_trigger_soft_disabled(struct trace_event_file *file) 715 713 { 716 714 unsigned long eflags = file->flags; 717 715 718 - if (!(eflags & EVENT_FILE_FL_TRIGGER_COND)) { 719 - if (eflags & EVENT_FILE_FL_TRIGGER_MODE) 720 - event_triggers_call(file, NULL, NULL, NULL); 721 - if (eflags & EVENT_FILE_FL_SOFT_DISABLED) 722 - return true; 723 - if (eflags & EVENT_FILE_FL_PID_FILTER) 724 - return trace_event_ignore_this_pid(file); 725 - } 726 - return false; 716 + if (likely(!(eflags & (EVENT_FILE_FL_TRIGGER_MODE | 717 + EVENT_FILE_FL_SOFT_DISABLED | 718 + EVENT_FILE_FL_PID_FILTER)))) 719 + return false; 720 + 721 + if (likely(eflags & EVENT_FILE_FL_TRIGGER_COND)) 722 + return false; 723 + 724 + return __trace_trigger_soft_disabled(file); 727 725 } 728 726 729 727 #ifdef CONFIG_BPF_EVENTS
-1
kernel/trace/ftrace.c
··· 7191 7191 core_initcall(ftrace_nodyn_init); 7192 7192 7193 7193 static inline int ftrace_init_dyn_tracefs(struct dentry *d_tracer) { return 0; } 7194 - static inline void ftrace_startup_enable(int command) { } 7195 7194 static inline void ftrace_startup_all(int command) { } 7196 7195 7197 7196 # define ftrace_startup_sysctl() do { } while (0)
+6 -4
kernel/trace/trace.c
··· 1474 1474 if (!str) 1475 1475 return 0; 1476 1476 buf_size = memparse(str, &str); 1477 - /* nr_entries can not be zero */ 1478 - if (buf_size == 0) 1479 - return 0; 1480 - trace_buf_size = buf_size; 1477 + /* 1478 + * nr_entries can not be zero and the startup 1479 + * tests require some buffer space. Therefore 1480 + * ensure we have at least 4096 bytes of buffer. 1481 + */ 1482 + trace_buf_size = max(4096UL, buf_size); 1481 1483 return 1; 1482 1484 } 1483 1485 __setup("trace_buf_size=", set_buf_size);
-1
kernel/trace/trace.h
··· 136 136 137 137 struct eprobe_trace_entry_head { 138 138 struct trace_entry ent; 139 - unsigned int type; 140 139 }; 141 140 142 141 struct kretprobe_trace_entry_head {
+7 -9
kernel/trace/trace_eprobe.c
··· 242 242 243 243 static int eprobe_event_define_fields(struct trace_event_call *event_call) 244 244 { 245 - int ret; 246 245 struct eprobe_trace_entry_head field; 247 246 struct trace_probe *tp; 248 247 249 248 tp = trace_probe_primary_from_call(event_call); 250 249 if (WARN_ON_ONCE(!tp)) 251 250 return -ENOENT; 252 - 253 - DEFINE_FIELD(unsigned int, type, FIELD_STRING_TYPE, 0); 254 251 255 252 return traceprobe_define_arg_fields(event_call, sizeof(field), tp); 256 253 } ··· 267 270 struct trace_event_call *pevent; 268 271 struct trace_event *probed_event; 269 272 struct trace_seq *s = &iter->seq; 273 + struct trace_eprobe *ep; 270 274 struct trace_probe *tp; 275 + unsigned int type; 271 276 272 277 field = (struct eprobe_trace_entry_head *)iter->ent; 273 278 tp = trace_probe_primary_from_call( ··· 277 278 if (WARN_ON_ONCE(!tp)) 278 279 goto out; 279 280 281 + ep = container_of(tp, struct trace_eprobe, tp); 282 + type = ep->event->event.type; 283 + 280 284 trace_seq_printf(s, "%s: (", trace_probe_name(tp)); 281 285 282 - probed_event = ftrace_find_event(field->type); 286 + probed_event = ftrace_find_event(type); 283 287 if (probed_event) { 284 288 pevent = container_of(probed_event, struct trace_event_call, event); 285 289 trace_seq_printf(s, "%s.%s", pevent->class->system, 286 290 trace_event_name(pevent)); 287 291 } else { 288 - trace_seq_printf(s, "%u", field->type); 292 + trace_seq_printf(s, "%u", type); 289 293 } 290 294 291 295 trace_seq_putc(s, ')'); ··· 500 498 return; 501 499 502 500 entry = fbuffer.entry = ring_buffer_event_data(fbuffer.event); 503 - if (edata->ep->event) 504 - entry->type = edata->ep->event->event.type; 505 - else 506 - entry->type = 0; 507 501 store_trace_args(&entry[1], &edata->ep->tp, rec, sizeof(*entry), dsize); 508 502 509 503 trace_event_buffer_commit(&fbuffer);
+66 -7
kernel/trace/trace_events_trigger.c
··· 84 84 } 85 85 EXPORT_SYMBOL_GPL(event_triggers_call); 86 86 87 + bool __trace_trigger_soft_disabled(struct trace_event_file *file) 88 + { 89 + unsigned long eflags = file->flags; 90 + 91 + if (eflags & EVENT_FILE_FL_TRIGGER_MODE) 92 + event_triggers_call(file, NULL, NULL, NULL); 93 + if (eflags & EVENT_FILE_FL_SOFT_DISABLED) 94 + return true; 95 + if (eflags & EVENT_FILE_FL_PID_FILTER) 96 + return trace_event_ignore_this_pid(file); 97 + return false; 98 + } 99 + EXPORT_SYMBOL_GPL(__trace_trigger_soft_disabled); 100 + 87 101 /** 88 102 * event_triggers_post_call - Call 'post_triggers' for a trace event 89 103 * @file: The trace_event_file associated with the event ··· 1309 1295 struct trace_buffer *buffer, void *rec, 1310 1296 struct ring_buffer_event *event) 1311 1297 { 1298 + struct trace_event_file *file = data->private_data; 1299 + 1300 + if (file) { 1301 + if (tracer_tracing_is_on(file->tr)) 1302 + return; 1303 + 1304 + tracer_tracing_on(file->tr); 1305 + return; 1306 + } 1307 + 1312 1308 if (tracing_is_on()) 1313 1309 return; 1314 1310 ··· 1330 1306 struct trace_buffer *buffer, void *rec, 1331 1307 struct ring_buffer_event *event) 1332 1308 { 1333 - if (tracing_is_on()) 1334 - return; 1309 + struct trace_event_file *file = data->private_data; 1310 + 1311 + if (file) { 1312 + if (tracer_tracing_is_on(file->tr)) 1313 + return; 1314 + } else { 1315 + if (tracing_is_on()) 1316 + return; 1317 + } 1335 1318 1336 1319 if (!data->count) 1337 1320 return; ··· 1346 1315 if (data->count != -1) 1347 1316 (data->count)--; 1348 1317 1349 - tracing_on(); 1318 + if (file) 1319 + tracer_tracing_on(file->tr); 1320 + else 1321 + tracing_on(); 1350 1322 } 1351 1323 1352 1324 static void ··· 1357 1323 struct trace_buffer *buffer, void *rec, 1358 1324 struct ring_buffer_event *event) 1359 1325 { 1326 + struct trace_event_file *file = data->private_data; 1327 + 1328 + if (file) { 1329 + if (!tracer_tracing_is_on(file->tr)) 1330 + return; 1331 + 1332 + tracer_tracing_off(file->tr); 1333 + return; 1334 + } 1335 + 1360 1336 if (!tracing_is_on()) 1361 1337 return; 1362 1338 ··· 1378 1334 struct trace_buffer *buffer, void *rec, 1379 1335 struct ring_buffer_event *event) 1380 1336 { 1381 - if (!tracing_is_on()) 1382 - return; 1337 + struct trace_event_file *file = data->private_data; 1338 + 1339 + if (file) { 1340 + if (!tracer_tracing_is_on(file->tr)) 1341 + return; 1342 + } else { 1343 + if (!tracing_is_on()) 1344 + return; 1345 + } 1383 1346 1384 1347 if (!data->count) 1385 1348 return; ··· 1394 1343 if (data->count != -1) 1395 1344 (data->count)--; 1396 1345 1397 - tracing_off(); 1346 + if (file) 1347 + tracer_tracing_off(file->tr); 1348 + else 1349 + tracing_off(); 1398 1350 } 1399 1351 1400 1352 static int ··· 1594 1540 struct trace_buffer *buffer, void *rec, 1595 1541 struct ring_buffer_event *event) 1596 1542 { 1597 - trace_dump_stack(STACK_SKIP); 1543 + struct trace_event_file *file = data->private_data; 1544 + 1545 + if (file) 1546 + __trace_stack(file->tr, tracing_gen_ctx(), STACK_SKIP); 1547 + else 1548 + trace_dump_stack(STACK_SKIP); 1598 1549 } 1599 1550 1600 1551 static void
+32 -21
kernel/trace/trace_osnoise.c
··· 1437 1437 static struct cpumask save_cpumask; 1438 1438 1439 1439 /* 1440 + * osnoise_sleep - sleep until the next period 1441 + */ 1442 + static void osnoise_sleep(void) 1443 + { 1444 + u64 interval; 1445 + ktime_t wake_time; 1446 + 1447 + mutex_lock(&interface_lock); 1448 + interval = osnoise_data.sample_period - osnoise_data.sample_runtime; 1449 + mutex_unlock(&interface_lock); 1450 + 1451 + /* 1452 + * differently from hwlat_detector, the osnoise tracer can run 1453 + * without a pause because preemption is on. 1454 + */ 1455 + if (!interval) { 1456 + /* Let synchronize_rcu_tasks() make progress */ 1457 + cond_resched_tasks_rcu_qs(); 1458 + return; 1459 + } 1460 + 1461 + wake_time = ktime_add_us(ktime_get(), interval); 1462 + __set_current_state(TASK_INTERRUPTIBLE); 1463 + 1464 + while (schedule_hrtimeout_range(&wake_time, 0, HRTIMER_MODE_ABS)) { 1465 + if (kthread_should_stop()) 1466 + break; 1467 + } 1468 + } 1469 + 1470 + /* 1440 1471 * osnoise_main - The osnoise detection kernel thread 1441 1472 * 1442 1473 * Calls run_osnoise() function to measure the osnoise for the configured runtime, ··· 1475 1444 */ 1476 1445 static int osnoise_main(void *data) 1477 1446 { 1478 - u64 interval; 1479 1447 1480 1448 while (!kthread_should_stop()) { 1481 - 1482 1449 run_osnoise(); 1483 - 1484 - mutex_lock(&interface_lock); 1485 - interval = osnoise_data.sample_period - osnoise_data.sample_runtime; 1486 - mutex_unlock(&interface_lock); 1487 - 1488 - do_div(interval, USEC_PER_MSEC); 1489 - 1490 - /* 1491 - * differently from hwlat_detector, the osnoise tracer can run 1492 - * without a pause because preemption is on. 1493 - */ 1494 - if (interval < 1) { 1495 - /* Let synchronize_rcu_tasks() make progress */ 1496 - cond_resched_tasks_rcu_qs(); 1497 - continue; 1498 - } 1499 - 1500 - if (msleep_interruptible(interval)) 1501 - break; 1450 + osnoise_sleep(); 1502 1451 } 1503 1452 1504 1453 return 0;
+5 -5
kernel/trace/trace_probe.c
··· 871 871 switch (ptype) { 872 872 case PROBE_PRINT_NORMAL: 873 873 fmt = "(%lx)"; 874 - arg = "REC->" FIELD_STRING_IP; 874 + arg = ", REC->" FIELD_STRING_IP; 875 875 break; 876 876 case PROBE_PRINT_RETURN: 877 877 fmt = "(%lx <- %lx)"; 878 - arg = "REC->" FIELD_STRING_FUNC ", REC->" FIELD_STRING_RETIP; 878 + arg = ", REC->" FIELD_STRING_FUNC ", REC->" FIELD_STRING_RETIP; 879 879 break; 880 880 case PROBE_PRINT_EVENT: 881 - fmt = "(%u)"; 882 - arg = "REC->" FIELD_STRING_TYPE; 881 + fmt = ""; 882 + arg = ""; 883 883 break; 884 884 default: 885 885 WARN_ON_ONCE(1); ··· 903 903 parg->type->fmt); 904 904 } 905 905 906 - pos += snprintf(buf + pos, LEN_OR_ZERO, "\", %s", arg); 906 + pos += snprintf(buf + pos, LEN_OR_ZERO, "\"%s", arg); 907 907 908 908 for (i = 0; i < tp->nr_args; i++) { 909 909 parg = tp->args + i;
-1
kernel/trace/trace_probe.h
··· 38 38 #define FIELD_STRING_IP "__probe_ip" 39 39 #define FIELD_STRING_RETIP "__probe_ret_ip" 40 40 #define FIELD_STRING_FUNC "__probe_func" 41 - #define FIELD_STRING_TYPE "__probe_type" 42 41 43 42 #undef DEFINE_FIELD 44 43 #define DEFINE_FIELD(type, item, name, is_signed) \
+2 -4
kernel/trace/trace_selftest.c
··· 784 784 .retfunc = &trace_graph_return, 785 785 }; 786 786 787 - #if defined(CONFIG_DYNAMIC_FTRACE) && \ 788 - defined(CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS) 789 - #define TEST_DIRECT_TRAMP 787 + #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS 790 788 noinline __noclone static void trace_direct_tramp(void) { } 791 789 #endif 792 790 ··· 847 849 goto out; 848 850 } 849 851 850 - #ifdef TEST_DIRECT_TRAMP 852 + #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS 851 853 tracing_reset_online_cpus(&tr->array_buffer); 852 854 set_graph_array(tr); 853 855
+1 -1
tools/tracing/rtla/src/osnoise.c
··· 810 810 811 811 retval = enable_tracer_by_name(trace->trace.inst, tracer); 812 812 if (retval) { 813 - err_msg("Could not enable osnoiser tracer for tracing\n"); 813 + err_msg("Could not enable %s tracer for tracing\n", tracer); 814 814 goto out_err; 815 815 } 816 816
+5 -5
tools/tracing/rtla/src/osnoise_hist.c
··· 426 426 static const char * const msg[] = { 427 427 "", 428 428 " usage: rtla osnoise hist [-h] [-D] [-d s] [-p us] [-r us] [-s us] [-S us] [-t[=file]] \\", 429 - " [-c cpu-list] [-P priority] [-b N] [-e N] [--no-header] [--no-summary] \\", 429 + " [-c cpu-list] [-P priority] [-b N] [-E N] [--no-header] [--no-summary] \\", 430 430 " [--no-index] [--with-zeros]", 431 431 "", 432 432 " -h/--help: print this menu", ··· 439 439 " -D/--debug: print debug info", 440 440 " -t/--trace[=file]: save the stopped trace to [file|osnoise_trace.txt]", 441 441 " -b/--bucket-size N: set the histogram bucket size (default 1)", 442 - " -e/--entries N: set the number of entries of the histogram (default 256)", 442 + " -E/--entries N: set the number of entries of the histogram (default 256)", 443 443 " --no-header: do not print header", 444 444 " --no-summary: do not print summary", 445 445 " --no-index: do not print index", ··· 486 486 while (1) { 487 487 static struct option long_options[] = { 488 488 {"bucket-size", required_argument, 0, 'b'}, 489 - {"entries", required_argument, 0, 'e'}, 489 + {"entries", required_argument, 0, 'E'}, 490 490 {"cpus", required_argument, 0, 'c'}, 491 491 {"debug", no_argument, 0, 'D'}, 492 492 {"duration", required_argument, 0, 'd'}, ··· 507 507 /* getopt_long stores the option index here. */ 508 508 int option_index = 0; 509 509 510 - c = getopt_long(argc, argv, "c:b:d:e:Dhp:P:r:s:S:t::0123", 510 + c = getopt_long(argc, argv, "c:b:d:E:Dhp:P:r:s:S:t::0123", 511 511 long_options, &option_index); 512 512 513 513 /* detect the end of the options. */ ··· 534 534 if (!params->duration) 535 535 osnoise_hist_usage("Invalid -D duration\n"); 536 536 break; 537 - case 'e': 537 + case 'E': 538 538 params->entries = get_llong_from_str(optarg); 539 539 if ((params->entries < 10) || (params->entries > 9999999)) 540 540 osnoise_hist_usage("Entries must be > 10 and < 9999999\n");
+1
tools/tracing/rtla/src/osnoise_top.c
··· 573 573 osnoise_free_top(tool->data); 574 574 osnoise_destroy_tool(record); 575 575 osnoise_destroy_tool(tool); 576 + free(params); 576 577 out_exit: 577 578 exit(return_value); 578 579 }
+5 -5
tools/tracing/rtla/src/timerlat_hist.c
··· 429 429 char *msg[] = { 430 430 "", 431 431 " usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-p us] [-i us] [-T us] [-s us] [-t[=file]] \\", 432 - " [-c cpu-list] [-P priority] [-e N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\", 432 + " [-c cpu-list] [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\", 433 433 " [--no-index] [--with-zeros]", 434 434 "", 435 435 " -h/--help: print this menu", ··· 443 443 " -T/--trace[=file]: save the stopped trace to [file|timerlat_trace.txt]", 444 444 " -n/--nano: display data in nanoseconds", 445 445 " -b/--bucket-size N: set the histogram bucket size (default 1)", 446 - " -e/--entries N: set the number of entries of the histogram (default 256)", 446 + " -E/--entries N: set the number of entries of the histogram (default 256)", 447 447 " --no-irq: ignore IRQ latencies", 448 448 " --no-thread: ignore thread latencies", 449 449 " --no-header: do not print header", ··· 494 494 {"cpus", required_argument, 0, 'c'}, 495 495 {"bucket-size", required_argument, 0, 'b'}, 496 496 {"debug", no_argument, 0, 'D'}, 497 - {"entries", required_argument, 0, 'e'}, 497 + {"entries", required_argument, 0, 'E'}, 498 498 {"duration", required_argument, 0, 'd'}, 499 499 {"help", no_argument, 0, 'h'}, 500 500 {"irq", required_argument, 0, 'i'}, ··· 516 516 /* getopt_long stores the option index here. */ 517 517 int option_index = 0; 518 518 519 - c = getopt_long(argc, argv, "c:b:d:e:Dhi:np:P:s:t::T:012345", 519 + c = getopt_long(argc, argv, "c:b:d:E:Dhi:np:P:s:t::T:012345", 520 520 long_options, &option_index); 521 521 522 522 /* detect the end of the options. */ ··· 543 543 if (!params->duration) 544 544 timerlat_hist_usage("Invalid -D duration\n"); 545 545 break; 546 - case 'e': 546 + case 'E': 547 547 params->entries = get_llong_from_str(optarg); 548 548 if ((params->entries < 10) || (params->entries > 9999999)) 549 549 timerlat_hist_usage("Entries must be > 10 and < 9999999\n");