scx_show_state.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 state_str(state):
  21. return prog['scx_enable_state_str'][state].string_().decode()
  22. root = prog['scx_root']
  23. enable_state = read_atomic("scx_enable_state_var")
  24. if root:
  25. print(f'ops : {root.ops.name.string_().decode()}')
  26. else:
  27. print('ops : ')
  28. print(f'enabled : {read_static_key("__scx_enabled")}')
  29. print(f'switching_all : {read_int("scx_switching_all")}')
  30. print(f'switched_all : {read_static_key("__scx_switched_all")}')
  31. print(f'enable_state : {state_str(enable_state)} ({enable_state})')
  32. print(f'aborting : {prog["scx_aborting"].value_()}')
  33. print(f'bypass_depth : {prog["scx_bypass_depth"].value_()}')
  34. print(f'nr_rejected : {read_atomic("scx_nr_rejected")}')
  35. print(f'enable_seq : {read_atomic("scx_enable_seq")}')