summaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)Author
2026-10-01perf build: Run shellcheck, mypy, and remaining pylint checks in parallelIan Rogers
Following the approach used for pylint on standalone scripts and tests, move the shellcheck and mypy checks in tools/perf/Build and tools/perf/tests/Build, as well as the mypy and pylint checks in tools/perf/util/Build and tools/perf/pmu-events/Build, into dedicated phony targets invoked as top-level sub-makes from Makefile.perf. Also add 'perf' to pylint's --ignored-modules (leaving perf module type-checking to mypy via perf.pyi), since astroid's ImportlibFinder only resolves .pyi stubs for package directories (__init__.pyi) rather than single-file stubs like perf.pyi and does not introspect C extensions by default. This removes the need for pylint to wait on building $(LANG_BINDINGS). This avoids blocking jevents code generation, archive creation (libperf-util.a, libperf-test.a, libpmu-events.a), and final linking of the perf binary and Python extension on linter execution. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test: Update attr.py to use argparseIan Rogers
optparse is deprecated since Python 3.2 and triggers a pylint deprecated-module warning on newer versions of pylint. Replace optparse.OptionParser in tools/perf/tests/shell/lib/attr.py with argparse.ArgumentParser. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test uprobe_from_different_cu: Scope probe name to PIDIan Rogers
'perf probe' names the event after the function and binary, so concurrent runs, as with 'perf test -r3', all add probe_testfile:foo and all but one fail with 'event "foo" already exists'. Name the event foo_$$. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test: Remove exclusive tag from 'perf trace' testsNamhyung Kim
Now it's safe to run multiple 'perf trace' commands at the same time. Let's make them non-exclusive so that they can run in parallel. $ sudo perf test 'perf trace' 113: Check open filename arg using perf trace + vfs_getname : Skip 114: perf trace enum augmentation tests : Ok 115: perf trace BTF general tests : Ok 116: perf trace exit race : Ok 117: perf trace record and replay : Ok 118: perf trace summary : Ok [ irogers: Keep trace+probe_vfs_getname.sh exclusive, as without BPF every 'perf trace' opens its probe:vfs_getname* probe. ] Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20250814071754.193265-6-namhyung@kernel.org Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test trace_btf_general: Drop --max-events=1 and make non-exclusiveIan Rogers
With --max-events=1 an unrelated event can end perf trace before the command's syscall is seen. Trace the whole command and grep for the expected line, as trace_btf_enum.sh does, and remove the exclusive tag. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test trace_summary: Improve error diagnosticsIan Rogers
On a mismatch print the command, the match count, the matching lines and the end of the output. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test record+probe_libc_inet_pton: Scope event to PID and make non-exclusiveIan Rogers
Scope the uprobe name to the pid, retry adding and deleting it as concurrent uprobe_events writes can fail with EBUSY, and delete it from an exit trap. Create the temporary files with mktemp rather than reserving names with mktemp -u. Remove the exclusive tag. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test probe_vfs_getname: Scope probe name to PID and make non-exclusiveIan Rogers
The fixed vfs_getname probe name collides between parallel tests, and the cleanup deletes every probe:vfs_getname* probe. Name the probe getname_flags_$$, match it exactly, and remove it from an exit trap. Not starting with vfs_getname also stops perf trace, which opens every probe:vfs_getname* event, from pinning it. Remove the exclusive tag from probe_vfs_getname.sh and record+script_probe_vfs_getname.sh. trace+probe_vfs_getname.sh needs perf trace to find its probe, so it uses vfs_getname_$$ and stays exclusive. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test common: Only disable probes in clear_all_probesIan Rogers
Writing 0 to events/enable disables every tracepoint, breaking perf sessions running in parallel. Disable just the kprobes and uprobes, an enabled one would make clearing kprobe_events or uprobe_events fail with EBUSY. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Add an option to disable syscall augmentationIan Rogers
'perf trace' falls back to the raw_syscalls tracepoints, filtering in user space, when the augmentation BPF programs can't be loaded. Add --no-syscall-augment to use that path even when they can, so both can be tested. Suggest it when tasks are lost, as the tracepoints' per-task events don't limit how many tasks are traced. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Remove unused codeNamhyung Kim
Now syscall init for augmented arguments is simplified. Let's get rid of dead code. Reviewed-by: Aaron Tomlin <atomlin@atomlin.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20250814071754.193265-5-namhyung@kernel.org Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Do not return 0 from syscall tracepoint BPFNamhyung Kim
Howard reported that returning 0 from the BPF resulted in affecting global syscall tracepoint handling. What we want to do is just to drop syscall output in the current perf session. So we need a different approach. Currently perf trace uses bpf-output event for augmented arguments and raw_syscalls:sys_{enter,exit} tracepoint events for normal arguments. But I think we can just use bpf-output in both cases and drop the trace point events. Then it needs to distinguish bpf-output data if it's for enter or exit. Repurpose struct trace_entry.type which is common in both syscall entry and exit tracepoints. [ irogers: Use the local syscall_{enter,exit}_args, always return 1 from augmented__output(), output the unaugmented args when the perf_event_open augmenter fails, dispatch from a trace__bpf_output() handler, add a per-task tracking event and keep excluding kernel callchains. ] Closes: https://lore.kernel.org/r/20250529065537.529937-1-howardchu95@gmail.com Suggested-by: Howard Chu <howardchu95@gmail.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20250814071754.193265-4-namhyung@kernel.org Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Open the BPF output event on every CPU for task targetsIan Rogers
The bpf-output event is opened per task without inherit, and __augmented_syscalls__ holds each CPU's event for the first thread in the thread map. bpf_perf_event_output() only writes to an event active on the current CPU, so the target's other threads and its children aren't augmented. As BPF now picks the target's tasks, open the event system wide. A CPU event isn't enabled by exec, so for a workload enable it when opened, BPF waiting for the exec instead. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Filter the target's tasks in BPFIan Rogers
The augmented syscalls BPF programs are attached to raw_syscalls system wide, so they run for every task. To make the bpf-output event system wide, and so augment the target's children, they need to know which tasks are the target's. Add a pids_to_trace map, seeded from the target's thread map, that sys_enter and sys_exit check, leaving other tasks' events alone. tp_btf programs add children on fork when inheriting, remove exited tasks and follow a thread that exec gives the leader's pid. Tasks that don't fit in the map, including when seeding, are counted and reported as lost. Other forks drop any entry for the child's pid, seeded for a task that had exited, such as a zombie. A workload waits for its exec, like enable_on_exec. When inheriting, unless given threads with -t, key the map by tgid, like off-cpu's task_filter, so a process's threads share its entry. New threads are then traced with their process, which is forgotten when its last thread exits, and exec keeps the key. The sched programs attach when the skeleton loads and the map is seeded before the events are opened, so the forks and exits that follow are seen. sys_enter and sys_exit now attach once the maps are populated, rather than at load where the empty prog arrays made them veto every raw_syscalls event. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf thread_map: Add thread_map__tgid()Ian Rogers
bpf-filter reads the tgid of each thread in a thread map from /proc, to key its BPF map by process, and perf trace is about to do the same. Move convert_to_tgid() to thread_map.c as thread_map__tgid(), taking the thread map and index both users have. While moving it, fix two bugs. Match Tgid: at the start of a line, as a task can set its comm, shown on the Name: line before it, to contain "Tgid: <n>". And check the character after the number before freeing the buffer it points into, rather than after. Fixes: eb1693b1150d4b99 ("perf bpf-filter: Split per-task filter use case") Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Destroy the BPF skeleton if it fails to loadIan Rogers
If augmented_syscalls__prepare() fails to load the skeleton, 'perf trace' falls back to unaugmented tracing but leaves the skeleton in place. augmented_syscalls__set_filter_pids() then writes to maps that were never created and fails with -ENOENT, so a system wide session, or one using --filter-pids, exits with "Not enough memory to run!". Destroy the skeleton on failure and clear the pointer, so the setters do nothing. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Use the CPU map index for the BPF output event's fdsIan Rogers
augmented_syscalls__setup_bpf_output() looks up the bpf-output event's file descriptor using the CPU number, but the fd xyarray is indexed by position in the CPU map. With -C, or with offline CPUs, the two differ and the lookup finds another CPU's fd or NULL, leaving those CPUs unaugmented. Use the CPU map index. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Split unaugmented sys_exit programNamhyung Kim
We want to handle syscall exit path differently so let's split the unaugmented exit BPF program. Currently it does nothing (same as sys_enter). [ irogers: Use struct syscall_{enter,exit}_args and make trace__find_syscall_bpf_prog() fall back to the exit program for exits ] Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20250814071754.193265-3-namhyung@kernel.org Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Only take augmented arguments from the BPF output eventIan Rogers
syscall__augmented_args() treats any data after the syscall arguments as augmented arguments. trace__sys_enter() avoids this for raw_syscalls:sys_enter, but trace__fprintf_sys_enter() also handles syscalls:sys_enter_* tracepoint events, whose trailing data since v6.19 holds the __data_loc strings of internal fields. Only the BPF output event carries augmented arguments, so only look for them there. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Don't allocate syscall arg formats for internal fieldsIan Rogers
syscall__read_info() sizes sc->arg_fmt by the tracepoint's field count, which includes the internal fields that follow the arguments, and only then subtracts them from sc->nr_args. syscall__alloc_arg_fmts() copies sc->fmt->arg[] for every entry, so with more than 6 fields, for example renameat2 with its 2 path strings, it reads beyond the end of that RAW_SYSCALL_ARGS_NUM sized array. Count the arguments before allocating, and pass the array's size to syscall_arg_fmt__init_array() so its walk stops before the internal fields, rather than stepping beyond the array. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Stop at internal fields when walking syscall argumentsIan Rogers
Since v6.19 syscall tracepoints may end with __data_loc char[] fields holding user space strings, these aren't syscall arguments. syscall__scnprintf_args() walks them anyway, printing the extra raw syscall arguments at those indices under the internal field's name, and trace__bpf_sys_enter_beauty_map() considers them when building the BPF beauty map. The internal fields come after the arguments, so stop at the first one. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Start BPF summary before starting workloadIan Rogers
trace_start_bpf_summary() is called after evlist__start_workload(), so a short lived workload can make its syscalls, or even exit, before the BPF summary is enabled. It also ignores --delay. Enable it along with the evlist, before the workload starts or after the initial delay. Reviewed-by: Aaron Tomlin <atomlin@atomlin.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf trace: Copy sockaddr arguments by their lengthIan Rogers
The BTF augmenter copies sizeof(struct sockaddr), 16 bytes, for the sockaddr arguments of connect, bind and sendto, and runs before the sys_enter_connect and sys_enter_sendto programs that copy their length. An IPv6 address needs 24 or 28 bytes, so the rest was read from past the payload, and now that the printers are bounded only its family is shown. Copy them as buffers sized by the length argument after them, up to the 32 bytes augmented buffers are limited to. That holds an IPv6 address and doubles the AF_LOCAL path shown. Committer testing: Is using BPF: root@x2:~# strace -e bpf perf trace -e connect,bind |& head -5 bpf(BPF_TOKEN_CREATE, {token_create={flags=0, bpffs_fd=12}}, 8) = -1 EOPNOTSUPP (Operation not supported) bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffea3054260, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, core_relo_cnt=0, fd_array=NULL, core_relos=NULL, core_relo_rec_size=0, log_true_size=0, prog_token_fd=0}, 148) = 12 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffea3054390, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, core_relo_cnt=0, fd_array=NULL, core_relos=NULL, core_relo_rec_size=0, log_true_size=0, prog_token_fd=0, fd_array_cnt=0, signature=NULL, signature_size=0, keyring_id=0}, 168) = 12 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffea3053f80, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="libbpf_nametest", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, core_relo_cnt=0, fd_array=NULL, core_relos=NULL, core_relo_rec_size=0, log_true_size=0, prog_token_fd=0}, 148) = 12 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_ARRAY, key_size=4, value_size=4, max_entries=1, map_flags=BPF_F_MMAPABLE, inner_map_fd=0, map_name="libbpf_mmap", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0, map_extra=0, value_type_btf_obj_fd=0, map_token_fd=0, excl_prog_hash=NULL, excl_prog_hash_size=0}, 92) = 12 root@x2:~# And btf: root@x2:~# strace -e openat perf trace -e connect,bind |& grep "/sys/kernel/btf/vmlinux" openat(AT_FDCWD, "/sys/kernel/btf/vmlinux", O_RDONLY) = 12 ^C root@x2:~# And copying the sockaddr parameters according to its addrlen or the cap in the augmented bpf, that probably needs to be a bit bigger for local sockets: ⬢ [acme@toolbx perf-tools-next]$ echo -n /var/run/.heim_org.h5l.kcm-soc | wc -c 30 ⬢ [acme@toolbx perf-tools-next]$ ls -la /var/run/.heim_org.h5l.kcm-socket srw-rw-rw-. 1 nobody nobody 0 Sep 14 23:13 /var/run/.heim_org.h5l.kcm-socket ⬢ [acme@toolbx perf-tools-next]$ root@x2:~# perf trace -e connect,bind --max-events 10 0.000 ( 0.717 ms): pool-0/29901 connect(fd: 9, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0 3.733 ( 0.059 ms): pool-0/29901 connect(fd: 10, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0 8.859 ( 0.054 ms): pool-0/29901 connect(fd: 9, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0 10.880 ( 0.053 ms): pool-0/29901 connect(fd: 9, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0 1225.303 ( 0.081 ms): systemd-resolv/103685 connect(fd: 30, uservaddr: { .family: INET6, port: 53, addr: fd55:6f31:c26b::1, scope_id: 4 }, addrlen: 28) = 0 1226.000 ( 0.046 ms): systemd-resolv/103685 connect(fd: 31, uservaddr: { .family: INET6, port: 53, addr: fd55:6f31:c26b::1, scope_id: 4 }, addrlen: 28) = 0 1371.972 ( 0.055 ms): systemd-resolv/103685 connect(fd: 27, uservaddr: { .family: INET6, port: 53, addr: fd55:6f31:c26b::1, scope_id: 4 }, addrlen: 28) = 0 1382.266 ( 0.260 ms): Socket Thread/2663038 connect(fd: 178, uservaddr: { .family: INET, port: 443, addr: 186.192.83.34 }, addrlen: 16) = -1 (unknown) (Operation now in progress) 5003.508 ( 0.063 ms): pool-0/29901 connect(fd: 9, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0 5007.007 ( 0.054 ms): pool-0/29901 connect(fd: 10, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-soc }, addrlen: 110) = 0 root@x2:~# Fixes: a68fd6a6cdd309bb ("perf trace: Collect augmented data using BPF") Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01tools/power turbostat: Read complete CPU listsAli Ahmet Memis
CPU_SUBSET_MAXCPUS accepts CPU IDs through 8191, but the sysfs and cgroup CPU-list readers stop at 1024 bytes. A fragmented cpuset or hybrid PMU CPU list can exceed that size and be truncated. initialize_cpu_set_from_sysfs() can also pass a full, non-NUL-terminated buffer to parse_cpu_str(), causing an out-of-bounds read. Additionally, initialize_cpu_set_from_sysfs() returns with the file still open on success. It is now called once per CPU for thread_siblings_list, so large systems can leak thousands of descriptors during topology discovery. Use getline() so both readers receive a complete, NUL-terminated line. Close and free the sysfs CPU-list resources on every path, and report malformed input from the correct buffer. Fixes: eb187540d13a ("tools/power turbostat: Increase CPU_SUBSET_MAXCPUS to 8192") Fixes: 58839fdbd441 ("tools/power turbostat: Process HT siblings in CPU order") Cc: stable@vger.kernel.org Signed-off-by: Ali Ahmet Memis <ali@iusegentoo.com> Signed-off-by: Len Brown <len.brown@intel.com>
2026-10-01Merge tag 'net-7.3-rc6' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net Pull networking fixes from Paolo Abeni: "Including fixes from Bluetooth, WiFi and netfilter. We are actively retargeting several non-urgent fixes towards next, but the traffic on the ML looks ever-increasing, and propagating the push-back towards subsystems is not immediate. No known outstanding regressions. Current release - regressions: - netfilter: nft_set_rbtree: skip transaction elements during GC Previous releases - regressions: - sched: cls_api: reclaim an empty proto on the error path - core: - fix checksum offsets in skb_splice_from_iter() - cap skb->queue_mapping when the tx queue is picked - page_pool: fix use-after-free in page_pool_recycle_ring_bulk() - wifi: - mac80211: fix slab-out-of-bounds read in ieee80211_monitor_select_queue() - mac80211: drop oversized fragments to avoid extra_len overflow - netfilter: - flowtable: restore ieee80211 forward path - bluetooth: hci_conn: Lock parent access during enhanced SCO setup - eth: - bcmgenet: allocate RX buffers as page fragments - stmmac: fix rx Scatter-Gather support - octeontx2-pf: fix aura BPID assignment when CONFIG_DCB is enabled - gve: DQO: accept TSO packets with non-protocol gso_type bits - r8169: disable EEE on RTL8168h/8111h Previous releases - always broken: - tcp: refresh TS.Recent for accepted old ACKs - wifi: - ath11k: reset ar->num_stations on hardware start - cfg80211: fix RTS threshold setting for single-radio PHY - bluetooth: btintel_pcie: fix plen overflow in btintel_pcie_recv_frame() - eth: bcmgenet: fix NULL dereference in set_coalesce before first open Misc: - Eric is retiring from google and updating his contact info" * tag 'net-7.3-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (96 commits) net: phy: aquantia: fix system interface type not updated in forced mode net: usb: qmi_wwan: add Rolling Wireless RN947R net: mvneta: clear XDP pfmemalloc flag between frames ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel() net/mlx5e: Fix AF_XDP TX timestamp teardown NULL dereference r8169: disable EEE on RTL8168h/8111h octeontx2-pf: Fix RSS indirection table size sctp: check RCV_SHUTDOWN after the sendmsg connect wait net: sparx5: make ports inherit the switch base mac address type net: microchip: vcap: stop scanning after deleting key field netfilter: flowtable: restore ieee80211 forward path netfilter: flowtable: generalize pending status bit netfilter: bpf: reject invalid NAT manipulation types netfilter: nft_set_rbtree: skip transaction elements during GC ipvs: filter some flags received in the backup server ipvs: do not create invisible templates ipvs: bound LBLCR and LBLC cache growth ipvs: fix missing counter decrement in lblc netfilter: nft_flow_offload: drop flowtable reference on init error path selftests: net: check timestamp echo after an old ACK ...
2026-10-01selftests/filesystems: check that the nullfs root can't be reconfiguredChristian Brauner
Add a test for the root of an empty mount namespace: - fspick() of the root fails with EINVAL - mount(MS_REMOUNT) of the root fails with EINVAL - umount() of the root fails and doesn't remount it read-only Link: https://patch.msgid.link/20260930-work-mount-fixes-3-v1-12-be34c83956ae@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-10-01selftests/filesystems: check that a mount namespace file on top doesn't bury ↵Christian Brauner
a mount Add a test for moving a mount with a mount namespace file on top of it: - S, a bind mount of a file, with a newer mount namespace's file on top - A shared with a slave B that has Q on B/file - S moved onto A/file, its copy lands on B/file below Q B/file keeps reading Q and once Q is unmounted it reads the copy. Link: https://patch.msgid.link/20260930-work-mount-fixes-3-v1-9-be34c83956ae@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-10-01selftests/filesystems: check that OPEN_TREE_NAMESPACE keeps mounts coveredChristian Brauner
Add a test for open_tree(OPEN_TREE_NAMESPACE) from a user namespace that doesn't own the mount namespace it copies from: - a file covered by a private or an unbindable tmpfs mount - the non-recursive copy of the parent mount fails with EINVAL - the recursive copy keeps the file covered in the new mount namespace - the owner of the mount namespace keeps the bind mount semantics Link: https://patch.msgid.link/20260930-work-mount-fixes-3-v1-7-be34c83956ae@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-10-01selftests/filesystems: check that a recursive bind mount can't pin the ↵Christian Brauner
caller's mount namespace Add a test for a recursive bind mount of a namespace file in another mount namespace: - a bind mount of the network namespace file, held through a descriptor - the caller's own mount namespace file stacked on top of it there - the recursive bind mount through the descriptor fails with EINVAL - a plain bind mount of the file still works The copy would pin the namespace it is put in otherwise. Link: https://patch.msgid.link/20260930-work-mount-fixes-3-v1-5-be34c83956ae@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-10-01selftests/filesystems: check that a busy submount survives a synchronous umountChristian Brauner
Add a test for the shrinkable submounts of a synchronous umount: - P shared, P1 a slave that is shared in turn, P2 its peer - B on P/options with copies on P1 and P2, R on top of the copy in P2 - P with B moved below P1, R is the working directory - umount(P1) slides R to where the copy of B is looked up The umount fails with EBUSY and R stays mounted. Needs the tracefs automount below debugfs for the shrinkable mounts. Link: https://patch.msgid.link/20260930-work-mount-fixes-3-v1-3-be34c83956ae@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-10-01Merge tag 'iio-for-7.4a' of ↵Greg Kroah-Hartman
ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: IIO: 1st set of device support, features and cleanup for 7.4 2 merges - v7.3-rc4 to get a x86 build fix needed by the ad9910 driver. - devm_notifier_chain_register to pick up the IIO specific users of this new infrastructure. New device support ------------------ Major refactors or new drivers needed: adi,ad3530r - Support for the AD5710R and AD5711R 8 channel IDAC / VDAC parts. Needed substantial driver rework to support channel type controls. adi,ad5529r - New driver for this 16 channel DAC with 12 and 16 bit variants. adi,ad7768 - New driver for the 8 (AD7768) and 4 (AD7768-4) channel variants of this 24-bit simultaneous sampling ADC family. They are very different from the 1 channel variant that has as separate driver. adi,ad9910 - New driver for this DDS (Direct Digital Synthesizer). This was a large undertaking is it is a complex chip requiring quite a lot of new IIO ABI. Delayed from last cycle by an x86 bug that was fixed in rc4. adi,ade9000 - Add support for the ADE9078 polyphase energy metering device. Required significant changes to introduce multiple part support into this driver. adi,adis16201 - Add support for the ADIS16203 device, replacing the driver in staging. axiado,saradc - New driver for the SARADC found on the AX3000 and ADX3005 SoCs. liteon,ltr501 - Add support for the LTR-329ALS-01 ambient light sensor. Included various bits of driver modernization. microchip,mcp48fev02 - Split previously I2C specific mcp47feb02 into core and I2C specific parts. - Add an SPI specific part for the many parts in the MCP48FxBy1/2/4/8 series of SPI DACS 24 different part numbers covering: - 8, 10 and 12 bit resolutions - 1, 2, 4, and 8 channels - EEPROM and no non volatile storage variants. - Substantial driver modification and cleanup was needed prior to the new support. maxim,max40080 - New driver for this current-sense amplifier with integrated ADC. renesas,rzg2l_adc - Support the RZ/G3L ADC 1 that is dedicate to the on-chip thermal sensor unit. The thermal parts of this support will be going through that tree. sensortek,stk3310 - Add support for the STK36C61 Ambient Light, proximity and RGB color sensor. Handling had to be added for RGB elements and the driver in general had to be made ready for support multiple parts. ti,ads1100 - Add support for the ADS1110 with faster data rate and 2.048V reference. ti,ads112c04 - New driver to support this 16bit sigma-delta ADC. vishay,veml6031x00 - New driver for this ambient light sensor that was built in in stages. - Add triggered buffer data capture. - Add support for events and triggers. - Enable mysterious 'internal calibration' setting. Minor additions such as IDs, compatibles or device specific data. adi,ad3530r - Support the AD3536R which is low resolution equivalent of the already supported AD3532R. adi,ad4080 - Support the AD4885 - only needed chip specific data. aosong,am2315 - Add support for the AM2320, fully compatible wth the AM2315. invensense,icm42600 - Minor tweaks + addition of compatible for the ICM42630 IMU. mediatek,mt2701-adc - Compatible for the MT6572 rockchip,saradc - Support the RV1106. Features -------- IIO Core - Add a helper to discover if timestamps are enabled. In a few cases (typically when there is batching involved) we may have to refuse to start the buffer if timestamps are enabled. Provided a helper to allow that to be queried. IIO backend - CRC support. infineon,dps310 - Add triggered buffer support. linear,ltc2497 - Add 2x conversion speed mode. - Add the internal temperature channel. renesas,r9a09g077 - Add missing DMA properties to DT and enable use of DMA - Expose the sampling frequency as per channel attributes. ti,ad1015 - Add per channel labels from DT support. ti,ads112c14 - Add dataready trigger using continuous mode if only one channel is enabled. - Add burnout current control including new IIO ABI. - Add filter control. - Add new ABI for settling time. Cleanup and minor or late breaking fixes ---------------------------------------- Only calling out the more significant changes or ones that were carried on out on several drivers. multiple drivers - Add sanity check for spi_device_get_match_data() returning NULL due to use of driver_override. - Add some useful __counted_by_ptr markings. - Add some missing MODULE_DEVICE_TABLE() calls. - Use dmaenginge_get_dma_device() instead of chan->device->dev - A few precursor cleanups for planed devm_ object allocators. - Disable autosuspend on exit. Note there is work ongoing to make this unnecessary. - Header reorders and IWYU being applied to what was included. - Use devm_blocking_notifier_chain_register() to replace open coded equivalent. - Ensure some clk related structures are always fully initialized. - Use the size checked iio_push_to_buffers_with_ts() replacement for iio_push_to_buffers_with_timestamp(). - Avoid shadowing various error codes from store() callbacks. adi,axi-adc - Fix missing mutex_init() adi,ad4080 - Ensure autoincrement is set for multi register reads. adi,ad5758 - Fix wrong offset calculation - Reject out of range values rather than truncating values. - Make sure buffer used for bulk acceses is DMA safe. adi,ad7816 - Local lock to protect state by serializing accesses. A few extra locations were added much later in the cycle. - Stop using non DMA safe buffers by using spi_write_then_read() to ensure the data was bounce buffered. adi,adxl367 - Ensure interrupt mapping is resolved before device setup reducing work done before potential deferral. - Support INT2 pin. asahi-kasei,ak8975 - Use BIT() and GENMASK() to improve readability of defines. - Add an enum for scan mask elements. - Switch to devm_ for all resources. avago,apds9306 - Fix the default sampling frequency. awinc,aw96103 - Fix an early return that stopped all channels being checked. broadcom,iproc-adc - General modernization and conversion to devm managed cleanup. - Use dev_err_probe(), local dev pointer and drop some duplicate error messages. capella,cm32181 - Add device specific dt-binding as trivial-devices doesn't provide vdd-supply or interrupt properties. freescale,mma8452 - Modernize driver via guard(), IIO specific cleanup helpers and bulk regulator handling. infineon,dps310 - Add context analysis lock markings. - Single local acquire / release per raw read. - Replace opencoded get_unaligned_be24(). - Fix incorrect CFG_REG bit definitions. invensense,icm42600 - Ensure ODR is updated when switching power mode to paper over a hardware bug. - Fix detecting ODR change in invalid data packets. - Optimize high frequency data readback by not bothering to read the FIFO count when the watermark is known to have been passed. - Various other minor fixes. isil,isl29028 - Fix a runtime pm reference leak. liteon,ltr501 - Make the dt-binding property proximit-near-level only available on parts that support it. kionix,kx022a - Use as structure to make the channel layout explicit and use that for all cases (previously there were two similar buffers). pulsed-light,lidar-lite-v2 - Move binding from trivial-devices to it's own file as there are power enable and mode control pins that needs describing. renesas,r9a09g077 - Drop some interrupt descriptions for interrupts that aren't connected to the interrupt controller. - Avoid direct reads when buffer enabled. - Store the device PA and IRQ in state ready for the DMA support. st,hts221 - Fix a potential division by zero if calibration data corrupted. - Allow an unknown Who Am I value to support fallback dt-compatibles. - Replace opencoded oversampling_ration_available handling with read_avail callback. st,stm32-adc - Fix up some wrong minimum sample times. ti,ads1100 - Fix readings after datarate change by ensuring a long enough wait for a new sample. ti,tmp117 - Fix case where cached state was updated before we know if the write to the device succeeds. vishay,veml3328 - Reshape the scale array to improve readability as it is made up of value pairs. * tag 'iio-for-7.4a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (270 commits) iio: dac: ad5758: Fix the offset calculation iio: dac: ad5758: Reject out-of-range raw values iio: dac: ad5758: Fix alignment for DMA safety iio: pressure: dps310: check the lock markings with context analysis iio: core: add an accessor for scan_timestamp iio: pressure: dps310: add triggered buffer support iio: pressure: dps310: take the lock once per raw read iio: pressure: dps310: use get_unaligned_be24() for the 24-bit results iio: pressure: dps310: use a local device pointer in probe iio: pressure: dps310: fix CFG_REG bit definitions staging: iio: adc: ad7816: Protect sysfs attributes with mutex dt-bindings: iio: Add dedicated CM32181 schema iio: adc: stm32: fix minimum sampling time values iio: light: veml6031x00: Enable internal calibration iio: dac: add support for Microchip MCP48FEB02 dt-bindings: iio: dac: add support for MCP48FEB02 SPI iio: dac: mcp47feb02: refactor MCP47FEB02 I2C driver into two modules iio: dac: mcp47feb02: protect EEPROM store sequence with mutex iio: dac: mcp47feb02: Avoid unjustified probe error on missing label iio: adc: rzg2l_adc: Add RZ/G3L ADC support for TSU ...
2026-10-01Merge 7.3-rc5 into char-misc-nextGreg Kroah-Hartman
Lots of subtrees are based on newer -rc versions, so sync up further on the development cycle so that they can be cleanly merged into here. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-30selftests: drv-net: Request larger zcrx buffersBjörn Töpel
The large-chunk test always requests two base pages. On interfaces with a large MTU, that may not exceed two maximum-sized frames. Request a power-of-two buffer larger than twice the MTU. This makes the existing rx_buf_len check and data-integrity traffic exercise the larger layout. Signed-off-by: Björn Töpel <bjorn@kernel.org> Tested-by: Breno Leitao <leitao@debian.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260925104417.2325213-6-bjorn@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-30selftests/sched_ext: Test scx_bpf_cgroup_nr_cpus()Andrea Righi
Verify that scx_bpf_cgroup_nr_cpus() reports the number of CPUs in a cgroup's effective cpuset. Create a cgroup-v2 subtree where a child owns a cpuset and a leaf inherits it. Sample the kfunc from a BPF_PROG_TYPE_SYSCALL program and compare it with cpuset.cpus.effective for the root, the cpuset owner and the inheriting leaf, without a scheduler attached. Attach a scheduler and verify the value observed from ops.cgroup_init(). Then restrict the child's cpuset to a non-contiguous and a single-CPU set, and finally disable cpuset below the parent so that both cgroups inherit the parent's cpuset. A disabled cpuset css stays attached to its cgroup until it is asynchronously offlined, so poll briefly for the last step. Skip the test when the required controllers or two CPUs are unavailable. Assisted-by: LLM Signed-off-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2026-09-30sched_ext: Introduce scx_bpf_cgroup_nr_cpus()Andrea Righi
Hierarchical BPF schedulers may need to know how many CPUs a cgroup can run on when distributing group-wide weights. For example, fair's group share calculation scales a group's weight by the smaller of its estimated runnable task count and the number of CPUs in its effective cpuset. Without that count, a BPF scheduler can only use the machine-wide CPU count and may give a group confined to a few CPUs excessive shares. A task's effective affinity can include per-task restrictions, so it cannot reliably represent the group's cpuset. Reading the cpuset directly from BPF would require CO-RE access to private cgroup and cpuset structures, including inherited cpuset resolution, making the approach fragile across kernel versions. Add scx_bpf_cgroup_nr_cpus(), which returns the same count fair uses through cpuset_num_cpus(). The count is independent of CPU or CID numbering, so the kfunc is available to both cpu-form and cid-form schedulers from any context. Also add a compat wrapper which falls back to nr_cpu_ids on older kernels. Signed-off-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2026-09-30sched_ext: Sync tools autogen enum headers from the scx repoTejun Heo
Sync the four autogen enum headers with the scx repo at c9b90b3ad3d0 ("scheds/include: Sync with kernel sched_ext/for-7.4 (c6fe97c34a1a)"). The enum definition and ABI tables pick up the enumerators the kernel gained since the last sync. The two lookup tables are taken verbatim from scx's copies so the files stay identical: their task state lookups move from the removed scx_task_state to scx_ent_flags, where 7203d77d6e04 ("sched_ext: Simplify task state handling") put the states, and until now resolved to zero. The only entry the kernel copy gains is SCX_RQ_BAL_KEEP, which scx keeps for older kernels and which zero-fills here. Signed-off-by: Tejun Heo <tj@kernel.org>
2026-09-30sched_ext: Sync common and compat headers from the scx repoTejun Heo
Sync cid.bpf.h, common.bpf.h, compat.bpf.h and compat.h with the scx repo at c9b90b3ad3d0 ("scheds/include: Sync with kernel sched_ext/for-7.4 (c6fe97c34a1a)"), which accumulated the following since the last sync: - cid.bpf.h grew the cmask helpers the cid-form schedulers use: fill, empty and end tests, unchecked and word-level access, distribute picks over an arena rotor indexed by cid, range set and clear, and three-operand and, or and andnot that report whether the result is empty. Its word loops walk with bpf_arena_for() and its bit helpers take the fetching atomics when the loader's probe finds the JIT lowers them. - The prolog probe's default now makes is_migration_disabled() over-report, which errs toward local-only dispatch instead of crashing, and the cid-form open macros repoint the probe at bpf_scx_reg_cid(), which cid-form schedulers register through. - scx_bpf_kick_cid() and scx_bpf_cidperf_set() changed their return types without being renamed, so compat.bpf.h declares both flavors of each and lets the kernel pick, the way scx_bpf_dsq_insert() is handled. - A macro supplies scx_bpf_cid_topo()'s size argument from the output buffer, TRAILING_OVERLAP() embeds a struct that ends in a flexible array together with its storage, bpf_arena_for() walks a range in a form the verifier converges on, and features.bpf.h carries the kernel feature bits the loader probes before load. const-defs.h holds the per-architecture cacheline size that cid.bpf.h aligns its rotor slots to. scx_qmap already used the cmask helpers, and the three-operand forms of cmask_and() and cmask_andnot() had not reached its copy of cid.bpf.h, so tools/sched_ext no longer built against scx's headers. Its five calls take the three-operand form now, with the copy-then-operate pairs folded into one call each. Signed-off-by: Tejun Heo <tj@kernel.org>
2026-09-30selftests: cgroup: Preserve command arguments in with_stress.shRen Tamura
with_stress.sh invokes the requested command through unquoted $*. This subjects the arguments to word splitting and pathname expansion: arguments containing whitespace are split, empty arguments disappear, and literal wildcard characters can expand to filenames. Invoke the command through "$@" so that the command name and each argument are passed as supplied by the caller. Assisted-by: LLM Signed-off-by: Ren Tamura <ren.tamura.oss@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2026-09-30selftests: cgroup: Enable the cpu controller in test_cpuRen Tamura
test_cpu uses cg_read_strstr() to check for "cpu" in the root cgroup's cgroup.subtree_control. The substring also matches "cpuset", so a hierarchy with only cpuset enabled skips writing "+cpu" during setup. The tests then run without the required controller enabled and report failures. When cpu is unavailable in that hierarchy, the suite also reports failures instead of skipping. Always write "+cpu" during setup and skip if the write fails. Enabling a controller that is already enabled is a no-op, so a separate presence check is unnecessary. This requires write access to cgroup.subtree_control even when cpu is already enabled. Assisted-by: LLM Signed-off-by: Ren Tamura <ren.tamura.oss@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2026-09-30KVM: selftests: Spell out UCALL in nested TSC scaling test's enumsSean Christopherson
Explicitly spell out UCALL instead of prefixing only U in the nested TSC scaling test's ucall commands, as it's all too easy to think USLEEP means "do usleep()", when it actually means "do sleep() in userspace". Opportunistically name the enum and take an enum instead of a bare integer for the to-be-checked level, to make it more obvious that the fact that the level values happen to correspond to '1' and '2' for the nesting level is largely coincidental (or perhaps it was intentional, but it's not a hard requirement for the test). Link: https://patch.msgid.link/20260930173635.3362655-22-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
2026-09-30KVM: selftests: Use GUEST_SYNC2() in nested TSC scaling testSean Christopherson
Use GUEST_SYNC2() instead of open coding equivalent functionality using raw ucall() invocations in the nested TSC scaling test. No functional change intended. Link: https://patch.msgid.link/20260930173635.3362655-21-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
2026-09-30KVM: selftests: Randomize L2's TSC offset in the nested TSC scaling testSean Christopherson
Randomize L2's TSC offset in the nested TSC scaling test, not because it's all that interesting, but because hardcoding a copmletely arbitrary value is all kinds of silly. Link: https://patch.msgid.link/20260930173635.3362655-20-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
2026-09-30KVM: selftests: Test non-zero TSC offset on SVM in nested TSC scaling testSean Christopherson
Set L2's TSC offset for SVM as well as VMX in the nested TSC scaling test. Odds are good skipping SVM was pure oversight. Fixes: e6bcdd212238 ("KVM: selftests: Extend vmx_nested_tsc_scaling_test to cover SVM") Link: https://patch.msgid.link/20260930173635.3362655-19-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
2026-09-30KVM: selftests: Verify that KVM saturates L2 TSC freq on {under,over}flowSean Christopherson
Extend the nested TSC scaling test to validate the extreme ends of what hardware supports, i.e. validate that KVM allows L1 to scale L2's virtual TSC frequency up/down to the architectural maximum/minimum, from L1's perspective, and that KVM saturates L2's effective frequency when L2's frequency can't be virtualized by hardware (which is possible when stacking multipliers/ratios across L1 and L2). Link: https://patch.msgid.link/20260930173635.3362655-18-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
2026-09-30KVM: selftests: Test L1 "up" and L2 "down" in nested TSC scaling testSean Christopherson
Now that the guts of the nested TSC scaling test support scaling L2 down, validate all four combinations of scaling up/down L1 and L2. Ideally, the test would also validate integer+fractional scale up scenarios, but prioritize keeping the test and math somewhat understandable. Opportunistically drop the stale file comment about the test's name. Link: https://patch.msgid.link/20260930173635.3362655-17-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
2026-09-30KVM: selftests: Sanity check KVM's default TSC freq in nested TSC scaling testSean Christopherson
Explicitly verify that both L1 and L2 can run at KVM's default TSC frequency reported via KVM_GET_TSC_KHZ, e.g. that KVM_SET_TSC_KHZ can take in what KVM_GET_TSC_KHZ spits out. Link: https://patch.msgid.link/20260930173635.3362655-16-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
2026-09-30KVM: selftests: Explicitly pass TSC frequencies to guts of TSC scaling testSean Christopherson
Explicitly pass the L1 and L2 TSC frequencies, along with the L2 multiplier, to the main test routine in the nested TSC scaling test. This will allow testing both "scale up" and "scale down" scenarios, and that KVM saturates L2's frequency if it's scale up/down beyond what hardware can support, in which case the expected frequency will not exactly match the L2 multiplier. Link: https://patch.msgid.link/20260930173635.3362655-15-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
2026-09-30KVM: selftests: Use KVM's reported TSC KHz as L0's frequency (sanity checked)Sean Christopherson
Use KVM's reported default TSC frequency as L0's frequency instead of calibrating L0's frequency using RDTSC. Trying to calibrate the frequency in userspace is all but guaranteed to be wildly inaccurate, e.g. due to interrupts, preemption, etc, and no known CPU supports TSC scaling without also having a constant TSC. I.e. there's no need to calibrate the current frequency, as it should also be the same as KVM's default frequency. Opportunistically sanity check KVM's reported frequency against what is observed via RDTSC, e.g. so that KVM_GET_TSC_KHZ or platform issues show up much earlier in the test, before VMs get involved. Link: https://patch.msgid.link/20260930173635.3362655-14-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
2026-09-30KVM: selftests: Allow +/- 1 tolerance if expected TSC frequency is <100Sean Christopherson
Massage the nested TSC scaling test's checker to allow for validating an expected TSC frequency of 1Hz, which is achievable for L2 since L1 can use a completely arbitrary fractional ratio. To do so, set the minimum tolerance to 1, and make the thresholds inclusive, i.e. for an expected frequency of 1, allow the actual frequency to be in the range of [0,2]. Because scaling L2's frequency down to a single Hz makes the virtual TSC run soooo comically slow, and because all of the math is done with basic integer arithmetic, it's very easy for the test to observe what appears to be a frequency of 0. Link: https://patch.msgid.link/20260930173635.3362655-13-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
2026-09-30KVM: selftests: Print out the failing L{0,1,2} level in nested TSC scaling testSean Christopherson
Print out which one of L0, L1, or L2 TSC frequency checks failed if the nested TSC scaling test detects an out-of-bounds frequency. Triaging test failures without the level information is unnecessarily painful. Link: https://patch.msgid.link/20260930173635.3362655-12-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>