Files
Linus Torvalds 59a02493f3 Merge tag 'trace-v7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing updates from Steven Rostedt:

 - Add "within" to filter logic

   Add a way to trace events by what function they fall in.

	echo 'within == "vfs_read" > events/sched/sched_switch/filter

   Will only trigger sched_switch events that happen within the vfs_read
   function. It uses a stacktrace at the event and checks if any entry
   is within the specified function and if so, it prints the event.

 - Remove a duplicate definition of ftrace_set_clr_event() from the
   header

 - Do not have ftrace_set_clr_event() modify its input buffer

   Have the buffer passed into ftrace_set_clr_event() to be const char *
   and not allow modifications to it that might cause side effects.

 - Add kunit tests for ftrace_parse_event_string()

 - Add filter argument to __ftrace_set_clr_event()

   Make it possible to set a filter on an event at the same time it is
   enabled.

 - Add event filtering logic to the kernel command line

   To allow filtering events on boot, allow filtering to be specified on
   the kernel command line when enabling events.

 - Rename "ring_buffer_size()" to "ring_buffer_capacity()"

   "size" refers to how much is allocated whereas the actual return
   value is the amount of available data in the ring buffer minus its
   meta data.

 - Rename "trace_array_entries" to "trace_array_capacity"

   There's several functions that use "entries" and returns the amount
   of data that that is usable. "entries" should be only for the number
   of events, not the amount of data.

 - Print the histogram "bucket" size as unsigned.

   If a bucket size is LONG_MAX, then it shows up as a negative number.

 - Show bucket size in output of histograms

   The output of what the histogram is shown doesn't show the size of
   the buckets when buckets are used. The output should be the same as
   the input and since specifying buckets without a size is an invalid
   command, the output to display what was entered should also show the
   size.

 - Fix stacktrace modifier output

   Only show the stacktrace modifier when it was specified in creation.

 - Unregister filed variable histograms when the command fails

   If one histogram references a variable of another histogram it
   registers that other histogram. But if the first histogram fails in
   setup after it registered the other histogram it doesn't unregister
   it. Have the first histogram add the reference to the other histogram
   so the failure clean up will unregister the second histogram too.

 - Fix 64-bit signed histogram fields on 32-bit kernels

   A fix to convert char * to u64 with added casting also incorrectly
   added an intermediate cast to convert a long value to u64 which ended
   up truncating the upper 32 bits for 32-bit kernels. Remove the
   intermediate typecast.

 - Print signed histogram keys as signed

   Histogram keys were being printed as unsigned and with signed keys it
   was giving the wrong output.

 - Use copy_from_user() and not __copy_from_user() in syscall tracing

   The syscall tracing incorrectly was using __copy_from_user() which
   could be an issue if the system trusts perf doing the trace.

 - Take trace_types_lock when recording a new module in persistent
   buffer

   When a new module is loaded, the persistent ring buffer saves it in
   its persistent memory. All the trace_arrays are iterated looking for
   any persistent buffer to add the module to. But it did not hold the
   trace_types_lock meaning a trace_array could be added or removed
   while iterating the list.

 - Only create tracepoint guest_halt_poll_ns when it is used

   The tracepoint guest_halt_poll_ns is defined in the power management
   code but it is only used when CONFIG_CPU_IDLE_GOV_HALTPOLL is
   enabled. This wastes memory when that config isn't enabled so wrap
   the tracepoint around that as well.

 - Handle empty fields for events in trace_event_get_offsets()

   The user events could have empty fields and this causes
   trace_event_get_offsets() to crash as it expects events to always
   have fields. Make the function handle events with no fields.

 - Reject incomplete event filter expressions

   If a filter has an incomplete expression (common_pid == 1111 || ), it
   will cause a out-of-bounds bug. Have the predicate_parse() only
   process the expression if it is complete.

* tag 'trace-v7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: (27 commits)
  tracing: Reject incomplete event filter expressions
  tracing: Guard trace_event_get_offsets() against an empty fields list
  cpuidle: haltpoll: Only define guest_halt_poll_ns tracepoint when used
  tracing/osnoise: Add __printf attribute to osnoise_print()
  tracing/histograms: Verify event_call identity when updating synth_event refcount
  tracing: Save the event file instead of the compatible histogram
  tracing: Hold trace_types_lock when resetting last boot data from readers
  tracing: Hold trace_types_lock when updating modules in persistent instances
  tracing/syscalls: Use copy_from_user for the faultable syscall buffer
  tracing: Print a signed histogram key as signed
  tracing: Fix 64-bit and signed histogram fields on 32-bit kernels
  tracing: Clamp the printed end of a histogram bucket at U64_MAX
  tracing: Unregister field variable histograms when the command fails
  tracing: Only report the stacktrace modifier on a real field
  tracing: Add the bucket size to expr_field_str()
  tracing: Print the bucket size as unsigned
  tracing: Rename tracing_entries_fops to tracing_capacity_fops
  tracing: Rename trace_array::entries to capacity
  ring-buffer: Rename ring_buffer_size() to ring_buffer_capacity()
  tracing: Parse filter from boot event string
  ...
