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

Pull tracing fixes from Steven Rostedt:

- Fix tp_printk command line option crashing the kernel

With the code that can handle a buffer from a previous boot, the
trace_check_vprintf() needed access to the delta of the address space
used by the old buffer and the current buffer. To do so, the
trace_array (tr) parameter was used. But when tp_printk is enabled on
the kernel command line, no trace buffer is used and the trace event
is sent directly to printk(). That meant the tr field of the iterator
descriptor was NULL, and since tp_printk still uses
trace_check_vprintf() it caused a NULL dereference.

- Add ptrace.h include to x86 ftrace file for completeness

- Fix rtla installation when done with out-of-tree build

- Fix the help messages in rtla that were incorrect

- Several fixes to fix races with the timerlat and hwlat code

Several locking issues were discovered with the coordination between
timerlat kthread creation and hotplug. As timerlat has callbacks from
hotplug code to start kthreads when CPUs come online. There are also
locking issues with grabbing the cpu_read_lock() and the locks within
timerlat.

* tag 'trace-v6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
tracing/hwlat: Fix a race during cpuhp processing
tracing/timerlat: Fix a race during cpuhp processing
tracing/timerlat: Drop interface_lock in stop_kthread()
tracing/timerlat: Fix duplicated kthread creation due to CPU online/offline
x86/ftrace: Include <asm/ptrace.h>
rtla: Fix the help text in osnoise and timerlat top tools
tools/rtla: Fix installation from out-of-tree build
tracing: Fix trace_check_vprintf() when tp_printk is used

