Cap storage hw queue count to 4 (#40975)
Cap storage hw queue count to 4
Feng Wang committed
Jul 8, 2026 at 12:38 UTC
b25afb045e6877f1ba9899bfa44f9191f0f3e6c8
4 files changed
+16
-8
src/windows/common/helpers.cpp
+13
-1
@@ -39,6 +39,8 @@ using wsl::windows::common::helpers::LaunchWslRelayFlags;
39
constexpr auto c_WslSupportInterfaceKey = L"Software\\Classes\\Interface\\{46f3c96d-ffa3-42f0-b052-52f5e7ecbb08}";
40
constexpr auto c_WslSupportInterfaceName = L"IWslSupport";
41
42
+constexpr ULONG c_MaxStorageHwQueues = 4;
43
+
44
namespace {
45
46
class ProcessLauncher
@@ -762,8 +764,12 @@ try
764
}
765
CATCH_LOG()
766
765
-void wsl::windows::common::helpers::AppendCommonKernelCommandLine(_Inout_ std::wstring& kernelCmdLine, _In_ int pageReportingOrder, _In_ ULONG64 swiotlbSizeBytes)
767
+void wsl::windows::common::helpers::AppendCommonKernelCommandLine(
768
+ _Inout_ std::wstring& kernelCmdLine, _In_ int pageReportingOrder, _In_ ULONG64 swiotlbSizeBytes, _In_ ULONG cpuCount)
769
{
770
+ // Set number of processors.
771
+ kernelCmdLine += std::format(L" nr_cpus={}", cpuCount);
772
+
773
// Enable timesync workaround to sync on resume from sleep in modern standby.
774
kernelCmdLine += L" hv_utils.timesync_implicit=1";
775
@@ -778,6 +784,12 @@ void wsl::windows::common::helpers::AppendCommonKernelCommandLine(_Inout_ std::w
784
{
785
kernelCmdLine += std::format(L" swiotlb=force hv_pci_swiotlb={}", swiotlbSizeBytes);
786
}
787
+
788
+ // Cap the storage hw queue count. Default is CPU count.
789
+ if (cpuCount > c_MaxStorageHwQueues)
790
+ {
791
+ kernelCmdLine += std::format(L" hv_storvsc.storvsc_max_hw_queues={}", c_MaxStorageHwQueues);
792
+ }
793
}
794
795
UINT64 wsl::windows::common::helpers::ComputeDefaultSwiotlbConfig(_In_ UINT64 memoryBytes)
src/windows/common/helpers.hpp
+1
-1
@@ -205,7 +205,7 @@ bool TryAttachConsole();
205
206
void RegisterWithDcat(_In_ bool IncludeVersionNumber = true);
207
208
-void AppendCommonKernelCommandLine(_Inout_ std::wstring& kernelCmdLine, _In_ int pageReportingOrder, _In_ ULONG64 swiotlbSizeBytes);
208
+void AppendCommonKernelCommandLine(_Inout_ std::wstring& kernelCmdLine, _In_ int pageReportingOrder, _In_ ULONG64 swiotlbSizeBytes, _In_ ULONG cpuCount);
209
210
UINT64 ComputeDefaultSwiotlbConfig(_In_ UINT64 memoryBytes);
211
src/windows/service/exe/HcsVirtualMachine.cpp
+1
-2
@@ -166,8 +166,7 @@ HcsVirtualMachine::HcsVirtualMachine(_In_ const WSLCSessionSettings* Settings)
166
167
// Initialize kernel command line.
168
std::wstring kernelCmdLine = L"initrd=\\" LXSS_VM_MODE_INITRD_NAME L" " TEXT(WSLC_ROOT_INIT_ENV) L"=1 panic=-1";
169
- kernelCmdLine += std::format(L" nr_cpus={}", Settings->CpuCount);
170
- helpers::AppendCommonKernelCommandLine(kernelCmdLine, pageReportingOrder, swiotlbSizeBytes);
169
+ helpers::AppendCommonKernelCommandLine(kernelCmdLine, pageReportingOrder, swiotlbSizeBytes, Settings->CpuCount);
170
171
// Setup dmesg collector with optional DmesgOutput handle.
172
// TODO: move dmesg collector to user session process.
src/windows/service/exe/WslCoreVm.cpp
+1
-4
@@ -1575,11 +1575,8 @@ std::wstring WslCoreVm::GenerateConfigJson()
1575
// Initialize kernel command line.
1576
std::wstring kernelCmdLine = L"initrd=\\" LXSS_VM_MODE_INITRD_NAME L" " TEXT(WSL_ROOT_INIT_ENV) L"=1 panic=-1";
1577
1578
- // Set number of processors.
1579
- kernelCmdLine += std::format(L" nr_cpus={}", m_vmConfig.ProcessorCount);
1580
-
1578
// Append common kernel parameters shared between WSL2 and WSLC.
1582
- helpers::AppendCommonKernelCommandLine(kernelCmdLine, m_pageReportingOrder, m_vmConfig.SwiotlbSizeBytes);
1579
+ helpers::AppendCommonKernelCommandLine(kernelCmdLine, m_pageReportingOrder, m_vmConfig.SwiotlbSizeBytes, m_vmConfig.ProcessorCount);
1580
1581
if (m_vmConfig.EnableVirtio && helpers::IsVirtioSerialConsoleSupported())
1582
{