diff --git a/quattor/functions/hardware.pan b/quattor/functions/hardware.pan index 7cc987760..ddc21b4c0 100644 --- a/quattor/functions/hardware.pan +++ b/quattor/functions/hardware.pan @@ -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); diff --git a/quattor/types/hardware.pan b/quattor/types/hardware.pan index 43d468654..cff81790b 100644 --- a/quattor/types/hardware.pan +++ b/quattor/types/hardware.pan @@ -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; + }; };