From d8ea9f68ec0b71a2dc563e22942ce970f267689c Mon Sep 17 00:00:00 2001 From: Samir Mulani Date: Mon, 23 Sep 2024 12:27:23 +0530 Subject: [PATCH] Added support for lockstorm benchmark to dump data in special file. Added support for lockstorm benchmark to dump data under "lockstorm_benc" dir under job directory. Signed-off-by: Samir Mulani Addressed travis check error for lockstorm benchmark. Addressed python style issue. Signed-off-by: Samir Mulani --- cpu/lockstorm_benchmark.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/cpu/lockstorm_benchmark.py b/cpu/lockstorm_benchmark.py index d73a1e1b7..f4c7cb5c7 100644 --- a/cpu/lockstorm_benchmark.py +++ b/cpu/lockstorm_benchmark.py @@ -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): """ @@ -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): """ @@ -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"] @@ -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): """