Skip to content

Mitigate and instrument the utility-VM boot-connect timeout - #41165

Open
yeelam-gordon wants to merge 1 commit into
masterfrom
fix/instrument-notify-channel-accept
Open

Mitigate and instrument the utility-VM boot-connect timeout#41165
yeelam-gordon wants to merge 1 commit into
masterfrom
fix/instrument-notify-channel-accept

Conversation

@yeelam-gordon

Copy link
Copy Markdown
Contributor

Why (the symptom)

On heavily loaded machines, utility-VM creation intermittently fails with .../CreateVm/0x800705b4 (ERROR_TIMEOUT), which blocks install. Seen in automated test runs. Tracked as 62543002.

Root cause

During VM Initialize, the service waits for the guest to connect back over hvsocket within KernelBootTimeout (default 30s). This is a give-up watchdog, not a boot budget — a healthy boot connects in ~1-3s. Under host CPU contention a healthy-but-slow boot exceeds 30s and trips it. Two gaps:

  1. 30s leaves too little headroom on a contended host.
  2. The notify-channel accept was uninstrumented, so telemetry could not say which boot phase was slow.

The fix (two small changes)

  1. Raise default KernelBootTimeout 30s -> 90s. Still bounds a genuinely stuck VM; just gives a slow-but-alive boot room to finish. Overridable via wsl2.kernelBootTimeout.
  2. Wrap the notify-channel accept in its own SlowOperationWatcher{"WaitForNotifyChannelConnect"} (mirrors the adjacent mini_init one). Diagnostic only — no control-flow change.

Note: this is not fixed by #40519. That protects processes inside the guest after it connects; this failure is the host starving the VM's vCPUs before it connects — different phase, different contention. The real cure (a host-side CPU reservation for the booting VM) is a follow-up, gated on the telemetry above confirming CPU is the starved resource.

Testing

  • SlowOperationWatcher unit tests: 6/6 pass (emits real elapsedMs; hang backstop emits once).
  • wslservice build-verified with both changes.
  • Deterministic repro on the same accept path: setting kernelBootTimeout=1 yields the exact .../CreateVm/0x800705b4.

@shuaiyuanxx — could you review? You own the SlowOperationWatcher / boot path. (Bug 62543002 assigned to you.)

A healthy-but-slow guest boot (loaded host, cold first boot) trips the KernelBootTimeout watchdog and surfaces as CreateVm/0x800705b4. Raise the default KernelBootTimeout from 30s to 90s for headroom, and wrap the notify-channel accept in its own SlowOperationWatcher so a slow or hung boot is attributed to the correct phase. Diagnostic-only; no control-flow change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e76db014-5ee2-46f5-b078-42ad74b5197a
Copilot AI review requested due to automatic review settings July 24, 2026 15:08
@yeelam-gordon
yeelam-gordon requested a review from a team as a code owner July 24, 2026 15:08

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.

Pull request overview

This PR adjusts the utility-VM boot/connect behavior in the Windows service to reduce intermittent boot-connect timeouts under host contention, and adds telemetry to better attribute where boot is stalling.

Changes:

  • Increase the default wsl2.kernelBootTimeout from 30s to 90s.
  • Add a SlowOperationWatcher scope around the notify-channel accept to attribute slow boots to the correct phase.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/windows/service/exe/WslCoreVm.cpp Adds a SlowOperationWatcher around the guest notify-channel accept during VM initialization.
src/windows/common/WslCoreConfig.h Raises the default KernelBootTimeout from 30s to 90s.

Comment on lines 341 to 345
std::filesystem::path DebugConsoleLogFile;
std::wstring VmSwitch;
int KernelBootTimeout = (30 * 1000);
int KernelBootTimeout = (90 * 1000);
int DistributionStartTimeout = (60 * 1000);
int MountDeviceTimeout = (5 * 1000);

@OneBlue OneBlue left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm surprised that we find machines that take more than 30 seconds to connect the hvsocket.

The bug mentioned in the description points to a test failure, but in the test we increase that timeout to 120 :

WSL/test/windows/Common.cpp

Lines 2096 to 2097 in 404453c

g_originalConfig = LxssWriteWslConfig(LxssGenerateTestConfig());

(Default is here)

So if we timed out in the tests, I'd expect that the issue is somewhere else. Was there anything in dmesg in that test failure ?

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.

3 participants