Commit 3992eb28 authored by Karol Latecki's avatar Karol Latecki Committed by Jim Harris
Browse files

scripts/nvmf_perf: set cpu governor to performance



In performance tests always use best performance policy.
Previously this was manually managed on test systems,
but it's better to do this automatically every time.

Change-Id: Iff81863cf8d9cc713a3c4cce1d8edf7ebbf81c84
Signed-off-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6373


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarMichal Berger <michalx.berger@intel.com>
Reviewed-by: default avatarMaciej Wawryk <maciejx.wawryk@intel.com>
parent 2f910330
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ class Server:
        self.svc_restore_dict = {}
        self.sysctl_restore_dict = {}
        self.tuned_restore_dict = {}
        self.governor_restore = ""
        self.tuned_profile = ""

        self.enable_adq = False
@@ -89,6 +90,7 @@ class Server:
        self.configure_services()
        self.configure_sysctl()
        self.configure_tuned()
        self.configure_cpu_governor()

    def configure_adq(self):
        self.adq_load_modules()
@@ -216,6 +218,13 @@ class Server:
        self.exec_cmd(["sudo", "tuned-adm", "profile", self.tuned_profile])
        self.log_print("Tuned profile set to %s." % self.exec_cmd(["cat", "/etc/tuned/active_profile"]))

    def configure_cpu_governor(self):
        self.log_print("Setting CPU governor to performance...")

        # This assumes that there is the same CPU scaling governor on each CPU
        self.governor_restore = self.exec_cmd(["cat", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"]).strip()
        self.exec_cmd(["sudo", "cpupower", "frequency-set", "-g", "performance"])

    def restore_services(self):
        self.log_print("Restoring services...")
        for service, state in self.svc_restore_dict.items():
@@ -240,6 +249,12 @@ class Server:
            self.exec_cmd(["sudo", "tuned-adm", "profile", self.tuned_restore_dict["profile"]])
            self.log_print("Reverted tuned-adm to %s profile." % self.tuned_restore_dict["profile"])

    def restore_governor(self):
        self.log_print("Restoring CPU governor setting...")
        if self.governor_restore:
            self.exec_cmd(["sudo", "cpupower", "frequency-set", "-g", self.governor_restore])
            self.log_print("Reverted CPU governor to %s." % self.governor_restore)


class Target(Server):
    def __init__(self, name, general_config, target_config):
@@ -1289,10 +1304,12 @@ if __name__ == "__main__":
                i.kernel_init_disconnect(i.remote_nic_ips, target_obj.subsys_no)
            i.copy_result_files(target_results_dir)

    target_obj.restore_governor()
    target_obj.restore_tuned()
    target_obj.restore_services()
    target_obj.restore_sysctl()
    for i in initiators:
        i.restore_governor()
        i.restore_tuned()
        i.restore_services()
        i.restore_sysctl()