Skip to content

Expose bundled perf through WSL-owned paths - #41904

Draft
Ben Hillis (benhillis) wants to merge 2 commits into
microsoft:masterfrom
benhillis:user/benhill/perf_owned
Draft

Ben Hillis (benhillis) wants to merge 2 commits into
microsoft:masterfrom
benhillis:user/benhill/perf_owned

Conversation

@benhillis

Copy link
Copy Markdown
Member

Summary of the Pull Request

Bind-mounting bundled perf over /usr/bin/perf breaks package upgrades because package managers cannot create hard-link backups across the mount boundary. Expose bundled perf through WSL-owned paths instead, leaving distro packages untouched.

PR Checklist

  • Closes: No linked issue.
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: N/A (developer documentation only).

Detailed Description of the Pull Request / Additional comments

Mount artifacts read-only under /usr/lib/wsl/perf/<release> and generate /run/wsl/perf to configure helper resolution. A managed /usr/local/bin/perf symlink supports ordinary and standard sudo lookup without changing PATH, preserves user-owned entries, and is removed when artifacts are unavailable.

Validation Steps Performed

  • cmake --build . -- -m: passed.
  • bin\x64\Debug\test.bat /name:*KernelArtifacts*: passed (1/1), covering package-file replacement, read-only mounts, sanitized environments, user overrides, and custom-kernel transitions.
  • .\FormatSource.ps1 -Verify $true: passed.
  • python3 -m mkdocs build -f doc/mkdocs.yml: passed with repository documentation dependencies.
  • env -u PERF_EXEC_PATH sudo -n perf --version and env -u PERF_EXEC_PATH sudo -n perf --exec-path: passed.

Keep perf artifacts read-only and expose them through a per-distro wrapper and managed local symlink without modifying distro packages or session search paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dc502fd6-021a-4a35-8227-e3688decebda
Copilot AI balanced review requested due to automatic review settings October 13, 2026 18:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The wrapper unintentionally overrides user-configured PERF_EXEC_PATH values.

1 open finding
What changed in this PR

Moves bundled perf to WSL-owned paths, avoiding interference with distro package upgrades.

Changes:

  • Mounts bundled perf read-only under /usr/lib/wsl/perf/<release>.
  • Adds runtime wrapper and managed /usr/local/bin/perf symlink.
  • Expands tests and boot-process documentation.
File Description
test/​windows/​wsl/​UnitTests.cpp Tests mounts, wrappers, overrides, upgrades, and custom kernels.
src/​linux/​init/​WslDistributionConfig.h Removes obsolete perf environment state.
src/​linux/​init/​main.cpp Validates and relocates perf artifacts.
src/​linux/​init/​config.cpp Creates the wrapper and managed symlink.
doc/​docs/​technical-documentation/​boot-process.md Documents the new exposure model.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/linux/init/config.cpp Outdated
Default the runtime wrapper's PERF_EXEC_PATH only when unset or empty, and cover empty values and inherited overrides.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dc502fd6-021a-4a35-8227-e3688decebda
Copilot AI balanced review requested due to automatic review settings October 13, 2026 20:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new setup fails to expose perf during WSL’s supported read-only filesystem startup fallback.

0 open findings

1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Bundled perf unavailable after read-only WSL startup fallback

src/​linux/​init/​config.cpp:1288

This setup cannot expose bundled perf when WSL takes its supported read-only/full-filesystem startup fallback. SpawnDistribution remounts the temporary root overlay read-only before exec (main.cpp:1537-1555, 1670-1676), so on the first boot using this new path MoveTemporaryMount cannot create /usr/lib/wsl/perf/<release>; even if that directory already exists, UpdatePerfSymlink cannot create /usr/local/bin/perf. The errors are swallowed by the helper-level CATCH_LOGs, leaving perf unavailable. Please create the WSL-owned entries before that remount or retain a read-only-safe exposure fallback.

🧠 Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants