Skip to content

Commit

Permalink
Merge pull request #225 from jrha/max_threads
Browse files Browse the repository at this point in the history
hardware: Fix bugs in max threads calculation and validate schema property
  • Loading branch information
wpoely86 authored Sep 16, 2024
2 parents 13994d0 + b682732 commit d51718b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 2 additions & 6 deletions quattor/functions/hardware.pan
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@ function get_num_of_cores_max_threads = {
'threads', 0,
);
foreach (i; cpu; hw_config['cpu']) {
result['cores'] = result['cores'] + cpu['cores'];
if (is_defined(cpu['max_threads'])) {
result['threads'] = result['threads'] + cpu['max_threads'];
} else {
result['threads'] = result['threads'] + 1;
};
if (is_defined(cpu['cores'])) {
result['cores'] = result['cores'] + cpu['cores'];
} else {
result['cores'] = result['cores'] + 1;
result['threads'] = result['threads'] + cpu['cores'];
};
};
debug('%s: num of CPUs=%d, num of cores=%d', OBJECT, length(hw_config['cpu']), cores);
Expand Down
6 changes: 6 additions & 0 deletions quattor/types/hardware.pan
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ type structure_cpu = {
deprecated(0, 'The hyperthreading cpu property has been deprecated, please migrate to max_threads');
true;
}
} with {
if (exists(SELF['max_threads']) && SELF['max_threads'] < SELF['cores']) {
error("Number of execution threads (max_threads) cannot be less than number of CPU cores (cores)");
} else {
true;
};
};


Expand Down

0 comments on commit d51718b

Please sign in to comment.