Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reserveHT #1013

Merged
merged 1 commit into from
Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions rqd/rqd/rqmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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 """

Expand Down Expand Up @@ -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))

Expand Down
3 changes: 3 additions & 0 deletions rqd/tests/rqmachine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down