From 48927afd8b7fcc1bb07cfcdf920d760de0c5a87f Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Mon, 16 Aug 2021 09:43:36 -0700 Subject: [PATCH] Fix reserveHT --- rqd/rqd/rqmachine.py | 11 ++++++++--- rqd/tests/rqmachine_tests.py | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/rqd/rqd/rqmachine.py b/rqd/rqd/rqmachine.py index 3da883111..8c0077839 100644 --- a/rqd/rqd/rqmachine.py +++ b/rqd/rqd/rqmachine.py @@ -309,7 +309,7 @@ def getLoadAvg(self): loadAvgFile = open(rqd.rqconstants.PATH_LOADAVG, "r") loadAvg = int(float(loadAvgFile.read().split()[0]) * 100) if self.__enabledHT(): - loadAvg = loadAvg // 2 + loadAvg = loadAvg // self.__getHyperthreadingMultiplier() loadAvg = loadAvg + rqd.rqconstants.LOAD_MODIFIER loadAvg = max(loadAvg, 0) return loadAvg @@ -549,7 +549,7 @@ def __initMachineStats(self, pathCpuInfo=None): self.__renderHost.num_procs = __numProcs self.__renderHost.cores_per_proc = __totalCores // __numProcs - if hyperthreadingMultiplier > 1: + if hyperthreadingMultiplier >= 1: self.__renderHost.attributes['hyperthreadingMultiplier'] = str(hyperthreadingMultiplier) def getWindowsMemory(self): @@ -681,6 +681,9 @@ def getBootReport(self): def __enabledHT(self): return 'hyperthreadingMultiplier' in self.__renderHost.attributes + def __getHyperthreadingMultiplier(self): + return int(self.__renderHost.attributes['hyperthreadingMultiplier']) + def setupHT(self): """ Setup rqd for hyper-threading """ @@ -716,11 +719,13 @@ def reserveHT(self, reservedCores): log.critical(err) raise rqd.rqexceptions.CoreReservationFailureException(err) + hyperthreadingMultiplier = self.__getHyperthreadingMultiplier() tasksets = [] for _ in range(reservedCores // 100): core = self.__tasksets.pop() tasksets.append(str(core)) - tasksets.append(str(core + self.__coreInfo.total_cores // 100)) + if hyperthreadingMultiplier > 1: + tasksets.append(str(core + self.__coreInfo.total_cores // 100)) log.debug('Taskset: Reserving cores - %s', ','.join(tasksets)) diff --git a/rqd/tests/rqmachine_tests.py b/rqd/tests/rqmachine_tests.py index b4bfe7bad..c2d4bad87 100644 --- a/rqd/tests/rqmachine_tests.py +++ b/rqd/tests/rqmachine_tests.py @@ -304,6 +304,9 @@ def test_getLoadAvg(self): @mock.patch.object( rqd.rqmachine.Machine, '_Machine__enabledHT', new=mock.MagicMock(return_value=True)) + @mock.patch.object( + rqd.rqmachine.Machine, '_Machine__getHyperthreadingMultiplier', + new=mock.MagicMock(return_value=2)) def test_getLoadAvgHT(self): self.loadavg.set_contents(LOADAVG_HIGH_USAGE)