2026-10-27 15:01:12 -10:00

169 lines
6.2 KiB
Makefile

# SPDX-License-Identifier: GPL-2.0
# Do not instrument the tracer itself:
ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE)
ifdef CONFIG_FUNCTION_TRACER
# Avoid recursion due to instrumentation.
KCSAN_SANITIZE := n
ifdef CONFIG_FTRACE_SELFTEST
# selftest needs instrumentation
CFLAGS_trace_selftest_dynamic.o = $(CC_FLAGS_FTRACE)
obj-y += trace_selftest_dynamic.o
endif
endif
# Allow some files to be function traced
ifdef CONFIG_FUNCTION_SELF_TRACING
CFLAGS_trace_output.o = $(CC_FLAGS_FTRACE)
CFLAGS_trace_seq.o = $(CC_FLAGS_FTRACE)
CFLAGS_trace_stat.o = $(CC_FLAGS_FTRACE)
CFLAGS_tracing_map.o = $(CC_FLAGS_FTRACE)
CFLAGS_synth_event_gen_test.o = $(CC_FLAGS_FTRACE)
CFLAGS_trace_events.o = $(CC_FLAGS_FTRACE)
CFLAGS_trace_syscalls.o = $(CC_FLAGS_FTRACE)
CFLAGS_trace_events_filter.o = $(CC_FLAGS_FTRACE)
CFLAGS_trace_events_trigger.o = $(CC_FLAGS_FTRACE)
CFLAGS_trace_events_synth.o = $(CC_FLAGS_FTRACE)
CFLAGS_trace_events_hist.o = $(CC_FLAGS_FTRACE)
CFLAGS_trace_events_user.o = $(CC_FLAGS_FTRACE)
CFLAGS_trace_dynevent.o = $(CC_FLAGS_FTRACE)
endif
ifdef CONFIG_FTRACE_STARTUP_TEST
CFLAGS_trace_kprobe_selftest.o = $(CC_FLAGS_FTRACE)
obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe_selftest.o
endif
# If unlikely tracing is enabled, do not trace these files
ifdef CONFIG_TRACING_BRANCHES
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
endif
# for GCOV coverage profiling
ifdef CONFIG_GCOV_PROFILE_FTRACE
GCOV_PROFILE := y
endif
# Functions in these files can run from IRQ entry before hardirq context
# is visible to KCOV, and produce coverage unrelated to syscall inputs.
KCOV_INSTRUMENT_trace_preemptirq.o := n
KCOV_INSTRUMENT_trace_irqsoff.o := n
CFLAGS_bpf_trace.o := -I$(src)
CFLAGS_trace_benchmark.o := -I$(src)
CFLAGS_trace_events_filter.o := -I$(src)
obj-$(CONFIG_TRACE_CLOCK) += trace_clock.o
obj-$(CONFIG_FUNCTION_TRACER) += libftrace.o
obj-$(CONFIG_RING_BUFFER) += ring_buffer.o
obj-$(CONFIG_RING_BUFFER_BENCHMARK) += ring_buffer_benchmark.o
obj-$(CONFIG_TRACING) += trace.o
obj-$(CONFIG_TRACING) += trace_output.o
obj-$(CONFIG_TRACING) += trace_seq.o
obj-$(CONFIG_TRACING) += trace_stat.o
obj-$(CONFIG_TRACING) += trace_printk.o
obj-$(CONFIG_TRACING) += trace_pid.o
obj-$(CONFIG_TRACER_SNAPSHOT) += trace_snapshot.o
obj-$(CONFIG_TRACING) += pid_list.o
obj-$(CONFIG_TRACING_MAP) += tracing_map.o
obj-$(CONFIG_PREEMPTIRQ_DELAY_TEST) += preemptirq_delay_test.o
obj-$(CONFIG_SYNTH_EVENT_GEN_TEST) += synth_event_gen_test.o
obj-$(CONFIG_KPROBE_EVENT_GEN_TEST) += kprobe_event_gen_test.o
obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o
obj-$(CONFIG_FUNCTION_TRACER) += trace_functions.o
obj-$(CONFIG_PREEMPTIRQ_TRACEPOINTS) += trace_preemptirq.o
obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o
obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o
obj-$(CONFIG_SCHED_TRACER) += trace_sched_wakeup.o
obj-$(CONFIG_HWLAT_TRACER) += trace_hwlat.o
obj-$(CONFIG_OSNOISE_TRACER) += trace_osnoise.o
obj-$(CONFIG_NOP_TRACER) += trace_nop.o
obj-$(CONFIG_STACK_TRACER) += trace_stack.o
obj-$(CONFIG_MMIOTRACE) += trace_mmiotrace.o
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += trace_functions_graph.o
obj-$(CONFIG_TRACE_BRANCH_PROFILING) += trace_branch.o
obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += fgraph.o
ifeq ($(CONFIG_BLOCK),y)
obj-$(CONFIG_EVENT_TRACING) += blktrace.o
endif
obj-$(CONFIG_EVENT_TRACING) += trace_events.o
obj-$(CONFIG_EVENT_TRACING) += trace_export.o
obj-$(CONFIG_EVENT_TRACING_TEST) += trace_events_test.o
obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
ifeq ($(CONFIG_PERF_EVENTS),y)
obj-$(CONFIG_EVENT_TRACING) += trace_event_perf.o
endif
obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o
obj-$(CONFIG_EVENT_TRACING) += trace_events_trigger.o
obj-$(CONFIG_EPROBE_EVENTS) += trace_eprobe.o
obj-$(CONFIG_TRACE_EVENT_INJECT) += trace_events_inject.o
obj-$(CONFIG_SYNTH_EVENTS) += trace_events_synth.o
obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o
obj-$(CONFIG_USER_EVENTS) += trace_events_user.o
obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o
obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o
obj-$(CONFIG_TRACEPOINTS) += error_report-traces.o
obj-$(CONFIG_TRACEPOINTS) += power-traces.o
ifeq ($(CONFIG_PM),y)
obj-$(CONFIG_TRACEPOINTS) += rpm-traces.o
endif
ifeq ($(CONFIG_TRACING),y)
obj-$(CONFIG_KGDB_KDB) += trace_kdb.o
endif
obj-$(CONFIG_DYNAMIC_EVENTS) += trace_dynevent.o
obj-$(CONFIG_PROBE_EVENTS) += trace_probe.o
obj-$(CONFIG_DEBUG_INFO_BTF) += trace_btf.o
obj-$(CONFIG_UPROBE_EVENTS) += trace_uprobe.o
obj-$(CONFIG_BOOTTIME_TRACING) += trace_boot.o
obj-$(CONFIG_FTRACE_RECORD_RECURSION) += trace_recursion_record.o
obj-$(CONFIG_FPROBE) += fprobe.o
obj-$(CONFIG_RETHOOK) += rethook.o
obj-$(CONFIG_FPROBE_EVENTS) += trace_fprobe.o
obj-$(CONFIG_TRACEPOINT_BENCHMARK) += trace_benchmark.o
obj-$(CONFIG_RV) += rv/
obj-$(CONFIG_TRACE_REMOTE) += trace_remote.o
obj-$(CONFIG_SIMPLE_RING_BUFFER) += simple_ring_buffer.o
obj-$(CONFIG_TRACE_REMOTE_TEST) += remote_test.o
# simple_ring_buffer is used by the pKVM hypervisor which does not have access
# to all kernel symbols. Fail the build if forbidden symbols are found.
# Basic compiler and tooling-generated symbols that can safely be left
# undefined. Ensure KASAN is enabled to avoid logic that may disable
# FORTIFY_SOURCE when KASAN is not enabled. undefsyms_base.o does not
# automatically get KASAN flags because it is not linked into vmlinux.
targets += undefsyms_base.o
KASAN_SANITIZE_undefsyms_base.o := y
UNDEFINED_ALLOWLIST = __asan __gcov __kasan __kcsan __hwasan __sancov __sanitizer __tsan __ubsan __msan \
__aeabi_unwind_cpp __s390_indirect_jump __x86_indirect_thunk simple_ring_buffer \
current_thread_info_reg \
$(shell $(NM) -u $(obj)/undefsyms_base.o 2>/dev/null | awk '$$2 {print $$2}')
quiet_cmd_check_undefined = NM $<
cmd_check_undefined = \
undefsyms=$$($(NM) -u $< | awk '$$2 {print $$2}' | grep -v $(addprefix -e , $(UNDEFINED_ALLOWLIST)) || true); \
if [ -n "$$undefsyms" ]; then \
echo "Unexpected symbols in $<:" >&2; \
echo "$$undefsyms" >&2; \
false; \
fi; \
touch $@
$(obj)/%.o.checked: $(obj)/%.o $(obj)/undefsyms_base.o FORCE
$(call if_changed,check_undefined)
always-$(CONFIG_SIMPLE_RING_BUFFER) += simple_ring_buffer.o.checked
libftrace-y := ftrace.o