mirror-linux/tools/testing/selftests
Linus Torvalds b8c8c1414f tracing fixes for v6.14:
Function graph accounting fixes:
 
 - Fix the manage ops hashes
 
   The function graph registers a "manager ops" and "sub-ops" to ftrace.
   The manager ops does not have any callback but calls the sub-ops
   callbacks. The manage ops hashes (what is used to tell ftrace what
   functions to attach to) is built on the sub-ops it manages.
 
   There was an error in the way it built the hash. An empty hash means to
   attach to all functions. When the manager ops had one sub-ops it properly
   copied its hash. But when the manager ops had more than one sub-ops, it
   went into a loop to make a set of all functions it needed to add to the
   hash. If any of the subops hashes was empty, that would mean to attach
   to all functions. The error was that the first iteration of the loop
   passed in an empty hash to start with in order to add the other hashes.
   That starting hash was mistaken as to attach to all functions. This made
   the manage ops attach to all functions whenever it had two or more
   sub-ops, even if each sub-op was attached to only a single function.
 
 - Do not add duplicate entries to the manager ops hash
 
   If two or more subops hashes trace the same function, an entry for that
   function will be added to the manager ops for each subops. This causes
   waste and extra overhead.
 
 Fprobe accounting fixes:
 
 - Remove last function from fprobe hash
 
   Fprobes has a ftrace hash to manage which functions an fprobe is attached
   to. It also has a counter of how many fprobes are attached. When the last
   fprobe is removed, it unregisters the fprobe from ftrace but does not
   remove the functions the last fprobe was attached to from the hash. This
   leaves the old functions attached. When a new fprobe is added, the fprobe
   infrastructure attaches to not only the functions of the new fprobe, but
   also to the functions of the last fprobe.
 
 - Fix accounting of the fprobe counter
 
   When a fprobe is added, it updates a counter. If the counter goes from
   zero to one, it attaches its ops to ftrace. When an fprobe is removed, the
   counter is decremented. If the counter goes from 1 to zero, it removes the
   fprobes ops from ftrace. There was an issue where if two fprobes trace the
   same function, the addition of each fprobe would increment the counter.
   But when removing the first of the fprobes, it would notice that another
   fprobe is still attached to one of its functions no it does not remove
   the functions from the ftrace ops. But it also did not decrement the
   counter. When the last fprobe is removed, the counter is still one. This
   leaves the fprobes callback still registered with ftrace and it being
   called by the functions defined by the fprobes ops hash.  Worse yet,
   because all the functions from the fprobe ops hash have been removed, that
   tells ftrace that it wants to trace all functions. Thus, this puts the
   state of the system where every function is calling the fprobe callback
   handler (which does nothing as there are no registered fprobes), but this
   causes a good 13% slow down of the entire system.
 
 Other updates:
 
 - Add a selftest to test the above issues to prevent regressions.
 
 - Fix preempt count accounting in function tracing
 
   Better recursion protection was added to function tracing which added
   another layer of preempt disable. As the preempt_count gets traced in the
   event, it needs to subtract the amount of preempt disabling the tracer
   does to record what the preempt_count was when the trace was triggered.
 
 - Fix memory leak in output of set_event
 
   A variable is passed by the seq_file functions in the location that is
   set by the return of the next() function. The start() function allocates
   it and the stop() function frees it. But when the last item is found, the
   next() returns NULL which leaks the data that was allocated in start().
   The m->private is used for something else, so have next() free the data
   when it returns NULL, as stop() will then just receive NULL in that case.
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYIADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCZ7j6ARQccm9zdGVkdEBn
 b29kbWlzLm9yZwAKCRAp5XQQmuv6quFxAQDrO8tjYbhLqg/LMOQyzwn/EF3Jx9ub
 87961mA0rKTkYwEAhPNzTZ6GwKyKc4ny/R338KgNY69wWnOK6k/BTxCRmwk=
 =TOah
 -----END PGP SIGNATURE-----

