1f08c3bdfSopenharmony_ci#!/usr/bin/env python3
2f08c3bdfSopenharmony_ci''' This Python script interprets interrupt values.
3f08c3bdfSopenharmony_ci    Validates Ideal load balancer runs in same package where workload is running
4f08c3bdfSopenharmony_ci'''
5f08c3bdfSopenharmony_ci
6f08c3bdfSopenharmony_ciimport os
7f08c3bdfSopenharmony_ciimport sys
8f08c3bdfSopenharmony_cifrom optparse import OptionParser
9f08c3bdfSopenharmony_cifrom pm_sched_mc import *
10f08c3bdfSopenharmony_ci
11f08c3bdfSopenharmony_ci__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>"
12f08c3bdfSopenharmony_ci
13f08c3bdfSopenharmony_ciclass Usage(Exception):
14f08c3bdfSopenharmony_ci    def __init__(self, msg):
15f08c3bdfSopenharmony_ci        self.msg = msg
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_cidef main(argv=None):
18f08c3bdfSopenharmony_ci    if argv is None:
19f08c3bdfSopenharmony_ci        argv = sys.argv
20f08c3bdfSopenharmony_ci
21f08c3bdfSopenharmony_ci    usage = "-w"
22f08c3bdfSopenharmony_ci    parser = OptionParser(usage)
23f08c3bdfSopenharmony_ci    parser.add_option("-c", "--mc_level", dest="mc_level",
24f08c3bdfSopenharmony_ci        default=0, help="Sched mc power saving value 0/1/2")
25f08c3bdfSopenharmony_ci    parser.add_option("-t", "--smt_level", dest="smt_level",
26f08c3bdfSopenharmony_ci        default=0, help="Sched smt power saving value 0/1/2")
27f08c3bdfSopenharmony_ci    parser.add_option("-w", "--workload", dest="work_ld",
28f08c3bdfSopenharmony_ci        default="ebizzy", help="Workload can be ebizzy/kernbench")
29f08c3bdfSopenharmony_ci    (options, args) = parser.parse_args()
30f08c3bdfSopenharmony_ci
31f08c3bdfSopenharmony_ci    try:
32f08c3bdfSopenharmony_ci        count_num_cpu()
33f08c3bdfSopenharmony_ci        count_num_sockets()
34f08c3bdfSopenharmony_ci        if is_multi_socket():
35f08c3bdfSopenharmony_ci            set_sched_mc_power(options.mc_level)
36f08c3bdfSopenharmony_ci        if is_hyper_threaded():
37f08c3bdfSopenharmony_ci            set_sched_smt_power(options.smt_level)
38f08c3bdfSopenharmony_ci        map_cpuid_pkgid()
39f08c3bdfSopenharmony_ci        print("INFO: Created table mapping cpu to package")
40f08c3bdfSopenharmony_ci        background="no"
41f08c3bdfSopenharmony_ci        duration=120
42f08c3bdfSopenharmony_ci        pinned="yes"
43f08c3bdfSopenharmony_ci
44f08c3bdfSopenharmony_ci        trigger_workld(options.smt_level,options.work_ld, "single_job", duration, background, pinned, "no")
45f08c3bdfSopenharmony_ci        generate_loc_intr_report()
46f08c3bdfSopenharmony_ci        status = validate_ilb(options.mc_level, options.smt_level)
47f08c3bdfSopenharmony_ci        reset_schedmc()
48f08c3bdfSopenharmony_ci        if is_hyper_threaded():
49f08c3bdfSopenharmony_ci            reset_schedsmt()
50f08c3bdfSopenharmony_ci        return(status)
51f08c3bdfSopenharmony_ci
52f08c3bdfSopenharmony_ci    except Exception as details:
53f08c3bdfSopenharmony_ci        print("INFO: Idle Load Balancer test failed", details)
54f08c3bdfSopenharmony_ci        return(1)
55f08c3bdfSopenharmony_ci
56f08c3bdfSopenharmony_ciif __name__ == "__main__":
57f08c3bdfSopenharmony_ci    sys.exit(main())
58