scx_show_state.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env drgn
  2. #
  3. # Copyright (C) 2024 Tejun Heo <tj@kernel.org>
  4. # Copyright (C) 2024 Meta Platforms, Inc. and affiliates.
  5. desc = """
  6. This is a drgn script to show the current sched_ext state.
  7. For more info on drgn, visit https://github.com/osandov/drgn.
  8. """
  9. import drgn
  10. import sys
  11. def err(s):
  12. print(s, file=sys.stderr, flush=True)
  13. sys.exit(1)
  14. def read_int(name):
  15. return int(prog[name].value_())
  16. def read_atomic(name):
  17. return prog[name].counter.value_()
  18. def read_static_key(name):
  19. return prog[name].key.enabled.counter.value_()
  20. def ops_state_str(state):
  21. return prog['scx_ops_enable_state_str'][state].string_().decode()
  22. ops = prog['scx_ops']
  23. enable_state = read_atomic("scx_ops_enable_state_var")
  24. print(f'ops : {ops.name.string_().decode()}')
  25. print(f'enabled : {read_static_key("__scx_ops_enabled")}')
  26. print(f'switching_all : {read_int("scx_switching_all")}')
  27. print(f'switched_all : {read_static_key("__scx_switched_all")}')
  28. print(f'enable_state : {ops_state_str(enable_state)} ({enable_state})')
  29. print(f'bypass_depth : {prog["scx_ops_bypass_depth"].value_()}')
  30. print(f'nr_rejected : {read_atomic("scx_nr_rejected")}')
  31. print(f'enable_seq : {read_atomic("scx_enable_seq")}')