Merge tag 'ftrace-v6.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull tracing fixes from Steven Rostedt:
 "Function graph accounting fixes:

   - Fix the manage ops hashes

     The function graph registers a "manager ops" and "sub-ops" to
     ftrace. The manager ops does not have any callback but calls the
     sub-ops callbacks. The manage ops hashes (what is used to tell
     ftrace what functions to attach to) is built on the sub-ops it
     manages.

     There was an error in the way it built the hash. An empty hash
     means to attach to all functions. When the manager ops had one
     sub-ops it properly copied its hash. But when the manager ops had
     more than one sub-ops, it went into a loop to make a set of all
     functions it needed to add to the hash. If any of the subops hashes
     was empty, that would mean to attach to all functions. The error
     was that the first iteration of the loop passed in an empty hash to
     start with in order to add the other hashes. That starting hash was
     mistaken as to attach to all functions. This made the manage ops
     attach to all functions whenever it had two or more sub-ops, even
     if each sub-op was attached to only a single function.

   - Do not add duplicate entries to the manager ops hash

     If two or more subops hashes trace the same function, an entry for
     that function will be added to the manager ops for each subops.
     This causes waste and extra overhead.

  Fprobe accounting fixes:

   - Remove last function from fprobe hash

     Fprobes has a ftrace hash to manage which functions an fprobe is
     attached to. It also has a counter of how many fprobes are
     attached. When the last fprobe is removed, it unregisters the
     fprobe from ftrace but does not remove the functions the last
     fprobe was attached to from the hash. This leaves the old functions
     attached. When a new fprobe is added, the fprobe infrastructure
     attaches to not only the functions of the new fprobe, but also to
     the functions of the last fprobe.

   - Fix accounting of the fprobe counter

     When a fprobe is added, it updates a counter. If the counter goes
     from zero to one, it attaches its ops to ftrace. When an fprobe is
     removed, the counter is decremented. If the counter goes from 1 to
     zero, it removes the fprobes ops from ftrace.

     There was an issue where if two fprobes trace the same function,
     the addition of each fprobe would increment the counter. But when
     removing the first of the fprobes, it would notice that another
     fprobe is still attached to one of its functions no it does not
     remove the functions from the ftrace ops.

     But it also did not decrement the counter, so when the last fprobe
     is removed, the counter is still one. This leaves the fprobes
     callback still registered with ftrace and it being called by the
     functions defined by the fprobes ops hash. Worse yet, because all
     the functions from the fprobe ops hash have been removed, that
     tells ftrace that it wants to trace all functions.

     Thus, this puts the state of the system where every function is
     calling the fprobe callback handler (which does nothing as there
     are no registered fprobes), but this causes a good 13% slow down of
     the entire system.

  Other updates:

   - Add a selftest to test the above issues to prevent regressions.

   - Fix preempt count accounting in function tracing

     Better recursion protection was added to function tracing which
     added another layer of preempt disable. As the preempt_count gets
     traced in the event, it needs to subtract the amount of preempt
     disabling the tracer does to record what the preempt_count was when
     the trace was triggered.

   - Fix memory leak in output of set_event

     A variable is passed by the seq_file functions in the location that
     is set by the return of the next() function. The start() function
     allocates it and the stop() function frees it. But when the last
     item is found, the next() returns NULL which leaks the data that
     was allocated in start(). The m->private is used for something
     else, so have next() free the data when it returns NULL, as stop()
     will then just receive NULL in that case"

* tag 'ftrace-v6.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracing: Fix memory leak when reading set_event file
  ftrace: Correct preemption accounting for function tracing.
  selftests/ftrace: Update fprobe test to check enabled_functions file
  fprobe: Fix accounting of when to unregister from function graph
  fprobe: Always unregister fgraph function from ops
  ftrace: Do not add duplicate entries in subops manager ops
  ftrace: Fix accounting of adding subops to a manager ops
