[pve-devel] [PATCH container] cgroup: don't dup cgroup.events and don't busy-loop

Wolfgang Bumiller w.bumiller at proxmox.com
Fri May 15 15:53:22 CEST 2020


Events are reported via POLLPRI and POLLERR (priority and
exception flags), not POLLIN (which causes a busy-loop).

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 src/PVE/LXC/CGroup.pm | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/PVE/LXC/CGroup.pm b/src/PVE/LXC/CGroup.pm
index 5db1d48..d6b27ea 100644
--- a/src/PVE/LXC/CGroup.pm
+++ b/src/PVE/LXC/CGroup.pm
@@ -546,18 +546,16 @@ my sub v2_freeze_thaw {
 
     PVE::ProcFSTools::write_proc_entry("$path/cgroup.freeze", $desired_state);
     while (1) {
-	my @handles = $select->can_read();
-	next if !@handles;
-	open(my $dup, '<&', $fh)
-	    or die "failed to reopen cgroup.events file: $!\n";
-	seek($dup, 0, 0)
-	    or die "failed to rewind cgroup.events file: $!\n";
 	my $data = do {
 	    local $/ = undef;
-	    <$dup>
+	    <$fh>
 	};
 	$data = parse_flat_keyed_file($data);
 	last if $data->{frozen} == $desired_state;
+	my @handles = $select->has_exception();
+	next if !@handles;
+	seek($fh, 0, 0)
+	    or die "failed to rewind cgroup.events file: $!\n";
     }
 }
 
-- 
2.20.1





More information about the pve-devel mailing list