* Re: [pve-devel] [PATCH 3/5] fix #3593: Added vm core pinning qemu-server
@ 2022-06-09 15:46 Daniel Bowder
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Bowder @ 2022-06-09 15:46 UTC (permalink / raw)
To: pve-devel, Matthias Heiserer
> Can we avoid showing them? I don't think they offer any insight, because
> as I understand it, when starting, the current affinity list is always
> all available cores.
Yes, I have made this change and will add it to my next patch. The change
is simple
adding the 'quiet => 1' argument to the PVE::Tools::run_command() function.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH 0/5] fix #3593: Added vm core pinning @ 2022-06-08 11:54 Daniel Bowder 2022-06-08 11:54 ` [pve-devel] [PATCH 3/5] fix #3593: Added vm core pinning qemu-server Daniel Bowder 0 siblings, 1 reply; 3+ messages in thread From: Daniel Bowder @ 2022-06-08 11:54 UTC (permalink / raw) To: pve-devel These five patches add the ability to pin a QEMU VMs processes to a defined set of CPU cores. The changes required spanned multiple repos and have all been included in these five patches. The patches add "cpuset" as an option in the qm configuration file and enable the editing of this parameter via the gui. pve-docs qm.conf.5-opts.adoc | 4 ++++ 1 file changed, 4 insertions(+) pve-guest-common src/PVE/GuestHelpers.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) qemu-server PVE/QemuServer.pm | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) proxmox-widget-toolkit src/Toolkit.js | 5 +++++ src/Utils.js | 2 ++ 2 files changed, 7 insertions(+) pve-manager www/manager6/qemu/Options.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) ^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH 3/5] fix #3593: Added vm core pinning qemu-server 2022-06-08 11:54 [pve-devel] [PATCH 0/5] fix #3593: Added vm core pinning Daniel Bowder @ 2022-06-08 11:54 ` Daniel Bowder 2022-06-08 14:45 ` Matthias Heiserer 0 siblings, 1 reply; 3+ messages in thread From: Daniel Bowder @ 2022-06-08 11:54 UTC (permalink / raw) To: pve-devel; +Cc: Daniel Bowder Signed-off-by: Daniel Bowder <daniel@bowdernet.com> --- The third patch adds cpuset as a valid object in the qm conf file. A new type is created called 'pve-cpuset' so that the cpuset can go through some validation before passing it to the taskset command. The exec_taskset command is executed just after the 'post-start' hookscript, which ensures that there is a valid PID to pin. PVE/QemuServer.pm | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index e9aa248..6b9abc0 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -713,6 +713,11 @@ EODESCR description => "Some (read-only) meta-information about this guest.", optional => 1, }, + cpuset => { + type => 'string', format => 'pve-cpuset', + description => "Specifies the cpu core numbers to pin the vm qemu processes to with 'taskset'.", + optional => 1, + }, }; my $cicustom_fmt = { @@ -5802,6 +5807,8 @@ sub vm_start_nolock { PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-start'); + PVE::GuestHelpers::exec_taskset($conf, $vmid); + return $res; } @@ -8214,4 +8221,46 @@ sub check_volume_storage_type { return 1; } +sub parse_cpuset { + my ($data) = @_; + + my $res = ""; + + # Parse cpuset value + foreach my $value (PVE::Tools::split_list($data)) { + if ($value =~ m/^([0-9]+)-([0-9]+)$/) { + if (int($1) > int($2)) { + die "invalid cpuset value '$value', left value must be <= right\n"; + } + my @range = (int($1) .. int($2)); + for my $cpu (@range) { + $res .= "," . $cpu; + } + } elsif ($value =~ m/^([0-9]+)$/) { + $res .= "," . $1; + } else { + die "invalid cpuset value '$value'\n"; + } + } + + if (!$res) { + die "invalid cpuset '$data'\n"; + } + + # Trim leading "," + $res = substr($res, 1); + return $res; +} + +PVE::JSONSchema::register_format('pve-cpuset', \&pve_verify_cpuset); +sub pve_verify_cpuset { + my ($value, $noerr) = @_; + + return $value if parse_cpuset($value); + + return if $noerr; + + die "unable to parse cpuset option\n"; +} + 1; -- 2.30.2 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH 3/5] fix #3593: Added vm core pinning qemu-server 2022-06-08 11:54 ` [pve-devel] [PATCH 3/5] fix #3593: Added vm core pinning qemu-server Daniel Bowder @ 2022-06-08 14:45 ` Matthias Heiserer 0 siblings, 0 replies; 3+ messages in thread From: Matthias Heiserer @ 2022-06-08 14:45 UTC (permalink / raw) To: pve-devel I'm not sure where it comes from, but when starting a VM, the task log receives a bunch of messages on changed affinity: pid 95121's current affinity list: 0-7 pid 95121's new affinity list: 2,3 pid 95122's current affinity list: 0-7 pid 95122's new affinity list: 2,3 pid 95123's current affinity list: 0-7 pid 95123's new affinity list: 2,3 pid 95184's current affinity list: 0-7 pid 95184's new affinity list: 2,3 pid 95185's current affinity list: 0-7 pid 95185's new affinity list: 2,3 pid 95187's current affinity list: 0-7 pid 95187's new affinity list: 2,3 Can we avoid showing them? I don't think they offer any insight, because as I understand it, when starting, the current affinity list is always all available cores. On 08.06.2022 13:54, Daniel Bowder wrote: > Signed-off-by: Daniel Bowder <daniel@bowdernet.com> > --- > The third patch adds cpuset as a valid object in the qm conf file. A new type is created called 'pve-cpuset' so that the cpuset can go through some validation before passing it to the taskset command. The exec_taskset command is executed just after the 'post-start' hookscript, which ensures that there is a valid PID to pin. The commit message should be above the lines :) Otherwise, it won't be part of the commit, but only a comment visible on the mailing list. > PVE/QemuServer.pm | 49 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 49 insertions(+) > > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index e9aa248..6b9abc0 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -713,6 +713,11 @@ EODESCR > description => "Some (read-only) meta-information about this guest.", > optional => 1, > }, > + cpuset => { > + type => 'string', format => 'pve-cpuset', > + description => "Specifies the cpu core numbers to pin the vm qemu processes to with 'taskset'.", > + optional => 1, > + }, > }; > > my $cicustom_fmt = { > @@ -5802,6 +5807,8 @@ sub vm_start_nolock { > > PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-start'); > > + PVE::GuestHelpers::exec_taskset($conf, $vmid); > + > return $res; > } > > @@ -8214,4 +8221,46 @@ sub check_volume_storage_type { > return 1; > } > > +sub parse_cpuset { > + my ($data) = @_; > + > + my $res = ""; > + > + # Parse cpuset value > + foreach my $value (PVE::Tools::split_list($data)) { > + if ($value =~ m/^([0-9]+)-([0-9]+)$/) { > + if (int($1) > int($2)) { > + die "invalid cpuset value '$value', left value must be <= right\n"; > + } > + my @range = (int($1) .. int($2)); > + for my $cpu (@range) { > + $res .= "," . $cpu; > + } > + } elsif ($value =~ m/^([0-9]+)$/) { > + $res .= "," . $1; > + } else { > + die "invalid cpuset value '$value'\n"; > + } > + } > + > + if (!$res) { > + die "invalid cpuset '$data'\n"; > + } > + > + # Trim leading "," > + $res = substr($res, 1); > + return $res; > +} > + > +PVE::JSONSchema::register_format('pve-cpuset', \&pve_verify_cpuset); > +sub pve_verify_cpuset { > + my ($value, $noerr) = @_; > + > + return $value if parse_cpuset($value); > + > + return if $noerr; > + > + die "unable to parse cpuset option\n"; > +} > + > 1; BTW, my colleagues will also review your code at some point, so be prepared that there might be some more required changes ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-09 15:46 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-06-09 15:46 [pve-devel] [PATCH 3/5] fix #3593: Added vm core pinning qemu-server Daniel Bowder -- strict thread matches above, loose matches on Subject: below -- 2022-06-08 11:54 [pve-devel] [PATCH 0/5] fix #3593: Added vm core pinning Daniel Bowder 2022-06-08 11:54 ` [pve-devel] [PATCH 3/5] fix #3593: Added vm core pinning qemu-server Daniel Bowder 2022-06-08 14:45 ` Matthias Heiserer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox