Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/windows/common/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ using wsl::windows::common::helpers::LaunchWslRelayFlags;
constexpr auto c_WslSupportInterfaceKey = L"Software\\Classes\\Interface\\{46f3c96d-ffa3-42f0-b052-52f5e7ecbb08}";
constexpr auto c_WslSupportInterfaceName = L"IWslSupport";

constexpr ULONG c_MaxStorageHwQueues = 4;

namespace {

class ProcessLauncher
Expand Down Expand Up @@ -762,8 +764,12 @@ try
}
CATCH_LOG()

void wsl::windows::common::helpers::AppendCommonKernelCommandLine(_Inout_ std::wstring& kernelCmdLine, _In_ int pageReportingOrder, _In_ ULONG64 swiotlbSizeBytes)
void wsl::windows::common::helpers::AppendCommonKernelCommandLine(
_Inout_ std::wstring& kernelCmdLine, _In_ int pageReportingOrder, _In_ ULONG64 swiotlbSizeBytes, _In_ ULONG cpuCount)
{
// Set number of processors.
kernelCmdLine += std::format(L" nr_cpus={}", cpuCount);

// Enable timesync workaround to sync on resume from sleep in modern standby.
kernelCmdLine += L" hv_utils.timesync_implicit=1";

Expand All @@ -778,6 +784,12 @@ void wsl::windows::common::helpers::AppendCommonKernelCommandLine(_Inout_ std::w
{
kernelCmdLine += std::format(L" swiotlb=force hv_pci_swiotlb={}", swiotlbSizeBytes);
}

// Cap the storage hw queue count. Default is CPU count.
if (cpuCount > c_MaxStorageHwQueues)
{
kernelCmdLine += std::format(L" hv_storvsc.storvsc_max_hw_queues={}", c_MaxStorageHwQueues);
}
}

UINT64 wsl::windows::common::helpers::ComputeDefaultSwiotlbConfig(_In_ UINT64 memoryBytes)
Expand Down
2 changes: 1 addition & 1 deletion src/windows/common/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ bool TryAttachConsole();

void RegisterWithDcat(_In_ bool IncludeVersionNumber = true);

void AppendCommonKernelCommandLine(_Inout_ std::wstring& kernelCmdLine, _In_ int pageReportingOrder, _In_ ULONG64 swiotlbSizeBytes);
void AppendCommonKernelCommandLine(_Inout_ std::wstring& kernelCmdLine, _In_ int pageReportingOrder, _In_ ULONG64 swiotlbSizeBytes, _In_ ULONG cpuCount);

UINT64 ComputeDefaultSwiotlbConfig(_In_ UINT64 memoryBytes);

Expand Down
3 changes: 1 addition & 2 deletions src/windows/service/exe/HcsVirtualMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ HcsVirtualMachine::HcsVirtualMachine(_In_ const WSLCSessionSettings* Settings)

// Initialize kernel command line.
std::wstring kernelCmdLine = L"initrd=\\" LXSS_VM_MODE_INITRD_NAME L" " TEXT(WSLC_ROOT_INIT_ENV) L"=1 panic=-1";
kernelCmdLine += std::format(L" nr_cpus={}", Settings->CpuCount);
helpers::AppendCommonKernelCommandLine(kernelCmdLine, pageReportingOrder, swiotlbSizeBytes);
helpers::AppendCommonKernelCommandLine(kernelCmdLine, pageReportingOrder, swiotlbSizeBytes, Settings->CpuCount);

// Setup dmesg collector with optional DmesgOutput handle.
// TODO: move dmesg collector to user session process.
Expand Down
5 changes: 1 addition & 4 deletions src/windows/service/exe/WslCoreVm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1575,11 +1575,8 @@ std::wstring WslCoreVm::GenerateConfigJson()
// Initialize kernel command line.
std::wstring kernelCmdLine = L"initrd=\\" LXSS_VM_MODE_INITRD_NAME L" " TEXT(WSL_ROOT_INIT_ENV) L"=1 panic=-1";

// Set number of processors.
kernelCmdLine += std::format(L" nr_cpus={}", m_vmConfig.ProcessorCount);

// Append common kernel parameters shared between WSL2 and WSLC.
helpers::AppendCommonKernelCommandLine(kernelCmdLine, m_pageReportingOrder, m_vmConfig.SwiotlbSizeBytes);
helpers::AppendCommonKernelCommandLine(kernelCmdLine, m_pageReportingOrder, m_vmConfig.SwiotlbSizeBytes, m_vmConfig.ProcessorCount);

if (m_vmConfig.EnableVirtio && helpers::IsVirtioSerialConsoleSupported())
{
Expand Down