Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
6desc = """
7This is a drgn script to show the current sched_ext state.
8For more info on drgn, visit https://github.com/osandov/drgn.
9"""
10
11import drgn
12import sys
13
14def err(s):
15 print(s, file=sys.stderr, flush=True)
16 sys.exit(1)
17
18def read_int(name):
19 return int(prog[name].value_())
20
21def read_atomic(name):
22 return prog[name].counter.value_()
23
24def read_static_key(name):
25 return prog[name].key.enabled.counter.value_()
26
27def state_str(state):
28 return prog['scx_enable_state_str'][state].string_().decode()
29
30root = prog['scx_root']
31enable_state = read_atomic("scx_enable_state_var")
32
33if root:
34 print(f'ops : {root.ops.name.string_().decode()}')
35else:
36 print('ops : ')
37print(f'enabled : {read_static_key("__scx_enabled")}')
38print(f'switching_all : {read_int("scx_switching_all")}')
39print(f'switched_all : {read_static_key("__scx_switched_all")}')
40print(f'enable_state : {state_str(enable_state)} ({enable_state})')
41print(f'aborting : {prog["scx_aborting"].value_()}')
42print(f'bypass_depth : {prog["scx_bypass_depth"].value_()}')
43print(f'nr_rejected : {read_atomic("scx_nr_rejected")}')
44print(f'enable_seq : {read_atomic("scx_enable_seq")}')