[pve-devel] [PATCH manager 2/7] Broadcast supported CPU flags
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Sep 6 12:58:42 CEST 2019
On September 2, 2019 4:27 pm, Stefan Reiter wrote:
> pvestatd will read supported CPU flags once on startup (since these
> never change during runtime, and QEMU updates trigger a service
> restart), then broadcasts them as a key-value pair to the cluster.
>
> Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
> ---
>
> Changes from RFC:
>
> * Cache joined value
> * Add eval around QEMU query
> * Detect value regression (e.g. "better" value available in cluster kv) and
> handle accordingly
>
>
> PVE/Service/pvestatd.pm | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
> index e138b2e8..84258daf 100755
> --- a/PVE/Service/pvestatd.pm
> +++ b/PVE/Service/pvestatd.pm
> @@ -47,12 +47,15 @@ my $cmdline = [$0, @ARGV];
> my %daemon_options = (restart_on_error => 5, stop_wait_time => 5);
> my $daemon = __PACKAGE__->new('pvestatd', $cmdline, %daemon_options);
>
> +my $supported_cpuflags;
> +
> sub init {
> my ($self) = @_;
>
> $opt_debug = $self->{debug};
>
> PVE::Cluster::cfs_update();
> + update_supported_cpuflags();
but this only happens once, not on every status update cycle like all
the other update_foo subs? if we go the "cache based on
kvm_user_version" route, then this could actually move to update_status
> }
>
> sub shutdown {
> @@ -72,6 +75,25 @@ sub hup {
> $restart_request = 1;
> }
>
> +sub update_supported_cpuflags {
at least if this is reworked:
1.) get kvm_user_version
2.) check if cached kvm_user_version is different
3.) yes -> query_supported_cpu_flags, cache results + kvm_user_version
4.) yes -> handle regressions
5.) broadcast supported flags
> + eval {
> + $supported_cpuflags = join(" ", @{PVE::QemuServer::query_supported_cpu_flags()});
> + };
> + warn $@ if $@;
> +
> + # detect regression
> + if (!$supported_cpuflags || $supported_cpuflags eq '') {
> + my $prev_cpuflags = PVE::Cluster::get_node_kv('cpuflags', $nodename)->{$nodename};
> + if ($prev_cpuflags && $prev_cpuflags ne '') {
> + $supported_cpuflags = $prev_cpuflags;
> + warn "CPU flag detection failed, using old values\n";
> + } else {
> + $supported_cpuflags = '';
> + warn "CPU flag detection failed and no previous values found\n";
> + }
> + }
> +}
> +
> my $generate_rrd_string = sub {
> my ($data) = @_;
>
> @@ -91,7 +113,9 @@ sub update_node_status {
>
> my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
>
> - my $maxcpu = $cpuinfo->{cpus};
> + my $maxcpu = $cpuinfo->{cpus};
> +
> + PVE::Cluster::broadcast_node_kv('cpuflags', $supported_cpuflags);
this can then be replaced with a call to update_supported_cpuflags
>
> my $subinfo = PVE::INotify::read_file('subscription');
> my $sublevel = $subinfo->{level} || '';
> @@ -104,7 +128,7 @@ sub update_node_status {
> $netin += $netdev->{$dev}->{receive};
> $netout += $netdev->{$dev}->{transmit};
> }
> -
> +
> my $meminfo = PVE::ProcFSTools::read_meminfo();
>
> my $dinfo = df('/', 1); # output is bytes
> --
> 2.20.1
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
More information about the pve-devel
mailing list