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-v5.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull more tracing updates from Steven Rostedt:

- Add migrate-disable counter to tracing header

- Fix error handling in event probes

- Fix missed unlock in osnoise in error path

- Fix merge issue with tools/bootconfig

- Clean up bootconfig data when init memory is removed

- Fix bootconfig to loop only on subkeys

- Have kernel command lines override bootconfig options

- Increase field counts for synthetic events

- Have histograms dynamic allocate event elements to save space

- Fixes in testing and documentation

* tag 'trace-v5.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
tracing/boot: Fix to loop on only subkeys
selftests/ftrace: Exclude "(fault)" in testing add/remove eprobe events
tracing: Dynamically allocate the per-elt hist_elt_data array
tracing: synth events: increase max fields count
tools/bootconfig: Show whole test command for each test case
bootconfig: Fix missing return check of xbc_node_compose_key function
tools/bootconfig: Fix tracing_on option checking in ftrace2bconf.sh
docs: bootconfig: Add how to use bootconfig for kernel parameters
init/bootconfig: Reorder init parameter from bootconfig and cmdline
init: bootconfig: Remove all bootconfig data when the init memory is removed
tracing/osnoise: Fix missed cpus_read_unlock() in start_per_cpu_kthreads()
tracing: Fix some alloc_event_probe() error handling bugs
tracing: Add migrate-disabled counter to tracing output.

