summaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)AuthorFilesLines
2026-08-07selftests: net: shaper: Cover scalar attributesMohsin Bashir1-0/+68
Exercise queue-scope scalar shaper attributes reported by the device, including rate limits, burst, priority and weight. Build the set request from advertised capabilities so devices are tested for the attributes they claim rather than skipped for missing unrelated fields. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-12-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07selftests: net: shaper: Add reparenting rejection testMohsin Bashir1-0/+150
Add reject_reparenting to verify that the group operation rejects attempts to change an existing node's parent. The test creates two node shapers under netdev and verifies that re-grouping the first node under the second fails with EOPNOTSUPP. It also verifies that updating the node with the same parent succeeds, and that updating the node without specifying a parent keeps the queue leaves under the original node while updating their weights. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-11-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07selftests: net: shaper: Add queue migration between nodes testMohsin Bashir1-0/+102
Add move_queue_between_nodes to verify that a queue can be moved from one node to another via re-grouping. Creates N1 with Q1,Q2 and N2 with Q3, then re-groups N2 with Q1,Q3 to steal Q1 from N1. Verifies Q1 moved to N2 and Q2 remains under N1. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-10-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07selftests: net: shaper: Add child node deletion reparent testMohsin Bashir1-0/+77
Add delete_child_reparent to verify that deleting a child node reparents its queue leaves to the parent node. Creates a two-level hierarchy (N1 with Q1,Q2 and child N2 with Q3), deletes N2, and verifies Q3's parent becomes N1. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-9-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07selftests: net: shaper: Add nested depth limit discovery testMohsin Bashir1-0/+117
Add nested_depth_limit to incrementally create deeper nesting levels until the driver rejects. Reports the maximum supported nesting depth on both pass and fail. A device advertising nesting support must support at least depth 2, otherwise nesting is meaningless. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-8-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07selftests: net: shaper: Add .group rate update testMohsin Bashir1-0/+67
Add group_update_rate to test updating an existing node's rate via the .group callback. Creates a node with bw_max=10000, re-groups with bw_max=50000, and verifies the rate changed while leaves remain under the same node. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-7-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07selftests: net: shaper: Add node scope .set rate update testMohsin Bashir1-0/+38
Add set_node_shaper to test updating a NODE scope shaper's rate via the .set callback. Creates a node group with bw_max=10000, updates to 20000 via .set, and verifies the change. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-6-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07selftests: net: shaper: Add basic_groups_with_rate testMohsin Bashir1-13/+66
Add a test that groups queues under the netdev parent with rate limiting enabled. Extract the common group-under-netdev flow into _group_under_netdev helper to share with basic_groups. The test independently checks for netdev scope bw_max and metric capabilities before proceeding, and verifies that the netdev shaper persists after leaf deletion. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-5-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07selftests: net: shaper: Decouple basic_groups from netdev rate limitingMohsin Bashir1-24/+16
Decouple basic_groups from the set_nshapers test dependency. The test was gated on cfg.netdev which is set by set_nshapers. Replace with direct capability checks: netdev scope support (required for grouping under netdev handle) and queue scope nesting + weight. Remove bw-max and metric from the .group call so the test validates pure queue grouping without rate limiting. The rate-limited variant is restored in the following patch, which adds a dedicated basic_groups_with_rate test. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-4-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07selftests: net: shaper: Prepare helpers for group testsMohsin Bashir1-59/+86
dup_leaves expects the kernel to reject a group request that lists the same queue twice. When that rejection does not happen, ksft_raises only records a failed check and leaves cm.exception as None, so the following errno check raises AttributeError. Worse, the accepted group request leaves a node shaper and queue 0 behind, which makes later tests fail for an unrelated reason. Handle the negative test explicitly instead. If group fails, verify that the errno is EINVAL and return. If group succeeds, delete the node returned by the operation and queue 0 before reporting the failure. Give the duplicate leaves different weights so the request still contains two distinct leaf entries while exercising duplicate handle validation. This also introduces _delete_shaper(), cached _cap_get(), and _require_caps() helpers as preparation for the following shaper group tests. The follow-on tests need the same capability checks for node and queue scope support. Keeping that logic in one place avoids repeating raw EOPNOTSUPP handling in each test. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-3-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07selftests: net: shaper: Drop redundant command timeoutsMohsin Bashir1-3/+3
Commit 57bb59ab6fa3 ("selftests: net: bump default cmd() timeout to 20 seconds") raised the default cmd() timeout to 20 seconds, so the explicit timeout=10 passed to the ethtool channel commands in queue_update() is now redundant and, in fact, shorter than the default. Drop it and rely on the default timeout. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-2-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-07Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf 7.2-rc7Daniel Borkmann39-103/+1032
Cross-merge BPF and other fixes after downstream PR. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2026-08-07Merge branches 'pm-sleep', 'pm-runtime', 'pm-powercap' and 'pm-tools'Rafael J. Wysocki6-18/+77
Merge updates related to system sleep handling and runtime PM, a power capping update, and power management tools updates for 7.3-rc1: - Rename the PM core module parameter prefix to "pm" and allow the PM transition (DPM) watchdog to be disabled by default (Tzung-Bi Shih) - Fix off-by-one in wakelocks number limit check in the system sleep sysfs interface (Haowen Tu) - Remove kernel-doc markings from helper descriptions in the core hibernation code (Adi Nata) - Use %pe to print error pointer values in the hibernation core (Ronan Marchal) - Fix memory leak in snapshot_write_next() error path (Malaya Kumar Rout) - Delay allocating and linking the next swap_map_page in the hibernation image saving code until another image page actually needs to be recorded (Haesung Kim) - Stop setting runtime_error on runtime resume callback failures to allow drivers to recover from resume issues (Praveen Talari) - Handle PMU registration failure during probe in the intel_rapl_tpmi driver (Sumeet Pawnikar) - Avoid optional imports in intel_pstate_tracer unless they are really needed (Yousef Alhouseen) - Add generic CPPC performance display to the cpupower utility, build and call CPPC information on non-AMD processors, make cpupower print kernel and hardware frequency information, and add libm to cpupower for generic CPPC view (Jeremy Linton) - Remove conditional return with no effect from cpupower (Sang-Heon Jeon) * pm-sleep: PM: sleep: Allow disabling DPM watchdog by default PM: sleep: Rename module parameters prefix to "pm" PM: hibernate: swap: defer linking the next map page PM: hibernate: Fix memory leak in snapshot_write_next() error path PM: hibernate: Use %pe to print error pointer values PM: hibernate: Remove kernel-doc markings from helper descriptions PM: sleep: Fix off-by-one in wakelocks number limit check * pm-runtime: PM: runtime: Only set runtime_error on suspend callback failures * pm-powercap: powercap: intel_rapl_tpmi: Handle PMU registration failure during probe * pm-tools: cpupower: remove conditional return with no effect tools/power: intel_pstate_tracer: avoid optional imports for help cpupower: Add libm to cpupower for generic CPPC view cpupower: Print kernel and hardware frequency information cpupower: Build and call CPPC information on non-AMD processors cpupower: Add generic CPPC performance display
2026-08-07Merge branches 'thermal-core', 'thermal-hwmon', 'thermal-intel' and ↵Rafael J. Wysocki1-0/+1
'thermal-tools' Merge updates of the thermal core, thermal drivers for Intel platforms and the thermometer utility for 7.3-rc1: - Use sysfs_emit_at() in trans_table_show() (Thorsten Blum) - Remove hwmon class devices created for thermal zones when the thermal zone devices holding them are removed (Rafael Wysocki) - Add support for the Directed Package-level Thermal Interrupt to the Intel thermal throttling driver to allow package-level thermal interrupts to go to one specific CPU in a processor package instead of going to all of the CPUs in it (Ricardo Neri) - Clean up RFIM groups on DVFS failure and clean up ODVP on probe failures in the int340x thermal driver (Pengpeng Hou) - Remove redundant dev_err() from the int340x thermal driver and the bxt_pmic driver (Pan Chuang) - Simplify ptc_temperature_write() in the int340x thermal driver by using kstrtou32_from_user() (Dmitry Antipov) - Close fd on realloc() failure in the thermometer utility (Amarjeet) * thermal-core: thermal: sysfs: Use sysfs_emit_at() in trans_table_show() * thermal-hwmon: thermal: hwmon: Remove hwmon class device along with its parent * thermal-intel: thermal: intel: int340x: simplify ptc_temperature_write() thermal: intel: bxt_pmic: Remove redundant dev_err() thermal: intel: int340x: Remove redundant dev_err() thermal: intel: int3400: clean up ODVP on probe failures thermal: intel: int340x: clean up RFIM groups on DVFS failure thermal: intel: Add a syscore shutdown callback for kexec reboot thermal: intel: Add syscore callbacks for suspend and resume thermal: intel: Enable the Directed Package-level Thermal Interrupt thermal: intel: Add resources to handle directed package-level thermal interrupts x86/thermal: Add bit definitions for Intel Directed Package Thermal Interrupt * thermal-tools: tools/thermal/thermometer: close fd on realloc() failure
2026-08-07Merge branch 'pm-cpufreq'Rafael J. Wysocki2-7/+37
Merge cpufreq updates for 7.3-rc1: - Minor fixes and cleanups in assorted cpufreq drivers (Dan Carpenter, Guru Das Srinagesh, Haoxiang Li, Karl Mehltretter, Sasha Finkelstein, and Pan Chuang) - Fix cpufreq table creation and bios_limits() callback in the Rust bindings (Priya Bala Govindasamy) - Add IPQ5210 support to qcom-nvmem driver (Varadarajan Narayanan) - Adjust the .adjust_perf() cpufreq driver callback to allow the maximum performance value to be passed to drivers and update the intel_pstate driver to use it (Rafael Wysocki) - Set policy->cur to the actual requested frequency in the intel_pstate driver when the performance policy is used (Rafael Wysocki) - Simplify HWP handling on Broadwell processors in intel_pstate (Rafael Wysocki) - Fix setting minimum P-state at init time in intel_pstate (Rafael Wysocki) - Consolidate frequency values computation in intel_pstate and clean up code in that driver (Rafael Wysocki) - Add missing kernel-doc desciptions for structure and union members in the amd-pstate driver (David Vernet) - Handle missing policy in dynamic EPP callbacks in the amd-pstate driver (EDAMAMEX) - Introduce EXPORT_SYMBOL_FOR_PSTATE_UT() to export amd-pstate driver symbols to the amd-pstate-ut subdriver (K Prateek Nayak) - Add dynamic EPP as an "energy_performance_preference" mode in amd-pstate, remove the "amd_dynamic_epp" kernel command line option and the "dynamic_epp" sysfs attribute, and update the dynamic_epp documentation accordingly (K Prateek Nayak) - Add unit tests for CPPC Performance Priority and the "dynamic" EPP mode in the amd-pstate driver (K Prateek Nayak) - Set min_limit_freq based on bios_min_perf in amd-pstate and remove the defensive check for bios_min_perf from it (K Prateek Nayak) - Fix EPP return type and handle errors in amd-pstate during initialization, toggle auto_sel in active mode on shared memory systems, and cache the firmware programmed EPP value (Marco Scardovi) - Skip tests in amd-pstate-ut if the amd-pstate driver is not in active use (Qianheng Peng) - Replace sprintf() with sysfs_emit() in sysfs show in the cpufreq schedutil governor and fix a self-contradictory comment in sugov_iowait_apply() (Zhongqiu Han) - Fix the usage example for the sampling_rate tunable of the ondemand cpufreq governor in admin-guide (wangxiaodong) * pm-cpufreq: (40 commits) cpufreq: imx6q: fix out-of-bounds write when probed more than once cpufreq: imx6q: fix devres accumulation across driver rebind rust: cpufreq: Fix temporary write in Registration::bios_limit_callback rust: cpufreq: Add CPUFREQ_TABLE_END as last table entry in TableBuilder::to_table cpufreq: intel_pstate: Adjust policy->cur in active mode to policy cpufreq/amd-pstate: Document missing kernel-doc members cpufreq/amd-pstate-ut: Add unit test for CPPC Performance Priority cpufreq/amd-pstate-ut: Add unit test for "dynamic" EPP mode cpufreq/amd-pstate: Reduce the scope of exported symbols Documentation/amd-pstate: Update dynamic_epp documentation with new behavior cpufreq/amd-pstate: Remove "amd_dynamic_epp" cmdline and "dynamic_epp" sysfs cpufreq/amd-pstate: Add dynamic EPP as an "energy_performance_preference" mode cpufreq/amd-pstate: Extract platform profile to EPP conversion into a helper cpufreq/amd-pstate: Remove the defensive check for bios_min_perf cpufreq/amd-pstate: Set min_limit_freq based on bios_min_perf cpufreq: apple-soc: Calculate frequency as a 64-bit value kselftest: cpufreq: Backup and restore governor for sptests selftests/cpufreq: Remove unnecessary sudo from quick_shuffle() selftests/cpufreq: Remove unused local variables from switch_show_governor() cpufreq/amd-pstate: handle missing policy in dynamic EPP callbacks ...
2026-08-07perf sched latency: Add histogram and time interval optionsAaron Tomlin3-6/+239
While 'perf sched latency' reports task runtime and delay statistics (average and maximum delay), it does not provide a visual representation of how task wait times are distributed across latency ranges between snapshots (start and finish of the analysis window). The --histogram option collects CPU wait latencies (time between when a task becomes runnable and when it gets scheduled onto a CPU) into 22 latency buckets, displaying an ASCII bar chart distribution. The --hist-mode option configures the bucketing scheme: - log (default). Logarithmic latency buckets ranging from sub-microsecond (< 1 us) up to >= 1.05 seconds - linear. Equal-width linear latency buckets (i.e., 100 us steps up to >= 2.1 ms) The --time option allows filtering trace event processing to a specific time interval [start,stop]. Example histogram output excerpt: ❯ sudo perf sched latency --histogram --CPU 0 CPU Wait Latency Distribution Histogram (between snapshots) (total samples: 36114) ------------------------------------------------------------------- Latency Range | Count | Pct | Histogram Graph ------------------------------------------------------------------- < 1 us | 17 | 0.0% | # 2 - 4 us | 673 | 1.9% | # 4 - 8 us | 6237 | 17.3% | ###### 8 - 16 us | 3224 | 8.9% | ### 16 - 32 us | 1388 | 3.8% | # 32 - 64 us | 709 | 2.0% | # 64 - 128 us | 690 | 1.9% | # 128 - 256 us | 789 | 2.2% | # 256 - 512 us | 541 | 1.5% | # 512 - 1024 us | 2256 | 6.2% | ## 1 - 2 ms | 3577 | 9.9% | ### 2 - 4 ms | 13259 | 36.7% | ############## 4 - 8 ms | 2523 | 7.0% | ## 8 - 16 ms | 222 | 0.6% | # 16 - 32 ms | 10 | 0.0% | # >= 1.05 s | 3 | 0.0% | # ------------------------------------------------------------------- Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf sched latency: Auto-scale latency and runtime display unitsAaron Tomlin1-14/+32
Currently, 'perf sched latency' displays task runtime and delay values exclusively in milliseconds (ms). This can be hard to read when latencies are very small (in the microsecond or nanosecond range) or unusually large (seconds). Introduce auto-scaling for latency and runtime display columns. Values are dynamically scaled and output with the most appropriate unit: nanoseconds (ns), microseconds (us), milliseconds (ms), or seconds (s). Additionally, rename column headers from "Runtime ms", "Avg delay ms", and "Max delay ms" to "Runtime", "Avg delay", and "Max delay" respectively, adjust spacing to maintain column alignment and stripe redundant prefix strings from each row's format string to produce a clean, tabular output. For illustrative purposes, a comparison of the latency table header before and after this change is shown below: Before: ------------------------------------------------------------------------------------------------------------------------------------------- Task | Runtime ms | Count | Avg delay ms | Max delay ms | Max delay start | Max delay end | ------------------------------------------------------------------------------------------------------------------------------------------- kworker/2:2-mm_:154757 | 0.033 ms | 1 | avg: 0.829 ms | max: 0.829 ms | max start: 169486.543205 s | max end: 169486.544034 s After: ------------------------------------------------------------------------------------------------------------------------------------------ Task | Runtime | Count | Avg delay | Max delay | Max delay start | Max delay end | ------------------------------------------------------------------------------------------------------------------------------------------ kworker/2:2-mm_:154757 | 32.873 us | 1 | 829.347 us | 829.347 us | 169486.543205 s | 169486.544034 s | Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf sched: Handle missing trace samples in pipe modeAaron Tomlin1-21/+51
For pipe mode streams, event attributes are received dynamically during event processing, meaning session->evlist is not populated prior to perf_session__process_events(). To handle pipe input correctly: - Register the missing .attr, .tracing_data, .build_id, and .feature callbacks in cmd_sched() - Promote the handlers array to file-scope (latency_handlers[]) and dynamically assign matching tracepoint handlers (or process_sched_ignore) inside perf_sched__process_tracepoint_sample() when evsel->handler is NULL; replace process_sched_wakeup_ignore() with process_sched_ignore() - Perform the trace check post-processing when handling pipe data Fixes: 27295592c22e ("perf session: Share the common trace sample_check routine as perf_session__has_traces") Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf sched: Suppress latency table output when trace samples are missingAaron Tomlin1-11/+12
When 'perf sched latency' is executed on a perf.data file that lacks tracepoint samples (i.e., a file recorded without the -R flag or containing only non-tracepoint events), perf_session__has_traces() correctly outputs an error message. However, perf_sched__read_events() subsequently falls through and returns 0 (success). Consequently, caller functions such as perf_sched__lat() assume event processing succeeded and proceed to render empty latency header tables and total summary statistics. Fix this behaviour by ensuring perf_sched__read_events() aborts early and returns a suitable error code when perf_session__has_traces() evaluates to false. Additionally, validate thread__get_runtime() against NULL in map_switch_event() to prevent potential null-pointer dereferences. Fixes: 27295592c22e ("perf session: Share the common trace sample_check routine as perf_session__has_traces") Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf synthetic-events: Fix bounds and union member access in mmap2 build_id ↵Ian Rogers1-8/+12
synthesis Modify bounds and union member access in mmap2 build_id synthesis. Bound max_filename_len against the minimum of filename array capacity and the outer union stack layout minus sample ID trailers. This prevents both -E2BIG overruns and _FORTIFY_SOURCE array bounds aborts on strlcpy even if the enclosing union expands. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf synthetic-events: Fix bounds, stale state, and misc flags in kernel ↵Ian Rogers1-20/+50
module synthesis Clamp long DSO names to mmap/mmap2 filename boundaries accounting for sample ID headers to prevent buffer overruns in perf_event__synthesize_modules_maps_cb(). Explicitly clear misc flags and union padding to prevent stale Build-ID state from leaking between module synthesis events, and cast event buffer pointers to avoid _FORTIFY_SOURCE array bounds aborts when zeroing padding trailers. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf synthetic-events: Fix stack buffer overflow and bounds in cgroup synthesisIan Rogers1-6/+13
Fix a pre-existing stack buffer overflow bug in perf_event__synthesize_cgroup() where an in-place null padding loop wrote bytes past the end of the cgrp_root stack array buffer during cgroup tree traversal. Eliminate in-place path mutation, use PERF_ALIGN for path_len, clamp raw_path_len to prevent sample ID header trailer overruns, and use strlcpy with combined zero padding for alignment and sample ID headers. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf synthetic-events: Fix line synchronization, bounds, and truncation bugs ↵Ian Rogers1-62/+142
in proc maps reader Fix critical logic and boundary bugs in read_proc_maps_line() and caller. Ensure any mid-line hex/dec/char parsing failure invokes io__drain_line() safely, using a do-while loop to read and discard remaining characters until a newline or EOF is reached. Clamp pathname extraction size to account for trailing sample ID headers, use standard '//toolong' fallback literal for over-length pathnames, emit timeout flags for truncated entries securely via goto out;, and cast event buffer pointers to avoid _FORTIFY_SOURCE array bounds aborts across synthesis handlers. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf find-map: Remove PATH_MAX 128-byte stack array restrictionIan Rogers1-2/+8
Use getline() to dynamically allocate the required line buffer for maps parsing, guaranteeing bounds safety and avoiding compiler warnings by evaluating the return value in the loop condition directly. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf trace-event: Fix infinite loop in skip()Tanushree Shah1-4/+8
skip() ignores do_read()'s return value and unconditionally subtracts the requested chunk size from 'size' on every iteration. This was previously bounded by size being 'int': a maliciously large 64-bit value was truncated on assignment, capping the loop early by accident. Now that size is size_t, a crafted file supplying a very large size causes skip() to keep requesting BUFSIZ-sized reads and subtracting BUFSIZ from size regardless of whether do_read() actually succeeds, spinning indefinitely even after EOF or a read error. Check do_read()'s return value and break out of the loop on failure or EOF, so forward progress is only counted when a read actually succeeds. Signed-off-by: Tanushree Shah <tshah@linux.ibm.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf trace-event: Fix heap overflows in ↵Tanushree Shah1-0/+11
read_ftrace_printk()/read_saved_cmdline() Both functions read an attacker-controlled size directly from the input file and pass size + 1 to malloc() before reading size bytes into the result: read_ftrace_printk(): size is an unsigned int from read4(). When size == UINT_MAX, size + 1 overflows to 0, so malloc(0) returns a minimal allocation while size itself remains UINT_MAX. read_saved_cmdline(): size is an unsigned long long from read8(). When size == ULLONG_MAX, size + 1 overflows to 0 the same way. In both cases, do_read(buf, size) then attempts to read the full, unwrapped size into the tiny allocated buffer, a heap buffer overflow. This was previously masked by do_read()'s size parameter being 'int': passing these values truncated them, which the read() syscall's own boundary checks rejected before any data was read. Fixing that truncation (widening do_read() to size_t) is correct on its own, but it removes this accidental protection and exposes the pre-existing missing bounds check in both functions. Reject the one value that causes the overflow before it's used, in each function. Signed-off-by: Tanushree Shah <tshah@linux.ibm.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf trace-event: Avoid double free and leak in ↵Tanushree Shah1-1/+10
trace_event__cleanup()/trace_event__init() trace_event__cleanup() frees t->pevent but never clears the pointer. It can be called twice on the same trace_event: once from trace_report()'s error path, and again from perf_session__delete() during session teardown, resulting in a double free / use-after-free. Separately, trace_event__init() overwrites t->pevent/t->plugin_list without releasing any existing handle, leaking memory if it's called more than once on the same struct. eg. via a perf.data file with multiple PERF_RECORD_HEADER_TRACING_DATA headers. Guard against re-entry by returning early if t->pevent is already NULL, and clear it after cleanup so a repeat call is a safe no-op. Call trace_event__cleanup() at the start of trace_event__init(), so a repeated init releases any existing handle before allocating a new one. Signed-off-by: Tanushree Shah <tshah@linux.ibm.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-07perf trace-event: Fix integer truncation in do_read() and skip()Tanushree Shah1-14/+14
The do_read() and skip() functions use 'int' for size parameters, truncating 64-bit sizes from callers. This causes two issues: 1. Uninitialized memory dump: do_read() reads fewer bytes than allocated, leaving uninitialized heap memory that gets written to output files. 2. Out-of-bounds read: Parsing functions process the full 64-bit size while only partial data was read into the buffer. Change do_read(), __do_read(), and skip() to use size_t for size parameters and ssize_t for return values (where applicable), matching read()/write() system calls. Update callers to use ssize_t for storing return values. Fixes: 4a31e56599d4 ("perf tools: Get rid of read_or_die() in trace-event-read.c") Signed-off-by: Tanushree Shah <tshah@linux.ibm.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-08-08selftests/ftrace: Force C locale in ftracetestRui Qi1-0/+3
Some ftracetest test cases parse command output by matching English field names. Tools such as readelf may localize their output via gettext, while ftracetest currently inherits the user locale from the environment. If a translated field name is printed, parsing can fail even though the tested kernel behavior is unchanged. For example, add_remove_uprobe can fail to find the ELF entry point and then write a uprobe event with a missing offset. Export LC_ALL=C in the top-level ftracetest runner so every test case gets stable command output by default. Link: https://lore.kernel.org/all/20260807081512.2974757-2-qirui.001@bytedance.com/ Signed-off-by: Rui Qi <qirui.001@bytedance.com> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
2026-08-08selftests/ftrace: Convert ELF entry point to file offset in uprobe testRui Qi1-2/+25
The add_remove_uprobe test uses readelf -h to obtain the ELF entry point (e_entry) and passes it directly as the offset to uprobe_events. However, uprobe_events expects a file offset, not a virtual address. For PIE binaries, the virtual address happens to equal the file offset because the first LOAD segment has p_vaddr == p_offset, so the test works by coincidence. But for non-PIE executables, e_entry is an absolute virtual address that can far exceed the file size. When the probe is enabled, uprobe_register() checks offset > i_size_read(inode) and rejects it with -EINVAL. Fix this by converting the virtual address to a file offset using the ELF program headers: scan readelf -lW output for the LOAD segment containing the entry point, then compute file_offset = e_entry - p_vaddr + p_offset. For PIE binaries the result is unchanged; for non-PIE binaries the offset is correctly translated. The conversion uses only POSIX shell primitives, with no dependency on gawk or perl. Link: https://lore.kernel.org/all/20260807081512.2974757-3-qirui.001@bytedance.com/ Fixes: dc4b165855f2 ("selftests/ftrace: Use readelf to find entry point in uprobe test") Cc: stable@vger.kernel.org Signed-off-by: Rui Qi <qirui.001@bytedance.com> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
2026-08-07x86/paravirt: Use static_call() for the paravirt spinlock opsPeter Zijlstra1-1/+1
queued_spin_lock_slowpath() and queued_spin_unlock() are dispatched through pv_ops_lock via the paravirt-ops ALTERNATIVE machinery, which picks the target (native inline store / hypervisor call) once at boot and cannot change at runtime. Convert both to static_call(). The site becomes a direct call patched in place (one byte smaller), and on native the unlock still collapses to the inline "movb $0, (%rdi)" store, so the fast path is unchanged. Unlike the ALTERNATIVE mechanism, a static_call() target can also be updated at runtime via static_call_update(). This is a prerequisite for the contended_release tracepoint, which has to swap in a traced unlock while the system is running. [ ilvokhin: commit message; fix PARAVIRT_SPINLOCKS=n build; teach __static_call_validate() about the inline unlock insn; make the slowpath site module-safe: static_call_mod() + EXPORT_STATIC_CALL_TRAMP(); pass @lock to the callee-save unlock, fixing a boot hang under CALL_DEPTH_TRACKING. Boot tested native + KVM PV guest. ] Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Co-developed-by: Dmitry Ilvokhin <d@ilvokhin.com> Signed-off-by: Dmitry Ilvokhin <d@ilvokhin.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Juergen Gross <jgross@suse.com> Link: https://lore.kernel.org/all/20260603120811.GW3493090@noisy.programming.kicks-ass.net/ Link: https://patch.msgid.link/9a32ae399eb804a02a31af04dcabe7e7ee4f3fdf.1785778551.git.d@ilvokhin.com
2026-08-07tools/lib/thermal: Fix misplaced extern "C" closing braceAndreas Haufler1-2/+2
The public libthermal header opens the C++ 'extern "C" {' block inside the __LIBTHERMAL_H include guard, but places the closing brace after the guard has already ended: #endif /* __LIBTHERMAL_H */ #ifdef __cplusplus } #endif On a single inclusion the braces still balance, so the problem is invisible. On the second inclusion of the header in the same C++ translation unit the include guard skips the opening 'extern "C" {', while the closing '}' lives outside the guard and is emitted anyway. This leaves a stray '}' and breaks compilation for any C++ consumer that includes the header more than once. Move the closing block inside the include guard so both halves of the 'extern "C"' declaration are guarded consistently. Signed-off-by: Andreas Haufler <andreas@haufler.info> Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org> Link: https://patch.msgid.link/20260721083230.91246-1-andreas@haufler.info
2026-08-07Merge tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpfLinus Torvalds3-0/+88
Pull BPF fixes from Daniel Borkmann: - Fix BPF verifier to preserve full pointer state for commuted scalar += pointer arithmetic (Yiyang Chen, Eduard Zingerman) - Fix a use-after-free of request sockets in the BPF TCP iterator batching (Jose Fernandez) - Fix a use-after-free of sk_redir in the BPF sockmap send verdict path (Chengfeng Ye) - Fix a netns reference imbalance in the BPF conntrack kfuncs (Chengfeng Ye) - Fix bpf_get_fsverity_digest() dynptr assumptions and silent digest truncation (Eric Biggers) - Fix bpf_tcp_{gen,check}_syncookie to check sk_state before sk_protocol to make sure it is a full socket (Luxiao Xu) - Fix rqspinlock to reset the tail when preserving the queue on deadlock (Kumar Kartikeya Dwivedi) * tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: rqspinlock: Reset tail when preserving queue on deadlock bpf: Check sk_state before sk_protocol in bpf_tcp_*_syncookie fsverity: Fix silent truncation in bpf_get_fsverity_digest() fsverity: Fix bpf_get_fsverity_digest() dynptr assumptions bpf: tcp: Fix use-after-free in bpf_iter_tcp_established_batch() bpf: Fix netns reference imbalance in conntrack kfuncs bpf, sockmap: Fix sk_redir use-after-free in send verdict selftests/bpf: Cover commuted pointer state propagation bpf: Propagate untrusted pointer state in commuted arithmetic bpf: Preserve pointer state for commuted arithmetic bpf: Simplify sanitize_err() signature
2026-08-07selftests/bpf: Add load-acquire test for probe-memory pointer typesDaniel Borkmann1-0/+28
Add a verifier test that a BPF_LOAD_ACQ from a rdonly_untrusted_mem pointer (PTR_TO_MEM | MEM_RDONLY | PTR_UNTRUSTED, obtained via bpf_rdonly_cast()) is rejected. Such a source requires BPF_PROBE_MEM fault protection which is not applied to atomic loads; without the verifier fix the load is accepted and would crash the kernel on a fault. # LDLIBS=-static PKG_CONFIG='pkg-config --static' ./vmtest.sh -- ./test_progs -t verifier_load_acquire [...] #621/1 verifier_load_acquire/load-acquire, 8-bit:OK #621/2 verifier_load_acquire/load-acquire, 8-bit @unpriv:OK #621/3 verifier_load_acquire/load-acquire, 16-bit:OK #621/4 verifier_load_acquire/load-acquire, 16-bit @unpriv:OK #621/5 verifier_load_acquire/load-acquire, 32-bit:OK #621/6 verifier_load_acquire/load-acquire, 32-bit @unpriv:OK #621/7 verifier_load_acquire/load-acquire, 64-bit:OK #621/8 verifier_load_acquire/load-acquire, 64-bit @unpriv:OK [...] #621/19 verifier_load_acquire/load-acquire from rdonly_untrusted_mem pointer:OK #621/20 verifier_load_acquire/load-acquire with invalid register R15:OK #621/21 verifier_load_acquire/load-acquire with invalid register R15 @unpriv:OK #621/22 verifier_load_acquire/load-acquire from pkt pointer:OK #621/23 verifier_load_acquire/load-acquire from flow_keys pointer:OK #621/24 verifier_load_acquire/load-acquire from sock pointer:OK #621 verifier_load_acquire:OK Summary: 1/24 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20260806201047.333389-6-daniel@iogearbox.net Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
2026-08-07selftests/bpf: Add arena fault test for load-acquireDaniel Borkmann2-0/+46
Add stream_arena_load_acquire_fault, which performs a load-acquire from an unmapped arena address, next to the existing read and write fault tests. The test covers both halves of the JIT bug that treated a load-acquire as a store when populating its exception table entry: - the fault has to be reported as a READ, and at the address held by the source register, which __stderr() and test_address() check, and - the destination register has to be cleared by the fault handler, which the program checks by poisoning it before the load-acquire and returning it, so __retval(0) fails if it is left untouched Note, load-acquire is open coded since linux/filter.h cannot be included alongside vmlinux.h. # LDLIBS=-static PKG_CONFIG='pkg-config --static' ./vmtest.sh -- ./test_progs -t stream_arena_fault_address [...] #462/1 stream_arena_fault_address/read_fault:OK #462/2 stream_arena_fault_address/write_fault:OK #462/3 stream_arena_fault_address/load_acquire_fault:OK #462 stream_arena_fault_address:OK Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20260806201047.333389-5-daniel@iogearbox.net Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
2026-08-06docs, resolve_btfids: Document kfunc BTF annotation emissionIhor Solodrai1-0/+11
resolve_btfids now emits the bpf_kfunc and bpf_fastcall BTF decl tags and the arena address_space(1) type attribute for kfuncs, which were previously produced by pahole. Reflect this in the in-tree comments and documentation. Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Link: https://patch.msgid.link/20260807032029.78092-7-ihor.solodrai@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-06selftests/bpf: Verify decl tags emission in resolve_btfids testIhor Solodrai1-0/+40
Extend test_resolve_btfids() to assert that resolve_btfids emits a BTF_KIND_DECL_TAG named "bpf_kfunc" for every kfunc, and "bpf_fastcall" for kfuncs marked KF_FASTCALL. Add a btf_has_decl_tag() helper that scans the output BTF for a decl tag matching name and target. Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://patch.msgid.link/20260807032029.78092-6-ihor.solodrai@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-06resolve_btfids: Emit bpf_kfunc and bpf_fastcall decl tagsIhor Solodrai1-1/+30
Emit the bpf_kfunc decl tag for every discovered kfunc, and bpf_fastcall for kfuncs flagged KF_FASTCALL. These were previously produced by pahole under --btf_features=decl_tag_kfuncs. resolve_btfids now discovers kfuncs from the BTF ID sets [1] and becomes the source of truth for their annotations. Drop decl_tag_kfuncs pahole feature flag from scripts/Makefile.btf [1] https://lore.kernel.org/all/20260722233518.778854-1-ihor.solodrai@linux.dev/ Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://patch.msgid.link/20260807032029.78092-5-ihor.solodrai@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-06selftests/bpf: Verify arena type tags in resolve_btfids testIhor Solodrai2-0/+76
Extend test_resolve_btfids() to assert that resolve_btfids emits the address_space(1) type attribute (a BTF_KIND_TYPE_TAG with kflag=1) on the return type and/or arguments of kfuncs marked KF_ARENA_RET, KF_ARENA_ARG1 or KF_ARENA_ARG2. Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://patch.msgid.link/20260807032029.78092-4-ihor.solodrai@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-06resolve_btfids: Process KF_ARENA_* flags in resolve_btfidsIhor Solodrai1-5/+134
For kfuncs flagged with KF_ARENA_RET, KF_ARENA_ARG1 or KF_ARENA_ARG2, the address_space(1) attribute (a type tag with kflag=1) must be emitted for the corresponding type in BTF. This was previously done by pahole via the "attributes" BTF feature [1]. Implement the emission of the arena attributes in resolve_btfids: for flagged kfuncs create a new function prototype with updated BTF types. The original proto may be shared with sibling FUNCs, so it is not modified in place. Emission is unconditional: kbuild controls the pahole flags, so the input BTF is expected to not have these attributes. Invalid declarations are reported as errors. Drop the "attributes" pahole feature from scripts/Makefile.btf resolve_btfids now emits them for all supported pahole versions. [1] https://lore.kernel.org/dwarves/20250228194654.1022535-1-ihor.solodrai@linux.dev/ Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://patch.msgid.link/20260807032029.78092-3-ihor.solodrai@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-06resolve_btfids: Deduplicate BTF after btf2btf transformationsIhor Solodrai1-0/+6
btf2btf() adds new types to the BTF: the KF_IMPLICIT_ARGS transform synthesizes an _impl FUNC together with its FUNC_PROTO and copies of the kfunc's decl tags. Nothing deduplicates them afterwards. pahole runs btf__dedup() on its own output, but that happens before resolve_btfids sees the BTF, so any type the tool itself creates is emitted as-is, even when a structurally identical type is already present. Call btf__dedup() at the start of finalize_btf(), so that base distillation and the by-name sort both operate on the canonical set of types. On an x86_64 build with the BPF selftests config this removes 17 duplicate FUNC_PROTOs from vmlinux BTF. The dedup call increases runtime of resolve_btfids on vmlinux by 30-40%. The performance hit is an acceptable cost to keep kernel BTF deduped [1]. [1] https://lore.kernel.org/bpf/986e6f4e-4b51-4440-a37c-9624906d7370@linux.dev/ Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://patch.msgid.link/20260807032029.78092-2-ihor.solodrai@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-06selftests/mm: unpoison pages in memory-failure teardownMuhammad Usama Anjum1-22/+22
The memory-failure tests call cleanup() only after all result checks. A failed ASSERT_* invokes fixture teardown and aborts the test, so it skips cleanup() and leaves the injected page hardware-poisoned. Invoke cleanup() from FIXTURE_TEARDOWN() instead. Guard it with self->injection_attempted so tests that exit before injection do not try to unpoison a page when no injection was attempted. Injection can poison a page before returning an error or delivering SIGBUS, so teardown must clean up after every injection attempt. This runs the existing HWPoison and HardwareCorrupted checks on both normal and assertion-failure paths. Link: https://lore.kernel.org/20260729091127.1001179-1-usama.anjum@arm.com Fixes: ff4ef2fbd101 ("selftests/mm: add memory failure anonymous page test") Signed-off-by: Muhammad Usama Anjum <usama.anjum@arm.com> Reviewed-by: David Hildenbrand (Arm) <david@kernel.org> Acked-by: Miaohe Lin <linmiaohe@huawei.com> Cc: Liam R. Howlett <liam@infradead.org> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Naoya Horiguchi <nao.horiguchi@gmail.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-08-06selftests/mm: fix gup_longterm EINVAL error messagezhaozhengzhuo1-1/+1
The gup_longterm test prints a literal "n" when PIN_LONGTERM_TEST_START fails with EINVAL because the string is missing the newline escape sequence. Print a newline instead. Link: https://lore.kernel.org/23557F4CB8CF36FF+20260724074603.1479243-1-zhaozhengzhuo@uniontech.com Signed-off-by: zhaozhengzhuo <zhaozhengzhuo@uniontech.com> Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com> Reviewed-by: Dev Jain <dev.jain@arm.com> Acked-by: David Hildenbrand (arm) <david@kernel.org> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Peter Xu <peterx@redhat.com> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-08-06selftests/mm/pagemap_ioctl: fix missing NULL checks after calloc()longlong yan1-1/+7
The pagemap_ioctl selftest allocates memory via calloc() in several places but does not check the return values. If calloc() fails, the subsequent code will dereference a NULL pointer and crash. Additionally, in sanity_tests(), the calloc() failure check incorrectly uses MAP_FAILED (the mmap() error constant) instead of NULL. Since calloc() returns NULL on failure, the check never triggers and a failed allocation goes undetected. Add NULL checks after each calloc() call, and fix the wrong error constant in sanity_tests(). Use ksft_exit_fail_msg() consistent with the existing error handling pattern in the file. Link: https://lore.kernel.org/20260721063611.342-1-yanlonglong@kylinos.cn Signed-off-by: longlong yan <yanlonglong@kylinos.cn> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Reviewed-by: SJ Park <sj@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-08-06selftests/mm: use MAP_FAILED for mmap error checklonglong yan1-53/+53
Replace the direct comparison with (void *)-1 with the standard MAP_FAILED macro when checking mmap() Link: https://lore.kernel.org/20260720063439.522-1-yanlonglong@kylinos.cn Signed-off-by: longlong yan <yanlonglong@kylinos.cn> Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Cc: Liam R. Howlett <liam@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-08-06selftests/mm: fix BUG_ON checking wrong variable in mremap_dontunmapHongfu Li1-1/+1
In mremap_dontunmap_partial_mapping_overwrite(), mremap() stores its returned remapped address into remapped_mapping, while the BUG_ON incorrectly checks dest_mapping instead. If mremap() fails, dest_mapping still holds a valid pointer obtained from the prior mmap() call, making this BUG_ON never trigger at all. Correct the check to validate the actual mremap() return value stored in remapped_mapping. Link: https://lore.kernel.org/20260717070251.73212-1-hongfu.li@linux.dev Signed-off-by: Hongfu Li <lihongfu@kylinos.cn> Reviewed-by: SJ Park <sj@kernel.org> Cc: David Hildenbrand <david@kernel.org> Cc: Liam R. Howlett <liam@infradead.org> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-08-06selftests/mm: add PAGEMAP_SCAN test for THP PMD holesKiryl Shutsemau (Meta)1-27/+75
Add coverage for the PMD-hole case fixed by "fs/proc/task_mmu: fix PAGEMAP_SCAN written state for PMD holes": a MAP_PRIVATE|MAP_ANON THP that is uffd-wp'd and then dropped with MADV_DONTNEED leaves a pmd_none hole with no page table, which PAGEMAP_SCAN must still report as written. Factor the populate/drop/scan-both-paths sequence out of unpopulated_scan_test() into a helper, and add unpopulated_thp_scan_test() that reuses it with a THP. Include <linux/mman.h> for MADV_COLLAPSE; <sys/mman.h> lacks it on older glibc (e.g. 2.34). Same approach as commit fd5295afae91 ("selftests/mm: hmm-tests: include linux/mman.h to access MADV_COLLAPSE"). Link: https://lore.kernel.org/aljWYfPRCVc6IB2b@thinkstation Link: https://lore.kernel.org/20260715144234.442721-3-kirill@shutemov.name Signed-off-by: Kiryl Shutsemau <kas@kernel.org> Cc: Muhammad Usama Anjum <usama.anjum@arm.com> Cc: Peter Xu <peterx@redhat.com> Cc: Zenghui Yu <zenghui.yu@linux.dev> Cc: David Hildenbrand <david@kernel.org> Cc: Jann Horn <jannh@google.com> Cc: Liam R. Howlett <liam@infradead.org> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Shuah Khan <shuah@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@kernel.org> Assisted-by: Claude:claude-fable-5 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-08-06mm/vma: update create_init_stack_vma() to use vma_flags_tLorenzo Stoakes1-0/+4
Replace use of the legacy vm_flags_t flags with vma_flags_t values in create_init_stack_vma(). As part of this change we add VMA_STACK_EARLY and VMA_STACK_INCOMPLETE vma_flags_t defines, and slightly rework create_init_stack_vma() for clarity. No functional change intended. Link: https://lore.kernel.org/20260711-b4-vma-flags-mm-v2-9-0fa2357d5431@kernel.org Signed-off-by: Lorenzo Stoakes <ljs@kernel.org> Reviewed-by: Zi Yan <ziy@nvidia.com> Reviewed-by: Lance Yang <lance.yang@linux.dev> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <baohua@kernel.org> Cc: Christian Brauner <brauner@kernel.org> Cc: Dave Airlie <airlied@gmail.com> Cc: David Hildenbrand <david@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Nico Pache <npache@redhat.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-08-06mm: introduce vma_get_page_prot() and use itLorenzo Stoakes1-0/+5
There's a large number of vm_get_page_prot(vma->vm_flags) invocations. Make life easier by introducing vma_get_page_prot() parameterised by the VMA. This also makes converting vm_get_page_prot() to vma_flags_t easier. Also update the userland VMA tests to reflect the change. No functional change intended. Link: https://lore.kernel.org/20260711-b4-vma-flags-mm-v2-8-0fa2357d5431@kernel.org Signed-off-by: Lorenzo Stoakes <ljs@kernel.org> Acked-by: Zi Yan <ziy@nvidia.com> Acked-by: Jani Nikula <jani.nikula@intel.com> # for i915 Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> [DRM] Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <baohua@kernel.org> Cc: Christian Brauner <brauner@kernel.org> Cc: Dave Airlie <airlied@gmail.com> Cc: David Hildenbrand <david@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Lance Yang <lance.yang@linux.dev> Cc: Mike Rapoport <rppt@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Nico Pache <npache@redhat.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-08-06mm/vma: rename vma_get_page_prot to vma_flags_to_page_protLorenzo Stoakes1-1/+1
Having vma_get_page_prot() refer to VMA flags and vma_set_page_prot() refer to a VMA is confusing. Rename vma_get_page_prot() to vma_flags_to_page_prot() to resolve this confusion. No functional change intended. Link: https://lore.kernel.org/20260711-b4-vma-flags-mm-v2-7-0fa2357d5431@kernel.org Signed-off-by: Lorenzo Stoakes <ljs@kernel.org> Reviewed-by: Lance Yang <lance.yang@linux.dev> Reviewed-by: Zi Yan <ziy@nvidia.com> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <baohua@kernel.org> Cc: Christian Brauner <brauner@kernel.org> Cc: Dave Airlie <airlied@gmail.com> Cc: David Hildenbrand <david@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Nico Pache <npache@redhat.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>