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

Pull tracing fixes from Steven Rostedt:

- Fix bootconfig causing kernels to fail with CONFIG_BLK_DEV_RAM
enabled

- Fix allocation leaks in bootconfig tool

- Fix a double initialization of a variable

- Fix API bootconfig usage from kprobe boot time events

- Reject NULL location for kprobes

- Fix crash caused by preempt delay module not cleaning up kthread
correctly

- Add vmalloc_sync_mappings() to prevent x86_64 page faults from
recursively faulting from tracing page faults

- Fix comment in gpu/trace kerneldoc header

- Fix documentation of how to create a trace event class

- Make the local tracing_snapshot_instance_cond() function static

* tag 'trace-v5.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
tools/bootconfig: Fix resource leak in apply_xbc()
tracing: Make tracing_snapshot_instance_cond() static
tracing: Fix doc mistakes in trace sample
gpu/trace: Minor comment updates for gpu_mem_total tracepoint
tracing: Add a vmalloc_sync_mappings() for safe measure
tracing: Wait for preempt irq delay thread to finish
tracing/kprobes: Reject new event if loc is NULL
tracing/boottime: Fix kprobe event API usage
tracing/kprobes: Fix a double initialization typo
bootconfig: Fix to remove bootconfig data from initrd while boot

+116 -44
+1 -1
include/trace/events/gpu_mem.h
··· 24 24 * 25 25 * @pid: Put 0 for global total, while positive pid for process total. 26 26 * 27 - * @size: Virtual size of the allocation in bytes. 27 + * @size: Size of the allocation in bytes. 28 28 * 29 29 */ 30 30 TRACE_EVENT(gpu_mem_total,
+52 -17
init/main.c
··· 257 257 258 258 early_param("loglevel", loglevel); 259 259 260 + #ifdef CONFIG_BLK_DEV_INITRD 261 + static void * __init get_boot_config_from_initrd(u32 *_size, u32 *_csum) 262 + { 263 + u32 size, csum; 264 + char *data; 265 + u32 *hdr; 266 + 267 + if (!initrd_end) 268 + return NULL; 269 + 270 + data = (char *)initrd_end - BOOTCONFIG_MAGIC_LEN; 271 + if (memcmp(data, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN)) 272 + return NULL; 273 + 274 + hdr = (u32 *)(data - 8); 275 + size = hdr[0]; 276 + csum = hdr[1]; 277 + 278 + data = ((void *)hdr) - size; 279 + if ((unsigned long)data < initrd_start) { 280 + pr_err("bootconfig size %d is greater than initrd size %ld\n", 281 + size, initrd_end - initrd_start); 282 + return NULL; 283 + } 284 + 285 + /* Remove bootconfig from initramfs/initrd */ 286 + initrd_end = (unsigned long)data; 287 + if (_size) 288 + *_size = size; 289 + if (_csum) 290 + *_csum = csum; 291 + 292 + return data; 293 + } 294 + #else 295 + static void * __init get_boot_config_from_initrd(u32 *_size, u32 *_csum) 296 + { 297 + return NULL; 298 + } 299 + #endif 300 + 260 301 #ifdef CONFIG_BOOT_CONFIG 261 302 262 303 char xbc_namebuf[XBC_KEYLEN_MAX] __initdata; ··· 398 357 int pos; 399 358 u32 size, csum; 400 359 char *data, *copy; 401 - u32 *hdr; 402 360 int ret; 361 + 362 + data = get_boot_config_from_initrd(&size, &csum); 363 + if (!data) 364 + goto not_found; 403 365 404 366 strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); 405 367 parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL, ··· 411 367 if (!bootconfig_found) 412 368 return; 413 369 414 - if (!initrd_end) 415 - goto not_found; 416 - 417 - data = (char *)initrd_end - BOOTCONFIG_MAGIC_LEN; 418 - if (memcmp(data, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN)) 419 - goto not_found; 420 - 421 - hdr = (u32 *)(data - 8); 422 - size = hdr[0]; 423 - csum = hdr[1]; 424 - 425 370 if (size >= XBC_DATA_MAX) { 426 371 pr_err("bootconfig size %d greater than max size %d\n", 427 372 size, XBC_DATA_MAX); 428 373 return; 429 374 } 430 - 431 - data = ((void *)hdr) - size; 432 - if ((unsigned long)data < initrd_start) 433 - goto not_found; 434 375 435 376 if (boot_config_checksum((unsigned char *)data, size) != csum) { 436 377 pr_err("bootconfig checksum failed\n"); ··· 449 420 not_found: 450 421 pr_err("'bootconfig' found on command line, but no bootconfig found\n"); 451 422 } 423 + 452 424 #else 453 - #define setup_boot_config(cmdline) do { } while (0) 425 + 426 + static void __init setup_boot_config(const char *cmdline) 427 + { 428 + /* Remove bootconfig data from initrd */ 429 + get_boot_config_from_initrd(NULL, NULL); 430 + } 454 431 455 432 static int __init warn_bootconfig(char *str) 456 433 {
+24 -6
kernel/trace/preemptirq_delay_test.c
··· 113 113 114 114 for (i = 0; i < s; i++) 115 115 (testfuncs[i])(i); 116 + 117 + set_current_state(TASK_INTERRUPTIBLE); 118 + while (!kthread_should_stop()) { 119 + schedule(); 120 + set_current_state(TASK_INTERRUPTIBLE); 121 + } 122 + 123 + __set_current_state(TASK_RUNNING); 124 + 116 125 return 0; 117 126 } 118 127 119 - static struct task_struct *preemptirq_start_test(void) 128 + static int preemptirq_run_test(void) 120 129 { 130 + struct task_struct *task; 131 + 121 132 char task_name[50]; 122 133 123 134 snprintf(task_name, sizeof(task_name), "%s_test", test_mode); 124 - return kthread_run(preemptirq_delay_run, NULL, task_name); 135 + task = kthread_run(preemptirq_delay_run, NULL, task_name); 136 + if (IS_ERR(task)) 137 + return PTR_ERR(task); 138 + if (task) 139 + kthread_stop(task); 140 + return 0; 125 141 } 126 142 127 143 128 144 static ssize_t trigger_store(struct kobject *kobj, struct kobj_attribute *attr, 129 145 const char *buf, size_t count) 130 146 { 131 - preemptirq_start_test(); 147 + ssize_t ret; 148 + 149 + ret = preemptirq_run_test(); 150 + if (ret) 151 + return ret; 132 152 return count; 133 153 } 134 154 ··· 168 148 169 149 static int __init preemptirq_delay_init(void) 170 150 { 171 - struct task_struct *test_task; 172 151 int retval; 173 152 174 - test_task = preemptirq_start_test(); 175 - retval = PTR_ERR_OR_ZERO(test_task); 153 + retval = preemptirq_run_test(); 176 154 if (retval != 0) 177 155 return retval; 178 156
+15 -1
kernel/trace/trace.c
··· 947 947 EXPORT_SYMBOL_GPL(__trace_bputs); 948 948 949 949 #ifdef CONFIG_TRACER_SNAPSHOT 950 - void tracing_snapshot_instance_cond(struct trace_array *tr, void *cond_data) 950 + static void tracing_snapshot_instance_cond(struct trace_array *tr, 951 + void *cond_data) 951 952 { 952 953 struct tracer *tracer = tr->current_trace; 953 954 unsigned long flags; ··· 8526 8525 */ 8527 8526 allocate_snapshot = false; 8528 8527 #endif 8528 + 8529 + /* 8530 + * Because of some magic with the way alloc_percpu() works on 8531 + * x86_64, we need to synchronize the pgd of all the tables, 8532 + * otherwise the trace events that happen in x86_64 page fault 8533 + * handlers can't cope with accessing the chance that a 8534 + * alloc_percpu()'d memory might be touched in the page fault trace 8535 + * event. Oh, and we need to audit all other alloc_percpu() and vmalloc() 8536 + * calls in tracing, because something might get triggered within a 8537 + * page fault trace event! 8538 + */ 8539 + vmalloc_sync_mappings(); 8540 + 8529 8541 return 0; 8530 8542 } 8531 8543
+10 -14
kernel/trace/trace_boot.c
··· 95 95 struct xbc_node *anode; 96 96 char buf[MAX_BUF_LEN]; 97 97 const char *val; 98 - int ret; 99 - 100 - kprobe_event_cmd_init(&cmd, buf, MAX_BUF_LEN); 101 - 102 - ret = kprobe_event_gen_cmd_start(&cmd, event, NULL); 103 - if (ret) 104 - return ret; 98 + int ret = 0; 105 99 106 100 xbc_node_for_each_array_value(node, "probes", anode, val) { 107 - ret = kprobe_event_add_field(&cmd, val); 108 - if (ret) 109 - return ret; 110 - } 101 + kprobe_event_cmd_init(&cmd, buf, MAX_BUF_LEN); 111 102 112 - ret = kprobe_event_gen_cmd_end(&cmd); 113 - if (ret) 114 - pr_err("Failed to add probe: %s\n", buf); 103 + ret = kprobe_event_gen_cmd_start(&cmd, event, val); 104 + if (ret) 105 + break; 106 + 107 + ret = kprobe_event_gen_cmd_end(&cmd); 108 + if (ret) 109 + pr_err("Failed to add probe: %s\n", buf); 110 + } 115 111 116 112 return ret; 117 113 }
+7 -1
kernel/trace/trace_kprobe.c
··· 453 453 454 454 static bool within_notrace_func(struct trace_kprobe *tk) 455 455 { 456 - unsigned long addr = addr = trace_kprobe_address(tk); 456 + unsigned long addr = trace_kprobe_address(tk); 457 457 char symname[KSYM_NAME_LEN], *p; 458 458 459 459 if (!__within_notrace_func(addr)) ··· 940 940 * complete command or only the first part of it; in the latter case, 941 941 * kprobe_event_add_fields() can be used to add more fields following this. 942 942 * 943 + * Unlikely the synth_event_gen_cmd_start(), @loc must be specified. This 944 + * returns -EINVAL if @loc == NULL. 945 + * 943 946 * Return: 0 if successful, error otherwise. 944 947 */ 945 948 int __kprobe_event_gen_cmd_start(struct dynevent_cmd *cmd, bool kretprobe, ··· 954 951 int ret; 955 952 956 953 if (cmd->type != DYNEVENT_TYPE_KPROBE) 954 + return -EINVAL; 955 + 956 + if (!loc) 957 957 return -EINVAL; 958 958 959 959 if (kretprobe)
+1 -1
samples/trace_events/trace-events-sample.h
··· 416 416 * Note, TRACE_EVENT() itself is simply defined as: 417 417 * 418 418 * #define TRACE_EVENT(name, proto, args, tstruct, assign, printk) \ 419 - * DEFINE_EVENT_CLASS(name, proto, args, tstruct, assign, printk); \ 419 + * DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, printk); \ 420 420 * DEFINE_EVENT(name, name, proto, args) 421 421 * 422 422 * The DEFINE_EVENT() also can be declared with conditions and reg functions:
+6 -3
tools/bootconfig/main.c
··· 314 314 ret = delete_xbc(path); 315 315 if (ret < 0) { 316 316 pr_err("Failed to delete previous boot config: %d\n", ret); 317 + free(data); 317 318 return ret; 318 319 } 319 320 ··· 322 321 fd = open(path, O_RDWR | O_APPEND); 323 322 if (fd < 0) { 324 323 pr_err("Failed to open %s: %d\n", path, fd); 324 + free(data); 325 325 return fd; 326 326 } 327 327 /* TODO: Ensure the @path is initramfs/initrd image */ 328 328 ret = write(fd, data, size + 8); 329 329 if (ret < 0) { 330 330 pr_err("Failed to apply a boot config: %d\n", ret); 331 - return ret; 331 + goto out; 332 332 } 333 333 /* Write a magic word of the bootconfig */ 334 334 ret = write(fd, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN); 335 335 if (ret < 0) { 336 336 pr_err("Failed to apply a boot config magic: %d\n", ret); 337 - return ret; 337 + goto out; 338 338 } 339 + out: 339 340 close(fd); 340 341 free(data); 341 342 342 - return 0; 343 + return ret; 343 344 } 344 345 345 346 int usage(void)