2025-02-22 09:03:54 -08:00
..
acct selftests: acct: Add ksft_exit_skip if not running as root 2025-01-14 17:06:31 -07:00
alsa selftests/alsa: Fix circular dependency involving global-timer 2024-12-20 10:00:41 +01:00
amd-pstate
arm64 CRC updates for 6.14 2025-01-22 19:55:08 -08:00
bpf BPF fixes: 2025-02-20 15:37:17 -08:00
breakpoints selftests: breakpoints: use remaining time to check if suspend succeed 2024-10-02 14:37:30 -06:00
cachestat
capabilities
cgroup selftests/cgroup: use bash in test_cpuset_v1_hp.sh 2025-02-04 09:36:54 -10:00
clone3 clone3: clone3_cap_checkpoint_restore: remove unused MAX_PID_NS_LEVEL macro 2024-09-30 11:39:56 -06:00
connector
core selftests: core: add unshare_test to gitignore 2024-09-30 11:42:11 -06:00
coredump selftests: coredump: Add stackdump test 2025-01-04 10:12:18 +01:00
cpu-hotplug
cpufreq selftests/cpufreq: gitignore output files and clean them in make clean 2024-12-09 17:51:41 -07:00
damon selftests/damon: remove tests for DAMON debugfs interface 2025-01-25 20:22:29 -08:00
devices kselftest/devices/probe: Fix SyntaxWarning in regex strings for Python3 2024-10-02 14:30:58 -06:00
dma
dmabuf-heaps kselftests: dmabuf-heaps: Ensure the driver name is null-terminated 2024-07-29 09:02:54 +02:00
drivers selftests: drv-net: rss_ctx: don't fail reconfigure test if queue offset not supported 2025-02-03 18:39:23 -08:00
dt kselftest: dt: Ignore nodes that have ancestors disabled 2024-09-05 07:54:16 -05:00
efivarfs selftests/efivarfs: add concurrent update tests 2025-01-21 16:34:41 +01:00
exec AT_EXECVE_CHECK update for v6.14-rc1 (fix1) 2025-01-31 17:12:31 -08:00
fchmodat2
filelock
filesystems selftests: always check mask returned by statmount(2) 2025-02-07 10:27:26 +01:00
firmware
fpu
ftrace selftests/ftrace: Update fprobe test to check enabled_functions file 2025-02-21 09:36:12 -05:00
futex
gpio selftests: gpio: gpio-sim: Fix missing chip disablements 2025-01-23 15:44:48 +01:00
hid selftests/hid: Add host-tools to .gitignore 2024-12-10 12:46:54 +01:00
ia64
intel_pstate selftests/intel_pstate: check if cpupower is installed 2024-10-28 21:18:57 -06:00
iommu iommufd/selftest: Cover IOMMU_FAULT_QUEUE_ALLOC in iommufd_fail_nth 2024-12-03 12:15:00 -04:00
ipc selftests/ipc: Remove unused variables 2025-01-14 17:06:31 -07:00
ir
kcmp
kexec
kmod
kselftest AT_EXECVE_CHECK introduction for v6.14-rc1 2025-01-22 20:34:42 -08:00
kvm KVM: selftests: Add CPUID tests for Hyper-V features that need in-kernel APIC 2025-02-12 08:55:11 -08:00
landlock AT_EXECVE_CHECK update for v6.14-rc1 (fix1) 2025-01-31 17:12:31 -08:00
lib selftests: lib: remove strscpy test 2024-08-01 13:55:33 -06:00
livepatch selftests: livepatch: handle PRINTK_CALLER in check_result() 2025-01-27 11:41:28 +01:00
lkdtm
locking
lsm selftests: refactor the lsm `flags_overset_lsm_set_self_attr` test 2024-12-18 18:14:29 -05:00
media_tests selftest: media_tests: fix trivial UAF typo 2025-01-14 17:06:31 -07:00
membarrier
memfd selftests/memfd/memfd_test: fix possible NULL pointer dereference 2025-01-25 20:22:44 -08:00
memory-hotplug
mincore
mm selftests/mm: fix check for running THP tests 2025-02-17 22:40:04 -08:00
module selftests: find_symbol: Actually use load_mod() parameter 2024-11-28 11:17:38 -08:00
mount
mount_setattr selftests/mount_setattr: Fix failures on 64K PAGE_SIZE kernels 2024-11-20 09:18:48 +01:00
move_mount_set_group
mqueue
nci
net selftests/net/forwarding: Add a test case for tc-flower of mixed port and port-range 2025-02-19 18:54:59 -08:00
nolibc selftests/nolibc: add configurations for riscv32 2025-01-13 22:21:34 +01:00
ntb
openat2
pci_endpoint selftests: pci_endpoint: Migrate to Kselftest framework 2025-01-21 14:17:55 -06:00
pcie_bwctrl selftests/pcie_bwctrl: Create selftests 2024-11-16 10:09:30 -06:00
perf_events
pid_namespace tests/pid_namespace: add pid_max tests 2024-12-02 11:25:25 +01:00
pidfd Mainly individually changelogged singleton patches. The patch series in 2025-01-26 17:50:53 -08:00
power_supply
powerpc selftests/powerpc: Fix argument order to timer_sub() 2025-01-11 10:39:45 +05:30
prctl
proc - In the series "treewide: Refactor heap related implementation", 2024-07-21 17:56:22 -07:00
pstore
ptp selftest/ptp: update ptp selftest to exercise the gettimex options 2024-10-04 15:36:43 -07:00
ptrace
rcutorture Merge branches 'fixes.2024.12.14a', 'rcutorture.2024.12.14a', 'srcu.2024.12.14a' and 'torture-test.2024.12.14a' into rcu-merge.2024.12.14a 2024-12-14 17:32:26 +01:00
resctrl selftests/resctrl: Discover SNC kernel support and adjust messages 2025-01-14 17:06:32 -07:00
ring-buffer selftests/ring-buffer: Add test for out-of-bound pgoff mapping 2025-01-14 17:06:32 -07:00
riscv RISC-V Patches for the 6.14 Merge Window, Part 1 2025-01-31 15:13:25 -08:00
rlimits
rseq OpenRISC updates for 6.14 2025-01-25 10:16:56 -08:00
rtc selftest: rtc: Add to check rtc alarm status for alarm related test 2024-10-23 14:13:00 -06:00
rust selftests: rust: config: disable GCC_PLUGINS 2024-08-11 17:32:55 -06:00
safesetid
sched
sched_ext sched_ext: selftests: Fix grammar in tests description 2025-02-13 06:46:22 -10:00
seccomp selftests/seccomp: validate uretprobe syscall passes through seccomp 2025-02-06 13:19:14 -08:00
sgx
signal selftests: Add a test mangling with uc_sigmask 2024-10-29 01:01:49 -06:00
size
sparc64
splice
static_keys
sync
syscall_user_dispatch
sysctl
tc-testing selftests/tc-testing: Add a test case for qdisc_tree_reduce_backlog() 2025-02-05 18:15:00 -08:00
tdx
thermal/intel
timens
timers selftests: timers: clocksource-switch: Adapt progress to kselftest framework 2025-01-14 17:06:31 -07:00
tmpfs selftests: tmpfs: Add kselftest support to tmpfs 2025-01-14 17:06:32 -07:00
tpm2 selftests: tpm2: test_smoke: Run only when TPM2 is avaialable. 2024-09-17 18:56:37 +03:00
tty
turbostat tools/power turbostat: Add selftests for added perf counters 2024-07-26 13:51:25 -04:00
uevent
user_events
vDSO selftests/vDSO: support DT_GNU_HASH 2025-01-14 17:06:31 -07:00
watchdog selftests/watchdog-test: Fix system accidentally reset after watchdog-test 2024-10-28 21:34:43 -06:00
wireguard Networking changes for 6.13. 2024-11-21 08:28:08 -08:00
x86 x86/mm/selftests: Fix typo in lam.c 2024-12-06 20:04:32 +01:00
zram selftests/zram: gitignore output file 2025-01-14 17:06:31 -07:00
.gitignore
Makefile Char/Misc/IIO driver updates for 6.14-rc1 2025-01-27 16:51:51 -08:00
gen_kselftest_tar.sh
kselftest.h selftests: kselftest: Fix the wrong format specifier 2025-01-14 17:06:31 -07:00
kselftest_deps.sh
kselftest_harness.h selftests: harness: fix printing of mismatch values in __EXPECT() 2025-01-14 17:06:32 -07:00
kselftest_install.sh
kselftest_module.h
lib.mk - 875fa64577da ("mm/hugetlb_vmemmap: fix race with speculative PFN 2024-07-21 17:15:46 -07:00
run_kselftest.sh selftests/run_kselftest.sh: Fix help string for --per-test-log 2025-01-14 17:06:32 -07:00