1#!/usr/bin/env python3 2''' This Python script validates sched domain information in dmesg 3 with information in sysfs topology 4''' 5 6import os 7import sys 8from pm_sched_mc import * 9from optparse import OptionParser 10 11__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>" 12 13class Usage(Exception): 14 def __init__(self, msg): 15 self.msg = msg 16 17def main(argv=None): 18 if argv is None: 19 argv = sys.argv 20 21 usage = "-w" 22 parser = OptionParser(usage) 23 parser.add_option("-c", "--mc_level", dest="mc_level", default=-1, 24 help="Sched mc power saving value 0/1/2") 25 parser.add_option("-t", "--smt_level", dest="smt_level", default=-1, 26 help="Sched smt power saving value 0/1/2") 27 (options, args) = parser.parse_args() 28 29 try: 30 clear_dmesg() 31 count_num_cpu() 32 map_cpuid_pkgid() 33 34 if is_hyper_threaded() and int(options.smt_level) >= 0: 35 set_sched_smt_power(options.smt_level) 36 37 if int(options.mc_level) >= 0: 38 set_sched_mc_power(options.mc_level) 39 if int(options.smt_level) >= 0 or int(options.mc_level) >= 0: 40 status = verify_sched_domain_dmesg(options.mc_level, options.smt_level) 41 reset_schedmc() 42 if is_hyper_threaded(): 43 reset_schedsmt() 44 return(status) 45 else: 46 print("INFO: Invalid arguments given") 47 return 1 48 except Exception as details: 49 print("INFO: sched domain test failed: ", details) 50 return(1) 51 52# Run test based on the command line arguments 53if __name__ == "__main__": 54 sys.exit(main()) 55