Skip to content

Commit

Permalink
Merge pull request avocado-framework-tests#2900 from SamirMulani/lock…
Browse files Browse the repository at this point in the history
…storm

Added support for lockstorm benchmark to dump data in special file.
  • Loading branch information
Naresh-ibm authored Sep 23, 2024
2 parents 5167a66 + d8ea9f6 commit ef7e5c3
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions cpu/lockstorm_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
from avocado.utils.software_manager.manager import SoftwareManager


def clear_dmesg():
process.run("dmesg -C ", sudo=True)


class lockstorm_benchmark(Test):
def setUp(self):
"""
Expand Down Expand Up @@ -61,10 +65,11 @@ def capture_dmesg_dump(self, smt_state):
:param smt_state: Here we are passing the smt state that we are
going to change.
"""
cmd = "dmesg | tail -n 1"
cmd = "dmesg | grep 'lockstorm: spinlock iterations'"
self.log.info(f"=================Dump data for \
SMT Mode: {smt_state} benchmark======================\n\n")
dump_data = process.run(cmd, shell=True)
return dump_data

def test(self):
"""
Expand All @@ -74,6 +79,8 @@ def test(self):
2.Running the lockstorm benchmark.
3. Capturing the benchmark stats.
"""
lockstorm_dir = self.logdir + "/lockstorm_benc"
os.makedirs(lockstorm_dir, exist_ok=True)
process.run('ppc64_cpu --cores-on=all', shell=True)
process.run('ppc64_cpu --smt=on', shell=True)
cpu_controller = ["2", "4", "6", "on", "off"]
Expand All @@ -85,12 +92,26 @@ def test(self):
process.run(cmd, shell=True)
cmd = "insmod ./lockstorm.ko" + " cpulist=%s" % \
(self.cpu_list)

clear_dmesg()
if self.cpu_list == 0:
cmd = "insmod ./lockstorm.ko"
process.system(cmd,
ignore_status=True, shell=False, sudo=True)
self.capture_dmesg_dump(smt_mode)
lockstorm_data = self.capture_dmesg_dump(smt_mode)
stdout_output = lockstorm_data.stdout
lockstorm_log = lockstorm_dir + "/lockstorm.log"
with open(lockstorm_log, "a") as payload:
payload.write(
"==================Iteration {}=============\
\n".format(str(test_run)))
payload.write("============SMT mode: {}============= \
\n".format(smt_mode))
lines = stdout_output.splitlines()
for line in lines:
decoded_string = line.decode('utf-8')
cleaned_string = decoded_string.lstrip('\t')
payload.write(cleaned_string + '\n')
payload.write("\n")

def tearDown(self):
"""
Expand Down

0 comments on commit ef7e5c3

Please sign in to comment.