+122 -39
+38 -1
Documentation/admin-guide/bootconfig.rst
··· 178 178 loader passes the correct initrd file size. If by any chance, the boot 179 179 loader passes a longer size, the kernel fails to find the bootconfig data. 180 180 181 - To do this operation, Linux kernel provides "bootconfig" command under 181 + To do this operation, Linux kernel provides ``bootconfig`` command under 182 182 tools/bootconfig, which allows admin to apply or delete the config file 183 183 to/from initrd image. You can build it by the following command:: 184 184 ··· 195 195 196 196 Then add "bootconfig" on the normal kernel command line to tell the 197 197 kernel to look for the bootconfig at the end of the initrd file. 198 + 199 + 200 + Kernel parameters via Boot Config 201 + ================================= 202 + 203 + In addition to the kernel command line, the boot config can be used for 204 + passing the kernel parameters. All the key-value pairs under ``kernel`` 205 + key will be passed to kernel cmdline directly. Moreover, the key-value 206 + pairs under ``init`` will be passed to init process via the cmdline. 207 + The parameters are concatinated with user-given kernel cmdline string 208 + as the following order, so that the command line parameter can override 209 + bootconfig parameters (this depends on how the subsystem handles parameters 210 + but in general, earlier parameter will be overwritten by later one.):: 211 + 212 + [bootconfig params][cmdline params] -- [bootconfig init params][cmdline init params] 213 + 214 + Here is an example of the bootconfig file for kernel/init parameters.:: 215 + 216 + kernel { 217 + root = 01234567-89ab-cdef-0123-456789abcd 218 + } 219 + init { 220 + splash 221 + } 222 + 223 + This will be copied into the kernel cmdline string as the following:: 224 + 225 + root="01234567-89ab-cdef-0123-456789abcd" -- splash 226 + 227 + If user gives some other command line like,:: 228 + 229 + ro bootconfig -- quiet 230 + 231 + The final kernel cmdline will be the following:: 232 + 233 + root="01234567-89ab-cdef-0123-456789abcd" ro bootconfig -- splash quiet 234 + 198 235 199 236 Config File Limitation 200 237 ======================
+26 -11
init/main.c
··· 153 153 #ifdef CONFIG_BOOT_CONFIG 154 154 /* Is bootconfig on command line? */ 155 155 static bool bootconfig_found; 156 - static bool initargs_found; 156 + static size_t initargs_offs; 157 157 #else 158 158 # define bootconfig_found false 159 - # define initargs_found false 159 + # define initargs_offs 0 160 160 #endif 161 161 162 162 static char *execute_command; ··· 422 422 if (IS_ERR(err) || !bootconfig_found) 423 423 return; 424 424 425 - /* parse_args() stops at '--' and returns an address */ 425 + /* parse_args() stops at the next param of '--' and returns an address */ 426 426 if (err) 427 - initargs_found = true; 427 + initargs_offs = err - tmp_cmdline; 428 428 429 429 if (!data) { 430 430 pr_err("'bootconfig' found on command line, but no bootconfig found\n"); ··· 468 468 return; 469 469 } 470 470 471 - #else 471 + static void __init exit_boot_config(void) 472 + { 473 + xbc_destroy_all(); 474 + } 475 + 476 + #else /* !CONFIG_BOOT_CONFIG */ 472 477 473 478 static void __init setup_boot_config(void) 474 479 { ··· 486 481 pr_warn("WARNING: 'bootconfig' found on the kernel command line but CONFIG_BOOT_CONFIG is not set.\n"); 487 482 return 0; 488 483 } 489 - #endif 484 + 485 + #define exit_boot_config() do {} while (0) 486 + 487 + #endif /* CONFIG_BOOT_CONFIG */ 488 + 490 489 early_param("bootconfig", warn_bootconfig); 491 490 492 491 /* Change NUL term back to "=", to make "param" the whole string. */ ··· 655 646 * Append supplemental init boot args to saved_command_line 656 647 * so that user can check what command line options passed 657 648 * to init. 649 + * The order should always be 650 + * " -- "[bootconfig init-param][cmdline init-param] 658 651 */ 659 - len = strlen(saved_command_line); 660 - if (initargs_found) { 661 - saved_command_line[len++] = ' '; 652 + if (initargs_offs) { 653 + len = xlen + initargs_offs; 654 + strcpy(saved_command_line + len, extra_init_args); 655 + len += ilen - 4; /* strlen(extra_init_args) */ 656 + strcpy(saved_command_line + len, 657 + boot_command_line + initargs_offs - 1); 662 658 } else { 659 + len = strlen(saved_command_line); 663 660 strcpy(saved_command_line + len, " -- "); 664 661 len += 4; 662 + strcpy(saved_command_line + len, extra_init_args); 665 663 } 666 - 667 - strcpy(saved_command_line + len, extra_init_args); 668 664 } 669 665 } 670 666 ··· 1508 1494 kprobe_free_init_mem(); 1509 1495 ftrace_free_init_mem(); 1510 1496 kgdb_free_init_mem(); 1497 + exit_boot_config(); 1511 1498 free_initmem(); 1512 1499 mark_readonly(); 1513 1500
+19 -7
kernel/trace/trace.c
··· 2603 2603 } 2604 2604 EXPORT_SYMBOL_GPL(trace_handle_return); 2605 2605 2606 + static unsigned short migration_disable_value(void) 2607 + { 2608 + #if defined(CONFIG_SMP) 2609 + return current->migration_disabled; 2610 + #else 2611 + return 0; 2612 + #endif 2613 + } 2614 + 2606 2615 unsigned int tracing_gen_ctx_irq_test(unsigned int irqs_status) 2607 2616 { 2608 2617 unsigned int trace_flags = irqs_status; ··· 2630 2621 trace_flags |= TRACE_FLAG_NEED_RESCHED; 2631 2622 if (test_preempt_need_resched()) 2632 2623 trace_flags |= TRACE_FLAG_PREEMPT_RESCHED; 2633 - return (trace_flags << 16) | (pc & 0xff); 2624 + return (trace_flags << 16) | (min_t(unsigned int, pc & 0xff, 0xf)) | 2625 + (min_t(unsigned int, migration_disable_value(), 0xf)) << 4; 2634 2626 } 2635 2627 2636 2628 struct ring_buffer_event * ··· 4199 4189 "# | / _----=> need-resched \n" 4200 4190 "# || / _---=> hardirq/softirq \n" 4201 4191 "# ||| / _--=> preempt-depth \n" 4202 - "# |||| / delay \n" 4203 - "# cmd pid ||||| time | caller \n" 4204 - "# \\ / ||||| \\ | / \n"); 4192 + "# |||| / _-=> migrate-disable \n" 4193 + "# ||||| / delay \n" 4194 + "# cmd pid |||||| time | caller \n" 4195 + "# \\ / |||||| \\ | / \n"); 4205 4196 } 4206 4197 4207 4198 static void print_event_info(struct array_buffer *buf, struct seq_file *m) ··· 4240 4229 seq_printf(m, "# %.*s / _----=> need-resched\n", prec, space); 4241 4230 seq_printf(m, "# %.*s| / _---=> hardirq/softirq\n", prec, space); 4242 4231 seq_printf(m, "# %.*s|| / _--=> preempt-depth\n", prec, space); 4243 - seq_printf(m, "# %.*s||| / delay\n", prec, space); 4244 - seq_printf(m, "# TASK-PID %.*s CPU# |||| TIMESTAMP FUNCTION\n", prec, " TGID "); 4245 - seq_printf(m, "# | | %.*s | |||| | |\n", prec, " | "); 4232 + seq_printf(m, "# %.*s||| / _-=> migrate-disable\n", prec, space); 4233 + seq_printf(m, "# %.*s|||| / delay\n", prec, space); 4234 + seq_printf(m, "# TASK-PID %.*s CPU# ||||| TIMESTAMP FUNCTION\n", prec, " TGID "); 4235 + seq_printf(m, "# | | %.*s | ||||| | |\n", prec, " | "); 4246 4236 } 4247 4237 4248 4238 void
+3 -3
kernel/trace/trace_boot.c
··· 522 522 if (!node) 523 523 return; 524 524 /* per-event key starts with "event.GROUP.EVENT" */ 525 - xbc_node_for_each_child(node, gnode) { 525 + xbc_node_for_each_subkey(node, gnode) { 526 526 data = xbc_node_get_data(gnode); 527 527 if (!strcmp(data, "enable")) { 528 528 enable_all = true; 529 529 continue; 530 530 } 531 531 enable = false; 532 - xbc_node_for_each_child(gnode, enode) { 532 + xbc_node_for_each_subkey(gnode, enode) { 533 533 data = xbc_node_get_data(enode); 534 534 if (!strcmp(data, "enable")) { 535 535 enable = true; ··· 625 625 if (!node) 626 626 return; 627 627 628 - xbc_node_for_each_child(node, inode) { 628 + xbc_node_for_each_subkey(node, inode) { 629 629 p = xbc_node_get_data(inode); 630 630 if (!p || *p == '\0') 631 631 continue;
+3 -2
kernel/trace/trace_eprobe.c
··· 151 151 152 152 ep = kzalloc(struct_size(ep, tp.args, nargs), GFP_KERNEL); 153 153 if (!ep) { 154 - trace_event_put_ref(ep->event); 154 + trace_event_put_ref(event); 155 155 goto error; 156 156 } 157 157 ep->event = event; ··· 851 851 ret = PTR_ERR(ep); 852 852 /* This must return -ENOMEM, else there is a bug */ 853 853 WARN_ON_ONCE(ret != -ENOMEM); 854 - goto error; /* We know ep is not allocated */ 854 + ep = NULL; 855 + goto error; 855 856 } 856 857 857 858 argc -= 2; argv += 2;
+1
kernel/trace/trace_events.c
··· 181 181 182 182 __common_field(unsigned short, type); 183 183 __common_field(unsigned char, flags); 184 + /* Holds both preempt_count and migrate_disable */ 184 185 __common_field(unsigned char, preempt_count); 185 186 __common_field(int, pid); 186 187
+12 -2
kernel/trace/trace_events_hist.c
··· 508 508 struct hist_elt_data { 509 509 char *comm; 510 510 u64 *var_ref_vals; 511 - char *field_var_str[SYNTH_FIELDS_MAX]; 511 + char **field_var_str; 512 + int n_field_var_str; 512 513 }; 513 514 514 515 struct snapshot_context { ··· 1402 1401 { 1403 1402 unsigned int i; 1404 1403 1405 - for (i = 0; i < SYNTH_FIELDS_MAX; i++) 1404 + for (i = 0; i < elt_data->n_field_var_str; i++) 1406 1405 kfree(elt_data->field_var_str[i]); 1406 + 1407 + kfree(elt_data->field_var_str); 1407 1408 1408 1409 kfree(elt_data->comm); 1409 1410 kfree(elt_data); ··· 1453 1450 BUILD_BUG_ON(STR_VAR_LEN_MAX & (sizeof(u64) - 1)); 1454 1451 1455 1452 size = STR_VAR_LEN_MAX; 1453 + 1454 + elt_data->field_var_str = kcalloc(n_str, sizeof(char *), GFP_KERNEL); 1455 + if (!elt_data->field_var_str) { 1456 + hist_elt_data_free(elt_data); 1457 + return -EINVAL; 1458 + } 1459 + elt_data->n_field_var_str = n_str; 1456 1460 1457 1461 for (i = 0; i < n_str; i++) { 1458 1462 elt_data->field_var_str[i] = kzalloc(size, GFP_KERNEL);
+3 -3
kernel/trace/trace_osnoise.c
··· 1548 1548 static int start_per_cpu_kthreads(struct trace_array *tr) 1549 1549 { 1550 1550 struct cpumask *current_mask = &save_cpumask; 1551 - int retval; 1551 + int retval = 0; 1552 1552 int cpu; 1553 1553 1554 1554 cpus_read_lock(); ··· 1568 1568 retval = start_kthread(cpu); 1569 1569 if (retval) { 1570 1570 stop_per_cpu_kthreads(); 1571 - return retval; 1571 + break; 1572 1572 } 1573 1573 } 1574 1574 1575 1575 cpus_read_unlock(); 1576 1576 1577 - return 0; 1577 + return retval; 1578 1578 } 1579 1579 1580 1580 #ifdef CONFIG_HOTPLUG_CPU
+8 -3
kernel/trace/trace_output.c
··· 492 492 trace_seq_printf(s, "%c%c%c", 493 493 irqs_off, need_resched, hardsoft_irq); 494 494 495 - if (entry->preempt_count) 496 - trace_seq_printf(s, "%x", entry->preempt_count); 495 + if (entry->preempt_count & 0xf) 496 + trace_seq_printf(s, "%x", entry->preempt_count & 0xf); 497 + else 498 + trace_seq_putc(s, '.'); 499 + 500 + if (entry->preempt_count & 0xf0) 501 + trace_seq_printf(s, "%x", entry->preempt_count >> 4); 497 502 else 498 503 trace_seq_putc(s, '.'); 499 504 ··· 661 656 trace_seq_printf( 662 657 s, "%16s %7d %3d %d %08x %08lx ", 663 658 comm, entry->pid, iter->cpu, entry->flags, 664 - entry->preempt_count, iter->idx); 659 + entry->preempt_count & 0xf, iter->idx); 665 660 } else { 666 661 lat_print_generic(s, entry, iter->cpu); 667 662 }
+1 -1
kernel/trace/trace_synth.h
··· 5 5 #include "trace_dynevent.h" 6 6 7 7 #define SYNTH_SYSTEM "synthetic" 8 - #define SYNTH_FIELDS_MAX 32 8 + #define SYNTH_FIELDS_MAX 64 9 9 10 10 #define STR_VAR_LEN_MAX MAX_FILTER_STR_VAL /* must be multiple of sizeof(u64) */ 11 11
+3 -1
tools/bootconfig/main.c
··· 111 111 char key[XBC_KEYLEN_MAX]; 112 112 struct xbc_node *leaf; 113 113 const char *val; 114 + int ret; 114 115 115 116 xbc_for_each_key_value(leaf, val) { 116 - if (xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX) < 0) { 117 + ret = xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX); 118 + if (ret < 0) { 117 119 fprintf(stderr, "Failed to compose key %d\n", ret); 118 120 break; 119 121 }
+2 -2
tools/bootconfig/scripts/ftrace2bconf.sh
··· 239 239 emit_kv $PREFIX.cpumask = $val 240 240 fi 241 241 val=`cat $INSTANCE/tracing_on` 242 - if [ `echo $val | sed -e s/f//g`x != x ]; then 243 - emit_kv $PREFIX.tracing_on = $val 242 + if [ "$val" = "0" ]; then 243 + emit_kv $PREFIX.tracing_on = 0 244 244 fi 245 245 246 246 val=`cat $INSTANCE/current_tracer`
+2 -2
tools/bootconfig/test-bootconfig.sh
··· 26 26 NO=1 27 27 28 28 xpass() { # pass test command 29 - echo "test case $NO ($3)... " 29 + echo "test case $NO ($*)... " 30 30 if ! ($@ && echo "\t\t[OK]"); then 31 31 echo "\t\t[NG]"; NG=$((NG + 1)) 32 32 fi ··· 34 34 } 35 35 36 36 xfail() { # fail test command 37 - echo "test case $NO ($3)... " 37 + echo "test case $NO ($*)... " 38 38 if ! (! $@ && echo "\t\t[OK]"); then 39 39 echo "\t\t[NG]"; NG=$((NG + 1)) 40 40 fi
+1 -1
tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc
··· 22 22 echo 0 > events/eprobes/$EPROBE/enable 23 23 24 24 content=`grep '^ *ls-' trace | grep 'file='` 25 - nocontent=`grep '^ *ls-' trace | grep 'file=' | grep -v -e '"/' -e '"."'` || true 25 + nocontent=`grep '^ *ls-' trace | grep 'file=' | grep -v -e '"/' -e '"."' -e '(fault)' ` || true 26 26 27 27 if [ -z "$content" ]; then 28 28 exit_fail