+34 -15
+2
arch/x86/include/asm/ftrace.h
··· 2 2 #ifndef _ASM_X86_FTRACE_H 3 3 #define _ASM_X86_FTRACE_H 4 4 5 + #include <asm/ptrace.h> 6 + 5 7 #ifdef CONFIG_FUNCTION_TRACER 6 8 #ifndef CC_USING_FENTRY 7 9 # error Compiler does not support fentry?
+13 -2
kernel/trace/trace.c
··· 3697 3697 void trace_check_vprintf(struct trace_iterator *iter, const char *fmt, 3698 3698 va_list ap) 3699 3699 { 3700 - long text_delta = iter->tr->text_delta; 3701 - long data_delta = iter->tr->data_delta; 3700 + long text_delta = 0; 3701 + long data_delta = 0; 3702 3702 const char *p = fmt; 3703 3703 const char *str; 3704 3704 bool good; ··· 3709 3709 3710 3710 if (static_branch_unlikely(&trace_no_verify)) 3711 3711 goto print; 3712 + 3713 + /* 3714 + * When the kernel is booted with the tp_printk command line 3715 + * parameter, trace events go directly through to printk(). 3716 + * It also is checked by this function, but it does not 3717 + * have an associated trace_array (tr) for it. 3718 + */ 3719 + if (iter->tr) { 3720 + text_delta = iter->tr->text_delta; 3721 + data_delta = iter->tr->data_delta; 3722 + } 3712 3723 3713 3724 /* Don't bother checking when doing a ftrace_dump() */ 3714 3725 if (iter->fmt == static_fmt_buf)
+2
kernel/trace/trace_hwlat.c
··· 520 520 if (!hwlat_busy || hwlat_data.thread_mode != MODE_PER_CPU) 521 521 goto out_unlock; 522 522 523 + if (!cpu_online(cpu)) 524 + goto out_unlock; 523 525 if (!cpumask_test_cpu(cpu, tr->tracing_cpumask)) 524 526 goto out_unlock; 525 527
+13 -9
kernel/trace/trace_osnoise.c
··· 1953 1953 { 1954 1954 struct task_struct *kthread; 1955 1955 1956 - mutex_lock(&interface_lock); 1957 - kthread = per_cpu(per_cpu_osnoise_var, cpu).kthread; 1956 + kthread = xchg_relaxed(&(per_cpu(per_cpu_osnoise_var, cpu).kthread), NULL); 1958 1957 if (kthread) { 1959 - per_cpu(per_cpu_osnoise_var, cpu).kthread = NULL; 1960 - mutex_unlock(&interface_lock); 1961 - 1962 1958 if (cpumask_test_and_clear_cpu(cpu, &kthread_cpumask) && 1963 1959 !WARN_ON(!test_bit(OSN_WORKLOAD, &osnoise_options))) { 1964 1960 kthread_stop(kthread); ··· 1968 1972 put_task_struct(kthread); 1969 1973 } 1970 1974 } else { 1971 - mutex_unlock(&interface_lock); 1972 1975 /* if no workload, just return */ 1973 1976 if (!test_bit(OSN_WORKLOAD, &osnoise_options)) { 1974 1977 /* ··· 1989 1994 { 1990 1995 int cpu; 1991 1996 1992 - for_each_possible_cpu(cpu) 1997 + cpus_read_lock(); 1998 + 1999 + for_each_online_cpu(cpu) 1993 2000 stop_kthread(cpu); 2001 + 2002 + cpus_read_unlock(); 1994 2003 } 1995 2004 1996 2005 /* ··· 2005 2006 struct task_struct *kthread; 2006 2007 void *main = osnoise_main; 2007 2008 char comm[24]; 2009 + 2010 + /* Do not start a new thread if it is already running */ 2011 + if (per_cpu(per_cpu_osnoise_var, cpu).kthread) 2012 + return 0; 2008 2013 2009 2014 if (timerlat_enabled()) { 2010 2015 snprintf(comm, 24, "timerlat/%d", cpu); ··· 2064 2061 if (cpumask_test_and_clear_cpu(cpu, &kthread_cpumask)) { 2065 2062 struct task_struct *kthread; 2066 2063 2067 - kthread = per_cpu(per_cpu_osnoise_var, cpu).kthread; 2064 + kthread = xchg_relaxed(&(per_cpu(per_cpu_osnoise_var, cpu).kthread), NULL); 2068 2065 if (!WARN_ON(!kthread)) 2069 2066 kthread_stop(kthread); 2070 2067 } 2071 - per_cpu(per_cpu_osnoise_var, cpu).kthread = NULL; 2072 2068 } 2073 2069 2074 2070 for_each_cpu(cpu, current_mask) { ··· 2097 2095 mutex_lock(&interface_lock); 2098 2096 cpus_read_lock(); 2099 2097 2098 + if (!cpu_online(cpu)) 2099 + goto out_unlock; 2100 2100 if (!cpumask_test_cpu(cpu, &osnoise_cpumask)) 2101 2101 goto out_unlock; 2102 2102
+1 -1
tools/tracing/rtla/Makefile.rtla
··· 38 38 .PHONY: install 39 39 install: doc_install 40 40 @$(MKDIR) -p $(DESTDIR)$(BINDIR) 41 - $(call QUIET_INSTALL,rtla)$(INSTALL) rtla -m 755 $(DESTDIR)$(BINDIR) 41 + $(call QUIET_INSTALL,rtla)$(INSTALL) $(RTLA) -m 755 $(DESTDIR)$(BINDIR) 42 42 @$(STRIP) $(DESTDIR)$(BINDIR)/rtla 43 43 @test ! -f $(DESTDIR)$(BINDIR)/osnoise || $(RM) $(DESTDIR)$(BINDIR)/osnoise 44 44 @$(LN) rtla $(DESTDIR)$(BINDIR)/osnoise
+1 -1
tools/tracing/rtla/src/osnoise_top.c
··· 442 442 case 'd': 443 443 params->duration = parse_seconds_duration(optarg); 444 444 if (!params->duration) 445 - osnoise_top_usage(params, "Invalid -D duration\n"); 445 + osnoise_top_usage(params, "Invalid -d duration\n"); 446 446 break; 447 447 case 'e': 448 448 tevent = trace_event_alloc(optarg);
+2 -2
tools/tracing/rtla/src/timerlat_top.c
··· 459 459 " -c/--cpus cpus: run the tracer only on the given cpus", 460 460 " -H/--house-keeping cpus: run rtla control threads only on the given cpus", 461 461 " -C/--cgroup[=cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited", 462 - " -d/--duration time[m|h|d]: duration of the session in seconds", 462 + " -d/--duration time[s|m|h|d]: duration of the session", 463 463 " -D/--debug: print debug info", 464 464 " --dump-tasks: prints the task running on all CPUs if stop conditions are met (depends on !--no-aa)", 465 465 " -t/--trace[file]: save the stopped trace to [file|timerlat_trace.txt]", ··· 613 613 case 'd': 614 614 params->duration = parse_seconds_duration(optarg); 615 615 if (!params->duration) 616 - timerlat_top_usage("Invalid -D duration\n"); 616 + timerlat_top_usage("Invalid -d duration\n"); 617 617 break; 618 618 case 'e': 619 619 tevent = trace_event_alloc(optarg);