mirror of
https://github.com/unraid/webgui.git
synced 2026-03-20 20:02:44 -05:00
CPU pinning: code consistency
This commit is contained in:
@@ -32,7 +32,7 @@ function create() {
|
||||
$loop = floor(($total-1)/32)+1;
|
||||
$text = [];
|
||||
for ($c = 0; $c < $loop; $c++) {
|
||||
$max = ($c == $loop-1 ? ($total%32?:32) : 32);
|
||||
$max = ($c==$loop-1 ? ($total%32?:32) : 32);
|
||||
for ($n = 0; $n < $max; $n++) {
|
||||
unset($cpu1,$cpu2);
|
||||
list($cpu1, $cpu2) = preg_split('/[,-]/',$cpus[$c*32+$n]);
|
||||
@@ -100,6 +100,7 @@ function apply(form) {
|
||||
if (!--wait) {
|
||||
setTimeout(function(){$('#wait-'+id).hide();},500);
|
||||
$('input[value="Done"]').prop('disabled',false);
|
||||
// isolated cpus, need reboot notice?
|
||||
if (id == 'is') notice();
|
||||
}
|
||||
}
|
||||
@@ -108,6 +109,7 @@ function apply(form) {
|
||||
} else {
|
||||
$('#wait-'+id).hide();
|
||||
$('input[value="Done"]').prop('disabled',false);
|
||||
if (id == 'is') notice();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -88,18 +88,18 @@ case 'ct':
|
||||
echo "\0".implode(';',array_map('urlencode',$cts));
|
||||
break;
|
||||
case 'is':
|
||||
$sys = file('/boot/syslinux/syslinux.cfg',FILE_IGNORE_NEW_LINES+FILE_SKIP_EMPTY_LINES);
|
||||
$size = count($sys);
|
||||
$syslinux = file('/boot/syslinux/syslinux.cfg',FILE_IGNORE_NEW_LINES+FILE_SKIP_EMPTY_LINES);
|
||||
$size = count($syslinux);
|
||||
$menu = $i = 0;
|
||||
$isolcpus = $isol = [];
|
||||
// find the default section
|
||||
while ($i < $size) {
|
||||
if (scan($sys[$i],'label ')) {
|
||||
if (scan($syslinux[$i],'label ')) {
|
||||
$n = $i + 1;
|
||||
// find the current isolcpus setting
|
||||
while (!scan($sys[$n],'label ') && $n < $size) {
|
||||
if (scan($sys[$n],'menu default')) $menu = 1;
|
||||
if (scan($sys[$n],'append')) foreach (explode(' ',$sys[$n]) as $cmd) if (scan($cmd,'isolcpus')) {$isol = explode('=',$cmd)[1]; break;}
|
||||
while (!scan($syslinux[$n],'label ') && $n < $size) {
|
||||
if (scan($syslinux[$n],'menu default')) $menu = 1;
|
||||
if (scan($syslinux[$n],'append')) foreach (explode(' ',$syslinux[$n]) as $cmd) if (scan($cmd,'isolcpus')) {$isol = explode('=',$cmd)[1]; break;}
|
||||
$n++;
|
||||
}
|
||||
if ($menu) break; else $i = $n - 1;
|
||||
@@ -123,20 +123,19 @@ case 'is':
|
||||
break;
|
||||
case 'cmd':
|
||||
$isolcpus_now = $isolcpus_new = '';
|
||||
$syslinux = file('/boot/syslinux/syslinux.cfg',FILE_IGNORE_NEW_LINES+FILE_SKIP_EMPTY_LINES);
|
||||
$cmdline = explode(' ',file_get_contents('/proc/cmdline'));
|
||||
foreach ($cmdline as $cmd) if (scan($cmd,'isolcpus')) {$isolcpus_now = $cmd; break;}
|
||||
|
||||
$sys = file('/boot/syslinux/syslinux.cfg',FILE_IGNORE_NEW_LINES+FILE_SKIP_EMPTY_LINES);
|
||||
$size = count($sys);
|
||||
$size = count($syslinux);
|
||||
$menu = $i = 0;
|
||||
// find the default section
|
||||
while ($i < $size) {
|
||||
if (scan($sys[$i],'label ')) {
|
||||
if (scan($syslinux[$i],'label ')) {
|
||||
$n = $i + 1;
|
||||
// find the current isolcpus setting
|
||||
while (!scan($sys[$n],'label ') && $n < $size) {
|
||||
if (scan($sys[$n],'menu default')) $menu = 1;
|
||||
if (scan($sys[$n],'append')) foreach (explode(' ',$sys[$n]) as $cmd) if (scan($cmd,'isolcpus')) {$isolcpus_new = $cmd; break;}
|
||||
while (!scan($syslinux[$n],'label ') && $n < $size) {
|
||||
if (scan($syslinux[$n],'menu default')) $menu = 1;
|
||||
if (scan($syslinux[$n],'append')) foreach (explode(' ',$syslinux[$n]) as $cmd) if (scan($cmd,'isolcpus')) {$isolcpus_new = $cmd; break;}
|
||||
$n++;
|
||||
}
|
||||
if ($menu) break; else $i = $n - 1;
|
||||
|
||||
@@ -120,18 +120,18 @@ case 'ct':
|
||||
break;
|
||||
case 'is':
|
||||
$cfg = '/boot/syslinux/syslinux.cfg';
|
||||
$sys = file($cfg, FILE_IGNORE_NEW_LINES+FILE_SKIP_EMPTY_LINES);
|
||||
$size = count($sys);
|
||||
$syslinux = file($cfg, FILE_IGNORE_NEW_LINES+FILE_SKIP_EMPTY_LINES);
|
||||
$size = count($syslinux);
|
||||
$menu = $i = 0;
|
||||
$cmd = [];
|
||||
// find the default section
|
||||
while ($i < $size) {
|
||||
if (scan($sys[$i],'label ')) {
|
||||
if (scan($syslinux[$i],'label ')) {
|
||||
$n = $i + 1;
|
||||
while (!scan($sys[$n],'label ') && $n < $size) {
|
||||
if (scan($sys[$n],'menu default')) $menu = 1;
|
||||
while (!scan($syslinux[$n],'label ') && $n < $size) {
|
||||
if (scan($syslinux[$n],'menu default')) $menu = 1;
|
||||
// find the current command
|
||||
if (scan($sys[$n],'append')) {$cmd = preg_split('/\s+/',trim($sys[$n])); break;}
|
||||
if (scan($syslinux[$n],'append')) {$cmd = preg_split('/\s+/',trim($syslinux[$n])); break;}
|
||||
$n++;
|
||||
}
|
||||
if ($menu) break; else $i = $n - 1;
|
||||
@@ -146,8 +146,7 @@ case 'is':
|
||||
if ($isolcpus != '') {
|
||||
$numbers = explode(',',$isolcpus);
|
||||
sort($numbers,SORT_NUMERIC);
|
||||
$previous = array_shift($numbers);
|
||||
$isolcpus = $previous;
|
||||
$isolcpus = $previous = array_shift($numbers);
|
||||
$range = false;
|
||||
// convert sequential numbers to a range
|
||||
foreach ($numbers as $number) {
|
||||
@@ -166,8 +165,8 @@ case 'is':
|
||||
for ($c = 0; $c < count($cmd); $c++) if (scan($cmd[$c],'isolcpus')) {$cmd[$c] = $isolcpus; break;}
|
||||
// or insert a new setting
|
||||
if ($c == count($cmd) && $isolcpus) array_splice($cmd,-1,0,$isolcpus);
|
||||
$sys[$n] = ' '.str_replace(' ',' ',implode(' ',$cmd));
|
||||
file_put_contents($cfg, implode("\n",$sys)."\n");
|
||||
$syslinux[$n] = ' '.str_replace(' ',' ',implode(' ',$cmd));
|
||||
file_put_contents($cfg, implode("\n",$syslinux)."\n");
|
||||
}
|
||||
$reply = ['success' => $name];
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user