All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/sched_ext: Fix scx_show_state per-scheduler state reads
@ 2026-05-26 13:51 Zicheng Qu
  2026-05-26 17:44 ` Andrea Righi
  0 siblings, 1 reply; 4+ messages in thread
From: Zicheng Qu @ 2026-05-26 13:51 UTC (permalink / raw)
  To: tj, void, arighi, changwoo, enjuk, emil, sched-ext, linux-kernel
  Cc: tanghui20, zhangqiao22, quzicheng, quzicheng315

From: Zicheng Qu <quzicheng@huawei.com>

scx_show_state.py still reads scx_aborting and scx_bypass_depth as
global symbols. Those symbols no longer exist after the state was moved
into struct scx_sched, so the drgn script fails when it reaches either
field.

Fixes: 5c8d98a1b4de ("sched_ext: Move bypass state into scx_sched")
Fixes: c1743da43cf5 ("sched_ext: Move aborting flag to per-scheduler field")
Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
---
 tools/sched_ext/scx_show_state.py | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/sched_ext/scx_show_state.py b/tools/sched_ext/scx_show_state.py
index 02e43c184d43..446d82807f90 100644
--- a/tools/sched_ext/scx_show_state.py
+++ b/tools/sched_ext/scx_show_state.py
@@ -27,18 +27,25 @@ def read_static_key(name):
 def state_str(state):
     return prog['scx_enable_state_str'][state].string_().decode()
 
+def read_root_ops_name():
+    if root:
+        return root.ops.name.string_().decode()
+    return ''
+
+def read_root_field(name, default):
+    if root:
+        return getattr(root, name).value_()
+    return default
+
 root = prog['scx_root']
 enable_state = read_atomic("scx_enable_state_var")
 
-if root:
-    print(f'ops           : {root.ops.name.string_().decode()}')
-else:
-    print('ops           : ')
+print(f'ops           : {read_root_ops_name()}')
 print(f'enabled       : {read_static_key("__scx_enabled")}')
 print(f'switching_all : {read_int("scx_switching_all")}')
 print(f'switched_all  : {read_static_key("__scx_switched_all")}')
 print(f'enable_state  : {state_str(enable_state)} ({enable_state})')
-print(f'aborting      : {prog["scx_aborting"].value_()}')
-print(f'bypass_depth  : {prog["scx_bypass_depth"].value_()}')
+print(f'aborting      : {read_root_field("aborting", False)}')
+print(f'bypass_depth  : {read_root_field("bypass_depth", 0)}')
 print(f'nr_rejected   : {read_atomic("scx_nr_rejected")}')
 print(f'enable_seq    : {read_atomic("scx_enable_seq")}')
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/sched_ext: Fix scx_show_state per-scheduler state reads
  2026-05-26 13:51 [PATCH] tools/sched_ext: Fix scx_show_state per-scheduler state reads Zicheng Qu
@ 2026-05-26 17:44 ` Andrea Righi
  2026-05-27  9:38   ` [PATCH v2] " quzicheng315
  0 siblings, 1 reply; 4+ messages in thread
From: Andrea Righi @ 2026-05-26 17:44 UTC (permalink / raw)
  To: Zicheng Qu
  Cc: tj, void, changwoo, enjuk, emil, sched-ext, linux-kernel,
	tanghui20, zhangqiao22, quzicheng

Hi Zicheng,

On Tue, May 26, 2026 at 09:51:23PM +0800, Zicheng Qu wrote:
> From: Zicheng Qu <quzicheng@huawei.com>
> 
> scx_show_state.py still reads scx_aborting and scx_bypass_depth as
> global symbols. Those symbols no longer exist after the state was moved
> into struct scx_sched, so the drgn script fails when it reaches either
> field.
> 
> Fixes: 5c8d98a1b4de ("sched_ext: Move bypass state into scx_sched")
> Fixes: c1743da43cf5 ("sched_ext: Move aborting flag to per-scheduler field")
> Signed-off-by: Zicheng Qu <quzicheng@huawei.com>

Makes sense to me.

Let's keep in mind that with the sub-scheduler support the script will only
report aborting and bypass_depth only from scx_root (not the sub-scheds). Maybe
we should mention this in the patch description, but the patch looks good.

Reviewed-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

> ---
>  tools/sched_ext/scx_show_state.py | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/sched_ext/scx_show_state.py b/tools/sched_ext/scx_show_state.py
> index 02e43c184d43..446d82807f90 100644
> --- a/tools/sched_ext/scx_show_state.py
> +++ b/tools/sched_ext/scx_show_state.py
> @@ -27,18 +27,25 @@ def read_static_key(name):
>  def state_str(state):
>      return prog['scx_enable_state_str'][state].string_().decode()
>  
> +def read_root_ops_name():
> +    if root:
> +        return root.ops.name.string_().decode()
> +    return ''
> +
> +def read_root_field(name, default):
> +    if root:
> +        return getattr(root, name).value_()
> +    return default
> +
>  root = prog['scx_root']
>  enable_state = read_atomic("scx_enable_state_var")
>  
> -if root:
> -    print(f'ops           : {root.ops.name.string_().decode()}')
> -else:
> -    print('ops           : ')
> +print(f'ops           : {read_root_ops_name()}')
>  print(f'enabled       : {read_static_key("__scx_enabled")}')
>  print(f'switching_all : {read_int("scx_switching_all")}')
>  print(f'switched_all  : {read_static_key("__scx_switched_all")}')
>  print(f'enable_state  : {state_str(enable_state)} ({enable_state})')
> -print(f'aborting      : {prog["scx_aborting"].value_()}')
> -print(f'bypass_depth  : {prog["scx_bypass_depth"].value_()}')
> +print(f'aborting      : {read_root_field("aborting", False)}')
> +print(f'bypass_depth  : {read_root_field("bypass_depth", 0)}')
>  print(f'nr_rejected   : {read_atomic("scx_nr_rejected")}')
>  print(f'enable_seq    : {read_atomic("scx_enable_seq")}')
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] tools/sched_ext: Fix scx_show_state per-scheduler state reads
  2026-05-26 17:44 ` Andrea Righi
