mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-02 16:44:10 +08:00
431844b65f
As discussed during the distro-centric session within the sched_ext Microconference at LPC 2024, introduce a sequence counter that is incremented every time a BPF scheduler is loaded. This feature can help distributions in diagnosing potential performance regressions by identifying systems where users are running (or have ran) custom BPF schedulers. Example: arighi@virtme-ng~> cat /sys/kernel/sched_ext/enable_seq 0 arighi@virtme-ng~> sudo scx_simple local=1 global=0 ^CEXIT: unregistered from user space arighi@virtme-ng~> cat /sys/kernel/sched_ext/enable_seq 1 In this way user-space tools (such as Ubuntu's apport and similar) are able to gather and include this information in bug reports. Cc: Giovanni Gherdovich <giovanni.gherdovich@suse.com> Cc: Kleber Sacilotto de Souza <kleber.souza@canonical.com> Cc: Marcelo Henrique Cerri <marcelo.cerri@canonical.com> Cc: Phil Auld <pauld@redhat.com> Signed-off-by: Andrea Righi <andrea.righi@linux.dev> Signed-off-by: Tejun Heo <tj@kernel.org>
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
#!/usr/bin/env drgn
|
|
#
|
|
# Copyright (C) 2024 Tejun Heo <tj@kernel.org>
|
|
# Copyright (C) 2024 Meta Platforms, Inc. and affiliates.
|
|
|
|
desc = """
|
|
This is a drgn script to show the current sched_ext state.
|
|
For more info on drgn, visit https://github.com/osandov/drgn.
|
|
"""
|
|
|
|
import drgn
|
|
import sys
|
|
|
|
def err(s):
|
|
print(s, file=sys.stderr, flush=True)
|
|
sys.exit(1)
|
|
|
|
def read_int(name):
|
|
return int(prog[name].value_())
|
|
|
|
def read_atomic(name):
|
|
return prog[name].counter.value_()
|
|
|
|
def read_static_key(name):
|
|
return prog[name].key.enabled.counter.value_()
|
|
|
|
def ops_state_str(state):
|
|
return prog['scx_ops_enable_state_str'][state].string_().decode()
|
|
|
|
ops = prog['scx_ops']
|
|
enable_state = read_atomic("scx_ops_enable_state_var")
|
|
|
|
print(f'ops : {ops.name.string_().decode()}')
|
|
print(f'enabled : {read_static_key("__scx_ops_enabled")}')
|
|
print(f'switching_all : {read_int("scx_switching_all")}')
|
|
print(f'switched_all : {read_static_key("__scx_switched_all")}')
|
|
print(f'enable_state : {ops_state_str(enable_state)} ({enable_state})')
|
|
print(f'bypass_depth : {read_atomic("scx_ops_bypass_depth")}')
|
|
print(f'nr_rejected : {read_atomic("scx_nr_rejected")}')
|
|
print(f'enable_seq : {read_atomic("scx_enable_seq")}')
|