[FEATURE] Carry "ftrace: Drop weak function locations of modules when loading them" (amdgpu module load takes ~3 s)

Open
#1,137 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
c, linux

Research direction

Read the upstream v2 patch linked in the issue and compare it with the kernel’s ftrace module loading code around ftrace_module_enable() and test_for_valid_rec(). The issue describes the quadratic lookup cost and provides benchmark results; check how the proposed change handles module symbols and preserves ftrace behavior. Done means carrying the fix and confirming module load performance improves without changing available_filter_functions or ftrace selftests.

Written by the indexing model from the issue text.

Description

Pre-flight checklist
  • I have searched existing issues/PRs and this has not been requested before.
  • I have read the Contributing Guidelines.
Request type
  • New patch / patchset inclusion
Summary

Please consider carrying the pending upstream fix for the quadratic cost of ftrace_module_enable() when loading large modules.

Since b39181f7c690 ("ftrace: Add FTRACE_MCOUNT_MAX_OFFSET to avoid adding weak function"), ftrace_module_enable() calls test_for_valid_rec() for every ftrace record of the module being loaded, and for a module address kallsyms_lookup() scans the whole symbol table of that module. Loading a module therefore costs O(records x symbols), all under ftrace_lock. amdgpu is the worst case.

Motivation / use case

On linux-cachyos 7.3.1-1 (Ryzen 7 5800X3D, RX 9070 XT, amdgpu in the initramfs through the kms hook), udev asks for amdgpu at 0.59 s but amdgpu's init only starts at 3.85 s (initcall_debug + udev debug log): about 3.2 s are spent inserting the module, before any hardware init. amdgpu.ko here has 16,203 ftrace records and 77,543 symbols.

Because amdgpu is in the initramfs, switch-root waits for it, so the whole boot is about 3 s slower. For comparison, xfs.ko (5,335 records, 31,048 symbols) takes about 0.44 s to modprobe on the same machine. This affects every AMD GPU user with early KMS.

Patch / upstream reference
Testing / benchmarks
  • Patch author (Ryzen 3 3200U, v7.2.5): amdgpu init done at 6.19 s -> 2.00 s; kernel part of systemd-analyze 6.65 s -> 2.46 s; nouveau load 457 ms -> 118 ms.
  • Reviewer on the list (Ryzen 9 5900X + RX 6900 XT, 7.2.15): userspace 4.5 s -> 2.4 s.
  • Omarchy (7.3-rc5): "amdgpu initializing" 6.20 s -> 1.82 s; available_filter_functions byte-identical; ftrace and livepatch selftests unchanged.
  • Here, without the patch: see Motivation.
Additional context

4099b98203d6 ("ftrace: Fix softlockup in ftrace_module_enable") only added cond_resched() to the loop; the quadratic cost is still there.

Dominant language
Shell
Stars
4.9k
Forks
190
Avg merge
1d 3h
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CachyOS/linux-cachyos

All issues in CachyOS/linux-cachyos

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.