@ 2026-05-27  9:38   ` quzicheng315
  2026-05-27 19:16     ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: quzicheng315 @ 2026-05-27  9:38 UTC (permalink / raw)
  To: arighi
  Cc: changwoo, emil, enjuk, linux-kernel, quzicheng315, quzicheng,
	sched-ext, tanghui20, tj, void, zhangqiao22

From: Zicheng Qu <quzicheng315@gmail.com>

scx_show_state.py still reads scx_aborting and scx_bypass_depth as
global symbols. Those symbols no longer exist after the state was moved
into struct scx_sched, so the drgn script fails when it reaches either
field.

Read aborting and bypass_depth from scx_root instead. This preserves the
script's current root-scheduler view: with sub-scheduler support, the
reported values are for the root scheduler and sub-schedulers are not
enumerated.

Fixes: 5c8d98a1b4de ("sched_ext: Move bypass state into scx_sched")
Fixes: c1743da43cf5 ("sched_ext: Move aborting flag to per-scheduler field")
Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
---
v2:
- Clarify that aborting and bypass_depth are reported for scx_root only,
  as Andrea pointed out.
- Add Reviewed-by from Andrea.

 tools/sched_ext/scx_show_state.py | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/sched_ext/scx_show_state.py b/tools/sched_ext/scx_show_state.py
index 02e43c184d43..446d82807f90 100644
--- a/tools/sched_ext/scx_show_state.py
+++ b/tools/sched_ext/scx_show_state.py
@@ -27,18 +27,25 @@ def read_static_key(name):
 def state_str(state):
     return prog['scx_enable_state_str'][state].string_().decode()
 
+def read_root_ops_name():
+    if root:
+        return root.ops.name.string_().decode()
+    return ''
+
+def read_root_field(name, default):
+    if root:
+        return getattr(root, name).value_()
+    return default
+
 root = prog['scx_root']
 enable_state = read_atomic("scx_enable_state_var")
 
-if root:
-    print(f'ops           : {root.ops.name.string_().decode()}')
-else:
-    print('ops           : ')
+print(f'ops           : {read_root_ops_name()}')
 print(f'enabled       : {read_static_key("__scx_enabled")}')
 print(f'switching_all : {read_int("scx_switching_all")}')
 print(f'switched_all  : {read_static_key("__scx_switched_all")}')
 print(f'enable_state  : {state_str(enable_state)} ({enable_state})')
-print(f'aborting      : {prog["scx_aborting"].value_()}')
-print(f'bypass_depth  : {prog["scx_bypass_depth"].value_()}')
+print(f'aborting      : {read_root_field("aborting", False)}')
+print(f'bypass_depth  : {read_root_field("bypass_depth", 0)}')
 print(f'nr_rejected   : {read_atomic("scx_nr_rejected")}')
 print(f'enable_seq    : {read_atomic("scx_enable_seq")}')
-- 
2.43.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] tools/sched_ext: Fix scx_show_state per-scheduler state reads
  2026-05-27  9:38   ` [PATCH v2] " quzicheng315
@ 2026-05-27 19:16     ` Tejun Heo
  0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2026-05-27 19:16 UTC (permalink / raw)
  To: Zicheng Qu, Andrea Righi
  Cc: changwoo, enjuk, emil, sched-ext, linux-kernel, tanghui20,
	zhangqiao22, quzicheng, void

Hello,

Applied to sched_ext/for-7.1-fixes.

Thanks.

--
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-27 19:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 13:51 [PATCH] tools/sched_ext: Fix scx_show_state per-scheduler state reads Zicheng Qu
2026-05-26 17:44 ` Andrea Righi
2026-05-27  9:38   ` [PATCH v2] " quzicheng315
2026-05-27 19:16     ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.