pm_sched_domain.py 1.6 KB

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