[pve-devel] [PATCH common] cpuset: remove max-cpu range check

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Apr 20 10:50:52 CEST 2017


CpuSets usually come from (or a built using) values read
from cgroups anyway. (Eg. for container balancing we only
use ids found in lxc/cpuset.effective_cpus.)
---
Requires the accompanying pve-manager patch.

 src/PVE/CpuSet.pm | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/src/PVE/CpuSet.pm b/src/PVE/CpuSet.pm
index 9f76f38..eaa4e3c 100644
--- a/src/PVE/CpuSet.pm
+++ b/src/PVE/CpuSet.pm
@@ -5,28 +5,13 @@ use warnings;
 use PVE::Tools;
 use PVE::ProcFSTools;
 
-my $MAX_CPUID;
-
-sub max_cpuid {
-
-    return $MAX_CPUID if defined($MAX_CPUID);
-
-    my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
-
-    $MAX_CPUID = $cpuinfo->{cpus} || 1;
-
-    return $MAX_CPUID;
-}
-
 sub new {
     my ($this) = @_;
 
     my $class = ref($this) || $this;
 
     my $self = bless { members => {} }, $class;
-    
-    max_cpuid() if !defined($MAX_CPUID); # initialize $MAX_CPUID
-    
+
     return $self;
 }
 
@@ -48,8 +33,6 @@ sub new_from_cgroup {
 	if ($part =~ /^\s*(\d+)(?:-(\d+))?\s*$/) {
 	    my ($from, $to) = ($1, $2);
 	    $to //= $1;
-	    die "cpu id '$from' is out of range\n" if $from >= $MAX_CPUID;
-	    die "cpu id '$to' is out of range\n" if $to >= $MAX_CPUID;
 	    die "invalid range: $part ($to < $from)\n" if $to < $from;
 	    for (my $i = $from; $i <= $to; $i++) {
 		$members->{$i} = 1;
@@ -91,7 +74,6 @@ sub insert {
     my $count = 0;
     
     foreach my $cpu (@members) {
-	die "cpu id '$cpu' is out of range\n" if $cpu >= $MAX_CPUID;
 	next if $self->{members}->{$cpu};
 	$self->{members}->{$cpu} = 1;
 	$count++;
@@ -106,7 +88,6 @@ sub delete {
     my $count = 0;
     
     foreach my $cpu (@members) {
-	die "cpu id '$cpu' is out of range\n" if $cpu >= $MAX_CPUID;
 	next if !$self->{members}->{$cpu};
 	delete $self->{members}->{$cpu};
 	$count++;
-- 
2.11.0





More information about the pve-devel mailing list