Skip to content

virtiofs: Use aggregate share feature in WSLC - #41151

Merged
Daman Mulye (damanm24) merged 6 commits into
masterfrom
user/damanmulye/wslc_aggregate_share
Jul 24, 2026
Merged

virtiofs: Use aggregate share feature in WSLC#41151
Daman Mulye (damanm24) merged 6 commits into
masterfrom
user/damanmulye/wslc_aggregate_share

Conversation

@damanm24

@damanm24 Daman Mulye (damanm24) commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

This is a follow-up to PR: #41129 which removes the need to limit the amount of virtiofs shares in WSLC. It does so by mounting all virtiofs shares under a single, unified root share which limits the memory footprint of virtio devices. See the original PR for more details.

Copilot AI review requested due to automatic review settings July 23, 2026 16:12
@damanm24
Daman Mulye (damanm24) requested review from a team as code owners July 23, 2026 16:12

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 extends WSLC’s virtiofs integration to use an aggregate virtiofs device with per-share children, reducing virtiofs device proliferation and enabling safe add/remove of Windows-folder shares without hitting the previous per-device aperture/limit behaviors.

Changes:

  • Update WSLC mount IPC to optionally carry a virtiofs child name, allowing the guest to mount an aggregate child via MountVirtioFsChild(tag, childName, ...).
  • Switch the WSLC service-side share plumbing to lazily create a single aggregate virtiofs device and add/remove shares as children.
  • Refresh WSLC tests to validate independent children, child removal, and mounting many shares; remove the legacy “max shares” limit logic and update DeviceHost dependency.

Reviewed changes

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

Show a summary per file
File Description
test/windows/WSLCTests.cpp Updates/extends WSLC virtiofs tests for aggregate-child semantics (independent children, removal, many mounts, RO enforcement).
src/windows/wslcsession/WSLCVirtualMachine.h Extends internal mount helper signature to support an optional virtiofs child name.
src/windows/wslcsession/WSLCVirtualMachine.cpp Removes share-reuse cache/limit logic; passes aggregate tag + child name for virtiofs mounts; always removes shares on unmount/failure.
src/windows/service/exe/HcsVirtualMachine.h Tracks a single aggregate virtiofs device instance for WSLC shares.
src/windows/service/exe/HcsVirtualMachine.cpp Creates a single aggregate virtiofs device and adds/removes per-share children via GuestDeviceManager.
src/windows/common/GuestDeviceManager.h Adds RemoveVirtiofsChild API.
src/windows/common/GuestDeviceManager.cpp Implements RemoveVirtiofsChild with locking consistent with other device-host calls.
src/windows/common/DeviceHostProxy.h Adds RemoveVirtiofsChild forwarding API.
src/windows/common/DeviceHostProxy.cpp Implements RemoveVirtiofsChild by calling the virtiofs device’s RemoveChild.
src/shared/inc/lxinitshared.h Extends WSLC_MOUNT message with ChildNameIndex for the new IPC field.
src/shared/inc/defs.h Removes the legacy c_maxVirtioFsShares limit constant.
src/linux/init/WSLCInit.cpp Teaches WSLC init to mount either a normal filesystem mount or a virtiofs aggregate child mount depending on ChildNameIndex.
src/linux/init/drvfs.h Declares MountVirtioFsChild for use by WSLC init.
src/linux/init/drvfs.cpp Adjusts MountVirtioFsChild definition signature to match the header (defaults live in the header).
packages.config Bumps Microsoft.WSL.DeviceHost dependency version.

Comment thread src/linux/init/WSLCInit.cpp Outdated
Copilot AI review requested due to automatic review settings July 23, 2026 16:45

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

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.

Comment thread src/shared/inc/lxinitshared.h
Copilot AI review requested due to automatic review settings July 23, 2026 20:39

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

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/linux/init/WSLCInit.cpp:20

  • WSLCInit.cpp now uses std::is_same_v, but the file doesn’t explicitly include <type_traits>. This can cause build breaks depending on transitive include order; add <type_traits> here so the dependency is explicit.
#include "drvfs.h"
#include "SocketChannel.h"
#include "message.h"
#include "localhost.h"
#include "common.h"

Copilot AI review requested due to automatic review settings July 23, 2026 20:59

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

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 24, 2026 16:37

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

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/linux/init/WSLCInit.cpp:21

  • WSLCInit.cpp now uses std::is_same_v in HandleMountMessage, but the file does not include <type_traits>. This relies on transitive includes and can break the build if headers change.
#include "util.h"
#include "drvfs.h"
#include "SocketChannel.h"
#include "message.h"
#include "localhost.h"
#include "common.h"
#include <utmp.h>

@benhillis

Copy link
Copy Markdown
Member

Looks good to me!

@damanm24
Daman Mulye (damanm24) enabled auto-merge (squash) July 24, 2026 18:26
@damanm24
Daman Mulye (damanm24) merged commit 0f8ad5b into master Jul 24, 2026
12 checks passed
@damanm24
Daman Mulye (damanm24) deleted the user/damanmulye/wslc_aggregate_share branch July 24, 2026 18:28
Ben Hillis (benhillis) pushed a commit that referenced this pull request Jul 24, 2026
Now that DrvFs shares are carried by a single aggregate virtiofs device
(#41129 / #41151), only a small, fixed number of virtiofs devices exist
per VM. That leaves enough memory-aperture headroom to give each
aggregate multiple request queues, which significantly improves
concurrent DrvFs throughput.

Non-aggregate (per-share file-backed) and section-backed devices stay at
a single queue: many of them can exist, and raising their queue count
would reintroduce the aperture exhaustion that the one-queue default was
added to avoid.

fio on /mnt/c (16 parallel jobs, psync), 4 queues vs 1:
  randread 4k        +56% IOPS  (-36% latency)
  randwrite 4k       +622% IOPS (-85% latency)
  smallfile randrw   +48% IOPS  (-33% latency)
  seqread 1M         +15% IOPS
  seqwrite 1M        -10% IOPS  (single-stream, bandwidth-bound; within noise)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4ab64eb9-4271-4241-b838-3da58ec39305
Ben Hillis (benhillis) added a commit that referenced this pull request Jul 24, 2026
Now that DrvFs shares are carried by a single aggregate virtiofs device
(#41129 / #41151), only a small, fixed number of virtiofs devices exist
per VM. That leaves enough memory-aperture headroom to give each
aggregate multiple request queues, which significantly improves
concurrent DrvFs throughput.

Non-aggregate (per-share file-backed) and section-backed devices stay at
a single queue: many of them can exist, and raising their queue count
would reintroduce the aperture exhaustion that the one-queue default was
added to avoid.

fio on /mnt/c (16 parallel jobs, psync), 4 queues vs 1:
  randread 4k        +56% IOPS  (-36% latency)
  randwrite 4k       +622% IOPS (-85% latency)
  smallfile randrw   +48% IOPS  (-33% latency)
  seqread 1M         +15% IOPS
  seqwrite 1M        -10% IOPS  (single-stream, bandwidth-bound; within noise)

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4ab64eb9-4271-4241-b838-3da58ec39305
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.

4 participants