mirror of
https://github.com/unraid/webgui.git
synced 2026-03-09 12:31:56 -05:00
VMs: enable cpu cache passthrough; AMD + multithreaded
This commit is contained in:
@@ -321,11 +321,22 @@
|
||||
$intCPUThreadsPerCore = 1;
|
||||
|
||||
$cpumode = '';
|
||||
$cpucache = '';
|
||||
$cpufeatures = '';
|
||||
if (!empty($domain['cpumode']) && $domain['cpumode'] == 'host-passthrough') {
|
||||
$cpumode .= "mode='host-passthrough'";
|
||||
$cpucache = "<cache mode='passthrough'/>";
|
||||
|
||||
// detect if the processor is hyperthreaded:
|
||||
$intCPUThreadsPerCore = max(intval(shell_exec('/usr/bin/lscpu | grep \'Thread(s) per core\' | awk \'{print $4}\'')), 1);
|
||||
|
||||
// detect if the processor is AMD + multithreaded, and if so, enable topoext cpu feature
|
||||
if ($intCPUThreadsPerCore > 1) {
|
||||
$strCPUInfo = file_get_contents('/proc/cpuinfo');
|
||||
if (strpos($strCPUInfo, 'AuthenticAMD') !== false) {
|
||||
$cpufeatures .= "<feature policy='require' name='topoext'/>";
|
||||
}
|
||||
}
|
||||
|
||||
// even amount of cores assigned and cpu is hyperthreaded: pass that info along to the cpu section below
|
||||
if ($intCPUThreadsPerCore > 1 && ($vcpus % $intCPUThreadsPerCore == 0)) {
|
||||
@@ -336,6 +347,8 @@
|
||||
|
||||
$cpustr = "<cpu $cpumode>
|
||||
<topology sockets='1' cores='{$intCores}' threads='{$intThreads}'/>
|
||||
$cpucache
|
||||
$cpufeatures
|
||||
</cpu>
|
||||
<vcpu placement='static'>{$vcpus}</vcpu>
|
||||
<cputune>
|
||||
|
||||
Reference in New Issue
Block a user