[pve-devel] [PATCH common 2/2] cpuset: make MAX_CPUID a less confusing variable name

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Apr 13 11:33:28 CEST 2017


It's a maximum ID, not a count.
---
 src/PVE/CpuSet.pm | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/PVE/CpuSet.pm b/src/PVE/CpuSet.pm
index 24eb653..1b2b90f 100644
--- a/src/PVE/CpuSet.pm
+++ b/src/PVE/CpuSet.pm
@@ -13,7 +13,7 @@ sub max_cpuid {
 
     my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
 
-    $MAX_CPUID = $cpuinfo->{max_cpuid} + 1;
+    $MAX_CPUID = $cpuinfo->{max_cpuid};
 
     return $MAX_CPUID;
 }
@@ -48,8 +48,8 @@ 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 "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 +91,7 @@ sub insert {
     my $count = 0;
     
     foreach my $cpu (@members) {
-	die "cpu id '$cpu' is out of range\n" if $cpu >= $MAX_CPUID;
+	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 +106,7 @@ sub delete {
     my $count = 0;
     
     foreach my $cpu (@members) {
-	die "cpu id '$cpu' is out of range\n" if $cpu >= $MAX_CPUID;
+	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